diff --git a/src/features/devtools/utils/layoutSchemaValidation.ts b/src/features/devtools/utils/layoutSchemaValidation.ts index f8989c6355..c96ee4ec01 100644 --- a/src/features/devtools/utils/layoutSchemaValidation.ts +++ b/src/features/devtools/utils/layoutSchemaValidation.ts @@ -91,6 +91,26 @@ export function formatLayoutSchemaValidationError(error: DefinedError): string | return `Ugyldig verdi for egenskapen ${propertyString}, verdien \`${error.data}\` er ikke av typen \`${ error.params.type }\` ${canBeExpression ? 'eller et uttrykk' : ''}`; + case 'minimum': + if (error.params.comparison === '>=') { + return `Ugyldig verdi for egenskapen ${propertyString}, verdien \`${error.data}\` er mindre enn minimumsverdien ${ + error.params.limit + }`; + } + + return `Ugyldig verdi for egenskapen ${propertyString}, verdien \`${error.data}\` er mindre enn eller lik minimumsverdien ${ + error.params.limit + }`; + case 'maximum': + if (error.params.comparison === '<=') { + return `Ugyldig verdi for egenskapen ${propertyString}, verdien \`${error.data}\` er større enn maksimumsverdien ${ + error.params.limit + }`; + } + + return `Ugyldig verdi for egenskapen ${propertyString}, verdien \`${error.data}\` er større enn eller lik maksimumsverdien ${ + error.params.limit + }`; case 'if': case 'anyOf': case 'oneOf': diff --git a/src/features/propagateTraceWhenPdf/index.ts b/src/features/propagateTraceWhenPdf/index.ts new file mode 100644 index 0000000000..b84c6533cb --- /dev/null +++ b/src/features/propagateTraceWhenPdf/index.ts @@ -0,0 +1,48 @@ +import axios from 'axios'; + +import { getSearch, SearchParams } from 'src/features/routing/AppRoutingContext'; +import { appPath } from 'src/utils/urls/appUrlHelper'; + +function getCookies(): { [key: string]: string } { + const cookie = {}; + document.cookie.split(';').forEach((el) => { + const split = el.split('='); + cookie[split[0].trim()] = split.slice(1).join('='); + }); + return cookie; +} + +export function propagateTraceWhenPdf() { + try { + const isPdf = new URLSearchParams(getSearch('')).get(SearchParams.Pdf) === '1'; + + if (isPdf) { + const cookies = getCookies(); + axios.interceptors.request.use((config) => { + try { + if (config.url?.startsWith(appPath) !== true) { + return config; + } + + // This header is caught in app-lib/backend and used to allow injection of traceparent/context + config.headers['X-Altinn-IsPdf'] = 'true'; + + const traceparent = cookies['altinn-telemetry-traceparent']; + const tracestate = cookies['altinn-telemetry-tracestate']; + if (traceparent) { + config.headers['traceparent'] = traceparent; + } + if (tracestate) { + config.headers['tracestate'] = tracestate; + } + return config; + } catch (err) { + console.error('Error configuring propagation of W3C trace for request', err); + return config; + } + }); + } + } catch (err) { + console.error('Error configuring propagation of W3C trace', err); + } +} diff --git a/src/features/routing/AppRoutingContext.tsx b/src/features/routing/AppRoutingContext.tsx index 47fe582ec4..2e98aecf6b 100644 --- a/src/features/routing/AppRoutingContext.tsx +++ b/src/features/routing/AppRoutingContext.tsx @@ -90,7 +90,7 @@ function getPath(hashFromState: string): string { return hash.slice(1).split('?')[0]; } -function getSearch(hashFromState: string): string { +export function getSearch(hashFromState: string): string { const hash = window.inUnitTest ? hashFromState : window.location.hash; const search = hash.split('?')[1] ?? ''; return search ? `?${search}` : ''; diff --git a/src/index.tsx b/src/index.tsx index b3c7909953..55cb721883 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -34,6 +34,7 @@ import { TextResourcesProvider } from 'src/features/language/textResources/TextR import { OrgsProvider } from 'src/features/orgs/OrgsProvider'; import { PartyProvider } from 'src/features/party/PartiesProvider'; import { ProfileProvider } from 'src/features/profile/ProfileProvider'; +import { propagateTraceWhenPdf } from 'src/features/propagateTraceWhenPdf'; import { AppRoutingProvider } from 'src/features/routing/AppRoutingContext'; import { AppPrefetcher } from 'src/queries/appPrefetcher'; import { PartyPrefetcher } from 'src/queries/partyPrefetcher'; @@ -57,6 +58,8 @@ const router = createHashRouter([ ]); document.addEventListener('DOMContentLoaded', () => { + propagateTraceWhenPdf(); + const container = document.getElementById('root'); const root = container && createRoot(container); root?.render( diff --git a/src/layout/RepeatingGroup/config.ts b/src/layout/RepeatingGroup/config.ts index a2ad34c43c..eab3b7e9d3 100644 --- a/src/layout/RepeatingGroup/config.ts +++ b/src/layout/RepeatingGroup/config.ts @@ -256,7 +256,7 @@ export const Config = new CG.component({ 'maxCount', new CG.int() .optional() - .setMin(2) + .setMin(1) .setTitle('Max number of rows') .setDescription('Maximum number of rows that can be added.'), ), @@ -265,7 +265,8 @@ export const Config = new CG.component({ new CG.prop( 'minCount', new CG.int() - .optional() + .setMin(0) + .optional({ default: 0 }) .setTitle('Min number of rows') .setDescription( 'Minimum number of rows that should be added. If the user has not added enough rows, ' + diff --git a/test/e2e/integration/frontend-test/pdf.ts b/test/e2e/integration/frontend-test/pdf.ts index 06662de273..c5e218bfae 100644 --- a/test/e2e/integration/frontend-test/pdf.ts +++ b/test/e2e/integration/frontend-test/pdf.ts @@ -1,3 +1,5 @@ +import type { Interception } from 'cypress/types/net-stubbing'; + import { AppFrontend } from 'test/e2e/pageobjects/app-frontend'; import { Likert } from 'test/e2e/pageobjects/likert'; @@ -10,11 +12,50 @@ describe('PDF', () => { it('should generate PDF for message step', () => { cy.goto('message'); - cy.testPdf('message', () => { - cy.findByRole('heading', { level: 1, name: /frontend-test/i }).should('be.visible'); - cy.findByRole('table').should('contain.text', 'Mottaker:Testdepartementet'); - cy.findByRole('heading', { level: 2, name: /appen for test av app frontend/i }).should('be.visible'); - cy.findByRole('heading', { level: 2, name: /vedlegg/i }).should('be.visible'); + cy.testPdf({ + snapshotName: 'message', + callback: () => { + cy.findByRole('heading', { level: 1, name: /frontend-test/i }).should('be.visible'); + cy.findByRole('table').should('contain.text', 'Mottaker:Testdepartementet'); + cy.findByRole('heading', { level: 2, name: /appen for test av app frontend/i }).should('be.visible'); + cy.findByRole('heading', { level: 2, name: /vedlegg/i }).should('be.visible'); + }, + }); + }); + + it('downstream requests includes trace context header', () => { + const traceparentValue = '00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01'; + const tracestateValue = 'altinn'; + const domain = new URL(Cypress.config().baseUrl!).hostname; + const cookieOptions: Partial = { domain, sameSite: 'lax' }; + + cy.goto('message'); + + cy.testPdf({ + beforeReload: () => { + cy.setCookie('altinn-telemetry-traceparent', traceparentValue, cookieOptions); + cy.setCookie('altinn-telemetry-tracestate', tracestateValue, cookieOptions); + cy.intercept(`**`).as('allRequests'); + }, + callback: () => { + cy.get('@allRequests.all').then((_intercepts) => { + const intercepts = (_intercepts as unknown as Interception[]).filter( + (intercept) => + intercept.request.resourceType === 'xhr' && + intercept.request.url.includes(domain) && + intercept.request.headers['cookie'].includes('altinn-telemetry-traceparent='), + ); + expect(intercepts.length).to.be.greaterThan(10); + for (const { request } of intercepts) { + cy.log('Request intercepted:', request.url.split(domain)[1]); + expect(request.headers, 'request headers').to.include({ + 'x-altinn-ispdf': 'true', + traceparent: traceparentValue, + tracestate: tracestateValue, + }); + } + }); + }, }); }); @@ -62,9 +103,10 @@ describe('PDF', () => { cy.findByRole('textbox', { name: /Zip Code/i }).type('0101'); cy.findByRole('textbox', { name: /Post Place/i }).should('have.value', 'OSLO'); - cy.testPdf( - 'changeName 1', - () => { + cy.testPdf({ + snapshotName: 'changeName 1', + returnToForm: true, + callback: () => { cy.findByRole('table').should('contain.text', 'Mottaker:Testdepartementet'); cy.getSummary('Nytt fornavn').should('contain.text', 'Ola'); cy.getSummary('Nytt etternavn').should('contain.text', 'Nordmann'); @@ -83,8 +125,7 @@ describe('PDF', () => { cy.getSummary('Referanse 2').should('contain.text', 'Dole'); cy.getSummary('Adresse').should('contain.text', 'Økern 1'); }, - true, - ); + }); cy.findByRole('radio', { name: /gårdsbruk/i }).check(); cy.findByRole('textbox', { name: /gårdsbruk du vil ta navnet fra/i }).type('Økern gård'); @@ -105,28 +146,31 @@ describe('PDF', () => { cy.waitUntilSaved(); cy.gotoNavPage('form'); // Go back to form to avoid waiting for map to load while zoom animation is happending - cy.testPdf('changeName 2', () => { - cy.findByRole('table').should('contain.text', 'Mottaker:Testdepartementet'); - cy.getSummary('Nytt fornavn').should('contain.text', 'Ola'); - cy.getSummary('Nytt etternavn').should('contain.text', 'Nordmann'); - cy.getSummary('Nytt mellomnavn').should('contain.text', '"Big G"'); - cy.getSummary('Til:').should('contain.text', 'Ola "Big G" Nordmann'); - cy.getSummary('begrunnelse for endring av navn').should('contain.text', 'Gårdsbruk'); - cy.getSummary('Gårdsbruk du vil ta navnet fra').should('contain.text', 'Økern gård'); - cy.getSummary('Kommune gårdsbruket ligger i').should('contain.text', '4444'); - cy.getSummary('Gårdsnummer').should('contain.text', '1234'); - cy.getSummary('Bruksnummer').should('contain.text', '56'); - cy.getSummary('Forklar din tilknytning til gårdsbruket').should('contain.text', 'Gris'); - cy.getSummary('Når vil du at navnendringen').should('contain.text', '01/01/2020'); - cy.getSummary('Mobil nummer').should('contain.text', '+47 987 65 432'); - cy.getSummary('hvor fikk du vite om skjemaet').should('contain.text', 'Altinn'); - cy.getSummary('Referanse').should('contain.text', 'Ola Nordmann'); - cy.getSummary('Referanse 2').should('contain.text', 'Ole'); - cy.getSummary('Adresse').should('contain.text', 'Økern 1'); - cy.getSummary('Velg lokasjon').findByAltText('Marker').should('be.visible'); - cy.getSummary('Velg lokasjon') - .findByText(/Valgt lokasjon: 67(\.\d{1,6})?° nord, 16(\.\d{1,6})?° øst/) - .should('be.visible'); + cy.testPdf({ + snapshotName: 'changeName 2', + callback: () => { + cy.findByRole('table').should('contain.text', 'Mottaker:Testdepartementet'); + cy.getSummary('Nytt fornavn').should('contain.text', 'Ola'); + cy.getSummary('Nytt etternavn').should('contain.text', 'Nordmann'); + cy.getSummary('Nytt mellomnavn').should('contain.text', '"Big G"'); + cy.getSummary('Til:').should('contain.text', 'Ola "Big G" Nordmann'); + cy.getSummary('begrunnelse for endring av navn').should('contain.text', 'Gårdsbruk'); + cy.getSummary('Gårdsbruk du vil ta navnet fra').should('contain.text', 'Økern gård'); + cy.getSummary('Kommune gårdsbruket ligger i').should('contain.text', '4444'); + cy.getSummary('Gårdsnummer').should('contain.text', '1234'); + cy.getSummary('Bruksnummer').should('contain.text', '56'); + cy.getSummary('Forklar din tilknytning til gårdsbruket').should('contain.text', 'Gris'); + cy.getSummary('Når vil du at navnendringen').should('contain.text', '01/01/2020'); + cy.getSummary('Mobil nummer').should('contain.text', '+47 987 65 432'); + cy.getSummary('hvor fikk du vite om skjemaet').should('contain.text', 'Altinn'); + cy.getSummary('Referanse').should('contain.text', 'Ola Nordmann'); + cy.getSummary('Referanse 2').should('contain.text', 'Ole'); + cy.getSummary('Adresse').should('contain.text', 'Økern 1'); + cy.getSummary('Velg lokasjon').findByAltText('Marker').should('be.visible'); + cy.getSummary('Velg lokasjon') + .findByText(/Valgt lokasjon: 67(\.\d{1,6})?° nord, 16(\.\d{1,6})?° øst/) + .should('be.visible'); + }, }); }); @@ -157,17 +201,20 @@ describe('PDF', () => { cy.gotoNavPage('hide'); cy.findByRole('textbox', { name: /oppgave giver/i }).type('Ola Nordmann'); - cy.testPdf('group', () => { - cy.findByRole('table').should('contain.text', 'Mottaker:Testdepartementet'); + cy.testPdf({ + snapshotName: 'group', + callback: () => { + cy.findByRole('table').should('contain.text', 'Mottaker:Testdepartementet'); - cy.getSummary('Group summary title').should('contain.text', 'Endre fra : NOK 1'); - cy.getSummary('Group summary title').should('contain.text', 'Endre verdi 1 til : NOK 5'); + cy.getSummary('Group summary title').should('contain.text', 'Endre fra : NOK 1'); + cy.getSummary('Group summary title').should('contain.text', 'Endre verdi 1 til : NOK 5'); - cy.getSummary('Group summary title').should('contain.text', 'Endre fra : NOK 120'); - cy.getSummary('Group summary title').should('contain.text', 'Endre verdi 120 til : NOK 350'); + cy.getSummary('Group summary title').should('contain.text', 'Endre fra : NOK 120'); + cy.getSummary('Group summary title').should('contain.text', 'Endre verdi 120 til : NOK 350'); - cy.getSummary('Group summary title').should('contain.text', 'Endre fra : NOK 1 233'); - cy.getSummary('Group summary title').should('contain.text', 'Endre verdi 1233 til : NOK 3 488'); + cy.getSummary('Group summary title').should('contain.text', 'Endre fra : NOK 1 233'); + cy.getSummary('Group summary title').should('contain.text', 'Endre verdi 1233 til : NOK 3 488'); + }, }); }); @@ -184,31 +231,37 @@ describe('PDF', () => { }); }); - cy.testPdf('likert', () => { - cy.findByRole('table').should('contain.text', 'Mottaker:Testdepartementet'); - - cy.getSummary('Skolearbeid').should('contain.text', 'Gjør du leksene dine? : Alltid'); - cy.getSummary('Skolearbeid').should('contain.text', 'Fungerer kalkulatoren din? : Nesten alltid'); - cy.getSummary('Skolearbeid').should('contain.text', 'Er pulten din ryddig? : Ofte'); - - cy.getSummary('Medvirkning').should('contain.text', 'Hører skolen på elevenes forslag? : Alltid'); - cy.getSummary('Medvirkning').should( - 'contain.text', - 'Er dere elever med på å lage regler for hvordan dere skal ha det i klassen/gruppa? : Nesten alltid', - ); - cy.getSummary('Medvirkning').should( - 'contain.text', - 'De voksne på skolen synes det er viktig at vi elever er greie med hverandre. : Ofte', - ); + cy.testPdf({ + snapshotName: 'likert', + callback: () => { + cy.findByRole('table').should('contain.text', 'Mottaker:Testdepartementet'); + + cy.getSummary('Skolearbeid').should('contain.text', 'Gjør du leksene dine? : Alltid'); + cy.getSummary('Skolearbeid').should('contain.text', 'Fungerer kalkulatoren din? : Nesten alltid'); + cy.getSummary('Skolearbeid').should('contain.text', 'Er pulten din ryddig? : Ofte'); + + cy.getSummary('Medvirkning').should('contain.text', 'Hører skolen på elevenes forslag? : Alltid'); + cy.getSummary('Medvirkning').should( + 'contain.text', + 'Er dere elever med på å lage regler for hvordan dere skal ha det i klassen/gruppa? : Nesten alltid', + ); + cy.getSummary('Medvirkning').should( + 'contain.text', + 'De voksne på skolen synes det er viktig at vi elever er greie med hverandre. : Ofte', + ); + }, }); }); it('should generate PDF for datalist step', () => { cy.gotoAndComplete('datalist'); - cy.testPdf('datalist', () => { - cy.findByRole('table').should('contain.text', 'Mottaker:Testdepartementet'); - cy.getSummary('Hvem gjelder saken?').should('contain.text', 'Caroline'); + cy.testPdf({ + snapshotName: 'datalist', + callback: () => { + cy.findByRole('table').should('contain.text', 'Mottaker:Testdepartementet'); + cy.getSummary('Hvem gjelder saken?').should('contain.text', 'Caroline'); + }, }); }); @@ -248,8 +301,10 @@ describe('PDF', () => { cy.goto('changename'); - cy.testPdf(false, () => { - cy.findByRole('heading', { name: /this is a custom pdf/i }).should('be.visible'); + cy.testPdf({ + callback: () => { + cy.findByRole('heading', { name: /this is a custom pdf/i }).should('be.visible'); + }, }); }); @@ -283,10 +338,12 @@ describe('PDF', () => { cy.goto('changename'); - cy.testPdf(false, () => { - cy.findByRole('heading', { name: /grid gruppe/i }).should('be.visible'); - cy.findByText('Prosentandel av gjeld i boliglån').should('be.visible'); - cy.findByText('Utregnet totalprosent').should('be.visible'); + cy.testPdf({ + callback: () => { + cy.findByRole('heading', { name: /grid gruppe/i }).should('be.visible'); + cy.findByText('Prosentandel av gjeld i boliglån').should('be.visible'); + cy.findByText('Utregnet totalprosent').should('be.visible'); + }, }); }); diff --git a/test/e2e/integration/subform-test/subform.ts b/test/e2e/integration/subform-test/subform.ts index 4cd23c4b78..d537163b35 100644 --- a/test/e2e/integration/subform-test/subform.ts +++ b/test/e2e/integration/subform-test/subform.ts @@ -186,19 +186,22 @@ describe('Subform test', () => { cy.findByRole('textbox', { name: /produksjonsår/i }).type('2030'); cy.findByRole('button', { name: /ferdig/i }).click(); - cy.testPdf('subform', () => { - cy.getSummary('Navn').should('contain.text', 'Per'); - cy.getSummary('Alder').should('contain.text', '28 år'); - - cy.getSummary('Registreringsnummer').eq(0).should('contain.text', 'ABC123'); - cy.getSummary('Merke').eq(0).should('contain.text', 'Digdir'); - cy.getSummary('Modell').eq(0).should('contain.text', 'Scooter2000'); - cy.getSummary('Produksjonsår').eq(0).should('contain.text', '2024'); - - cy.getSummary('Registreringsnummer').eq(1).should('contain.text', 'XYZ987'); - cy.getSummary('Merke').eq(1).should('contain.text', 'Altinn'); - cy.getSummary('Modell').eq(1).should('contain.text', '3.0'); - cy.getSummary('Produksjonsår').eq(1).should('contain.text', '2030'); + cy.testPdf({ + snapshotName: 'subform', + callback: () => { + cy.getSummary('Navn').should('contain.text', 'Per'); + cy.getSummary('Alder').should('contain.text', '28 år'); + + cy.getSummary('Registreringsnummer').eq(0).should('contain.text', 'ABC123'); + cy.getSummary('Merke').eq(0).should('contain.text', 'Digdir'); + cy.getSummary('Modell').eq(0).should('contain.text', 'Scooter2000'); + cy.getSummary('Produksjonsår').eq(0).should('contain.text', '2024'); + + cy.getSummary('Registreringsnummer').eq(1).should('contain.text', 'XYZ987'); + cy.getSummary('Merke').eq(1).should('contain.text', 'Altinn'); + cy.getSummary('Modell').eq(1).should('contain.text', '3.0'); + cy.getSummary('Produksjonsår').eq(1).should('contain.text', '2030'); + }, }); }); }); diff --git a/test/e2e/support/custom.ts b/test/e2e/support/custom.ts index 2cdaf74b38..bf25e2b93a 100644 --- a/test/e2e/support/custom.ts +++ b/test/e2e/support/custom.ts @@ -594,7 +594,7 @@ Cypress.Commands.add('directSnapshot', (snapshotName, { width, minHeight }, rese }); const DEFAULT_COMMAND_TIMEOUT = Cypress.config().defaultCommandTimeout; -Cypress.Commands.add('testPdf', (snapshotName, callback, returnToForm = false) => { +Cypress.Commands.add('testPdf', ({ snapshotName = false, beforeReload, callback, returnToForm = false }) => { cy.log('Testing PDF'); // Store initial viewport size for later @@ -628,6 +628,7 @@ Cypress.Commands.add('testPdf', (snapshotName, callback, returnToForm = false) = cy.visit(visitUrl); }); + beforeReload?.(); cy.reload(); // Wait for readyForPrint, after this everything should be rendered so using timeout: 0 diff --git a/test/e2e/support/global.ts b/test/e2e/support/global.ts index 55f84055aa..4aa4461647 100644 --- a/test/e2e/support/global.ts +++ b/test/e2e/support/global.ts @@ -22,6 +22,13 @@ export type StartAppInstanceOptions = { urlSuffix?: string; }; +export interface TestPdfOptions { + snapshotName?: string; + beforeReload?: () => void; + callback: () => void; + returnToForm?: boolean; +} + declare global { // eslint-disable-next-line @typescript-eslint/no-namespace namespace Cypress { @@ -29,7 +36,7 @@ declare global { /** * Quickly go to a certain task in the app */ - goto(target: FrontendTestTask): Chainable; + goto(target: FrontendTestTask, options?: StartAppInstanceOptions): Chainable; /** * In 'ttd/frontend-test' we're using a pattern of initially hidden pages to expand with new test cases. @@ -231,7 +238,7 @@ declare global { options: { width: number; minHeight: number }, reset?: boolean, ): Chainable; - testPdf(snapshotName: string | false, callback: () => void, returnToForm?: boolean): Chainable; + testPdf(options: TestPdfOptions): Chainable; getCurrentPageId(): Chainable; /** diff --git a/test/e2e/support/navigation.ts b/test/e2e/support/navigation.ts index 6ab4978960..afc91a7be2 100644 --- a/test/e2e/support/navigation.ts +++ b/test/e2e/support/navigation.ts @@ -1,7 +1,7 @@ import { AppFrontend } from 'test/e2e/pageobjects/app-frontend'; import { getLocalPartyId } from 'test/e2e/support/auth'; import { getTargetUrl } from 'test/e2e/support/start-app-instance'; -import type { FrontendTestTask } from 'test/e2e/support/global'; +import type { FrontendTestTask, StartAppInstanceOptions } from 'test/e2e/support/global'; const appFrontend = new AppFrontend(); @@ -77,34 +77,54 @@ function generateEvalString(target: FrontendTestTask, extra?: Extras): string { * These should always complete the task fully, i.e. end the task and move to the next one after it. * It never generates a PDF for the previous tasks. */ -const gotoFunctions: { [key in FrontendTestTask]: (extra?: Extras) => void } = { - message: () => { +const gotoFunctions: { [key in FrontendTestTask]: (extra?: Extras, startOptions?: StartAppInstanceOptions) => void } = { + message: (extra?: Extras, startOptions?: StartAppInstanceOptions) => { cy.intercept('**/active', []).as('noActiveInstances'); - cy.startAppInstance(appFrontend.apps.frontendTest); + if (extra) { + throw new Error('Extra not supported for message navigator'); + } + cy.startAppInstance(appFrontend.apps.frontendTest, startOptions); cy.findByRole('button', { name: /lukk skjema/i }).should('be.visible'); }, - changename: (extra?: Extras) => { + changename: (extra?: Extras, startOptions?: StartAppInstanceOptions) => { cy.startAppInstance(appFrontend.apps.frontendTest, { + ...startOptions, evaluateBefore: generateEvalString('changename', extra), }); }, - group: () => { + group: (extra?: Extras, startOptions?: StartAppInstanceOptions) => { + if (extra) { + throw new Error('Extra not supported for group navigator'); + } cy.startAppInstance(appFrontend.apps.frontendTest, { + ...startOptions, evaluateBefore: generateEvalString('group'), }); }, - likert: () => { + likert: (extra?: Extras, startOptions?: StartAppInstanceOptions) => { + if (extra) { + throw new Error('Extra not supported for likert navigator'); + } cy.startAppInstance(appFrontend.apps.frontendTest, { + ...startOptions, evaluateBefore: generateEvalString('likert'), }); }, - datalist: () => { + datalist: (extra?: Extras, startOptions?: StartAppInstanceOptions) => { + if (extra) { + throw new Error('Extra not supported for datalist navigator'); + } cy.startAppInstance(appFrontend.apps.frontendTest, { + ...startOptions, evaluateBefore: generateEvalString('datalist'), }); }, - confirm: () => { + confirm: (extra?: Extras, startOptions?: StartAppInstanceOptions) => { + if (extra) { + throw new Error('Extra not supported for confirm navigator'); + } cy.startAppInstance(appFrontend.apps.frontendTest, { + ...startOptions, evaluateBefore: generateEvalString('datalist', ({ baseUrl }) => ({ code: `await fetch('${baseUrl}/instances/' + instanceId + '/process/next', { method: 'PUT', headers });`, })), @@ -112,8 +132,8 @@ const gotoFunctions: { [key in FrontendTestTask]: (extra?: Extras) => void } = { }, }; -Cypress.Commands.add('goto', (task) => { - gotoFunctions[task](); +Cypress.Commands.add('goto', (task, options) => { + gotoFunctions[task](undefined, options); }); Cypress.Commands.add('gotoHiddenPage', (target) => { diff --git a/test/e2e/support/start-app-instance.ts b/test/e2e/support/start-app-instance.ts index c4b01573d4..45a0b95ef4 100644 --- a/test/e2e/support/start-app-instance.ts +++ b/test/e2e/support/start-app-instance.ts @@ -150,6 +150,7 @@ Cypress.Commands.add('startAppInstance', (appName, options) => { user && login(user, authenticationLevel); !user && cy.clearCookies(); + cy.visit(targetUrlRaw, visitOptions); if (evaluateBefore) {