Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cypress testing #121

Open
wants to merge 91 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
fa7da62
Added in the cypress and coverage packages.
cschwinderg Apr 1, 2022
550d475
Added in a basic test.
cschwinderg Apr 1, 2022
c6cf709
Added a reusable login command and an authentication test.
cschwinderg Apr 1, 2022
8aa44ae
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 4, 2022
7f2ad28
Fixed issues with cypress tests after merge.
cschwinderg Apr 4, 2022
7f236a1
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 5, 2022
5d7f438
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 5, 2022
6541b73
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 5, 2022
cc17618
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 6, 2022
2d86bd1
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 6, 2022
658cb38
Added a test for filling out the application.
cschwinderg Apr 6, 2022
1e382b2
Added more authentication tests.
cschwinderg Apr 6, 2022
dd91fdd
Fixed issue of code coverage missing files in output.
cschwinderg Apr 6, 2022
4eedec4
Added some more tests.
cschwinderg Apr 7, 2022
eaf8bf3
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 7, 2022
c0d4f4e
Updated the service routes, since v1 was removed. Refactored the reba…
cschwinderg Apr 7, 2022
6ecd245
Added some more tests and ran prettier.
cschwinderg Apr 7, 2022
1e350e5
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 7, 2022
d18db9f
Fixed tests after merge.
cschwinderg Apr 7, 2022
070fe05
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 7, 2022
e9b5920
Added flag to ignore the reportWebVitals.ts file in cypress tests.
cschwinderg Apr 7, 2022
1e71374
Added some more lines to ignore code coverage.
cschwinderg Apr 8, 2022
052d0ba
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 8, 2022
94e4912
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 11, 2022
57a780c
Updated cypress tests to use preferred cypress coding practices.
cschwinderg Apr 11, 2022
e1cf32f
Removed only flag.
cschwinderg Apr 11, 2022
7dbf0a6
Added some new tests for the helpdesk.
cschwinderg Apr 11, 2022
aa06976
Fixed an issue with running all of the tests at once.
cschwinderg Apr 11, 2022
ad39ed0
Fixed rebate form tests.
cschwinderg Apr 12, 2022
6943e1d
Fixed routes tests.
cschwinderg Apr 12, 2022
4c3ba7d
Fixed issues with the loginToCSB command.
cschwinderg Apr 12, 2022
0ef7079
Moved the application step functions into a cypress command so they c…
cschwinderg Apr 12, 2022
9d4ad17
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 12, 2022
ede9b48
Updated cypress to the latest version.
cschwinderg Apr 12, 2022
ee56b0c
Added in more helpdesk tests.
cschwinderg Apr 12, 2022
e3aafc1
Added retries to the cypress tests.
cschwinderg Apr 12, 2022
a93efcd
Fixed error messages that were removed.
cschwinderg Apr 13, 2022
71b9171
Default step 1 parameter to false like all others.
cschwinderg Apr 13, 2022
0e42371
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 13, 2022
e37026e
Ran prettier on the cypress files.
cschwinderg Apr 13, 2022
e76d573
Removed unnecessary changes.
cschwinderg Apr 13, 2022
f7a426f
Removed istanbul ignore statements.
cschwinderg Apr 13, 2022
ad48e2e
Updated the text for targeting the user sign on page loaded.
cschwinderg Apr 13, 2022
73fc158
Finished removing istanbul flags.
cschwinderg Apr 14, 2022
bdcedd6
Replaced data-testids with aria-labels.
cschwinderg Apr 14, 2022
ae9f101
Fixed code smells.
cschwinderg Apr 14, 2022
1ec1a98
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 19, 2022
6d6bf63
Fixed issues with the rebate-form test since the form was updated.
cschwinderg Apr 20, 2022
d2b6838
Fixed the authentication tests.
cschwinderg Apr 20, 2022
40a46c0
Fixed the helpdesk test and also added a new test.
cschwinderg Apr 20, 2022
5d97275
Fixed the routes tests.
cschwinderg Apr 20, 2022
4440146
Fixed a code smell with the cypress tests.
cschwinderg Apr 20, 2022
58f4ad7
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 20, 2022
0468834
Removed an unnecessary test.
cschwinderg Apr 20, 2022
b8faceb
Fixed some merge issues.
cschwinderg Apr 20, 2022
83923b1
Fixed another merge issue.
cschwinderg Apr 20, 2022
22d8cb4
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 21, 2022
7ed4096
Switched over to only using the csbtest and csbtest8 users for cypres…
cschwinderg Apr 21, 2022
38b9d50
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 22, 2022
9c32101
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 25, 2022
86348ee
Fixed issues with the tests.
cschwinderg Apr 25, 2022
0c875da
Fixed cypress tests.
cschwinderg Apr 25, 2022
9ce061a
Fixed filling out form cypress test.
cschwinderg Apr 25, 2022
701dc5f
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 26, 2022
6cb0b20
Added code to wait for file upload to complete prior to continuing test.
cschwinderg Apr 26, 2022
99841e7
Made tests more reliable by removing a check for "Submitting form..."…
cschwinderg Apr 26, 2022
eecdec3
Fixed issue of coverage missing some files.
cschwinderg Apr 26, 2022
6f6f1c7
Merge branch 'develop' into feature/cypress-testing
cschwinderg Apr 26, 2022
582cf6a
Removed duplicate test and fixed step 4 since autopopulate on NCES ID…
cschwinderg Apr 26, 2022
dc7cb55
Removed unnecessary packages.
cschwinderg Apr 27, 2022
24fb1e3
Fixed cypress tests.
cschwinderg Apr 27, 2022
3453bed
Added myself to the package.json files.
cschwinderg Apr 27, 2022
2560933
Re-install @cypress/instrument-cra as a dependency to follow existing…
courtneymyers Apr 27, 2022
49aa047
Update orchestrating app's npm scripts to have better output for conc…
courtneymyers Apr 27, 2022
86cfd3e
Removed testing code for filling out form that should be filled out b…
cschwinderg Apr 28, 2022
07862ce
Update npm run scripts (while keeping cypress and coverage scripts se…
courtneymyers Apr 29, 2022
93fbc3e
Update npm coverage script to run all tests
courtneymyers Apr 29, 2022
e629b8d
Fixed the tests.
cschwinderg Apr 29, 2022
ba3daf4
Removed the readme file and prettier config. Re-ran prettier on all c…
cschwinderg Apr 29, 2022
5d401e1
Updated the gitignore file to ignore cypress videos and screenshots.
cschwinderg Apr 29, 2022
9197667
Remove example cypress fixture and format config file
courtneymyers Apr 29, 2022
62b6c94
Switched as much as possible over to findByRole.
cschwinderg May 9, 2022
ca2ab4c
Fixed code smells.
cschwinderg May 10, 2022
3e13c65
Switched some more items over to findByRole and ran prettier on all o…
cschwinderg May 10, 2022
c4d06a0
Fixed codesmells.
cschwinderg May 10, 2022
d6ee5d0
Merge branch 'develop' into feature/cypress-testing
cschwinderg Jul 5, 2022
202a614
Merge branch 'develop' into feature/cypress-testing
cschwinderg Jul 22, 2022
b8afd58
#121 Fixed cypress testing issues with latest updates to csb code.
cschwinderg Jul 22, 2022
620c871
Merge branch 'develop' into feature/cypress-testing
cschwinderg Jul 22, 2022
d438f17
Merge branch 'develop' into feature/cypress-testing
cschwinderg Aug 25, 2022
d8777f5
Fixed issue of some files missing from code coverage.
cschwinderg Aug 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,7 @@ dist

# TernJS port file
.tern-port

# Cypress
app/cypress/screenshots/
app/cypress/videos/
143 changes: 143 additions & 0 deletions app/client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion app/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@
"author": "USEPA (https://www.epa.gov)",
"contributors": [
"Brad Cooper <[email protected]>",
"Caleb Schwind <[email protected]>",
"Courtney Myers <[email protected]>",
"Devin Galloway <[email protected]>"
],
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"coverage": "react-scripts -r @cypress/instrument-cra start"
},
"devDependencies": {
"@cypress/instrument-cra": "1.4.0"
},
"dependencies": {
"@formio/premium": "1.18.4",
Expand Down Expand Up @@ -46,6 +51,18 @@
"web-vitals": "2.1.4"
},
"proxy": "http://localhost:3001",
"nyc": {
"all": true,
"cache": false,
"include": [
"src"
],
"extension": [
".js",
".ts",
".tsx"
]
},
"eslintConfig": {
"extends": [
"react-app",
Expand Down
8 changes: 8 additions & 0 deletions app/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"baseUrl": "http://localhost:3000",
"defaultCommandTimeout": 8000,
"viewportWidth": 1280,
"viewportHeight": 800,
"chromeWebSecurity": false,
"retries": 1
}
Binary file added app/cypress/fixtures/testPicture.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 108 additions & 0 deletions app/cypress/integration/authentication.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
describe("Authentication", () => {
// TODO Remove this when the app is more stable
Cypress.on("uncaught:exception", (_err, _runnable) => {
// returning false here prevents Cypress from
// failing the test
debugger;
return false;
});

beforeEach(() => {
cy.clearCookie("csb-token");

cy.loginToCSB("csbtest");
});

const loggedOutMessage = "You have successfully logged out.";
const samInfoText =
"No SAM.gov records match your email. Only Government and Electronic Business SAM.gov Points of Contacts (and alternates) may edit and submit Clean School Bus Rebate Forms.";
const samErrorText = "Error retrieving SAM.gov data. Please contact support.";

it("Sign in to CSB", () => {
// verify the user name is displayed on the screen
cy.findByText("[email protected]");
});

it("Sign out of CSB", () => {
// verify the user name is displayed on the screen
cy.findByText("[email protected]");

// sign out
cy.findByRole("link", { name: "Sign out" }).click();

// verify sign out was completed
cy.findByText(loggedOutMessage);
cy.contains(
"Click the Sign in button below to login to the Clean School Bus Rebate Dashboard using Login.gov."
);
});

it("Verify error messages based on error parameter value", () => {
cy.visit("/welcome?error=auth");
cy.findByText(
"Authentication error. Please log in again or contact support."
);

cy.visit("/welcome?error=saml");
cy.findByText("Error logging in. Please try again or contact support.");

cy.visit("/welcome?error=sam-fetch");
cy.findByText(samErrorText);

cy.visit("/welcome?info=sam-results");
cy.findByText(samInfoText);

cy.visit("/welcome?info=timeout");
cy.findByText(
"For security reasons, you have been logged out due to 15 minutes of inactivity."
);

cy.visit("/welcome?success=logout");
cy.findByText(loggedOutMessage);
});

it("Test SAM.gov service failure", () => {
// sign out
cy.findByText("[email protected]");
cy.findByRole("link", { name: "Sign out" }).click();
cy.findByText(loggedOutMessage);

// simulate the sam-data service failing
const origin =
location.hostname === "localhost"
? `${location.protocol}//${location.hostname}:3000`
: window.location.origin;
cy.intercept(`${origin}/api/sam-data`, {
statusCode: 500,
body: {},
}).as("sam-data");

// verify the appropriate error message is displayed
cy.loginToCSB("csbtest");
cy.findByText(samErrorText);
});

it("Test SAM.gov service with no results", () => {
// sign out
cy.findByText("[email protected]");
cy.findByRole("link", { name: "Sign out" }).click();
cy.findByText(loggedOutMessage);

// simulate the sam-data service with no results
const origin =
location.hostname === "localhost"
? `${location.protocol}//${location.hostname}:3000`
: window.location.origin;
cy.intercept(`${origin}/api/sam-data`, {
statusCode: 200,
body: {
records: [],
results: false,
},
}).as("sam-data");

// verify the appropriate message is displayed
cy.loginToCSB("csbtest");
cy.findByText(samInfoText);
});
});
Loading