Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 7183f80

Browse files
committed
Task 108911: Upgrade cypress 10 & add test tags
Cypress grep: - Cypress 10.0^ dependency - Grep Module import to /plugins/index.js & /support/e2e.js - Tags in use: @dev,@ stage, @integration - For more recipes: https://github.com/cypress-io/cypress-grep Cypress upgrade: - Cypress package version: 10.9.0 - Folder where tests live is renamed: from 'integration', to 'e2e' - Test files renamed: from '.spec.js', now '.cy.js' - Support files renamed from: /support/index.js, now support/e2e.js - Cypress config files changed: from cypress.json, now cypress.config.ts - Latest changes: https://docs.cypress.io/guides/references/changelog Cypress 10.9.0 known issues: - Unable to run all tests at once via Cypress GUI: cypress-io/cypress#21628 - Error Log each time tests run in terminal: cypress-io/cypress#22273 README: - grep run command - grep recipes Files removed: - test examples - Unnecessary
1 parent 8440274 commit 7183f80

20 files changed

+1960
-56
lines changed

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,23 @@ To execute the tests and push the results to the cypress dashboard:
103103
npm run cypress:run -- --record --key 'KEY' url="BASE_URL_OF_APP",authorizationHeader="secret"
104104
```
105105

106+
To execute tests with grep tags on dev:
107+
108+
```
109+
$ npm run cy:run -- --env grepTags=@dev,grepTags=@stage,url="BASE_URL_OF_APP",authorizationHeader="<SECRET HERE>"
110+
```
111+
112+
To execute tests with grep tags on stage:
113+
114+
```
115+
$ npm run cy:run -- --env grepTags=@stage,url="BASE_URL_OF_APP",authorizationHeader="<SECRET HERE>"
116+
```
117+
118+
To only execute all.cy.js file which has all import test files
119+
```
120+
$ npm run cy:run -- --spec "cypress/e2e/all.cy.js", --env grepTags=@stage,url="BASE_URL_OF_APP",authorizationHeader="<SECRET HERE>"
121+
```
122+
106123
We append a wildcard (\*\*) to the URL argument (see `cypress.json`), so it must have a trailing slash (e.g., `url="https://localhost:5001/"`).
107124

108125
### Useful tips
@@ -142,3 +159,18 @@ See support/index.js for the cy.intercept command.
142159

143160

144161
Further details about Cypress can be found here: https://docs.cypress.io/api/table-of-contents
162+
163+
To run tests with multiple tags in a list:
164+
165+
```
166+
i.e., greTags=@dev+@stage
167+
```
168+
169+
To run tests including multiple tags independently targeting individual tags:
170+
171+
```
172+
i.e., grepTags=@dev,grepTags=@stage
173+
```
174+
175+
Further details on using cypress-grep test tagging: https://github.com/cypress-io/cypress-grep
176+
cypress 10.9.0 Latest changes: https://docs.cypress.io/guides/references/changelog

end-to-end-tests/cypress.config.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const { defineConfig } = require("cypress");
2+
3+
module.exports = defineConfig({
4+
projectId: "jd9h7w",
5+
video: false,
6+
7+
env: {
8+
db: {
9+
userName: "",
10+
password: "",
11+
server: "",
12+
options: {
13+
database: "",
14+
encrypt: true,
15+
rowCollectionOnRequestCompletion: true,
16+
},
17+
},
18+
},
19+
20+
tenantId: "fad277c9-c60a-4da1-b5f3-b3b8b34a82f9",
21+
clientId: "8b708989-014c-451c-a564-b2bed382f61f",
22+
modifyObstructiveCode: true,
23+
chromeWebSecurity: false,
24+
25+
e2e: {
26+
setupNodeEvents(on, config) {
27+
// implement node event listeners here
28+
},
29+
},
30+
});

end-to-end-tests/cypress.json

-21
This file was deleted.

end-to-end-tests/cypress/integration/End2EndTests/project-runthrough-ks2.js renamed to end-to-end-tests/cypress/e2e/End2EndTests/project-runthrough-ks2.cy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function clickBackLink() {
2020
}
2121

2222

23-
describe("Locate project and check against Key Stage 2 table", () => {
23+
describe("Locate project and check against Key Stage 2 table", { tags: '@skip'}, () => {
2424
afterEach(() => {
2525
cy.storeSessionData()
2626
});

end-to-end-tests/cypress/integration/End2EndTests/project-runthrough.spec.js renamed to end-to-end-tests/cypress/e2e/End2EndTests/project-runthrough.cy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function clickBackLink() {
2626
.click();
2727
}
2828

29-
describe("Creating and editing an academy transfer", function () {
29+
describe("Creating and editing an academy transfer", { tags: '@dev'}, function () {
3030

3131
afterEach(() => {
3232
cy.storeSessionData();

end-to-end-tests/cypress/integration/Performance/preview and download template.js renamed to end-to-end-tests/cypress/e2e/Performance/preview and download template.cy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let selectAllCheckboxesUptoIndex = (index) => {
1919
});
2020
}
2121

22-
describe("Performance test for preview and download template with multiple academies", function () {
22+
describe("Performance test for preview and download template with multiple academies", { tags: '@dev'}, function () {
2323
let startTimeStamp;
2424
let endTimeStamp;
2525
let timeTaken;

end-to-end-tests/cypress/integration/SQLTests/DatabaseTests.js renamed to end-to-end-tests/cypress/e2e/SQLTests/DatabaseTests.cy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This was an attempt to try and create some tests or methods that can coneect
33
*/
4-
describe('Example to Demonstrate SQL Database Testing in Cypress', () => {
4+
describe('Example to Demonstrate SQL Database Testing in Cypress', { tags: '@spike'}, () => {
55

66
it.skip('TEST CONNECTION with Pre-Prod', function () {
77
cy.sqlServer("SELECT TOP (2) * FROM [cdm].[contact]").then((result) => {
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/// <reference types ='Cypress'/>
2+
// Run all tests NOTE: this is a work around as cypress 10.0 GUI does not allow to run all tests
3+
4+
// Benefits-and-risks
5+
import '../e2e/benefits-and-risks/equalities-impact-assessment.cy'
6+
7+
// End2EndTests
8+
import '../e2e/End2EndTests/project-runthrough-ks2.cy'
9+
import '../e2e/End2EndTests/project-runthrough.cy'
10+
11+
// Error-messages
12+
import '../e2e/error-messages/advisory-board-date.cy'
13+
import '../e2e/error-messages/target-date.cy'
14+
15+
// Landing-page
16+
import '../e2e/landing-page/landing-page.cy'
17+
18+
// Multiple-academies
19+
import '../e2e/multiple-academies/select-multiple-academies.cy'
20+
21+
// Performance
22+
import '../e2e/Performance/preview and download template.cy'
23+
24+
// SQLTests
25+
import '../e2e/SQLTests/DatabaseTests.cy'
26+
27+
// Trusts-transfers
28+
import '../e2e/trust-transfers/search-incoming-trust.cy'

end-to-end-tests/cypress/integration/benefits-and-risks/equalities-impact-assessment.js renamed to end-to-end-tests/cypress/e2e/benefits-and-risks/equalities-impact-assessment.cy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types ='Cypress'/>
22

3-
describe('Tests to check equalities impact assessment form', () => {
3+
describe('Tests to check equalities impact assessment form',{ tags: '@dev'}, () => {
44
afterEach(() => {
55
cy.storeSessionData();
66
});

end-to-end-tests/cypress/integration/error-messages/advisory-board-date.js renamed to end-to-end-tests/cypress/e2e/error-messages/advisory-board-date.cy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe('Tests to check advisory board date error messages', () => {
1+
describe('Tests to check advisory board date error messages', { tags: '@dev'}, () => {
22
afterEach(() => {
33
cy.storeSessionData();
44
});

end-to-end-tests/cypress/integration/error-messages/target-date.js renamed to end-to-end-tests/cypress/e2e/error-messages/target-date.cy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe('Tests to check target date error messages', () => {
1+
describe('Tests to check target date error messages', { tags: '@dev'}, () => {
22
afterEach(() => {
33
cy.storeSessionData();
44
});

end-to-end-tests/cypress/integration/landing-page/landing-page.js renamed to end-to-end-tests/cypress/e2e/landing-page/landing-page.cy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const url = Cypress.env('url') + 'project-type'
44

5-
describe('Landing Page',() => {
5+
describe('Landing Page', { tags: '@dev'}, () => {
66
beforeEach(() => {
77
cy.visit(url)
88
})

end-to-end-tests/cypress/integration/multiple-academies/select-multiple-academies.js renamed to end-to-end-tests/cypress/e2e/multiple-academies/select-multiple-academies.cy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
let outgoingTrustId = '10059580';
22
let incomingTrustId = '10060470';
33

4-
describe('Select multiple academies', () => {
4+
describe('Select multiple academies', { tags: '@dev'}, () => {
55
afterEach(() => {
66
cy.storeSessionData();
77
});

end-to-end-tests/cypress/integration/trust-transfers/search-incoming-trust.js renamed to end-to-end-tests/cypress/e2e/trust-transfers/search-incoming-trust.cy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let trustId = '10060470';
22

3-
describe('Tests to check search incoming trust error message', () => {
3+
describe('Tests to check search incoming trust error message', { tags: '@dev'}, () => {
44
afterEach(() => {
55
cy.storeSessionData();
66
});

end-to-end-tests/cypress/fixtures/example.json

-5
This file was deleted.

end-to-end-tests/cypress/plugins/index.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,21 @@ const sqlServer = require('cypress-sql-server');
3434
module.exports = (on, config) => {
3535
tasks = sqlServer.loadDBPlugin(config.env.db);
3636
on('task', tasks);
37-
}
37+
}
38+
39+
// ***********************************************************
40+
41+
//***Cypress Grep module for filtering tests Any new tags should be added to the examples**
42+
/**
43+
* @example {{tags: '@dev'} : Development
44+
* @example {tags: '@stage'} : Staging
45+
* @example {tags: '@integration'} : Integration
46+
* @example {tags: ['@dev', '@stage']}
47+
* @example {tags: '@spike'}
48+
* @example {tags: '@skip'}
49+
*/
50+
module.export = (on, config) => {
51+
52+
require('cypress-grep/src/plugin')(config)
53+
}
54+
// ***********************************************************

end-to-end-tests/cypress/support/commands.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,23 @@ Cypress.Commands.add('OutGoingSearch_Link_Back', () => cy.get(`${backLink}`))
111111
// PAGE: Set transfer dates
112112
// PAGE: Benefits and risks
113113
// PAGE: Rationale
114-
// PAGE: Trust information and project dates
114+
// PAGE: Trust information and project dates
115+
116+
// Universal: Navigate to Transfer and pick the first project
117+
118+
// Selects Transfers by default: universal
119+
Cypress.Commands.add('selectsTransferLandingPage', () => {
120+
let url = Cypress.env('url');
121+
cy.visit(url);
122+
cy.get('[data-cy="select-projecttype-input-conversion"]').click();
123+
cy.get('[data-cy="select-common-submitbutton"]').click();
124+
})
125+
126+
// Selects the first project on the list: universal
127+
Cypress.Commands.add('selectsFirstProjectOnList', () => {
128+
let url = Cypress.env('url');
129+
cy.visit(url);
130+
cy.get('[data-cy="select-projecttype-input-conversion"]').click();
131+
cy.get('[data-cy="select-common-submitbutton"]').click();
132+
cy.get('[id="school-name-0"]').click();
133+
})

end-to-end-tests/cypress/support/index.js renamed to end-to-end-tests/cypress/support/e2e.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ***********************************************************
2-
// This example support/index.js is processed and
2+
// This example support/e2e.js is processed and
33
// loaded automatically before your test files.
44
//
55
// This is a great place to put global configuration and
@@ -30,4 +30,11 @@ beforeEach(() => {
3030
(req) => req.headers['Authorization'] = 'Bearer ' + Cypress.env('authorizationHeader'),
3131
(req) => req.headers['AuthorizationRole'] = 'transfers.create'
3232
)
33-
})
33+
})
34+
35+
// ***********************************************************
36+
37+
//Cypress Grep module for filtering tests
38+
require('cypress-grep')()
39+
40+
// ***********************************************************

0 commit comments

Comments
 (0)