Skip to content

Commit

Permalink
feat(OperatorSetup): activation du connecteur Geofolia
Browse files Browse the repository at this point in the history
  • Loading branch information
thom4parisot committed Feb 16, 2024
1 parent f3e2efb commit 9f6edcb
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
34 changes: 33 additions & 1 deletion src/components/OperatorSetup/Flow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 () => {
Expand Down
8 changes: 4 additions & 4 deletions src/components/OperatorSetup/Sources/Geofolia.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
<script setup>
import { ref } from 'vue'
import { convertGeofoliaArchiveToGeoJSON } from '@/cartobio-api.js'
import { sources } from "@/referentiels/imports.js"
const fileInput = ref(null)
const emit = defineEmits(['upload:start', 'upload:complete'])
const source = 'geofolia'
const erreur = ref('')
async function handleFileUpload () {
Expand All @@ -41,12 +41,12 @@ async function handleFileUpload () {
try {
const geojson = await convertGeofoliaArchiveToGeoJSON(archive)
emit('upload:complete', { geojson, source, warnings: [], metadata: {} })
emit('upload:complete', { geojson, source: sources.GEOFOLIA, warnings: [], metadata: {} })
} catch (error) {
if (error.response?.status >= 400 && error.response?.status <= 500) {
erreur.value = 'votre fichier ne semble pas être valide.'
erreur.value = 'Votre fichier n\'est pas reconnu comme un export Geofolia.'
} else {
erreur.value = 'erreur inconnue, merci de réessayer plus tard.'
erreur.value = 'Erreur inconnue, merci de réessayer plus tard.'
throw error
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/exploitations/[numeroBio]/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const operatorSetupActions = [
selector: markRaw(ActionFromSource),
wizzard: defineAsyncComponent(() => import('@/components/OperatorSetup/Flows/MultiSources.vue')),
extraProps: {
sources: [sources.TELEPAC, ...(permissions.isOc ? [sources.RPG] : []), sources.CVI]
sources: [sources.GEOFOLIA, sources.TELEPAC, ...(permissions.isOc ? [sources.RPG] : []), sources.CVI]
}
},
{ id: 'manual', selector: markRaw(ActionFromScratch) },
Expand Down
2 changes: 1 addition & 1 deletion widget/Notification.ce.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const operatorSetupActions = [
selector: null,
wizzard: markRaw(FlowMultiSources),
extraProps: {
sources: [sources.TELEPAC, sources.CVI]
sources: [sources.GEOFOLIA, sources.TELEPAC, sources.CVI]
}
},
]
Expand Down

0 comments on commit 9f6edcb

Please sign in to comment.