Skip to content

Commit efa2635

Browse files
turegjorupclaude
andcommitted
test: use a dedicated fixture slide for the media checksum tests
Pinning slide_abc_1 by title was still flaky: testRemoveSlide() deletes the oldest slide of playlist_abc_1, and with randomised fixture createdAt values that is sometimes slide_abc_1 itself — the lookup then returned null on the shared per-class database. Add slide_media_checksum_test (tenant ABC, two known media, attached to no playlist) following the existing *_relations_checksum_test fixture convention, and use it in the three media checksum tests. No other test can mutate or delete it. The ABC slide count grows to 62, so bump the totalItems assertion in SlidesTest. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2e68b03 commit efa2635

4 files changed

Lines changed: 18 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7-
- De-flaked `RelationsChecksumListenerTest`: the media-checksum tests now look up a fixture
8-
slide that is guaranteed to have media, instead of an unordered `findOneBy()` that could
9-
return the media-less `slide_abc_notified` and crash on the missing `media` checksum key.
7+
- De-flaked `RelationsChecksumListenerTest`: the media-checksum tests now use a dedicated
8+
fixture slide (`slide_media_checksum_test`) with known media and no playlist membership.
9+
Previously an unordered `findOneBy()` could return the media-less `slide_abc_notified`
10+
(crashing on the missing `media` checksum key) or a slide deleted earlier in the class by
11+
`testRemoveSlide()`, which removes a random-`createdAt` fixture slide from the shared DB.
1012
- Fixed the 2.x → 3.0 screen client auto-upgrade path: ship a copy of `release.json` at the
1113
deprecated `/client/release.json` location polled by 2.x clients. Without it the catch-all
1214
`/client` route answered with the SPA's HTML and already-running 2.x screens never detected

fixtures/slide.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@ App\Entity\Tenant\Slide:
3737
slide_relations_checksum_test (extends slide):
3838
title: "slide_relations_checksum_test"
3939
tenant: "@tenant_xyz"
40+
# Dedicated to the media tests in RelationsChecksumListenerTest: known media
41+
# (two distinct, so one can be removed and the 'media' checksum key remains)
42+
# and on no playlist, so testRemoveSlide() can never delete it.
43+
slide_media_checksum_test (extends slide):
44+
title: "slide_media_checksum_test"
45+
tenant: "@tenant_abc"
46+
media: ["@media_abc_1", "@media_abc_2"]

tests/Api/SlidesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function testGetCollection(): void
2222
'@context' => '/contexts/Slide',
2323
'@id' => '/v2/slides',
2424
'@type' => 'hydra:Collection',
25-
'hydra:totalItems' => 61,
25+
'hydra:totalItems' => 62,
2626
'hydra:view' => [
2727
'@id' => '/v2/slides?itemsPerPage=10&page=1',
2828
'@type' => 'hydra:PartialCollectionView',

tests/EventListener/RelationsChecksumListenerTest.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,8 @@ public function testPersistSlide(): void
210210

211211
public function testUpdateMedia(): void
212212
{
213-
$tenant = $this->em->getRepository(Tenant::class)->findOneBy(['tenantKey' => 'ABC']);
214-
// Look up a fixture slide that is guaranteed to have media: an unordered
215-
// findOneBy(['tenant' => ...]) can return slide_abc_notified, which has
216-
// none — and then the 'media' checksum key doesn't exist.
217213
/** @var Tenant\Slide $slide */
218-
$slide = $this->em->getRepository(Tenant\Slide::class)->findOneBy(['title' => 'slide_abc_1', 'tenant' => $tenant]);
214+
$slide = $this->em->getRepository(Tenant\Slide::class)->findOneBy(['title' => 'slide_media_checksum_test']);
219215

220216
$before = $slide->getRelationsChecksum()['media'];
221217

@@ -529,10 +525,8 @@ public function testRemoveScreenFromScreenGroupUpdatesChecksum(): void
529525
public function testAddMediaToSlideUpdatesChecksum(): void
530526
{
531527
$tenant = $this->em->getRepository(Tenant::class)->findOneBy(['tenantKey' => 'ABC']);
532-
// slide_abc_1 is guaranteed to have media; an unordered findOneBy can
533-
// return slide_abc_notified, which has none (no 'media' checksum key).
534528
/** @var Tenant\Slide $slide */
535-
$slide = $this->em->getRepository(Tenant\Slide::class)->findOneBy(['title' => 'slide_abc_1', 'tenant' => $tenant]);
529+
$slide = $this->em->getRepository(Tenant\Slide::class)->findOneBy(['title' => 'slide_media_checksum_test']);
536530
$beforeChecksum = $slide->getRelationsChecksum()['media'];
537531

538532
// Find a media not already on this slide
@@ -558,11 +552,8 @@ public function testAddMediaToSlideUpdatesChecksum(): void
558552

559553
public function testRemoveMediaFromSlideUpdatesChecksum(): void
560554
{
561-
$tenant = $this->em->getRepository(Tenant::class)->findOneBy(['tenantKey' => 'ABC']);
562-
// slide_abc_1 is guaranteed to have media; an unordered findOneBy can
563-
// return slide_abc_notified, which has none (no 'media' checksum key).
564555
/** @var Tenant\Slide $slide */
565-
$slide = $this->em->getRepository(Tenant\Slide::class)->findOneBy(['title' => 'slide_abc_1', 'tenant' => $tenant]);
556+
$slide = $this->em->getRepository(Tenant\Slide::class)->findOneBy(['title' => 'slide_media_checksum_test']);
566557
$this->assertGreaterThan(0, $slide->getMedia()->count());
567558

568559
$beforeChecksum = $slide->getRelationsChecksum()['media'];
@@ -573,6 +564,8 @@ public function testRemoveMediaFromSlideUpdatesChecksum(): void
573564
$this->em->flush();
574565

575566
$this->em->refresh($slide);
567+
// The fixture slide has two media, so one remains after the removal and
568+
// the 'media' checksum key still exists.
576569
$this->assertNotEquals($beforeChecksum, $slide->getRelationsChecksum()['media']);
577570
$this->assertFalse($slide->isChanged());
578571
}

0 commit comments

Comments
 (0)