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

Introduce updated cypress test #3167

Merged
merged 101 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
d7d72b4
upgrade cypress to `8.3.1`
Sep 6, 2021
ce20592
reinitialise cypress
Sep 6, 2021
af34b00
wrap login to separate cypress command
Sep 6, 2021
1a19d76
refactor auth test - store user in fixture
Sep 6, 2021
22a4acd
wrap patient create into cy command
Sep 6, 2021
24ca0a4
wrap facility crud as cy command
Sep 6, 2021
3394f6b
refactor facility spec into its
Sep 6, 2021
818c2ca
facility spec refactored, session persist command added
Sep 6, 2021
7605fda
refactored profile edit spec
Sep 6, 2021
2d1417f
added locations, inventory tests
Sep 6, 2021
1e3fa62
just initialise some test boilerplate
Sep 6, 2021
53d07f4
add user_crud test boilerplate with todos
Sep 6, 2021
588a450
user spec doing
Sep 7, 2021
8d90146
added sample test spec boilerplate
Sep 7, 2021
78835bc
persist localstorage for avoiding repeated logins
Sep 7, 2021
d4891a1
fix error
Sep 7, 2021
f5c7455
fix user test as possible
Sep 7, 2021
b1cbcdc
sample test basic test added
Sep 7, 2021
4798ee7
sample list basic test added
Sep 7, 2021
e80b7d9
add facility inventory basic tests
Sep 7, 2021
c1c1fc3
delete cypress examples
Sep 8, 2021
94c348e
fixing death_report test
Sep 8, 2021
6b44a2f
add shifting manage, filter tests
Sep 8, 2021
4c0afe1
added boilerplate tests for external_results, resource
Sep 8, 2021
e1aca96
change in convention
Sep 8, 2021
5c1568c
add name to user select
Sep 9, 2021
a446ca5
fix shifting filter test
Sep 9, 2021
23ebdcc
download button in shifting test fixed
Sep 9, 2021
8e1bdb4
fix download error -
Sep 9, 2021
edfc240
fix download error -
Sep 9, 2021
675ad6a
fix resource test
Sep 9, 2021
82ed912
resource filter test added
Sep 9, 2021
1f10066
add test for airbnb's date picker in filters
Sep 10, 2021
09641d2
complete black test for external results
Sep 10, 2021
6922d39
generate random username of length 10
Sep 10, 2021
703d4d4
Merge branch 'develop' of https://github.com/abhinandanarya06/care_fe…
Sep 10, 2021
e9799aa
fix assets tests
Sep 10, 2021
254bde0
fix assets filter test
Sep 10, 2021
1020573
fix forgot password test
Sep 10, 2021
4b4779e
fix death report test
Sep 10, 2021
43a2f3e
fix patient test
Sep 10, 2021
ed4124e
fix sample tests
Sep 10, 2021
0df2d34
fix user tests
Sep 10, 2021
f7c0ddb
correct test describe names
Sep 10, 2021
3bcb6d8
''
Sep 10, 2021
2031c05
Merge pull request #1794 from abhinandanarya06/develop
Sep 10, 2021
9bb6df2
removing unnecessary commands
Sep 10, 2021
170455c
fix errors
Sep 10, 2021
d59fadb
shift facility class to spec itself for now
Sep 15, 2021
c11e3ab
adding typescript only for future conversion
Sep 15, 2021
b807608
prettier
Sep 15, 2021
dbbafee
add auth test
Sep 15, 2021
b67498d
add boilerplate for other feature tests
Sep 16, 2021
f54bf04
fix auth test
Oct 27, 2021
b42b35e
upgrade cypress to `8.7.0`
Oct 27, 2021
493c1b9
add cypress workflow
Oct 27, 2021
76ec309
fixing cypress workflow
Oct 27, 2021
155683f
--
Oct 27, 2021
17e1d46
make parallel run
Oct 28, 2021
11f0c29
fixing deploy error
Oct 28, 2021
5a5d991
Delete cypress.yml
Oct 28, 2021
93a728c
Merge remote-tracking branch 'upstream/cypress' into fix-cypress
rabilrbl Jun 9, 2022
279dd3f
Merge upstream cypress and migrate to cypress 10
rabilrbl Jun 9, 2022
7508811
Fix facility type
rabilrbl Jun 21, 2022
4ebeac5
Update cypress
rabilrbl Jul 3, 2022
b058143
Merge branch 'develop' into fix-cypress
rabilrbl Jul 13, 2022
6c50cc9
Fix login captcha issue
rabilrbl Jul 13, 2022
882ef19
Merge branch 'coronasafe:develop' into fix-cypress
rabilrbl Jul 19, 2022
19603dc
Fix types
rabilrbl Jul 18, 2022
e5e555e
Introduce appropriate types on cypress files
rabilrbl Jul 19, 2022
13cfc6d
Apply ts types to all cypress files
rabilrbl Jul 19, 2022
1443015
Update .gitignore
rabilrbl Jul 19, 2022
0c93fbe
Change login with api on roles cypress test
rabilrbl Jul 19, 2022
f3d2156
Remove yarn.lock
rabilrbl Jul 19, 2022
aa50796
Change verification of token from `access` to `refresh`
rabilrbl Jul 19, 2022
234c93a
Remove extra comments in commands
rabilrbl Jul 19, 2022
4adac3d
Revert token verification from `refresh` to `access`
rabilrbl Jul 19, 2022
31348b3
Fix eslint errors
rabilrbl Jul 19, 2022
664e8b6
Remove comments and whitespace
rabilrbl Jul 19, 2022
0c64156
Update test and fix errors
rabilrbl Jul 19, 2022
8cc82d3
Merge branch 'coronasafe:develop' into fix-cypress
rabilrbl Aug 6, 2022
2f8e784
Update Cypress 10.4.0
rabilrbl Aug 6, 2022
3835365
Fix delayed UI loading in browsers
rabilrbl Aug 6, 2022
94ac904
Fix profile click timeout
rabilrbl Aug 12, 2022
5673454
Merge branch 'coronasafe:develop' into fix-cypress
rabilrbl Aug 16, 2022
d83b7b3
Fix cypress phone search error
rabilrbl Aug 16, 2022
77f0e7a
Changed inventory test based on UI change
rabilrbl Aug 16, 2022
d08fdce
Updated tests based on new UI errors
rabilrbl Aug 16, 2022
67a569e
Merge branch 'coronasafe:develop' into fix-cypress
rabilrbl Aug 23, 2022
acef40d
Fix User Crud Cypress test cases
rabilrbl Aug 23, 2022
e310731
Fix shifting Cypress test case erros
rabilrbl Aug 23, 2022
a6f4088
Fix assets button error on cypress
rabilrbl Aug 23, 2022
5dfc3f8
Remove facility delete from cypress tests
rabilrbl Aug 23, 2022
528af64
FIx button click for filters under resources
rabilrbl Aug 23, 2022
21a3128
Yet another cypress test error fix
rabilrbl Aug 26, 2022
ab7486d
Cypress Version Update; Fix User CRUD Tests
gigincg Aug 27, 2022
c4a4ae0
Minor Fixes
gigincg Aug 27, 2022
b6dd4d9
Add force action to prevent errors
rabilrbl Aug 27, 2022
0ccebe8
Merge branch 'develop' into fix-cypress
gigincg Aug 28, 2022
2846cc0
Merge branch 'coronasafe:develop' into fix-cypress
rabilrbl Aug 30, 2022
9cfd7b6
fix (cypress): changed missing staff user
khavinshankar Sep 1, 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 @@ -50,3 +50,7 @@ public/build-meta.json
# Using NPM
# package-lock.json
yarn.lock

# Cypress
cypress/downloads
cypress/fixtures/token.json
23 changes: 23 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { defineConfig } from "cypress";

import fs from "fs";

export default defineConfig({
defaultCommandTimeout: 10000,

e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
on("task", {
readFileMaybe(filename) {
if (fs.existsSync(filename)) {
return fs.readFileSync(filename, "utf8");
}

return null;
},
});
},
baseUrl: "http://localhost:4000",
},
});
3 changes: 0 additions & 3 deletions cypress.json

This file was deleted.

6,874 changes: 6,874 additions & 0 deletions cypress/downloads/external-result--09-06-2022_12_35_30.csv

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions cypress/e2e/assets_spec/assets.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/// <reference types="cypress" />

import { cy, describe, before, beforeEach, it } from "local-cypress";

describe("Assets List", () => {
before(() => {
cy.loginByApi("devdistrictadmin", "Coronasafe@123");
cy.saveLocalStorage();
});

beforeEach(() => {
cy.restoreLocalStorage();
cy.visit("http://localhost:4000");
cy.wait(1000);
cy.get("a").contains("Assets").click();
cy.url().should("include", "/assets");
});

it("Search Asset Name", () => {
cy.get("[name='search']").type("TEst");
});

it("Scan Asset QR", () => {
cy.contains("Scan Asset QR").click().wait(1000);
cy.get("video").should("exist");
cy.get("button").contains("Close Scanner").should("exist").click();
});

it("Next/Previous Page", () => {
cy.wait(1000);
// only works for desktop mode
cy.get("button").contains(">").click({ force: true });
cy.wait(1000);
cy.get("button").contains("<").click({ force: true });
});
});
37 changes: 37 additions & 0 deletions cypress/e2e/assets_spec/filter.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />

import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress";

describe("Assets Filter", () => {
before(() => {
cy.loginByApi("devdistrictadmin", "Coronasafe@123");
cy.saveLocalStorage();
});

beforeEach(() => {
cy.restoreLocalStorage();
cy.visit("http://localhost:4000");
cy.get("a").contains("Assets").click();
cy.contains("Advanced Filters").click();
cy.wait(2000);
});

it("Filter by Facility", () => {
cy.get("[placeholder='Search by facility name or by district']")
.type("test")
.wait(3000)
.type("{downarrow}{enter}");
});

it("Filter by Asset Type", () => {
cy.get("[name='asset_type']").select("EXTERNAL");
});

it("Filter by Asset Status", () => {
cy.get("[name='asset_status']").select("ACTIVE");
});

afterEach(() => {
cy.contains("Apply").click();
});
});
26 changes: 26 additions & 0 deletions cypress/e2e/auth_spec/auth.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// <reference types="cypress" />

import { cy, describe, beforeEach, it } from "local-cypress";

describe("Authorisation/Authentication", () => {
beforeEach(() => {
cy.visit("http://localhost:4000");
});

it("Try login as admin with correct password", () => {
cy.login("devdistrictadmin", "Coronasafe@123");
cy.get("p").contains("Sign Out").click();
cy.wait(1000);
cy.url().should("include", "/");
});

it("Try login admin with incorrect password", () => {
cy.log("Logging in the user: devdistrictadmin:Coronasafe@123");

cy.visit("http://localhost:4000/");
cy.get("input[name='username']").type("devdistrictadmin");
cy.get("input[name='password']").type("coronasafe@123");
cy.get("button").contains("Login").click();
cy.contains("No active account").should("exist");
});
});
19 changes: 19 additions & 0 deletions cypress/e2e/auth_spec/forget_password.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { cy, describe, beforeEach, it } from "local-cypress";

describe("Forgot Password", () => {
beforeEach(() => {
cy.visit("http://localhost:4000");
cy.get("a").contains("Forgot password?").click().wait(100);
});

it("Send Password Reset Link", () => {
cy.get("[name='username']").type("dummy_user_1");
cy.contains("Send Reset Link").click().wait(1000);
cy.contains("Password Reset Email Sent").should("exist");
});

it("Go to Login page", () => {
cy.get("a").contains("Login").click();
cy.url().should("contain", "/login");
});
});
21 changes: 21 additions & 0 deletions cypress/e2e/auth_spec/roles.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { afterEach, cy, describe, it } from "local-cypress";
import * as users from "../../fixtures/users.json";

describe("authentication", () => {
users.forEach((user) => {
it("Login as " + user.username + " - " + user.rolename, () => {
cy.loginByApi(user.username, "passwordR0FL");

// Assert user
cy.get("a[href='/user/profile'] i").click();
cy.url().should("include", "/user/profile");
cy.get("dd").should("contain", user.username);
cy.get("dd").should("contain", user.rolename);
});
});
afterEach(() => {
cy.log("Logging out");
cy.get("p").contains("Sign Out").click();
cy.url().should("include", "/");
});
});
63 changes: 63 additions & 0 deletions cypress/e2e/death_report_spec/death_report.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { cy, it, describe, before, beforeEach } from "local-cypress";

const user = { username: "devdistrictadmin", password: "Coronasafe@123" };
const address = "C-106,\nSector-H,\nAliganj,\nLucknow,\nUttar Pradesh";

describe("Death Report", () => {
before(() => {
cy.loginByApi(user.username, user.password);
cy.saveLocalStorage();
});

beforeEach(() => {
cy.restoreLocalStorage();
cy.visit("http://localhost:4000");
cy.get("a").contains("Patients").click();
cy.url().should("include", "/patients");
cy.contains("Details").click();
cy.url().then((url) => {
const patient_id = url.split("/")[6];
cy.visit(`http://localhost:4000/death_report/${patient_id}`);
});
});

it("Add Data And Submit " + user.username, () => {
// Wait For Form Data To Prepopulate
cy.wait(1000);

// Clear Exisiting Data And Fill New Data
cy.get("input[name='name']").clear().type("Apurva Nagar");
cy.get("input[name='age']").clear().type("20");
cy.get("input[name='gender']").clear().type("Male");
cy.get("textarea[name='address']").clear().type(address);
cy.get("input[name='phone_number']").clear().type("+919919266674");
cy.get("input[name='is_declared_positive']").clear().type("No");
cy.get("input[name='date_declared_positive']").clear().type("2021-12-01");
cy.get("input[name='test_type']").clear().type("Rapid Antigen");
cy.get("input[name='date_of_test']").clear().type("2021-12-01");
cy.get("input[name='date_of_result']").clear().type("2021-12-01");
cy.get("input[name='hospital_tested_in']").clear().type("Apollo Hospital");
cy.get("input[name='hospital_died_in']").clear().type("Apollo Hospital");
cy.get("input[name='date_of_admission']").clear().type("2021-12-01");
cy.get("input[name='date_of_death']").clear().type("2021-12-01");
cy.get("input[name='comorbidities']").clear().type("awesomeness");
cy.get("input[name='history_clinical_course']")
.clear()
.type("No cure for awesomeness");
cy.get("input[name='brought_dead']").clear().type("No");
cy.get("input[name='home_or_cfltc']").clear().type("-");
cy.get("input[name='is_vaccinated']").clear().type("Yes");
cy.get("input[name='kottayam_confirmation_sent']").clear().type("Yes");
cy.get("input[name='kottayam_sample_date']").clear().type("2021-12-01");
cy.get("input[name='cause_of_death']")
.clear()
.type("Too awesome for earth");
cy.get("input[name='srf_id']").clear().type("123456");

// See Preview Of Report
cy.get("button").contains("Preview").click();

// Print Death Report
cy.get("button").contains("Print Death Report").click();
});
});
44 changes: 44 additions & 0 deletions cypress/e2e/external_results_spec/external_result.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { cy, describe, it, before, beforeEach, afterEach } from "local-cypress";

describe("Edit Profile Testing", () => {
before(() => {
cy.loginByApi("devdistrictadmin", "Coronasafe@123");
cy.saveLocalStorage();
});

beforeEach(() => {
cy.restoreLocalStorage();
cy.visit("http://localhost:4000");
cy.get("a").contains("External Result").click();
cy.url().should("include", "/external_results");
});

it("Search by Patient name", () => {
cy.get("[name='search'][placeholder='Search by Patient Name']")
.type("akhil")
.wait(2000)
.url()
.should("include", "akhil");
});

it("Search by phone number", () => {
cy.get("[placeholder='Search by Phone Number']")
.type("4738743424")
.wait(2000)
.url()
.should("include", "%2B91+47387-43424");
});

it("upload list", () => {
cy.contains("Upload List").click().wait(100);
// TODO: attach file and save
});

it("export", () => {
cy.contains("Export").click().wait(1000);
});

afterEach(() => {
cy.saveLocalStorage();
});
});
52 changes: 52 additions & 0 deletions cypress/e2e/external_results_spec/filter.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress";

describe("External Results Filters", () => {
before(() => {
cy.loginByApi("devdistrictadmin", "Coronasafe@123");
cy.saveLocalStorage();
});

beforeEach(() => {
cy.restoreLocalStorage();
cy.visit("http://localhost:4000");
cy.get("a").contains("External Result").click();
cy.url().should("include", "/external_results");
cy.contains("Filters").click();
});

it("filter by lsg", () => {
cy.get("[placeholder='Select Local Body']")
.type("ernakulam")
.type("{downarrow}{enter}");
});

it("filter by ward", () => {
cy.get("[placeholder='Select wards']")
.type("ernakulam")
.type("{downarrow}{enter}");
});

it("filter by created date", () => {
cy.get("[name='created_date_after']").type("06/12/2020");
cy.get("[name='created_date_before']").type("31/12/2020");
});

it("filter by result date", () => {
cy.get("[name='result_date_after']").type("02/03/2021");
cy.get("[name='result_date_before']").type("02/04/2021");
});

it("filter by sample collection date", () => {
cy.get("[name='sample_collection_date_after']").type("04/01/2021");
cy.get("[name='sample_collection_date_before']").type("03/03/2021");
});

it("filter by srf id", () => {
cy.get("[name='srf_id']").type("432");
cy.contains("Apply").click();
});

afterEach(() => {
cy.saveLocalStorage();
});
});
Loading