Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Open country selection for FR papers #681

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/components/ModelSteps/Edit/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import set from 'lodash/set'
import { CONTACTS_DOCTYPE, FILES_DOCTYPE } from 'src/constants'

import { getReferencedBy } from 'cozy-client'
import { isForeignPaper } from 'cozy-client/dist/models/paper'

/**
* Checks if the edition of the metadata of type "Information" is permitted
Expand Down Expand Up @@ -118,10 +117,8 @@ export const updateReferencedContact = async ({
export const getPaperDefinitionByFile = (papersDefinitions, file) => {
return papersDefinitions.find(paper => {
const countryCondition =
Object.keys(file.metadata).includes('country') && paper.country
? isForeignPaper(file)
? paper.country === 'foreign'
: paper.country === 'fr'
file.metadata.country && paper.country
? paper.country === 'foreign'
: true

return paper.label === file.metadata.qualification.label && countryCondition
Expand Down
13 changes: 10 additions & 3 deletions src/components/ModelSteps/Edit/helpers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ describe('updateReferencedContact', () => {
})
})

describe('getPaperDefinitionByFile', () => {
// eslint-disable-next-line jest/no-focused-tests
fdescribe('getPaperDefinitionByFile', () => {
describe('paperDefinition has no country defined', () => {
it('should return the paperDefinition "isp_invoice"', () => {
const fakeFile = makeFakeFile({ qualificationLabel: 'isp_invoice' })
Expand Down Expand Up @@ -423,7 +424,10 @@ describe('getPaperDefinitionByFile', () => {
})
const res = getPaperDefinitionByFile(mockPapersDefinitions, fakeFile)

expect(res).toMatchObject({ label: 'driver_license', country: 'fr' })
expect(res).toMatchObject({
label: 'driver_license',
country: 'foreign'
})
})

it('for "fr" country in file', () => {
Expand All @@ -433,7 +437,10 @@ describe('getPaperDefinitionByFile', () => {
})
const res = getPaperDefinitionByFile(mockPapersDefinitions, fakeFile)

expect(res).toMatchObject({ label: 'driver_license', country: 'fr' })
expect(res).toMatchObject({
label: 'driver_license',
country: 'foreign'
})
})
})

Expand Down
Loading