Use data attribute to determine current gallery photo in test
This commit is contained in:
@@ -21,7 +21,10 @@ const GalleryContent = <template>
|
|||||||
{{@bindKeyboard @handleKeydown}}
|
{{@bindKeyboard @handleKeydown}}
|
||||||
>
|
>
|
||||||
{{! template-lint-disable no-invalid-interactive }}
|
{{! 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">
|
<div class="actions-btn-container">
|
||||||
<DropdownMenu
|
<DropdownMenu
|
||||||
@iconSize={{24}}
|
@iconSize={{24}}
|
||||||
|
|||||||
@@ -287,35 +287,30 @@ module('Integration | Component | photo-gallery', function (hooks) {
|
|||||||
</template>
|
</template>
|
||||||
);
|
);
|
||||||
|
|
||||||
// Let carousel settle
|
assert
|
||||||
await new Promise((resolve) => setTimeout(resolve, 150));
|
.dom('.photo-gallery-content')
|
||||||
|
.hasAttribute('data-current-event-id', 'event1');
|
||||||
|
|
||||||
// Right Arrow
|
// Right Arrow
|
||||||
await triggerKeyEvent(document, 'keydown', 'ArrowRight');
|
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
|
assert
|
||||||
.dom('.thumbnail-strip-container .carousel-slide.active img')
|
.dom('.photo-gallery-content')
|
||||||
.hasAttribute('data-src', 'photo2.jpg');
|
.hasAttribute('data-current-event-id', 'event2');
|
||||||
|
|
||||||
// Right Arrow again
|
// Right Arrow again
|
||||||
await triggerKeyEvent(document, 'keydown', 'ArrowRight');
|
await triggerKeyEvent(document, 'keydown', 'ArrowRight');
|
||||||
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
||||||
|
|
||||||
assert
|
assert
|
||||||
.dom('.thumbnail-strip-container .carousel-slide.active img')
|
.dom('.photo-gallery-content')
|
||||||
.hasAttribute('data-src', 'photo3.jpg');
|
.hasAttribute('data-current-event-id', 'event3');
|
||||||
|
|
||||||
// Left Arrow
|
// Left Arrow
|
||||||
await triggerKeyEvent(document, 'keydown', 'ArrowLeft');
|
await triggerKeyEvent(document, 'keydown', 'ArrowLeft');
|
||||||
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
||||||
|
|
||||||
assert
|
assert
|
||||||
.dom('.thumbnail-strip-container .carousel-slide.active img')
|
.dom('.photo-gallery-content')
|
||||||
.hasAttribute('data-src', 'photo2.jpg');
|
.hasAttribute('data-current-event-id', 'event2');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('escape key closes gallery', async function (assert) {
|
test('escape key closes gallery', async function (assert) {
|
||||||
|
|||||||
Reference in New Issue
Block a user