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
2 changes: 1 addition & 1 deletion templates/components/FoldersGrid.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<twig:FolderCard :item="folder" />
{% endfor %}
{% for file in files %}
<twig:FileCard :item="file" :media="mediasByFileId[file.id] ?? null" :inAlbum="filesInAlbum is defined and file.id in filesInAlbum" />
<twig:FileCard :item="file" :media="mediasByFileId[file.id] ?? null" :inAlbum="filesInAlbum is defined and (file.id ~ '') in filesInAlbum" />
{% endfor %}
{% endif %}
</div>
Expand Down
39 changes: 39 additions & 0 deletions tests/Web/FileDeleteWebTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}