fix: corriger l'erreur HTTP 400 sur les endpoints content-sources POST/PUT
- ContentSourceForm.vue : convertir testChapterNumber en float/null avant envoi (évite d'envoyer "" pour ?float, rejeté par Symfony 8 strict) - UpsertContentSourceResource : ajouter collectDenormalizationErrors: true pour que les erreurs de type retournent 422 au lieu de 400 via le chemin input: de API Platform 4 - ContentSource entity : corriger setImageSelector(string) → setImageSelector(?string) cohérent avec la colonne nullable - Ajouter les tests manquants (testChapterNumber float/null/chaîne vide) qui auraient détecté ces bugs plus tôt
This commit is contained in:
parent
21d8111734
commit
69c6757cf8
@@ -181,4 +181,35 @@ final class CreateContentSourceTest extends AbstractApiTestCase
|
||||
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
public function testItAcceptsTestChapterNumberAsFloat(): void
|
||||
{
|
||||
$response = static::createClient()->request('POST', '/api/content-sources', [
|
||||
'json' => [
|
||||
'baseUrl' => 'https://mangadex.org',
|
||||
'chapterUrlFormat' => 'https://mangadex.org/chapter/{id}',
|
||||
'scrapingType' => 'html',
|
||||
'testSlug' => 'one-piece',
|
||||
'testChapterNumber' => 1.5,
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function testItRejectsTestChapterNumberAsEmptyStringWith422(): void
|
||||
{
|
||||
// Cas réel du formulaire Vue : le champ vide envoie "" au lieu de null.
|
||||
// Doit retourner 422 (erreur de validation) et non 400 (données malformées).
|
||||
$response = static::createClient()->request('POST', '/api/content-sources', [
|
||||
'json' => [
|
||||
'baseUrl' => 'https://mangadex.org',
|
||||
'chapterUrlFormat' => 'https://mangadex.org/chapter/{id}',
|
||||
'scrapingType' => 'html',
|
||||
'testChapterNumber' => '',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,4 +188,49 @@ final class UpdateContentSourceTest extends AbstractApiTestCase
|
||||
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
public function testItAcceptsTestChapterNumberAsFloat(): void
|
||||
{
|
||||
$response = static::createClient()->request('PUT', "/api/content-sources/{$this->sourceId}", [
|
||||
'json' => [
|
||||
'baseUrl' => 'https://mangadex.org',
|
||||
'chapterUrlFormat' => 'https://mangadex.org/chapter/{id}',
|
||||
'scrapingType' => 'html',
|
||||
'testSlug' => 'one-piece',
|
||||
'testChapterNumber' => 1.5,
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
public function testItAcceptsTestChapterNumberAsNull(): void
|
||||
{
|
||||
$response = static::createClient()->request('PUT', "/api/content-sources/{$this->sourceId}", [
|
||||
'json' => [
|
||||
'baseUrl' => 'https://mangadex.org',
|
||||
'chapterUrlFormat' => 'https://mangadex.org/chapter/{id}',
|
||||
'scrapingType' => 'html',
|
||||
'testChapterNumber' => null,
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
public function testItRejectsTestChapterNumberAsEmptyStringWith422(): void
|
||||
{
|
||||
// Cas réel du formulaire Vue : le champ vide envoie "" au lieu de null.
|
||||
// Doit retourner 422 (erreur de validation) et non 400 (données malformées).
|
||||
$response = static::createClient()->request('PUT', "/api/content-sources/{$this->sourceId}", [
|
||||
'json' => [
|
||||
'baseUrl' => 'https://mangadex.org',
|
||||
'chapterUrlFormat' => 'https://mangadex.org/chapter/{id}',
|
||||
'scrapingType' => 'html',
|
||||
'testChapterNumber' => '',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user