From 92520bdb75d30b8ccb279ce1ff1db81475d451b5 Mon Sep 17 00:00:00 2001 From: Ronan Lenouvel Date: Thu, 23 Jul 2026 16:41:06 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix(FoldersGrid):=20comparer=20f?= =?UTF-8?q?ile.id=20(Uuid)=20=C3=A0=20filesInAlbum=20en=20le=20castant=20e?= =?UTF-8?q?n=20string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Twig `in` ne caste pas automatiquement un objet Uuid pour le comparer aux strings RFC4122 de filesInAlbum : l'option "conserver dans mes albums" n'apparaissait jamais dans la modale de suppression (#246), même pour un fichier dans un album. --- templates/components/FoldersGrid.html.twig | 2 +- tests/Web/FileDeleteWebTest.php | 39 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/templates/components/FoldersGrid.html.twig b/templates/components/FoldersGrid.html.twig index 5341b44..d9047eb 100644 --- a/templates/components/FoldersGrid.html.twig +++ b/templates/components/FoldersGrid.html.twig @@ -11,7 +11,7 @@ {% endfor %} {% for file in files %} - + {% endfor %} {% endif %} diff --git a/tests/Web/FileDeleteWebTest.php b/tests/Web/FileDeleteWebTest.php index ecaf87a..da03a9a 100644 --- a/tests/Web/FileDeleteWebTest.php +++ b/tests/Web/FileDeleteWebTest.php @@ -265,4 +265,43 @@ public function testDeleteRequiresAuthentication(): void $this->assertResponseRedirects('/login'); } + + public function testExplorerRendersDeleteButtonWithInAlbumTrueWhenFileHasMediaInAlbum(): void + { + // Non-régression rendu HTML (#246) : file.id (objet Uuid) doit être + // comparé correctement à filesInAlbum (strings RFC4122) côté Twig, + // sinon le bouton reçoit toujours inAlbum=false et la modale + // n'affiche jamais l'option "conserver dans mes albums". + $user = $this->createUser(); + $media = $this->createMediaFile($user, 'vacances.jpg', 'photo'); + $file = $media->getFile(); + $folderId = $file->getFolder()->getId()->toRfc4122(); + + $album = new Album('Vacances', $user); + $this->em->persist($album); + $this->em->persist(new AlbumMedia($album, $media, 0)); + $this->em->flush(); + $this->em->clear(); + + $this->login(); + $crawler = $this->client->request('GET', '/explorer?folder=' . $folderId); + + $this->assertResponseIsSuccessful(); + $button = $crawler->filter('[data-testid="delete-file-btn-' . $file->getId() . '"]'); + $this->assertStringContainsString('true)', $button->attr('onclick')); + } + + public function testExplorerRendersDeleteButtonWithInAlbumFalseWhenFileHasNoMedia(): void + { + $user = $this->createUser(); + $folder = $this->createFolder('Docs', $user); + $file = $this->createFile('rapport.txt', $folder, $user); + + $this->login(); + $crawler = $this->client->request('GET', '/explorer?folder=' . $folder->getId()->toRfc4122()); + + $this->assertResponseIsSuccessful(); + $button = $crawler->filter('[data-testid="delete-file-btn-' . $file->getId() . '"]'); + $this->assertStringContainsString('false)', $button->attr('onclick')); + } }