diff --git a/mocks/mocks/data/formio-api/accordion.json b/mocks/mocks/data/formio-api/accordion.json index 4c24db0a9..67063679f 100644 --- a/mocks/mocks/data/formio-api/accordion.json +++ b/mocks/mocks/data/formio-api/accordion.json @@ -411,7 +411,7 @@ "skjemanummer": "accordion-test", "tema": "AGR", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/activities.json b/mocks/mocks/data/formio-api/activities.json index 0e818be8e..d17659097 100644 --- a/mocks/mocks/data/formio-api/activities.json +++ b/mocks/mocks/data/formio-api/activities.json @@ -534,7 +534,7 @@ "skjemanummer": "testing-activities", "tema": "AGR", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/container-datagrid.json b/mocks/mocks/data/formio-api/container-datagrid.json index 2206bbed7..f7c54bc85 100644 --- a/mocks/mocks/data/formio-api/container-datagrid.json +++ b/mocks/mocks/data/formio-api/container-datagrid.json @@ -607,7 +607,7 @@ "skjemanummer": "containerDatagrid123", "tema": "GEN", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/container123.json b/mocks/mocks/data/formio-api/container123.json index 012312d12..ef7b072d4 100644 --- a/mocks/mocks/data/formio-api/container123.json +++ b/mocks/mocks/data/formio-api/container123.json @@ -688,7 +688,7 @@ "skjemanummer": "container-123", "tema": "GEN", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/custom-components-alert.json b/mocks/mocks/data/formio-api/custom-components-alert.json index 05672c3d3..d7d824564 100644 --- a/mocks/mocks/data/formio-api/custom-components-alert.json +++ b/mocks/mocks/data/formio-api/custom-components-alert.json @@ -669,7 +669,7 @@ "skjemanummer": "testingalert", "tema": "AGR", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/custom-components-checkbox.json b/mocks/mocks/data/formio-api/custom-components-checkbox.json index 3834404d2..ec37c480c 100644 --- a/mocks/mocks/data/formio-api/custom-components-checkbox.json +++ b/mocks/mocks/data/formio-api/custom-components-checkbox.json @@ -606,7 +606,7 @@ "skjemanummer": "checkbox-test", "tema": "AGR", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/datagrid-conditional.json b/mocks/mocks/data/formio-api/datagrid-conditional.json index 05dd2cdde..a70904565 100644 --- a/mocks/mocks/data/formio-api/datagrid-conditional.json +++ b/mocks/mocks/data/formio-api/datagrid-conditional.json @@ -1118,7 +1118,7 @@ "skjemanummer": "dg123456", "tema": "ENF", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/datagrid-react-components.json b/mocks/mocks/data/formio-api/datagrid-react-components.json index fa6daa1d2..afa343059 100644 --- a/mocks/mocks/data/formio-api/datagrid-react-components.json +++ b/mocks/mocks/data/formio-api/datagrid-react-components.json @@ -645,7 +645,7 @@ "skjemanummer": "datagrid-react", "tema": "DAG", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/datagrid.json b/mocks/mocks/data/formio-api/datagrid.json index 6c1bf8e5a..8bbacdaef 100644 --- a/mocks/mocks/data/formio-api/datagrid.json +++ b/mocks/mocks/data/formio-api/datagrid.json @@ -570,7 +570,7 @@ "skjemanummer": "datagrid-123", "tema": "DAG", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/driving-list.json b/mocks/mocks/data/formio-api/driving-list.json index a97a3d77d..ed0b347f3 100644 --- a/mocks/mocks/data/formio-api/driving-list.json +++ b/mocks/mocks/data/formio-api/driving-list.json @@ -166,7 +166,7 @@ "skjemanummer": "test-driving-list", "tema": "BIL", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/form-email.json b/mocks/mocks/data/formio-api/form-email.json index 20a4d7eb6..efd09dc5b 100644 --- a/mocks/mocks/data/formio-api/form-email.json +++ b/mocks/mocks/data/formio-api/form-email.json @@ -638,7 +638,7 @@ "skjemanummer": "TST 10-11.12", "tema": "SYK", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/form-select-v1.json b/mocks/mocks/data/formio-api/form-select-v1.json index 4b09a01c5..35a6d5c70 100644 --- a/mocks/mocks/data/formio-api/form-select-v1.json +++ b/mocks/mocks/data/formio-api/form-select-v1.json @@ -620,7 +620,7 @@ "skjemanummer": "Test-select", "tema": "BIL", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/form-select-v2.json b/mocks/mocks/data/formio-api/form-select-v2.json index 0dcff032b..8b0c14ac1 100644 --- a/mocks/mocks/data/formio-api/form-select-v2.json +++ b/mocks/mocks/data/formio-api/form-select-v2.json @@ -527,7 +527,7 @@ "skjemanummer": "Test-select", "tema": "BIL", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/hidden-conditional.json b/mocks/mocks/data/formio-api/hidden-conditional.json index 8883ef4ad..522425c4a 100644 --- a/mocks/mocks/data/formio-api/hidden-conditional.json +++ b/mocks/mocks/data/formio-api/hidden-conditional.json @@ -457,7 +457,7 @@ "skjemanummer": "hidden-test", "tema": "AAP", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/mellomlagring-nested-values.json b/mocks/mocks/data/formio-api/mellomlagring-nested-values.json index 6511214b1..7aefd2f96 100644 --- a/mocks/mocks/data/formio-api/mellomlagring-nested-values.json +++ b/mocks/mocks/data/formio-api/mellomlagring-nested-values.json @@ -26150,7 +26150,7 @@ "published": "2025-02-06T11:04:44.706Z", "publishedBy": "Rosseland, Rune", "publishedLanguages": ["nn-NO", "en"], - "ettersending": "PAPIR_OG_DIGITAL" + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"] }, "project": "628ca77305690db58c974cfd", "revisions": "", diff --git a/mocks/mocks/data/formio-api/month-picker.json b/mocks/mocks/data/formio-api/month-picker.json index 78529760d..3c9a551b3 100644 --- a/mocks/mocks/data/formio-api/month-picker.json +++ b/mocks/mocks/data/formio-api/month-picker.json @@ -698,7 +698,7 @@ "skjemanummer": "monthpicker-test", "tema": "AGR", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/nav083501.json b/mocks/mocks/data/formio-api/nav083501.json index da737fb9b..79c784fe2 100644 --- a/mocks/mocks/data/formio-api/nav083501.json +++ b/mocks/mocks/data/formio-api/nav083501.json @@ -6324,7 +6324,7 @@ "published": "2024-01-08T08:33:50.638Z", "publishedBy": "Rosseland, Rune", "publishedLanguages": [], - "ettersending": "PAPIR_OG_DIGITAL" + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"] }, "access": [ { diff --git a/mocks/mocks/data/formio-api/nav111221b.json b/mocks/mocks/data/formio-api/nav111221b.json index ea847109f..211ed4a6e 100644 --- a/mocks/mocks/data/formio-api/nav111221b.json +++ b/mocks/mocks/data/formio-api/nav111221b.json @@ -7059,7 +7059,7 @@ "skjemanummer": "NAV 11-12.21B", "tema": "TSO", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/navdatepicker.json b/mocks/mocks/data/formio-api/navdatepicker.json index c2ae5a632..80645fde8 100644 --- a/mocks/mocks/data/formio-api/navdatepicker.json +++ b/mocks/mocks/data/formio-api/navdatepicker.json @@ -823,7 +823,7 @@ "skjemanummer": "NAVDATEPICKER", "tema": "ERS", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/number.json b/mocks/mocks/data/formio-api/number.json index 9b5a694c0..c2e63c63f 100644 --- a/mocks/mocks/data/formio-api/number.json +++ b/mocks/mocks/data/formio-api/number.json @@ -933,7 +933,7 @@ "skjemanummer": "testing-number", "tema": "AGR", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/radio.json b/mocks/mocks/data/formio-api/radio.json index b4edb8adc..b3c67d50c 100644 --- a/mocks/mocks/data/formio-api/radio.json +++ b/mocks/mocks/data/formio-api/radio.json @@ -423,7 +423,7 @@ "skjemanummer": "radio-test", "tema": "AAP", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/select-boxes.json b/mocks/mocks/data/formio-api/select-boxes.json index cd78e2e94..5fc6bfd9f 100644 --- a/mocks/mocks/data/formio-api/select-boxes.json +++ b/mocks/mocks/data/formio-api/select-boxes.json @@ -441,7 +441,7 @@ "skjemanummer": "select-boxes-test", "tema": "AGR", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/test-mellomlagring-v2.json b/mocks/mocks/data/formio-api/test-mellomlagring-v2.json index cf1f7e0e5..7f648d39e 100644 --- a/mocks/mocks/data/formio-api/test-mellomlagring-v2.json +++ b/mocks/mocks/data/formio-api/test-mellomlagring-v2.json @@ -1837,7 +1837,7 @@ "isTestForm": true, "modified": "2023-08-30T12:17:45.811Z", "modifiedBy": "magnus.roed.hestvik@nav.no", - "ettersending": "PAPIR_OG_DIGITAL" + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"] }, "project": "628ca77305690db58c974cfd", "revisions": "", diff --git a/mocks/mocks/data/formio-api/test-mellomlagring.json b/mocks/mocks/data/formio-api/test-mellomlagring.json index 69a7cdaaa..04bc45630 100644 --- a/mocks/mocks/data/formio-api/test-mellomlagring.json +++ b/mocks/mocks/data/formio-api/test-mellomlagring.json @@ -2383,7 +2383,7 @@ "isTestForm": true, "modified": "2023-08-30T12:17:45.811Z", "modifiedBy": "magnus.roed.hestvik@nav.no", - "ettersending": "PAPIR_OG_DIGITAL" + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"] }, "project": "628ca77305690db58c974cfd", "revisions": "", diff --git a/mocks/mocks/data/formio-api/textfield.json b/mocks/mocks/data/formio-api/textfield.json index 987f266e1..55a2bcfca 100644 --- a/mocks/mocks/data/formio-api/textfield.json +++ b/mocks/mocks/data/formio-api/textfield.json @@ -264,7 +264,7 @@ "skjemanummer": "test-tekstfelt", "tema": "GEN", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/year.json b/mocks/mocks/data/formio-api/year.json index aef77a67f..f96716ad5 100644 --- a/mocks/mocks/data/formio-api/year.json +++ b/mocks/mocks/data/formio-api/year.json @@ -246,7 +246,7 @@ "skjemanummer": "test-arstall", "tema": "GEN", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/mocks/mocks/data/formio-api/your-information.json b/mocks/mocks/data/formio-api/your-information.json index 0c1d257e9..abb563c2e 100644 --- a/mocks/mocks/data/formio-api/your-information.json +++ b/mocks/mocks/data/formio-api/your-information.json @@ -602,7 +602,7 @@ "skjemanummer": "test-your-information", "tema": "ERS", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "", diff --git a/package.json b/package.json index 1c3f65903..9daa749dc 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "preview:bygger": "yarn workspace @navikt/bygger-backend preview", "preview:fyllut": "yarn workspace @navikt/fyllut-backend preview", "test": "concurrently \"yarn workspace @navikt/bygger-frontend test\" \"yarn workspace @navikt/bygger-backend test\" \"yarn workspace @navikt/fyllut-frontend test\" \"yarn workspace @navikt/fyllut-backend test\" \"yarn workspace @navikt/skjemadigitalisering-shared-domain test\" \"yarn workspace @navikt/skjemadigitalisering-shared-components test\"", + "test:nowarnings": "NODE_OPTIONS=--no-warnings yarn test", "test:bygger": "concurrently \"yarn workspace @navikt/bygger-frontend test\" \"yarn workspace @navikt/bygger-backend test\"", "test:fyllut": "concurrently \"yarn workspace @navikt/fyllut-frontend test\" \"yarn workspace @navikt/fyllut-backend test\"", "test:shared-domain": "yarn workspace @navikt/skjemadigitalisering-shared-domain test", diff --git a/packages/bygger-backend/src/migration/migrationScripts.test.ts b/packages/bygger-backend/src/migration/migrationScripts.test.ts index 6d5aba239..957fad48c 100644 --- a/packages/bygger-backend/src/migration/migrationScripts.test.ts +++ b/packages/bygger-backend/src/migration/migrationScripts.test.ts @@ -143,7 +143,7 @@ describe('Migration scripts', () => { properties: { ...originalForm.properties, submissionTypes: ['DIGITAL'], - ettersending: undefined, + subsequentSubmissionTypes: ['PAPER', 'DIGITAL'], }, }; const { migratedForm: actual } = migrateForm( @@ -341,7 +341,7 @@ describe('Migration scripts', () => { ...originalForm.properties, skjemanummer: 'Form1', submissionTypes: ['DIGITAL'], - ettersending: undefined, + subsequentSubmissionTypes: ['PAPER', 'DIGITAL'], }, }; diff --git a/packages/bygger-backend/src/services/ReportService.test.ts b/packages/bygger-backend/src/services/ReportService.test.ts index 6f14fa848..e7878a314 100644 --- a/packages/bygger-backend/src/services/ReportService.test.ts +++ b/packages/bygger-backend/src/services/ReportService.test.ts @@ -102,6 +102,7 @@ describe('ReportService', () => { skjemanummer: 'TEST1', signatures: undefined, submissionTypes: [], + subsequentSubmissionTypes: [], } as unknown as FormPropertiesType, }, ]; @@ -125,6 +126,7 @@ describe('ReportService', () => { skjemanummer: 'TEST1', signatures: [{ label: '' }], submissionTypes: [], + subsequentSubmissionTypes: [], } as unknown as FormPropertiesType, }, ]; @@ -148,6 +150,7 @@ describe('ReportService', () => { skjemanummer: 'TEST1', signatures: [{ label: 'Lege' }, { label: 'Verge' }, { label: 'Søker' }], submissionTypes: [], + subsequentSubmissionTypes: [], } as unknown as FormPropertiesType, }, ]; @@ -179,6 +182,7 @@ describe('ReportService', () => { published: '2022-07-28T10:00:10.325Z', modified: '2022-07-28T10:00:10.325Z', submissionTypes: [], + subsequentSubmissionTypes: [], } as unknown as FormPropertiesType, } as Form, ]; @@ -206,6 +210,7 @@ describe('ReportService', () => { published: '2022-07-28T10:00:10.325Z', modified: '2022-07-28T11:00:05.254Z', submissionTypes: [], + subsequentSubmissionTypes: [], } as unknown as FormPropertiesType, } as Form, ]; @@ -231,6 +236,7 @@ describe('ReportService', () => { skjemanummer: 'TEST1', modified: '2022-07-28T11:00:05.254Z', submissionTypes: [], + subsequentSubmissionTypes: [], } as unknown as FormPropertiesType, } as Form, ]; @@ -332,6 +338,7 @@ describe('ReportService', () => { ] as Component[], properties: { submissionTypes: [], + subsequentSubmissionTypes: [], } as unknown as FormPropertiesType, } as Form, { @@ -342,6 +349,7 @@ describe('ReportService', () => { status: 'published', properties: { submissionTypes: [], + subsequentSubmissionTypes: [], } as unknown as FormPropertiesType, } as Form, { @@ -359,6 +367,7 @@ describe('ReportService', () => { ] as Component[], properties: { submissionTypes: [], + subsequentSubmissionTypes: [], } as unknown as FormPropertiesType, } as Form, ]; @@ -427,7 +436,7 @@ describe('ReportService', () => { published: '2022-07-28T10:00:10.325Z', publishedLanguages: ['en', 'nn-NO'], submissionTypes: ['DIGITAL', 'PAPER'], - ettersending: 'PAPIR_OG_DIGITAL', + subsequentSubmissionTypes: ['DIGITAL', 'PAPER'], }, } as Form, { @@ -443,7 +452,7 @@ describe('ReportService', () => { published: '2022-07-28T10:00:10.325Z', publishedLanguages: ['en'], submissionTypes: [], - ettersending: 'KUN_PAPIR', + subsequentSubmissionTypes: ['PAPER'], }, } as Form, { @@ -480,7 +489,7 @@ describe('ReportService', () => { published: '2022-07-28T10:00:10.325Z', publishedLanguages: undefined, submissionTypes: ['PAPER'], - ettersending: 'KUN_PAPIR', + subsequentSubmissionTypes: ['PAPER'], }, } as Form, ]; diff --git a/packages/bygger-backend/src/services/ReportService.ts b/packages/bygger-backend/src/services/ReportService.ts index 16e895085..4af3512d4 100644 --- a/packages/bygger-backend/src/services/ReportService.ts +++ b/packages/bygger-backend/src/services/ReportService.ts @@ -1,8 +1,8 @@ import { Form, - ReportDefinition, formioFormsApiUtils, navFormUtils, + ReportDefinition, submissionTypesUtils, } from '@navikt/skjemadigitalisering-shared-domain'; import { stringify } from 'csv-stringify'; @@ -116,7 +116,7 @@ class ReportService { 'sist endret', 'endret av', 'submissionTypes', - 'ettersending', + 'subsequentSubmissionTypes', 'signaturfelt', 'path', 'har vedlegg', @@ -141,7 +141,7 @@ class ReportService { const attachmentNames = attachments.map((attachment) => attachment.vedleggstittel).join(','); const { title, path, properties, status, changedAt, changedBy, publishedAt, publishedBy } = formCompact; - const { submissionTypes, tema, signatures, ettersending } = properties; + const { submissionTypes, tema, signatures, subsequentSubmissionTypes } = properties; const baseInnsendingUrl = config.naisClusterName === 'prod-gcp' @@ -160,7 +160,9 @@ class ReportService { const ettersendingUrl = hasAttachment ? baseEttersendingUrl : undefined; const paperEttersendingUrl = - navFormUtils.isPaper('ettersending', form) && hasAttachment ? `${baseEttersendingUrl}?sub=paper` : undefined; + submissionTypesUtils.isPaperSubmission(subsequentSubmissionTypes) && hasAttachment + ? `${baseEttersendingUrl}?sub=paper` + : undefined; const isPublished = ['published', 'pending'].includes(status!); @@ -181,7 +183,7 @@ class ReportService { changedAt, changedBy, submissionTypes, - ettersending, + subsequentSubmissionTypes, numberOfSignatures, path, hasAttachment ? 'ja' : 'nei', diff --git a/packages/bygger-backend/src/services/forms/FormsService.test.ts b/packages/bygger-backend/src/services/forms/FormsService.test.ts index 6956c0c43..24a803f38 100644 --- a/packages/bygger-backend/src/services/forms/FormsService.test.ts +++ b/packages/bygger-backend/src/services/forms/FormsService.test.ts @@ -21,7 +21,7 @@ describe('FormsService', () => { let formsService; const accessToken = 'test-token'; const form: Form = { - properties: { submissionTypes: [] } as unknown as FormPropertiesType, + properties: { submissionTypes: [], subsequentSubmissionTypes: [] } as unknown as FormPropertiesType, id: 1, path: 'test-form', title: 'Test Form', diff --git a/packages/bygger-backend/src/services/forms/FormsService.ts b/packages/bygger-backend/src/services/forms/FormsService.ts index 4f1868cff..54f6eaee4 100644 --- a/packages/bygger-backend/src/services/forms/FormsService.ts +++ b/packages/bygger-backend/src/services/forms/FormsService.ts @@ -1,7 +1,7 @@ import { Form } from '@navikt/skjemadigitalisering-shared-domain'; import { fetchWithErrorHandling } from '../../fetchUtils'; import { logger } from '../../logging/logger'; -import { createHeaders, removeInnsendingFromForm } from '../utils/formsApiUtils'; +import { createHeaders, removeInnsendingTypeFromForm } from '../utils/formsApiUtils'; import { FormPostBody, FormPutBody, FormsService } from './types'; const createFormsService = (formsApiUrl: string): FormsService => { @@ -11,12 +11,12 @@ const createFormsService = (formsApiUrl: string): FormsService => { const search = select ? new URLSearchParams({ select }) : ''; const url = `${formsUrl}?${search}`; const response = await fetchWithErrorHandling(url, { headers: createHeaders() }); - return (response.data as Form[]).map(removeInnsendingFromForm); + return (response.data as Form[]).map(removeInnsendingTypeFromForm); }; const get = async (formPath: string): Promise
=> { const response = await fetchWithErrorHandling(`${formsUrl}/${formPath}`, { headers: createHeaders() }); - return removeInnsendingFromForm(response.data as Form) as Form; + return removeInnsendingTypeFromForm(response.data as Form) as Form; }; const post = async (body: FormPostBody, accessToken: string): Promise => { diff --git a/packages/bygger-backend/src/services/utils/formsApiUtils.test.ts b/packages/bygger-backend/src/services/utils/formsApiUtils.test.ts index bf247a6de..77a9099d5 100644 --- a/packages/bygger-backend/src/services/utils/formsApiUtils.test.ts +++ b/packages/bygger-backend/src/services/utils/formsApiUtils.test.ts @@ -1,30 +1,30 @@ import { Form, formioFormsApiUtils } from '@navikt/skjemadigitalisering-shared-domain'; -import { removeInnsendingFromForm } from './formsApiUtils'; +import { removeInnsendingTypeFromForm } from './formsApiUtils'; describe('formsApiUtils', () => { - describe('formioFormsApiUtils.mapInnsendingToSubmissionTypes', () => { + describe('formioFormsApiUtils.mapInnsendingTypeToSubmissionTypes', () => { it('should return [PAPER, DIGITAL] when innsending is PAPIR_OG_DIGITAL', () => { - expect(formioFormsApiUtils.mapInnsendingToSubmissionTypes('PAPIR_OG_DIGITAL')).toStrictEqual([ + expect(formioFormsApiUtils.mapInnsendingTypeToSubmissionTypes('PAPIR_OG_DIGITAL')).toStrictEqual([ 'PAPER', 'DIGITAL', ]); }); it('should return [PAPER] when innsending is KUN_PAPIR', () => { - expect(formioFormsApiUtils.mapInnsendingToSubmissionTypes('KUN_PAPIR')).toStrictEqual(['PAPER']); + expect(formioFormsApiUtils.mapInnsendingTypeToSubmissionTypes('KUN_PAPIR')).toStrictEqual(['PAPER']); }); it('should return [DIGITAL] when innsending is KUN_DIGITAL', () => { - expect(formioFormsApiUtils.mapInnsendingToSubmissionTypes('KUN_DIGITAL')).toStrictEqual(['DIGITAL']); + expect(formioFormsApiUtils.mapInnsendingTypeToSubmissionTypes('KUN_DIGITAL')).toStrictEqual(['DIGITAL']); }); it('should return an empty array when innsending is undefined', () => { - expect(formioFormsApiUtils.mapInnsendingToSubmissionTypes(undefined)).toStrictEqual([]); + expect(formioFormsApiUtils.mapInnsendingTypeToSubmissionTypes(undefined)).toStrictEqual([]); }); }); describe('removeInnsendingFromForm', () => { - it('should not return innsending and submissionTypes should be [PAPER, DIGITAL]', () => { + it('should remove innsending and ettersending, and set both submissionTypes and subsequentSubmissionTypes to [PAPER, DIGITAL]', () => { const form = { tags: [], type: 'test', @@ -34,6 +34,7 @@ describe('formsApiUtils', () => { path: '/test-path', properties: { innsending: 'PAPIR_OG_DIGITAL', + ettersending: 'PAPIR_OG_DIGITAL', ettersendelsesfrist: '12', skjemanummer: '', tema: '', @@ -41,13 +42,16 @@ describe('formsApiUtils', () => { }, components: [], } as unknown as Form; - const data = removeInnsendingFromForm(form); + const data = removeInnsendingTypeFromForm(form); expect(data).not.toHaveProperty('properties.innsending'); + expect(data).not.toHaveProperty('properties.ettersending'); expect(data).toHaveProperty('properties.submissionTypes'); + expect(data).toHaveProperty('properties.subsequentSubmissionTypes'); expect(data.properties.submissionTypes).toEqual(['PAPER', 'DIGITAL']); + expect(data.properties.subsequentSubmissionTypes).toEqual(['PAPER', 'DIGITAL']); }); - it('should return submissionType when exists', () => { + it('should keep existing submissionTypes and subsequentSubmissionTypes unchanged when already defined', () => { const form = { tags: [], type: 'test', @@ -57,6 +61,7 @@ describe('formsApiUtils', () => { path: '/test-path', properties: { submissionTypes: ['PAPER'], + subsequentSubmissionTypes: ['PAPER', 'DIGITAL'], ettersendelsesfrist: '12', skjemanummer: '', tema: '', @@ -64,10 +69,13 @@ describe('formsApiUtils', () => { }, components: [], } as unknown as Form; - const data = removeInnsendingFromForm(form); + const data = removeInnsendingTypeFromForm(form); expect(data).not.toHaveProperty('properties.innsending'); + expect(data).not.toHaveProperty('properties.ettersending'); expect(data).toHaveProperty('properties.submissionTypes'); + expect(data).toHaveProperty('properties.subsequentSubmissionTypes'); expect(data.properties.submissionTypes).toEqual(['PAPER']); + expect(data.properties.subsequentSubmissionTypes).toEqual(['PAPER', 'DIGITAL']); }); }); }); diff --git a/packages/bygger-backend/src/services/utils/formsApiUtils.ts b/packages/bygger-backend/src/services/utils/formsApiUtils.ts index 59db0ea15..586495ce9 100644 --- a/packages/bygger-backend/src/services/utils/formsApiUtils.ts +++ b/packages/bygger-backend/src/services/utils/formsApiUtils.ts @@ -11,15 +11,22 @@ const createHeaders = (accessToken?: string, revisionId?: number) => { }; }; -export const removeInnsendingFromForm = (form: Form): Form => { - const formProperties = (({ innsending, ...rest }) => rest)(form.properties); +/** + * + * Metoden er implementert kun for å støtte bakoverkompatibilitet og skal fjernes ved migrering + */ +export const removeInnsendingTypeFromForm = (form: Form): Form => { + const formProperties = (({ innsending, ettersending, ...rest }) => rest)(form.properties); return { ...form, properties: { ...formProperties, submissionTypes: form.properties.submissionTypes ?? - formioFormsApiUtils.mapInnsendingToSubmissionTypes(form.properties.innsending), + formioFormsApiUtils.mapInnsendingTypeToSubmissionTypes(form.properties.innsending), + subsequentSubmissionTypes: + form.properties.subsequentSubmissionTypes ?? + formioFormsApiUtils.mapEttersendingTypeToSubmissionTypes(form.properties.ettersending), }, }; }; diff --git a/packages/bygger/cypress/e2e/settings.spec.cy.ts b/packages/bygger/cypress/e2e/settings.spec.cy.ts index 0c65249e6..54ac498f8 100644 --- a/packages/bygger/cypress/e2e/settings.spec.cy.ts +++ b/packages/bygger/cypress/e2e/settings.spec.cy.ts @@ -7,7 +7,7 @@ const submitData = { tema: 'BIL', downloadPdfButtonText: 'DownloadPDFBtnTest', submissionTypes: ['PAPER', 'DIGITAL'], - ettersending: 'PAPIR_OG_DIGITAL', + subsequentSubmissionTypes: ['PAPER', 'DIGITAL'], descriptionOfSignatures: 'Test Instructions', signatureLabel: 'Test account', signatureDescription: 'Instruction from test...', @@ -65,7 +65,7 @@ describe('FormSettingsPage', () => { expect(req.body.properties.skjemanummer).to.include(submitData.skjemanummer); expect(req.body.properties.descriptionOfSignatures).to.include(submitData.descriptionOfSignatures); expect(req.body.properties.submissionTypes).to.deep.include.members(submitData.submissionTypes); - expect(req.body.properties.ettersending).to.include(submitData.ettersending); + expect(req.body.properties.subsequentSubmissionTypes).to.deep.members(submitData.subsequentSubmissionTypes); expect(req.body.properties.signatures[0].label).to.include(submitData.signatureLabel); expect(req.body.properties.signatures[0].description).to.include(submitData.signatureDescription); req.reply(req.body); @@ -85,7 +85,9 @@ describe('FormSettingsPage', () => { cy.get(`input[type="checkbox"][value="${type}"]`).check({ force: true }); }); - cy.findByRole('combobox', { name: 'Ettersending' }).select(submitData.ettersending); + submitData.subsequentSubmissionTypes.forEach((type) => { + cy.get(`input[type="checkbox"][value="${type}"]`).check({ force: true }); + }); cy.findByRole('spinbutton', { name: 'Mellomlagringstid (dager)' }).focus(); cy.findByRole('spinbutton', { name: 'Mellomlagringstid (dager)' }).clear(); diff --git a/packages/bygger/cypress/fixtures/form123456-published.json b/packages/bygger/cypress/fixtures/form123456-published.json index 3c5317a0a..e01ad1aed 100644 --- a/packages/bygger/cypress/fixtures/form123456-published.json +++ b/packages/bygger/cypress/fixtures/form123456-published.json @@ -3508,6 +3508,7 @@ "skjemanummer": "TST-123456", "tema": "DAG", "submissionTypes": ["PAPER", "DIGITAL"], + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "Lege", diff --git a/packages/bygger/cypress/fixtures/form123456.json b/packages/bygger/cypress/fixtures/form123456.json index b01366948..a390d4be4 100644 --- a/packages/bygger/cypress/fixtures/form123456.json +++ b/packages/bygger/cypress/fixtures/form123456.json @@ -3375,6 +3375,7 @@ "skjemanummer": "TST-123456", "tema": "DAG", "submissionTypes": ["PAPER", "DIGITAL"], + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "Lege", diff --git a/packages/bygger/cypress/fixtures/formMultiValues.json b/packages/bygger/cypress/fixtures/formMultiValues.json index cc2ba70e3..766bb4c27 100644 --- a/packages/bygger/cypress/fixtures/formMultiValues.json +++ b/packages/bygger/cypress/fixtures/formMultiValues.json @@ -347,7 +347,7 @@ "modifiedBy": "test@nav.no", "publishedLanguages": [], "descriptionOfSignaturesPositionUnder": true, - "ettersending": "INGEN", + "subsequentSubmissionTypes": [], "declarationType": "default", "downloadPdfButtonText": "ab", "isTestForm": false, diff --git a/packages/bygger/cypress/fixtures/getForm.json b/packages/bygger/cypress/fixtures/getForm.json index 0d6adb53b..ee3020c96 100644 --- a/packages/bygger/cypress/fixtures/getForm.json +++ b/packages/bygger/cypress/fixtures/getForm.json @@ -339,7 +339,7 @@ "skjemanummer": "cypress-settings", "tema": "CYPRESSTEST", "submissionTypes": ["PAPER", "DIGITAL"], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "signatures": [ { "label": "Lege", diff --git a/packages/bygger/cypress/fixtures/nav112233-published.json b/packages/bygger/cypress/fixtures/nav112233-published.json index 52e46aeea..fba011aa5 100644 --- a/packages/bygger/cypress/fixtures/nav112233-published.json +++ b/packages/bygger/cypress/fixtures/nav112233-published.json @@ -596,7 +596,7 @@ "description": "" } ], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "skjemanummer": "NAV 11-22.33", "ettersendelsesfrist": "14", "mellomlagringDurationDays": "28" diff --git a/packages/bygger/cypress/fixtures/nav112233.json b/packages/bygger/cypress/fixtures/nav112233.json index c9dd34969..2648e4fd8 100644 --- a/packages/bygger/cypress/fixtures/nav112233.json +++ b/packages/bygger/cypress/fixtures/nav112233.json @@ -783,7 +783,7 @@ "description": "" } ], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "skjemanummer": "NAV 11-22.33", "ettersendelsesfrist": "14", "mellomlagringDurationDays": "28" diff --git a/packages/bygger/cypress/fixtures/tekstblokk123.json b/packages/bygger/cypress/fixtures/tekstblokk123.json index eb872d243..2fd203f40 100644 --- a/packages/bygger/cypress/fixtures/tekstblokk123.json +++ b/packages/bygger/cypress/fixtures/tekstblokk123.json @@ -410,7 +410,7 @@ "modifiedBy": "magnus.roed.hestvik@nav.no", "publishedBy": "Hestvik, Magnus Røed", "publishedLanguages": [], - "ettersending": "PAPIR_OG_DIGITAL", + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"], "prefill": [] }, "access": [ diff --git a/packages/bygger/example_data/Form.json b/packages/bygger/example_data/Form.json index 1a4c6ec20..2983cd4d2 100644 --- a/packages/bygger/example_data/Form.json +++ b/packages/bygger/example_data/Form.json @@ -363,6 +363,7 @@ "machineName": "kxzxmneixaglyxf:debugSkjema", "properties": { "skjemanummer": "NAV 12-13.14", - "submissionTypes": [] + "submissionTypes": [], + "subsequentSubmissionTypes": [] } } diff --git a/packages/bygger/src/api/useTemaKoder.test.tsx b/packages/bygger/src/api/useTemaKoder.test.tsx index 2bb9c3488..b2dbbfe14 100644 --- a/packages/bygger/src/api/useTemaKoder.test.tsx +++ b/packages/bygger/src/api/useTemaKoder.test.tsx @@ -21,8 +21,10 @@ describe('useTemaKoder', () => { it('returns ready: false and empty temakoder initially', async () => { const { result } = renderHook(() => useTemaKoder(), { wrapper: appConfig }); - expect(result.current.ready).toBe(false); - expect(result.current.temaKoder).toEqual([]); + await waitFor(() => { + expect(result.current.ready).toBe(false); + expect(result.current.temaKoder).toEqual([]); + }); }); it('fetches temakoder and returns them when ready', async () => { diff --git a/packages/bygger/src/components/FormMetaDataEditor/FormMetadataEditor.test.tsx b/packages/bygger/src/components/FormMetaDataEditor/FormMetadataEditor.test.tsx index 827a8a9a3..9c65eea63 100644 --- a/packages/bygger/src/components/FormMetaDataEditor/FormMetadataEditor.test.tsx +++ b/packages/bygger/src/components/FormMetaDataEditor/FormMetadataEditor.test.tsx @@ -53,6 +53,7 @@ const defaultForm: Form = { properties: { skjemanummer: 'TST 12.34-56', submissionTypes: ['PAPER', 'DIGITAL'], + subsequentSubmissionTypes: ['PAPER', 'DIGITAL'], tema: 'BIL', enhetMaVelgesVedPapirInnsending: false, enhetstyper: [], @@ -122,8 +123,10 @@ describe('FormMetadataEditor', () => { }; const { rerender } = render(); - const checkbox = screen.getByRole('checkbox', { name: 'Digital' }); - await userEvent.click(checkbox); + const digitalCheckboxes = screen.getAllByRole('checkbox', { name: /Digital/i }); + const digitalInnsending = digitalCheckboxes[0]; + + await userEvent.click(digitalInnsending); expect(mockOnChange).toHaveBeenCalled(); const updatedForm = mockOnChange.mock.calls[0][0] as Form; @@ -146,8 +149,10 @@ describe('FormMetadataEditor', () => { const { rerender } = render(); expect(screen.queryByLabelText('Forklaring til innsending')).not.toBeNull(); - const kunPapirCheckbox = screen.getByRole('checkbox', { name: 'Papir' }); - await userEvent.click(kunPapirCheckbox); + const papirCheckboxes = screen.getAllByRole('checkbox', { name: /Papir/i }); + const papirInnsending = papirCheckboxes[0]; + + await userEvent.click(papirInnsending); await expect(mockOnChange).toHaveBeenCalled(); @@ -168,8 +173,11 @@ describe('FormMetadataEditor', () => { }, }; const { rerender } = render(); - expect(screen.queryByLabelText('Forklaring til submissionTypes')).toBeNull(); - await userEvent.click(screen.getByRole('checkbox', { name: /Papir/ })); + expect(screen.queryByLabelText('Forklaring til innsending')).not.toBeNull(); + const papirCheckboxes = screen.getAllByRole('checkbox', { name: /Papir/i }); + const papirInnsending = papirCheckboxes[0]; + + await userEvent.click(papirInnsending); expect(mockOnChange).toHaveBeenCalled(); const updatedForm = mockOnChange.mock.calls[0][0] as Form; @@ -214,7 +222,7 @@ describe('FormMetadataEditor', () => { describe('Ettersendelsesfrist', () => { it('lagres i properties', async () => { - const form = formMedProps({ ettersendelsesfrist: undefined, ettersending: 'KUN_DIGITAL' }); + const form = formMedProps({ ettersendelsesfrist: undefined, subsequentSubmissionTypes: ['DIGITAL'] }); render(); const input = screen.getByLabelText('Ettersendelsesfrist (dager)'); @@ -227,7 +235,7 @@ describe('FormMetadataEditor', () => { }); it('nullstilles i properties', async () => { - const form = formMedProps({ ettersendelsesfrist: '42', ettersending: 'KUN_DIGITAL' }); + const form = formMedProps({ ettersendelsesfrist: '42', subsequentSubmissionTypes: ['DIGITAL'] }); render(); const input = screen.getByLabelText('Ettersendelsesfrist (dager)'); await userEvent.clear(input); @@ -240,7 +248,7 @@ describe('FormMetadataEditor', () => { describe('mellomlagringDurationDays', () => { it('is saved in properties', async () => { - const form = formMedProps({ mellomlagringDurationDays: undefined, ettersending: 'KUN_DIGITAL' }); + const form = formMedProps({ mellomlagringDurationDays: undefined, subsequentSubmissionTypes: ['DIGITAL'] }); render(); const input = screen.getByLabelText('Mellomlagringstid (dager)'); @@ -309,7 +317,7 @@ describe('FormMetadataEditor', () => { }); }); - describe('Innstilling for valg av enhet ved papirsubmissionTypes', () => { + describe('Innstilling for valg av enhet ved papirinnsending', () => { const expectedCheckboxName = 'Bruker må velge enhet ved innsending på papir'; const editFormMetadataEditor = (form: Form, onChange: UpdateFormFunction) => ( @@ -326,19 +334,19 @@ describe('FormMetadataEditor', () => { expect(screen.queryByRole('checkbox', { name: expectedCheckboxName })).toBeTruthy(); }); - it('Vises når submissionTypes=PAPIR_OG_DIGITAL', async () => { + it('Vises når submissionTypes=[PAPER, DIGITAL]', async () => { const form: Form = formMedProps({ submissionTypes: ['PAPER', 'DIGITAL'] }); render(editFormMetadataEditor(form, mockOnChange)); expect(screen.queryByRole('checkbox', { name: expectedCheckboxName })).toBeTruthy(); }); - it('Vises ikke når submissionTypes=INGEN', async () => { + it('Vises ikke når submissionTypes=[]', async () => { const form: Form = formMedProps({ submissionTypes: [] }); render(editFormMetadataEditor(form, mockOnChange)); expect(screen.queryByRole('checkbox', { name: expectedCheckboxName })).toBeFalsy(); }); - it('Vises ikke når submissionTypes=KUN_DIGITAL', async () => { + it('Vises ikke når submissionTypes=DIGITAL', async () => { const form: Form = formMedProps({ submissionTypes: ['DIGITAL'] }); render(editFormMetadataEditor(form, mockOnChange)); expect(screen.queryByRole('checkbox', { name: expectedCheckboxName })).toBeFalsy(); @@ -392,7 +400,7 @@ describe('FormMetadataEditor', () => { }); render(editFormMetadataEditor(form, mockOnChange)); const checkboxes = screen.getAllByRole('checkbox', { checked: true }); - expect(checkboxes).toHaveLength(6); + expect(checkboxes).toHaveLength(8); }); it('fjerner valgt enhet ved klikk', async () => { diff --git a/packages/bygger/src/components/FormMetaDataEditor/fields/SubmissionFields.tsx b/packages/bygger/src/components/FormMetaDataEditor/fields/SubmissionFields.tsx index a828e5466..78b9a685f 100644 --- a/packages/bygger/src/components/FormMetaDataEditor/fields/SubmissionFields.tsx +++ b/packages/bygger/src/components/FormMetaDataEditor/fields/SubmissionFields.tsx @@ -1,12 +1,6 @@ import { Checkbox, Textarea, TextField } from '@navikt/ds-react'; -import { - Form, - FormSettingsDiff, - InnsendingType, - submissionTypesUtils, -} from '@navikt/skjemadigitalisering-shared-domain'; +import { Form, FormSettingsDiff, submissionTypesUtils } from '@navikt/skjemadigitalisering-shared-domain'; import LabelWithDiff from '../LabelWithDiff'; -import SubmissionTypeSelect from '../SubmissionTypeSelect'; import { FormMetadataError, UpdateFormFunction } from '../utils/utils'; import { SubmissionTypeCheckbox } from './SubmissionTypeCheckbox'; @@ -18,7 +12,7 @@ export interface SubmissionFieldsProps { } const SubmissionFields = ({ onChange, diff, form, errors }: SubmissionFieldsProps) => { - const { submissionTypes, ettersending, ettersendelsesfrist, hideUserTypes } = form.properties; + const { submissionTypes, subsequentSubmissionTypes, ettersendelsesfrist, hideUserTypes } = form.properties; const isLockedForm = !!form.lock; return ( @@ -40,21 +34,24 @@ const SubmissionFields = ({ onChange, diff, form, errors }: SubmissionFieldsProp } /> - } - value={ettersending} - error={errors?.ettersending} + } + value={subsequentSubmissionTypes} + error={errors?.subsequentSubmissionTypes} readonly={isLockedForm} - onChange={(event) => + onChange={(data) => onChange({ ...form, - properties: { ...form.properties, ettersending: event.target.value as InnsendingType }, + properties: { + ...form.properties, + subsequentSubmissionTypes: [...data], + }, }) } /> - {!!ettersending && ettersending !== 'INGEN' && ( + {!submissionTypesUtils.isNoneSubmission(subsequentSubmissionTypes) && ( e.currentTarget.blur()} // disable scroll wheel on number input className="mb" diff --git a/packages/bygger/src/components/FormMetaDataEditor/utils/utils.test.ts b/packages/bygger/src/components/FormMetaDataEditor/utils/utils.test.ts index 6eda31d0b..979b8837b 100644 --- a/packages/bygger/src/components/FormMetaDataEditor/utils/utils.test.ts +++ b/packages/bygger/src/components/FormMetaDataEditor/utils/utils.test.ts @@ -11,6 +11,7 @@ describe('Form Metadata Validation', () => { path: 'sample-path', properties: { submissionTypes: [], + subsequentSubmissionTypes: [], skjemanummer: 'NAV 12-13.14', tema: 'AAP', mellomlagringDurationDays: '28', @@ -31,7 +32,7 @@ describe('Form Metadata Validation', () => { const usageContext: UsageContext = 'edit'; // Set properties that are required for edit mode sampleForm.properties.submissionTypes = ['DIGITAL']; - sampleForm.properties.ettersending = 'KUN_PAPIR'; + sampleForm.properties.subsequentSubmissionTypes = ['PAPER']; const errors = validateFormMetadata(sampleForm, usageContext); @@ -51,20 +52,6 @@ describe('Form Metadata Validation', () => { expect(isFormMetadataValid(errors)).toBe(false); }); - it('should handle errors for an edit form', () => { - const usageContext: UsageContext = 'edit'; - - sampleForm.properties.submissionTypes = []; // Missing submissionTypes - sampleForm.properties.ettersending = undefined; // Missing ettersending - - const errors = validateFormMetadata(sampleForm, usageContext); - - expect(errors).toEqual({ - ettersending: 'Du må velge innsendingstype for ettersending', - }); - expect(isFormMetadataValid(errors)).toBe(false); - }); - it('should validate skjemanummer length for a new form', () => { const usageContext: UsageContext = 'create'; // Skjemanummer with length greater than 20 @@ -82,7 +69,7 @@ describe('Form Metadata Validation', () => { const usageContext: UsageContext = 'edit'; sampleForm.properties.mellomlagringDurationDays = '28.3'; sampleForm.properties.submissionTypes = ['DIGITAL']; - sampleForm.properties.ettersending = 'KUN_PAPIR'; + sampleForm.properties.subsequentSubmissionTypes = ['PAPER']; const errors = validateFormMetadata(sampleForm, usageContext); @@ -96,7 +83,7 @@ describe('Form Metadata Validation', () => { const usageContext: UsageContext = 'edit'; sampleForm.properties.mellomlagringDurationDays = '30'; sampleForm.properties.submissionTypes = ['DIGITAL']; - sampleForm.properties.ettersending = 'KUN_PAPIR'; + sampleForm.properties.subsequentSubmissionTypes = ['PAPER']; const errors = validateFormMetadata(sampleForm, usageContext); diff --git a/packages/bygger/src/components/FormMetaDataEditor/utils/utils.ts b/packages/bygger/src/components/FormMetaDataEditor/utils/utils.ts index 4ab9717f6..563bd9329 100644 --- a/packages/bygger/src/components/FormMetaDataEditor/utils/utils.ts +++ b/packages/bygger/src/components/FormMetaDataEditor/utils/utils.ts @@ -6,7 +6,7 @@ export type FormMetadataErrorKeys = | 'skjemanummer' | 'tema' | 'submissionTypes' - | 'ettersending' + | 'subsequentSubmissionTypes' | 'lockedFormReason' | 'declarationText' | 'uxSignalsId' @@ -37,9 +37,6 @@ export const validateFormMetadata = (form: Form, usageContext: UsageContext) => // Some fields are only required in edit mode if (usageContext === 'edit') { - if (!form.properties.ettersending) { - errors.ettersending = 'Du må velge innsendingstype for ettersending'; - } if (form.properties.declarationType === DeclarationType.custom && !form.properties.declarationText) { errors.declarationText = 'Du må lage en tilpasset erklæringstekst'; } diff --git a/packages/bygger/src/migration/MigrationPage.test.tsx b/packages/bygger/src/migration/MigrationPage.test.tsx index 58cf0869d..c7f960dc6 100644 --- a/packages/bygger/src/migration/MigrationPage.test.tsx +++ b/packages/bygger/src/migration/MigrationPage.test.tsx @@ -225,15 +225,17 @@ describe('MigrationPage', () => { describe('onClick', () => { beforeEach(async () => { - setMigrateOptionInput('search-filters', 0, 'prop1', true); - setMigrateOptionInput('edit-options', 0, 'prop1', false); - fireEvent.click(screen.getByRole('button', { name: 'Simuler og kontroller migrering' })); - await waitFor(() => expect(fetchSpy).toHaveBeenCalled()); - fireEvent.click(screen.getAllByLabelText('Inkluder i migrering')[1]); - fireEvent.click(screen.getByRole('button', { name: 'Migrer' })); - const selectForMigration = await screen.findAllByRole('checkbox', { name: 'Inkluder i migrering' }); - selectForMigration[0].click(); - selectForMigration[1].click(); + await waitFor(async () => { + setMigrateOptionInput('search-filters', 0, 'prop1', true); + setMigrateOptionInput('edit-options', 0, 'prop1', false); + fireEvent.click(screen.getByRole('button', { name: 'Simuler og kontroller migrering' })); + await waitFor(() => expect(fetchSpy).toHaveBeenCalled()); + fireEvent.click(screen.getAllByLabelText('Inkluder i migrering')[1]); + fireEvent.click(screen.getByRole('button', { name: 'Migrer' })); + const selectForMigration = await screen.findAllByRole('checkbox', { name: 'Inkluder i migrering' }); + selectForMigration[0].click(); + selectForMigration[1].click(); + }); }); it('opens a modal with info on which forms have been selected for migration', () => { diff --git a/packages/bygger/src/migration/components/BulkPublishPanel.test.tsx b/packages/bygger/src/migration/components/BulkPublishPanel.test.tsx index 883e5d98b..509f77ef3 100644 --- a/packages/bygger/src/migration/components/BulkPublishPanel.test.tsx +++ b/packages/bygger/src/migration/components/BulkPublishPanel.test.tsx @@ -17,6 +17,7 @@ const properties: FormPropertiesType = { skjemanummer: 'skjemanummer', tema: 'tema', submissionTypes: ['PAPER', 'DIGITAL'], + subsequentSubmissionTypes: ['PAPER', 'DIGITAL'], signatures: { signature1: '', signature2: '', diff --git a/packages/fyllut-backend/src/routers/api/form.test.ts b/packages/fyllut-backend/src/routers/api/form.test.ts index a895a5d9c..2976f8219 100644 --- a/packages/fyllut-backend/src/routers/api/form.test.ts +++ b/packages/fyllut-backend/src/routers/api/form.test.ts @@ -19,6 +19,7 @@ const testForm: NavFormType = { path: '/test-path', properties: { submissionTypes: ['PAPER', 'DIGITAL'], + subsequentSubmissionTypes: ['PAPER', 'DIGITAL'], ettersendelsesfrist: '12', skjemanummer: '', tema: '', diff --git a/packages/fyllut-backend/src/routers/api/form.ts b/packages/fyllut-backend/src/routers/api/form.ts index cfc595dea..122b98afe 100644 --- a/packages/fyllut-backend/src/routers/api/form.ts +++ b/packages/fyllut-backend/src/routers/api/form.ts @@ -51,7 +51,9 @@ const mapLimitedForm = (form: NavFormType, translate: TranslateFunction) => { skjemanummer: form.properties.skjemanummer, tema: form.properties.tema, innsending: form.properties.innsending, + submissionTypes: form.properties.submissionTypes, ettersending: form.properties.ettersending, + subsequentSubmissionTypes: form.properties.subsequentSubmissionTypes, enhetstyper: form.properties.enhetstyper, enhetMaVelgesVedPapirInnsending: form.properties.enhetMaVelgesVedPapirInnsending, uxSignalsId: form.properties.uxSignalsId, diff --git a/packages/fyllut-backend/src/routers/api/forms.ts b/packages/fyllut-backend/src/routers/api/forms.ts index e10edd1a8..913e6e548 100644 --- a/packages/fyllut-backend/src/routers/api/forms.ts +++ b/packages/fyllut-backend/src/routers/api/forms.ts @@ -11,6 +11,7 @@ const mapForm = (form): FormsResponseForm => ({ skjemanummer: form.skjemanummer ?? form.properties.skjemanummer, submissionTypes: form.properties.submissionTypes, ettersending: form.properties.ettersending, + subsequentSubmissionTypes: form.properties.subsequentSubmissionTypes, }, }); diff --git a/packages/fyllut/cypress/fixtures/mellomlagring/submitTestMellomlagring.json b/packages/fyllut/cypress/fixtures/mellomlagring/submitTestMellomlagring.json index 51a988174..ee68ff37c 100644 --- a/packages/fyllut/cypress/fixtures/mellomlagring/submitTestMellomlagring.json +++ b/packages/fyllut/cypress/fixtures/mellomlagring/submitTestMellomlagring.json @@ -2385,7 +2385,7 @@ "isTestForm": true, "modified": "2023-08-30T12:17:45.811Z", "modifiedBy": "magnus.roed.hestvik@nav.no", - "ettersending": "PAPIR_OG_DIGITAL" + "subsequentSubmissionTypes": ["PAPER", "DIGITAL"] }, "project": "628ca77305690db58c974cfd", "revisions": "", diff --git a/packages/shared-components/src/pages/FyllUtRouter.test.tsx b/packages/shared-components/src/pages/FyllUtRouter.test.tsx index 2269fb5f7..eb238def7 100644 --- a/packages/shared-components/src/pages/FyllUtRouter.test.tsx +++ b/packages/shared-components/src/pages/FyllUtRouter.test.tsx @@ -1,4 +1,4 @@ -import { render, screen } from '@testing-library/react'; +import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { RouterProvider, createMemoryRouter } from 'react-router-dom'; import { setupNavFormio } from '../../test/navform-render'; @@ -82,14 +82,16 @@ describe('FyllUtRouter', () => { }); describe('Submission method', () => { - it('Renders vedleggspanel when submission method is undefined', () => { + it('Renders vedleggspanel when submission method is undefined', async () => { renderFyllUtRouter({ form, translationsForNavForm }, { submissionMethod: undefined }); - expect(screen.queryByRole('heading', { name: form.title })).toBeInTheDocument(); - const stepperToggle = screen.queryByRole('button', { name: 'Steg 1 av 2' }); - if (stepperToggle) { - stepperToggle.click(); - } - expect(screen.queryByRole('link', { name: 'Vedleggsliste' })).toBeInTheDocument(); + await waitFor(async () => { + expect(screen.queryByRole('heading', { name: form.title })).toBeInTheDocument(); + const stepperToggle = screen.queryByRole('button', { name: 'Steg 1 av 2' }); + if (stepperToggle) { + stepperToggle.click(); + } + expect(screen.queryByRole('link', { name: 'Vedleggsliste' })).toBeInTheDocument(); + }); }); it('Renders vedleggspanel when submission method is paper', () => { diff --git a/packages/shared-domain/src/form/index.ts b/packages/shared-domain/src/form/index.ts index 462b95f6d..e1c597f62 100644 --- a/packages/shared-domain/src/form/index.ts +++ b/packages/shared-domain/src/form/index.ts @@ -5,6 +5,10 @@ import { TextSize } from '../text'; export type DisplayType = 'wizard' | 'form'; export type FormType = 'form' | 'resource'; +/** + * + * InnsendingType skal fjernes ved migrering + */ export type InnsendingType = 'PAPIR_OG_DIGITAL' | 'KUN_PAPIR' | 'KUN_DIGITAL' | 'INGEN'; export type SubmissionType = 'PAPER' | 'DIGITAL'; export type SubmissionMethod = 'paper' | 'digital'; @@ -68,6 +72,7 @@ export interface FormPropertiesType { innsending?: InnsendingType; submissionTypes: SubmissionType[]; ettersending?: InnsendingType; + subsequentSubmissionTypes: SubmissionType[]; ettersendelsesfrist?: string; innsendingForklaring?: string; innsendingOverskrift?: string; @@ -292,8 +297,15 @@ export interface NavFormType { status?: string; } +/** + * + * Fjern ettersending ved migrering + */ export interface FormsResponseForm extends Pick { - properties: Pick; + properties: Pick< + FormPropertiesType, + 'skjemanummer' | 'ettersending' | 'subsequentSubmissionTypes' | 'submissionTypes' + >; } export type SubmissionData = Record; diff --git a/packages/shared-domain/src/summary/MockedComponentObjectForTest.ts b/packages/shared-domain/src/summary/MockedComponentObjectForTest.ts index b66d4826d..201a8dc05 100644 --- a/packages/shared-domain/src/summary/MockedComponentObjectForTest.ts +++ b/packages/shared-domain/src/summary/MockedComponentObjectForTest.ts @@ -309,6 +309,7 @@ const dummyFormProperties: FormPropertiesType = { tema: '', mellomlagringDurationDays: '28', submissionTypes: [], + subsequentSubmissionTypes: [], }; const createFormPropertiesObject = (partialFormProperties: Partial = {}) => ({ diff --git a/packages/shared-domain/src/utils/forms-api-backwards-compatibility/form.ts b/packages/shared-domain/src/utils/forms-api-backwards-compatibility/form.ts index aa55b657e..30e59a92e 100644 --- a/packages/shared-domain/src/utils/forms-api-backwards-compatibility/form.ts +++ b/packages/shared-domain/src/utils/forms-api-backwards-compatibility/form.ts @@ -18,10 +18,14 @@ const mapFormToNavForm = (form: Form): NavFormType => { }; }; -const mapInnsendingToSubmissionTypes = (innsending?: InnsendingType): SubmissionType[] => { - if (!innsending) return []; +/** + * + * Metoden er implementert kun for å støtte bakoverkompatibilitet og skal fjernes ved migrering + */ +const mapInnsendingTypeToSubmissionTypes = (innsendingType?: InnsendingType): SubmissionType[] => { + if (!innsendingType) return []; - switch (innsending) { + switch (innsendingType) { case 'PAPIR_OG_DIGITAL': return ['PAPER', 'DIGITAL']; case 'KUN_PAPIR': @@ -33,13 +37,35 @@ const mapInnsendingToSubmissionTypes = (innsending?: InnsendingType): Submission } }; +const mapEttersendingTypeToSubmissionTypes = (ettersending?: InnsendingType): SubmissionType[] => { + if (!ettersending) return ['PAPER', 'DIGITAL']; + + switch (ettersending) { + case 'PAPIR_OG_DIGITAL': + return ['PAPER', 'DIGITAL']; + case 'KUN_PAPIR': + return ['PAPER']; + case 'KUN_DIGITAL': + return ['DIGITAL']; + default: + return []; + } +}; + +/** + * + * Metoden er implementert kun for å støtte bakoverkompatibilitet og skal fjernes ved migrering + */ const removeInnsendingFromForm = (form: NavFormType): NavFormType => { const formProperties = (({ innsending, ...rest }) => rest)(form.properties); return { ...form, properties: { ...formProperties, - submissionTypes: form.properties.submissionTypes ?? mapInnsendingToSubmissionTypes(form.properties.innsending), + submissionTypes: + form.properties.submissionTypes ?? mapInnsendingTypeToSubmissionTypes(form.properties.innsending), + subsequentSubmissionTypes: + form.properties.subsequentSubmissionTypes ?? mapEttersendingTypeToSubmissionTypes(form.properties.ettersending), }, }; }; @@ -80,4 +106,10 @@ const mapNavFormToForm = (form: NavFormType): Form => { }; }; -export { mapFormToNavForm, mapInnsendingToSubmissionTypes, mapNavFormToForm, removeInnsendingFromForm }; +export { + mapEttersendingTypeToSubmissionTypes, + mapFormToNavForm, + mapInnsendingTypeToSubmissionTypes, + mapNavFormToForm, + removeInnsendingFromForm, +}; diff --git a/packages/shared-domain/src/utils/forms-api-backwards-compatibility/index.ts b/packages/shared-domain/src/utils/forms-api-backwards-compatibility/index.ts index 0841a037f..5efdb3743 100644 --- a/packages/shared-domain/src/utils/forms-api-backwards-compatibility/index.ts +++ b/packages/shared-domain/src/utils/forms-api-backwards-compatibility/index.ts @@ -1,4 +1,10 @@ -import { mapFormToNavForm, mapInnsendingToSubmissionTypes, mapNavFormToForm, removeInnsendingFromForm } from './form'; +import { + mapEttersendingTypeToSubmissionTypes, + mapFormToNavForm, + mapInnsendingTypeToSubmissionTypes, + mapNavFormToForm, + removeInnsendingFromForm, +} from './form'; import { mapPublishedGlobalTranslationsToFormioFormat } from './translations'; const formioFormsApiUtils = { @@ -6,7 +12,8 @@ const formioFormsApiUtils = { mapNavFormToForm, mapPublishedGlobalTranslationsToFormioFormat, removeInnsendingFromForm, - mapInnsendingToSubmissionTypes, + mapInnsendingTypeToSubmissionTypes, + mapEttersendingTypeToSubmissionTypes, }; export default formioFormsApiUtils; diff --git a/packages/shared-domain/src/utils/navFormUtils.ts b/packages/shared-domain/src/utils/navFormUtils.ts index 15e73c2f7..230903f49 100644 --- a/packages/shared-domain/src/utils/navFormUtils.ts +++ b/packages/shared-domain/src/utils/navFormUtils.ts @@ -309,24 +309,6 @@ const getAttachmentProperties = (form: NavFormType): Attachment[] => { const isAttachment = (comp: Component) => comp.type === 'attachment' || comp.values?.some((v) => v.value === 'leggerVedNaa'); -const isDigital = (type: 'innsending' | 'ettersending', form: NavFormType) => { - // If field is empty, it defaults to PAPIR_OG_DIGITAL - if (!form.properties[type]) return true; - - return form.properties[type] === 'KUN_DIGITAL' || form.properties[type] === 'PAPIR_OG_DIGITAL'; -}; - -const isPaper = (type: 'innsending' | 'ettersending', form: NavFormType) => { - // If field is empty, it defaults to PAPIR_OG_DIGITAL - if (!form.properties[type]) return true; - - return form.properties[type] === 'KUN_PAPIR' || form.properties[type] === 'PAPIR_OG_DIGITAL'; -}; - -const isNone = (type: 'innsending' | 'ettersending', form: NavFormType) => { - return form.properties[type] === 'INGEN'; -}; - const createDefaultForm = (config): Form => ({ title: '', skjemanummer: '', @@ -335,7 +317,7 @@ const createDefaultForm = (config): Form => ({ skjemanummer: '', tema: '', submissionTypes: ['PAPER', 'DIGITAL'], - ettersending: 'PAPIR_OG_DIGITAL', + subsequentSubmissionTypes: ['PAPER', 'DIGITAL'], signatures: [{ label: '', description: '', key: uuidv4() }], ettersendelsesfrist: '14', mellomlagringDurationDays: (config?.mellomlagringDurationDays as string) ?? '28', @@ -378,10 +360,7 @@ const navFormUtils = { getAttachmentPanel, hasAttachment, getAttachmentProperties, - isDigital, - isPaper, isAttachment, - isNone, isEqual, prefillForm, createDefaultForm,