Use data attribute to determine current gallery photo in test

This commit is contained in:
2026-06-05 18:33:08 +04:00
parent 200100686d
commit d266bb92bd
2 changed files with 13 additions and 15 deletions

View File

@@ -21,7 +21,10 @@ const GalleryContent = <template>
{{@bindKeyboard @handleKeydown}}
>
{{! template-lint-disable no-invalid-interactive }}
<div class="photo-gallery-content">
<div
class="photo-gallery-content"
data-current-event-id={{@currentPhoto.eventId}}
>
<div class="actions-btn-container">
<DropdownMenu
@iconSize={{24}}

View File

@@ -287,35 +287,30 @@ module('Integration | Component | photo-gallery', function (hooks) {
</template>
);
// Let carousel settle
await new Promise((resolve) => setTimeout(resolve, 150));
assert
.dom('.photo-gallery-content')
.hasAttribute('data-current-event-id', 'event1');
// Right Arrow
await triggerKeyEvent(document, 'keydown', 'ArrowRight');
await new Promise((resolve) => setTimeout(resolve, 150));
// Let's just assert that currentPhoto was updated internally, which trickles down.
// The actual DOM update for the main image might be tricky if the carousel relies on scroll events.
// We can at least check if the thumbnail selection changed, as that is directly driven by currentPhoto
assert
.dom('.thumbnail-strip-container .carousel-slide.active img')
.hasAttribute('data-src', 'photo2.jpg');
.dom('.photo-gallery-content')
.hasAttribute('data-current-event-id', 'event2');
// Right Arrow again
await triggerKeyEvent(document, 'keydown', 'ArrowRight');
await new Promise((resolve) => setTimeout(resolve, 150));
assert
.dom('.thumbnail-strip-container .carousel-slide.active img')
.hasAttribute('data-src', 'photo3.jpg');
.dom('.photo-gallery-content')
.hasAttribute('data-current-event-id', 'event3');
// Left Arrow
await triggerKeyEvent(document, 'keydown', 'ArrowLeft');
await new Promise((resolve) => setTimeout(resolve, 150));
assert
.dom('.thumbnail-strip-container .carousel-slide.active img')
.hasAttribute('data-src', 'photo2.jpg');
.dom('.photo-gallery-content')
.hasAttribute('data-current-event-id', 'event2');
});
test('escape key closes gallery', async function (assert) {