Skip to content

Commit 1db7568

Browse files
authored
chore(EMS-3464): navigateToSignInAndSubmitForm command (#2999)
* chore(EMS-3464): rename misleading login command to navigateToRootUrl * chore(EMS-3464): dry navigateToSignInAndSubmitForm command * chore(EMS-3464): fix/update cypress command * chore(EMS-3464): fix/update e2e command
1 parent 2606df6 commit 1db7568

File tree

53 files changed

+94
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+94
-73
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ACCOUNT as ACCOUNT_ROUTES } from '../../../constants/routes/insurance/account';
2+
3+
const {
4+
SIGN_IN: { ROOT: SIGN_IN_ROOT },
5+
} = ACCOUNT_ROUTES;
6+
7+
const baseUrl = Cypress.config('baseUrl');
8+
9+
const signInUrl = `${baseUrl}${SIGN_IN_ROOT}`;
10+
11+
/**
12+
* navigateToSignInAndSubmitForm
13+
* 1) Navigate to the sign in form.
14+
* 2) Complete and submit the form.
15+
*/
16+
const navigateToSignInAndSubmitForm = () => {
17+
cy.navigateToUrl(signInUrl);
18+
19+
cy.completeAndSubmitSignInAccountForm({ assertRedirectUrl: false });
20+
};
21+
22+
export default navigateToSignInAndSubmitForm;

e2e-tests/commands/login.js

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ROUTES } from '../constants';
2+
3+
/**
4+
* navigateToRootUrl
5+
* Navigate to the root URL.
6+
*/
7+
const navigateToRootUrl = () => {
8+
cy.navigateToUrl(ROUTES.ROOT);
9+
};
10+
11+
export default navigateToRootUrl;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Cypress.Commands.add('accountAddAndGetOTP', require('../../insurance/account/add-and-get-OTP'));
2-
Cypress.Commands.add('createAccount', require('../../insurance/account/create-account'));
32
Cypress.Commands.add('completeSignInAndGoToApplication', require('../../insurance/account/complete-sign-in-and-go-to-application'));
43
Cypress.Commands.add('completeAndSubmitSignInAccountForm', require('../../insurance/account/complete-and-submit-sign-in-account-form'));
54
Cypress.Commands.add('completeSignInAndOTP', require('../../insurance/account/complete-sign-in-and-otp'));
6-
Cypress.Commands.add('login', require('../../login'));
5+
Cypress.Commands.add('createAccount', require('../../insurance/account/create-account'));
6+
Cypress.Commands.add('navigateToSignInAndSubmitForm', require('../../insurance/account/navigate-to-sign-in-and-submit-form'));
77
Cypress.Commands.add('signInAndAssertAllSectionsUrl', require('../../insurance/account/sign-in-and-assert-all-sections-url'));

e2e-tests/commands/shared-commands/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import './form';
99
import './intercept';
1010
import './url';
1111

12-
Cypress.Commands.add('saveSession', require('../save-session'));
12+
Cypress.Commands.add('autocompleteKeyboardInput', require('../autocomplete-keyboard-input'));
1313
Cypress.Commands.add('corePageChecks', require('../core-page-checks'));
1414
Cypress.Commands.add('keyboardInput', require('../keyboard-input'));
15-
Cypress.Commands.add('autocompleteKeyboardInput', require('../autocomplete-keyboard-input'));
15+
Cypress.Commands.add('navigateToRootUrl', require('../navigate-to-root-url'));
16+
Cypress.Commands.add('saveSession', require('../save-session'));

e2e-tests/insurance/cypress/e2e/journeys/account/sign-in/account-sign-in-with-an-expired-verification-inactive-state.spec.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ context(`Insurance - Account - Sign in - expired verification and ${IS_INACTIVE}
3434

3535
/**
3636
* navigate to the sign in page,
37-
* without a verified account.
37+
* without a verified account.
3838
*/
3939
cy.clickSignInButtonLink();
4040

@@ -78,9 +78,7 @@ context(`Insurance - Account - Sign in - expired verification and ${IS_INACTIVE}
7878
});
7979

8080
it(`should redirect to ${CONFIRM_EMAIL_RESENT}`, () => {
81-
cy.navigateToUrl(signInUrl);
82-
83-
cy.completeAndSubmitSignInAccountForm({ assertRedirectUrl: false });
81+
cy.navigateToSignInAndSubmitForm();
8482

8583
const expectedUrl = `${confirmEmailResentUrl}?id=${account.id}`;
8684

e2e-tests/insurance/cypress/e2e/journeys/account/sign-in/account-sign-in-with-an-expired-verification.spec.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ context('Insurance - Account - Sign in - expired verification', () => {
3131

3232
/**
3333
* navigate to the sign in page,
34-
* without a verified account.
34+
* without a verified account.
3535
*/
3636
cy.clickSignInButtonLink();
3737

@@ -63,9 +63,7 @@ context('Insurance - Account - Sign in - expired verification', () => {
6363
});
6464

6565
it(`should redirect to ${CONFIRM_EMAIL_RESENT}`, () => {
66-
cy.navigateToUrl(signInUrl);
67-
68-
cy.completeAndSubmitSignInAccountForm({ assertRedirectUrl: false });
66+
cy.navigateToSignInAndSubmitForm();
6967

7068
const expectedUrl = `${confirmEmailResentUrl}?id=${account.id}`;
7169

e2e-tests/insurance/cypress/e2e/journeys/account/sign-in/account-sign-in-with-an-unverified-account.spec.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ context('Insurance - Account - Sign in - unverified account', () => {
2929

3030
/**
3131
* navigate to the sign in page,
32-
* without a verified account.
32+
* without a verified account.
3333
*/
3434
cy.clickSignInButtonLink();
3535

@@ -51,9 +51,7 @@ context('Insurance - Account - Sign in - unverified account', () => {
5151
});
5252

5353
it(`should redirect to ${CONFIRM_EMAIL_RESENT}`, () => {
54-
cy.navigateToUrl(signInUrl);
55-
56-
cy.completeAndSubmitSignInAccountForm({ assertRedirectUrl: false });
54+
cy.navigateToSignInAndSubmitForm();
5755

5856
const expectedUrl = `${confirmEmailResentUrl}?id=${account.id}`;
5957

e2e-tests/insurance/cypress/e2e/journeys/account/sign-in/sign-in-retry/account-sign-in-retry-maximum-retries-with-invalid-credentials-suspends-account.spec.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ context('Insurance - Account - Sign in - Submitting the form with invalid creden
6565
before(() => {
6666
cy.saveSession();
6767

68-
cy.navigateToUrl(signInUrl);
69-
70-
cy.completeAndSubmitSignInAccountForm({ assertRedirectUrl: false });
68+
cy.navigateToSignInAndSubmitForm();
7169
});
7270

7371
it(`should redirect to ${SUSPENDED_ROOT} with ID query param`, () => {

e2e-tests/insurance/cypress/e2e/journeys/cookies-saved.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ context('Cookies saved page - Insurance', () => {
2121
const url = `${baseUrl}${COOKIES_SAVED}`;
2222

2323
beforeEach(() => {
24-
cy.login();
24+
cy.navigateToRootUrl();
2525

2626
cy.navigateToCheckIfEligibleUrl();
2727

e2e-tests/quote/cypress/e2e/journeys/cookies-consent/banner/cookies-consent-accept.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ context('Cookies consent - accept', () => {
88
const url = `${baseUrl}${ROUTES.QUOTE.BUYER_COUNTRY}`;
99

1010
beforeEach(() => {
11-
cy.login();
11+
cy.navigateToRootUrl();
1212

1313
cy.assertUrl(url);
1414
});

e2e-tests/quote/cypress/e2e/journeys/cookies-consent/banner/cookies-consent-reject.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ context('Cookies consent - reject', () => {
88
const url = `${baseUrl}${ROUTES.QUOTE.BUYER_COUNTRY}`;
99

1010
beforeEach(() => {
11-
cy.login();
11+
cy.navigateToRootUrl();
1212

1313
cy.assertUrl(url);
1414
});

e2e-tests/quote/cypress/e2e/journeys/cookies-consent/banner/cookies-consent.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const baseUrl = Cypress.config('baseUrl');
1414

1515
context('Cookies consent - initial/default', () => {
1616
beforeEach(() => {
17-
cy.login();
17+
cy.navigateToRootUrl();
1818

1919
const expectedUrl = `${baseUrl}${BUYER_COUNTRY}`;
2020

@@ -38,7 +38,7 @@ context('Cookies consent - initial/default', () => {
3838

3939
cy.checkText(partials.cookieBanner.heading(), `${COOKIES_CONSENT.HEADING_INTRO} ${PRODUCT.DESCRIPTION.QUOTE}`);
4040

41-
cy.login();
41+
cy.navigateToRootUrl();
4242
});
4343
});
4444

e2e-tests/quote/cypress/e2e/journeys/cookies-consent/change-cookies-consent-via-banner-and-cookies-page.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ context('Cookies consent - change via banner and cookies page', () => {
1717
cy.clearCookies();
1818
Cypress.session.clearAllSavedSessions();
1919

20-
cy.login();
20+
cy.navigateToRootUrl();
2121

2222
cy.saveSession();
2323
});

e2e-tests/quote/cypress/e2e/journeys/footer.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { FOOTER } from '../../../../content-strings';
33

44
context('Footer', () => {
55
beforeEach(() => {
6-
cy.login();
6+
cy.navigateToRootUrl();
77

88
cy.saveSession();
99
});

e2e-tests/quote/cypress/e2e/journeys/give-feedback.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import partials from '../../../../partials';
22

33
context('Give feedback link - As an exporter, I want to provide feedback about this service', () => {
44
before(() => {
5-
cy.login();
5+
cy.navigateToRootUrl();
66

77
partials.phaseBanner.feedbackLink().click();
88
});

e2e-tests/quote/cypress/e2e/journeys/privacy.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { LINKS } from '../../../../content-strings';
33

44
context('Privacy link - as en exporter, I want to read the privacy policy', () => {
55
before(() => {
6-
cy.login();
6+
cy.navigateToRootUrl();
77

88
partials.footer.supportLinks.privacy().click();
99
});

e2e-tests/quote/cypress/e2e/journeys/quote/accessibility-statement.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const baseUrl = Cypress.config('baseUrl');
3131

3232
context('Accessibility statement page - Quote', () => {
3333
beforeEach(() => {
34-
cy.login();
34+
cy.navigateToRootUrl();
3535

3636
partials.footer.supportLinks.accessibilityStatement().click();
3737
cy.assertUrl(`${baseUrl}${ROUTES.ACCESSIBILITY_STATEMENT}`);

e2e-tests/quote/cypress/e2e/journeys/quote/buyer-body/buyer-body-answer-yes.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ context(
1515
const url = `${baseUrl}${BUYER_BODY}`;
1616

1717
before(() => {
18-
cy.login();
18+
cy.navigateToRootUrl();
1919
cy.completeAndSubmitBuyerCountryForm({});
2020

2121
cy.assertUrl(url);

e2e-tests/quote/cypress/e2e/journeys/quote/buyer-body/buyer-body.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const url = `${baseUrl}${BUYER_BODY}`;
1919

2020
context('Buyer body page - as an exporter, I want to check if I can get an EXIP online quote for my buyers country', () => {
2121
beforeEach(() => {
22-
cy.login();
22+
cy.navigateToRootUrl();
2323
cy.completeAndSubmitBuyerCountryForm({});
2424

2525
cy.assertUrl(url);

e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const baseUrl = Cypress.config('baseUrl');
1818

1919
context('Buyer country page - as an exporter, I want to check if UKEF issue credit insurance cover for where my buyer is based', () => {
2020
beforeEach(() => {
21-
cy.login();
21+
cy.navigateToRootUrl();
2222

2323
const expectedUrl = `${baseUrl}${BUYER_COUNTRY}`;
2424

e2e-tests/quote/cypress/e2e/journeys/quote/cannot-apply-page.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const baseUrl = Cypress.config('baseUrl');
1212

1313
context('Cannot apply exit page', () => {
1414
beforeEach(() => {
15-
cy.login();
15+
cy.navigateToRootUrl();
1616
cy.completeAndSubmitBuyerCountryForm({});
1717
cy.completeAndSubmitBuyerBodyForm();
1818
cy.completeAndSubmitExporterLocationForm();

e2e-tests/quote/cypress/e2e/journeys/quote/change-your-answers/change-policy-type-multiple-times-via-back-button.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ context(
2121
const url = `${baseUrl}${TELL_US_ABOUT_YOUR_POLICY}`;
2222

2323
const completePreviousForms = () => {
24-
cy.login();
24+
cy.navigateToRootUrl();
2525

2626
cy.completeAndSubmitBuyerCountryForm({});
2727
cy.completeAndSubmitBuyerBodyForm();

e2e-tests/quote/cypress/e2e/journeys/quote/change-your-answers/change-your-answers-export-fields.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ context('Change your answers (export fields) - as an exporter, I want to change
2727
const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`;
2828

2929
before(() => {
30-
cy.login();
30+
cy.navigateToRootUrl();
3131
cy.submitQuoteAnswersHappyPathSinglePolicy({});
3232
cy.assertUrl(url);
3333
});

e2e-tests/quote/cypress/e2e/journeys/quote/change-your-answers/change-your-answers-policy-fields-multi-policy-credit-period.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ context('Change your answers (policy credit period field) - as an exporter, I wa
1717
const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`;
1818

1919
before(() => {
20-
cy.login();
20+
cy.navigateToRootUrl();
2121
cy.submitQuoteAnswersHappyPathMultiplePolicy();
2222
cy.assertUrl(url);
2323
});

e2e-tests/quote/cypress/e2e/journeys/quote/change-your-answers/change-your-answers-policy-type-and-length.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ context('Change your answers - as an exporter, I want to change the details befo
6565

6666
context('Policy type and length fields - user flow', () => {
6767
before(() => {
68-
cy.login();
68+
cy.navigateToRootUrl();
6969
cy.submitQuoteAnswersHappyPathSinglePolicy({});
7070

7171
cy.assertUrl(url);
@@ -108,7 +108,7 @@ context('Change your answers - as an exporter, I want to change the details befo
108108

109109
context('Policy type and length fields - check new answers', () => {
110110
beforeEach(() => {
111-
cy.login();
111+
cy.navigateToRootUrl();
112112

113113
cy.submitQuoteAnswersHappyPathSinglePolicy({});
114114
cy.assertUrl(url);
@@ -149,7 +149,7 @@ context('Change your answers - as an exporter, I want to change the details befo
149149
context('change `Policy type` and `Policy length` two times (single, multiple, then single 5 months)', () => {
150150
context('Policy type and length fields - user flow', () => {
151151
before(() => {
152-
cy.login();
152+
cy.navigateToRootUrl();
153153

154154
cy.submitQuoteAnswersHappyPathSinglePolicy({});
155155
cy.assertUrl(url);
@@ -201,7 +201,7 @@ context('Change your answers - as an exporter, I want to change the details befo
201201

202202
context('Policy type and length fields - check new answers', () => {
203203
beforeEach(() => {
204-
cy.login();
204+
cy.navigateToRootUrl();
205205

206206
cy.submitQuoteAnswersHappyPathSinglePolicy({});
207207
cy.assertUrl(url);
@@ -237,7 +237,7 @@ context('Change your answers - as an exporter, I want to change the details befo
237237
context('change `Policy type` and `Policy length` three times (single, multiple, single, then multiple)', () => {
238238
context('Policy type and length fields - user flow', () => {
239239
before(() => {
240-
cy.login();
240+
cy.navigateToRootUrl();
241241

242242
cy.submitQuoteAnswersHappyPathSinglePolicy({});
243243
cy.assertUrl(url);

e2e-tests/quote/cypress/e2e/journeys/quote/check-your-answers/check-your-answers-multi-policy.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ context('Check your answers page (multiple policy) - as an exporter, I want to r
3737
const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`;
3838

3939
before(() => {
40-
cy.login();
40+
cy.navigateToRootUrl();
4141
cy.submitQuoteAnswersHappyPathMultiplePolicy();
4242
cy.assertUrl(url);
4343
});

e2e-tests/quote/cypress/e2e/journeys/quote/check-your-answers/check-your-answers-single-policy.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ context('Check your answers page (single policy) - as an exporter, I want to rev
4040
const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`;
4141

4242
before(() => {
43-
cy.login();
43+
cy.navigateToRootUrl();
4444
cy.submitQuoteAnswersHappyPathSinglePolicy({});
4545
cy.assertUrl(url);
4646
});

e2e-tests/quote/cypress/e2e/journeys/quote/contact-us.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ context('Contact us page - Quote', () => {
1616
const url = ROUTES.CONTACT_US;
1717

1818
beforeEach(() => {
19-
cy.login();
19+
cy.navigateToRootUrl();
2020

2121
// click on contact link in footer
2222
footer.supportLinks.contact().click();

e2e-tests/quote/cypress/e2e/journeys/quote/cookies-saved.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ context('Cookies saved page - Quote', () => {
2020
const buyerCountryUrl = `${baseUrl}${BUYER_COUNTRY}`;
2121

2222
beforeEach(() => {
23-
cy.login();
23+
cy.navigateToRootUrl();
2424

2525
partials.footer.supportLinks.cookies().click();
2626

e2e-tests/quote/cypress/e2e/journeys/quote/cookies.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ context('Cookies page - Quote', () => {
2626
const buyerCountryUrl = `${baseUrl}${BUYER_COUNTRY}`;
2727

2828
beforeEach(() => {
29-
cy.login();
29+
cy.navigateToRootUrl();
3030

3131
partials.footer.supportLinks.cookies().click();
3232

e2e-tests/quote/cypress/e2e/journeys/quote/exporter-location/exporter-location-answer-no.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ context(
1616
const url = `${baseUrl}${EXPORTER_LOCATION}`;
1717

1818
before(() => {
19-
cy.login();
19+
cy.navigateToRootUrl();
2020
cy.completeAndSubmitBuyerCountryForm({});
2121
cy.completeAndSubmitBuyerBodyForm();
2222

e2e-tests/quote/cypress/e2e/journeys/quote/exporter-location/exporter-location.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ context('Exporter location page - as an exporter, I want to check if my company
1919
const url = `${baseUrl}${EXPORTER_LOCATION}`;
2020

2121
beforeEach(() => {
22-
cy.login();
22+
cy.navigateToRootUrl();
2323
cy.completeAndSubmitBuyerCountryForm({});
2424
cy.completeAndSubmitBuyerBodyForm();
2525

0 commit comments

Comments
 (0)