diff --git a/CHANGELOG.md b/CHANGELOG.md index 127fbf12f..6fd185d70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +- De-flaked `RelationsChecksumListenerTest`: the media-checksum tests now use a dedicated + fixture slide (`slide_media_checksum_test`) with known media and no playlist membership. + Previously an unordered `findOneBy()` could return the media-less `slide_abc_notified` + (crashing on the missing `media` checksum key) or a slide deleted earlier in the class by + `testRemoveSlide()`, which removes a random-`createdAt` fixture slide from the shared DB. - Fixed the 2.x → 3.0 screen client auto-upgrade path: ship a copy of `release.json` at the deprecated `/client/release.json` location polled by 2.x clients. Without it the catch-all `/client` route answered with the SPA's HTML and already-running 2.x screens never detected diff --git a/fixtures/slide.yaml b/fixtures/slide.yaml index 782e8d2a0..7c8c0cf7f 100644 --- a/fixtures/slide.yaml +++ b/fixtures/slide.yaml @@ -37,3 +37,10 @@ App\Entity\Tenant\Slide: slide_relations_checksum_test (extends slide): title: "slide_relations_checksum_test" tenant: "@tenant_xyz" + # Dedicated to the media tests in RelationsChecksumListenerTest: known media + # (two distinct, so one can be removed and the 'media' checksum key remains) + # and on no playlist, so testRemoveSlide() can never delete it. + slide_media_checksum_test (extends slide): + title: "slide_media_checksum_test" + tenant: "@tenant_abc" + media: ["@media_abc_1", "@media_abc_2"] diff --git a/tests/Api/SlidesTest.php b/tests/Api/SlidesTest.php index 492ef980b..d4a3e614c 100644 --- a/tests/Api/SlidesTest.php +++ b/tests/Api/SlidesTest.php @@ -22,7 +22,7 @@ public function testGetCollection(): void '@context' => '/contexts/Slide', '@id' => '/v2/slides', '@type' => 'hydra:Collection', - 'hydra:totalItems' => 61, + 'hydra:totalItems' => 62, 'hydra:view' => [ '@id' => '/v2/slides?itemsPerPage=10&page=1', '@type' => 'hydra:PartialCollectionView', diff --git a/tests/EventListener/RelationsChecksumListenerTest.php b/tests/EventListener/RelationsChecksumListenerTest.php index 6619b007a..efe2dd556 100644 --- a/tests/EventListener/RelationsChecksumListenerTest.php +++ b/tests/EventListener/RelationsChecksumListenerTest.php @@ -210,9 +210,8 @@ public function testPersistSlide(): void public function testUpdateMedia(): void { - $tenant = $this->em->getRepository(Tenant::class)->findOneBy(['tenantKey' => 'ABC']); /** @var Tenant\Slide $slide */ - $slide = $this->em->getRepository(Tenant\Slide::class)->findOneBy(['tenant' => $tenant]); + $slide = $this->em->getRepository(Tenant\Slide::class)->findOneBy(['title' => 'slide_media_checksum_test']); $before = $slide->getRelationsChecksum()['media']; @@ -527,7 +526,7 @@ public function testAddMediaToSlideUpdatesChecksum(): void { $tenant = $this->em->getRepository(Tenant::class)->findOneBy(['tenantKey' => 'ABC']); /** @var Tenant\Slide $slide */ - $slide = $this->em->getRepository(Tenant\Slide::class)->findOneBy(['tenant' => $tenant]); + $slide = $this->em->getRepository(Tenant\Slide::class)->findOneBy(['title' => 'slide_media_checksum_test']); $beforeChecksum = $slide->getRelationsChecksum()['media']; // Find a media not already on this slide @@ -553,9 +552,8 @@ public function testAddMediaToSlideUpdatesChecksum(): void public function testRemoveMediaFromSlideUpdatesChecksum(): void { - $tenant = $this->em->getRepository(Tenant::class)->findOneBy(['tenantKey' => 'ABC']); /** @var Tenant\Slide $slide */ - $slide = $this->em->getRepository(Tenant\Slide::class)->findOneBy(['tenant' => $tenant]); + $slide = $this->em->getRepository(Tenant\Slide::class)->findOneBy(['title' => 'slide_media_checksum_test']); $this->assertGreaterThan(0, $slide->getMedia()->count()); $beforeChecksum = $slide->getRelationsChecksum()['media']; @@ -566,6 +564,8 @@ public function testRemoveMediaFromSlideUpdatesChecksum(): void $this->em->flush(); $this->em->refresh($slide); + // The fixture slide has two media, so one remains after the removal and + // the 'media' checksum key still exists. $this->assertNotEquals($beforeChecksum, $slide->getRelationsChecksum()['media']); $this->assertFalse($slide->isChanged()); }