Skip to content

Commit 556e988

Browse files
authored
Merge pull request #1461 from navikt/cypress-mock-fix
Cypress mock fix
2 parents 6f5b3a2 + b44d7f1 commit 556e988

File tree

7 files changed

+23
-14
lines changed

7 files changed

+23
-14
lines changed

packages/fyllut/cypress.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default defineConfig({
1212
AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: 'http://127.0.0.1:3300/azure-openid/oauth2/v2.0/token',
1313
FORMIO_PROJECT_URL: 'http://127.0.0.1:3300/formio-api',
1414
SEND_INN_HOST: 'http://127.0.0.1:3300/send-inn',
15+
SEND_INN_FRONTEND: 'http://localhost:3300/send-inn-frontend',
1516
TOKEN_X_WELL_KNOWN_URL: 'http://127.0.0.1:3300/tokenx/.well-known',
1617
BASE_URL: 'http://localhost:3001',
1718
},

packages/fyllut/cypress/cypress.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ declare global {
2121

2222
clickStart(): Chainable<JQuery<HTMLElement>>;
2323

24+
verifySendInnRedirect(): Chainable<JQuery<HTMLElement>>;
25+
2426
defaultIntercepts(): Cypress.Chainable<JQuery<HTMLElement>>;
2527

2628
defaultInterceptsMellomlagring(): Chainable<JQuery<HTMLElement>>;

packages/fyllut/cypress/e2e/components/activities.cy.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ describe('Activities', () => {
149149
// Submit
150150
cy.clickSaveAndContinue();
151151
cy.wait('@submitMellomlagring');
152-
cy.url().should('include', '/send-inn-frontend');
152+
cy.verifySendInnRedirect();
153153
});
154154

155155
describe('saved application', () => {
@@ -202,7 +202,7 @@ describe('Activities', () => {
202202
// Submit
203203
cy.clickSaveAndContinue();
204204
cy.wait('@submitMellomlagring');
205-
cy.url().should('include', '/send-inn-frontend');
205+
cy.verifySendInnRedirect();
206206
});
207207

208208
it('should allow user to change chosen activity and update selected maalgruppe to reflect that', () => {
@@ -246,7 +246,7 @@ describe('Activities', () => {
246246
// Submit
247247
cy.clickSaveAndContinue();
248248
cy.wait('@submitMellomlagring');
249-
cy.url().should('include', '/send-inn-frontend');
249+
cy.verifySendInnRedirect();
250250
});
251251
});
252252
});
@@ -323,7 +323,7 @@ describe('Activities', () => {
323323
// Submit
324324
cy.clickSaveAndContinue();
325325
cy.wait('@submitMellomlagring');
326-
cy.url().should('include', '/send-inn-frontend');
326+
cy.verifySendInnRedirect();
327327
});
328328

329329
it('should default to ANNET for maalgruppe', () => {
@@ -359,7 +359,7 @@ describe('Activities', () => {
359359
// Submit
360360
cy.clickSaveAndContinue();
361361
cy.wait('@submitMellomlagring');
362-
cy.url().should('include', '/send-inn-frontend');
362+
cy.verifySendInnRedirect();
363363
});
364364
});
365365

packages/fyllut/cypress/e2e/digital-submission/mellomlagring.cy.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ describe('Mellomlagring', () => {
207207
cy.wait('@getMellomlagringValid');
208208
cy.findByRole('heading', { name: TEXTS.statiske.summaryPage.title }).should('exist');
209209
cy.findByText('Ønsker du å få gaven innpakket').should('exist');
210-
cy.findByRole('button', { name: TEXTS.grensesnitt.navigation.saveAndContinue }).should('exist').click();
210+
cy.clickSaveAndContinue();
211211
cy.wait('@submitMellomlagring');
212-
cy.url().should('not.include', 'testmellomlagring').should('include', '/send-inn-frontend');
212+
cy.verifySendInnRedirect();
213213
});
214214

215215
it('retrieves mellomlagring and lets you navigate to first empty panel', () => {
@@ -248,7 +248,7 @@ describe('Mellomlagring', () => {
248248
.should('exist')
249249
.within(() => {
250250
cy.get('a').should('have.length', 2);
251-
cy.findByRole('link', { name: 'Du må fylle ut: Farge' }).should('exist').click();
251+
cy.findByRole('link', { name: 'Du må fylle ut: Farge' }).should('exist').click({ force: true });
252252
});
253253

254254
cy.findByRole('group', { name: 'Farge' })
@@ -262,7 +262,7 @@ describe('Mellomlagring', () => {
262262
.should('exist')
263263
.within(() => {
264264
cy.get('a').should('have.length', 1);
265-
cy.findByRole('link', { name: 'Du må fylle ut: Tekst på kortet' }).should('exist').click();
265+
cy.findByRole('link', { name: 'Du må fylle ut: Tekst på kortet' }).should('exist').click({ force: true });
266266
});
267267
cy.findByLabelText('Tekst på kortet').should('have.focus').type('Takk for hjelpen!');
268268

@@ -336,7 +336,7 @@ describe('Mellomlagring', () => {
336336
cy.wait('@getMellomlagringValid');
337337
cy.findByRole('heading', { name: TEXTS.statiske.summaryPage.title }).should('exist');
338338
cy.findByText('Ønsker du å få gaven innpakket').should('exist');
339-
cy.findByRole('button', { name: TEXTS.grensesnitt.navigation.saveAndContinue }).click();
339+
cy.clickSaveAndContinue();
340340
cy.wait('@submitMellomlagring');
341341
});
342342
});

packages/fyllut/cypress/e2e/form/focus-handling.cy.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ describe('Focus handling', () => {
120120
.should('exist')
121121
.within(() => {
122122
cy.findByRole('link', { name: 'Du må fylle ut: Hvilken type bolig bor du i?' }).should('exist');
123-
cy.findByRole('link', { name: 'Du må fylle ut: Hvilken type bolig bor du i?' }).click();
123+
cy.findByRole('link', { name: 'Du må fylle ut: Hvilken type bolig bor du i?' }).click({ force: true });
124124
});
125125

126126
cy.findByRole('group', { name: 'Hvilken type bolig bor du i?' })
@@ -135,7 +135,7 @@ describe('Focus handling', () => {
135135
.should('exist')
136136
.within(() => {
137137
cy.findByRole('link', { name: 'Du må fylle ut: Mottakers fornavn' }).should('exist');
138-
cy.findByRole('link', { name: 'Du må fylle ut: Mottakers fornavn' }).click();
138+
cy.findByRole('link', { name: 'Du må fylle ut: Mottakers fornavn' }).click({ force: true });
139139
});
140140
cy.findByRole('textbox', { name: 'Mottakers fornavn' }).should('have.focus').type('Max');
141141

packages/fyllut/cypress/e2e/pdf/digital-submission-pdf.cy.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe('Pdf when digital submission', () => {
108108
cy.clickSaveAndContinue();
109109
// When failure, see mocks/routes/skjemabygging-proxy.js where the html content is verified (id='verify-nav111221b-nb')
110110
cy.wait('@submitMellomlagring');
111-
cy.url().should('include', '/send-inn-frontend');
111+
cy.verifySendInnRedirect();
112112
});
113113

114114
it('nynorsk', () => {
@@ -203,7 +203,7 @@ describe('Pdf when digital submission', () => {
203203
cy.clickSaveAndContinue();
204204
// When failure, see mocks/routes/skjemabygging-proxy.js where the html content is verified (id='verify-nav111221b-nn')
205205
cy.wait('@submitMellomlagring');
206-
cy.url().should('include', '/send-inn-frontend');
206+
cy.verifySendInnRedirect();
207207
});
208208
});
209209
});

packages/fyllut/cypress/support/commands.ts

+6
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ Cypress.Commands.add('clickStart', () => {
6060
return cy.findByRoleWhenAttached('link', { name: TEXTS.grensesnitt.introPage.start }).click();
6161
});
6262

63+
Cypress.Commands.add('verifySendInnRedirect', () => {
64+
return cy.origin(Cypress.env('SEND_INN_FRONTEND'), () => {
65+
cy.contains('Send Inn Frontend');
66+
});
67+
});
68+
6369
Cypress.Commands.add('defaultIntercepts', () => {
6470
cy.intercept('POST', '/fyllut/api/log*', { body: 'ok' }).as('logger');
6571
cy.intercept('GET', '/fyllut/api/config*').as('getConfig');

0 commit comments

Comments
 (0)