From cbb62989d4454581f5c7bf6979de31eb348801fd Mon Sep 17 00:00:00 2001 From: "ext.jeremy.guillot@maxicoffee.domains" Date: Sun, 6 Jul 2025 17:01:04 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20ajout=20de=20la=20fonctionnalit=C3=A9?= =?UTF-8?q?=20de=20test=20de=20configuration=20de=20scraper,=20incluant=20?= =?UTF-8?q?la=20mise=20=C3=A0=20jour=20de=20l'API=20pour=20tester=20les=20?= =?UTF-8?q?configurations=20en=20temps=20r=C3=A9el,=20la=20gestion=20des?= =?UTF-8?q?=20erreurs=20d=C3=A9taill=C3=A9es=20et=20l'int=C3=A9gration=20d?= =?UTF-8?q?es=20tests=20unitaires=20pour=20valider=20le=20bon=20fonctionne?= =?UTF-8?q?ment=20de=20cette=20nouvelle=20fonctionnalit=C3=A9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/apiContentSourceRepository.js | 20 + .../components/ContentSourceForm.vue | 31 +- .../presentation/pages/ScrapperEdit.vue | 188 ++++- public/api-docs.json | 727 ++++++++++++++++-- .../Command/TestScraperConfiguration.php | 18 + .../TestScraperConfigurationHandler.php | 113 +++ .../TestScraperConfigurationResponse.php | 39 + .../TestScraperConfigurationRequest.php | 377 +++++++++ .../TestScraperConfigurationResource.php | 93 +++ ...TestScraperConfigurationStateProcessor.php | 48 ++ .../Scraping/TestScraperConfigurationTest.php | 198 +++++ 11 files changed, 1751 insertions(+), 101 deletions(-) create mode 100644 src/Domain/Scraping/Application/Command/TestScraperConfiguration.php create mode 100644 src/Domain/Scraping/Application/CommandHandler/TestScraperConfigurationHandler.php create mode 100644 src/Domain/Scraping/Application/Response/TestScraperConfigurationResponse.php create mode 100644 src/Domain/Scraping/Infrastructure/ApiPlatform/Resource/TestScraperConfigurationRequest.php create mode 100644 src/Domain/Scraping/Infrastructure/ApiPlatform/Resource/TestScraperConfigurationResource.php create mode 100644 src/Domain/Scraping/Infrastructure/ApiPlatform/State/Processor/TestScraperConfigurationStateProcessor.php create mode 100644 tests/Feature/Scraping/TestScraperConfigurationTest.php diff --git a/assets/vue/app/domain/setting/infrastructure/api/apiContentSourceRepository.js b/assets/vue/app/domain/setting/infrastructure/api/apiContentSourceRepository.js index 9739da8..f068008 100644 --- a/assets/vue/app/domain/setting/infrastructure/api/apiContentSourceRepository.js +++ b/assets/vue/app/domain/setting/infrastructure/api/apiContentSourceRepository.js @@ -81,4 +81,24 @@ export class ApiContentSourceRepository { throw new Error(error.response?.data?.message || 'Erreur lors de l\'import des sources'); } } + + /** + * Teste une configuration de scraper + */ + async testConfiguration(configuration) { + try { + const response = await this.apiClient.post('/scraping/test-configuration', configuration); + return response.data; + } catch (error) { + // Gestion spécifique des erreurs de validation + if (error.response?.status === 422) { + const validationErrors = error.response.data?.violations || []; + const errorMessage = validationErrors.map(violation => + `${violation.propertyPath}: ${violation.message}` + ).join(', ') || 'Erreur de validation'; + throw new Error(errorMessage); + } + throw new Error(error.response?.data?.message || 'Erreur lors du test de la configuration'); + } + } } diff --git a/assets/vue/app/domain/setting/presentation/components/ContentSourceForm.vue b/assets/vue/app/domain/setting/presentation/components/ContentSourceForm.vue index 21e4b3f..20568c3 100644 --- a/assets/vue/app/domain/setting/presentation/components/ContentSourceForm.vue +++ b/assets/vue/app/domain/setting/presentation/components/ContentSourceForm.vue @@ -152,12 +152,21 @@ + +
+
+ URL qui sera testée : +
{{ generatedTestUrl }}
+
+
+