Files
Mangarr/tests/Feature/Reader/GetChapterContextTest.php
ext.jeremy.guillot@maxicoffee.domains 9c47c717d0 style(reader): améliorer la toolbar et l'UI du mode scroll
- Corriger la troncature de la toolbar (max-height 4rem → 5rem)
- Animer la toolbar en translateY pour un effet "bloc uni" avec le header
- Corriger le bug d'auto-hide du header après switch simple → scroll
- Augmenter la taille du titre de chapitre dans la toolbar (text-sm font-medium)
- Harmoniser le bouton scroll-to-top avec le style des ToolbarButtons
- Ajouter support de prop `class` sur les labels de ToolbarSection
2026-03-15 16:50:02 +01:00

83 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Feature\Reader;
use App\Factory\ChapterFactory;
use App\Factory\MangaFactory;
use App\Tests\Feature\AbstractApiTestCase;
use Zenstruck\Foundry\Test\ResetDatabase;
final class GetChapterContextTest extends AbstractApiTestCase
{
use ResetDatabase;
public function testItReturnsChapterContext(): void
{
// Arrange
$manga = MangaFactory::createOne([
'slug' => 'manga-1',
]);
$chapter1 = ChapterFactory::createOne([
'manga' => $manga,
'title' => 'Chapter 1',
'number' => 1,
'visible' => true,
'cbzPath' => '/path/to/chapter1.cbz',
]);
$chapter2 = ChapterFactory::createOne([
'manga' => $manga,
'title' => 'Chapter 2',
'number' => 2,
'visible' => true,
'cbzPath' => '/path/to/chapter2.cbz',
]);
$chapter3 = ChapterFactory::createOne([
'manga' => $manga,
'title' => 'Chapter 3',
'number' => 3,
'visible' => true,
'cbzPath' => '/path/to/chapter3.cbz',
]);
// Act
static::createClient()->request('GET', '/api/reader/chapter/' . $chapter1->getId());
// Assert
$this->assertResponseIsSuccessful();
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
$this->assertJsonContains([
'id' => (string)$chapter1->getId(),
'mangaId' => (string)$manga->getId(),
'title' => 'Chapter 1',
'number' => 1,
'totalPages' => 0,
'navigation' => [
'hydra:member' => [
null, (string)$chapter2->getId(),
],
]
]);
}
public function testItReturns404ForNonExistentChapter(): void
{
// Act
static::createClient()->request('GET', '/api/reader/chapter/0');
// Assert
$this->assertResponseStatusCodeSame(404);
$this->assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
$this->assertJsonContains([
'hydra:title' => 'An error occurred',
'hydra:description' => 'Le chapitre 0 n\'existe pas',
]);
}
}