diff --git a/CHANGELOG.md b/CHANGELOG.md index c82ed46d..fb85b29a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# [2.20.0](https://github.com/AgenceBio/cartobio-front/compare/v2.19.0...v2.20.0) (2023-02-?) + +* import de parcellaire depuis Geofolia +* le statut d'une dérogation de conversion est par défaut "en cours" + # [2.19.0](https://github.com/AgenceBio/cartobio-front/compare/v2.18.4...v2.19.0) (2023-02-10) * nouvelle page d'accueil diff --git a/src/components/OperatorSetup/Flow.test.js b/src/components/OperatorSetup/Flow.test.js index ba81ff14..71f19a80 100644 --- a/src/components/OperatorSetup/Flow.test.js +++ b/src/components/OperatorSetup/Flow.test.js @@ -100,7 +100,7 @@ describe("OperatorSetupFlow", () => { expect(wrapper.text()).toContain('Sélectionner ma dernière déclaration PAC') }) - it("should render tab content for Geofolia when selected", async () => { + it("should import successfully a Geofolia archive", async () => { const wrapper = mount(OperatorSetupFlow, { props: { actions: operatorSetupActions, @@ -112,6 +112,38 @@ describe("OperatorSetupFlow", () => { // Click on geofolia tab await wrapper.find('ul').find('.import-source-tab--geofolia').trigger('click') expect(wrapper.text()).toContain(`Sélectionner mon fichier de parcelles et d'interventions`) + + axios.__createMock.post.mockResolvedValueOnce({ + data: featureCollectionFixture + }) + + await wrapper.find('input[type="file"]').setValue('') + await flushPromises() + + // it is now called during preview + const confirmBtn = await wrapper.find('.fr-btn') + expect(confirmBtn.text()).toEqual('Importer ces données') + }) + + it("should fail on invalid Geofolia archive", async () => { + const wrapper = mount(OperatorSetupFlow, { + props: { + actions: [ ...operatorSetupActions ], + flowId: 'source', + operator: record.operator + } + }) + + const error = new AxiosError('Fichier invalide') + error.response = { status : 400 } + + axios.__createMock.post.mockRejectedValueOnce(error) + + await wrapper.find('ul').find('.import-source-tab--geofolia').trigger('click') + await wrapper.find('input[type="file"]').setValue('') + await flushPromises() + + expect(wrapper.text()).toContain('Votre fichier n\'est pas reconnu comme un export Geofolia.') }) it("should render tab content for RPG when selected", async () => { diff --git a/src/components/OperatorSetup/Sources/Geofolia.vue b/src/components/OperatorSetup/Sources/Geofolia.vue index 9443a20a..737f9e8b 100644 --- a/src/components/OperatorSetup/Sources/Geofolia.vue +++ b/src/components/OperatorSetup/Sources/Geofolia.vue @@ -27,11 +27,11 @@