Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions fixtures/slide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion tests/Api/SlidesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
10 changes: 5 additions & 5 deletions tests/EventListener/RelationsChecksumListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down Expand Up @@ -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
Expand All @@ -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'];
Expand All @@ -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());
}
Expand Down