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

Fixed the type issue in the cypress test file #8766

Merged
merged 8 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 2 deletions cypress/e2e/assets_spec/AssetHomepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ describe("Asset Tab", () => {
it("Export asset", () => {
assetPage.selectassetimportbutton();
cy.wait(2000);
assetPage.selectjsonexportbutton();
assetPage.selectJsonExportButton();
assetPage.selectassetimportbutton();
assetPage.selectcsvexportbutton();
assetPage.selectCsvExportButton();
});

afterEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/assets_spec/AssetsCreation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe("Asset", () => {
"d5694af2-21e2-4a39-9bad-2fb98d9818bd",
);
assetPage.clickConfigureAsset();
assetPage.verifyAssetConfiguration(200);
assetPage.verifyAssetConfiguration();
});

it("Add an vital monitor asset and configure it", () => {
Expand Down
5 changes: 4 additions & 1 deletion cypress/e2e/patient_spec/PatientFileUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ const loginPage = new LoginPage();
const patientPage = new PatientPage();
const patientFileUpload = new PatientFileUpload();

function runTests(testDescription, visitPatientFileUploadSection) {
function runTests(
testDescription: string,
visitPatientFileUploadSection: () => void,
) {
describe(testDescription, () => {
const cypressAudioName = "cypress audio";
const cypressFileName = "cypress name";
Expand Down
8 changes: 2 additions & 6 deletions cypress/e2e/sample_test_spec/SampleTestHomepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@ describe("Sample List", () => {
it("Search by District name", () => {
cy.intercept(/\/api\/v1\/test_sample/).as("test_sample");
cy.get("[name='district_name']").type("Test");
cy.wait("@test_sample").then((interception) => {
expect(interception.response.statusCode).to.equal(200);
});
cy.wait("@test_sample").its("response.statusCode").should("eq", 200);
cy.url().should("include", "Test");
});

it("Search by Patient Name", () => {
cy.intercept(/\/api\/v1\/test_sample/).as("test_sample");
cy.get("[name='patient_name']").type("Test");
cy.wait("@test_sample").then((interception) => {
expect(interception.response.statusCode).to.equal(200);
});
cy.wait("@test_sample").its("response.statusCode").should("eq", 200);
cy.url().should("include", "Test");
});

Expand Down
20 changes: 6 additions & 14 deletions cypress/pageobject/Asset/AssetCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,8 @@ export class AssetPage {
cy.intercept(/\/api\/v1\/asset/).as("asset");
}

verifyAssetConfiguration(statusCode: number) {
cy.wait("@asset").then((interception) => {
expect(interception.response.statusCode).to.equal(statusCode);
});
verifyAssetConfiguration() {
cy.wait("@asset").its("response.statusCode").should("eq", 200);
}

clickConfigureAsset() {
Expand Down Expand Up @@ -222,22 +220,16 @@ export class AssetPage {
cy.get("[data-testid=import-asset-button]").click();
}

selectjsonexportbutton() {
selectJsonExportButton() {
cy.intercept("GET", "**/api/v1/asset/?**json=true**").as("getJsonexport");
cy.get("#export-json-option").click();
cy.wait("@getJsonexport").then(({ request, response }) => {
expect(response.statusCode).to.eq(200);
expect(request.url).to.include("json=true");
});
cy.wait("@getJsonexport").its("response.statusCode").should("eq", 200);
}

selectcsvexportbutton() {
selectCsvExportButton() {
cy.intercept("GET", "**/api/v1/asset/?**csv=true**").as("getCsvexport");
cy.get("#export-csv-option").click();
cy.wait("@getCsvexport").then(({ request, response }) => {
expect(response.statusCode).to.eq(200);
expect(request.url).to.include("csv=true");
});
cy.wait("@getCsvexport").its("response.statusCode").should("eq", 200);
}

selectImportOption() {
Expand Down
8 changes: 4 additions & 4 deletions cypress/pageobject/Asset/AssetFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ export class AssetFilters {
cy.get("#close-slide-over").click();
}
// Assertions
assertFacilityText(text) {
assertFacilityText(text: string) {
cy.get("[data-testid=Facility]").should("contain", text);
}
assertAssetClassText(text) {
assertAssetClassText(text: string) {
cy.get("[data-testid='Asset Class']").should("contain", text);
}
assertStatusText(text) {
assertStatusText(text: string) {
cy.get("[data-testid=Status]").should("contain", text);
}
assertLocationText(text) {
assertLocationText(text: string) {
cy.get("[data-testid=Location]").should("contain", text);
}
}
24 changes: 12 additions & 12 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class FacilityPage {
.should("eq", 200);
}

typeFacilitySearch(facilityName) {
typeFacilitySearch(facilityName: string) {
cy.get("#search").click().clear();
cy.get("#search").click().type(facilityName);
}
Expand All @@ -21,7 +21,7 @@ class FacilityPage {
cy.get("#manage-facility-dropdown button").should("be.visible");
}

clickUpdateFacilityType(facilityType) {
clickUpdateFacilityType(facilityType: string) {
cy.get("#facility_type")
.click()
.then(() => {
Expand Down Expand Up @@ -225,11 +225,11 @@ class FacilityPage {
}

fillTriageEntryFields(
visited,
homeQuarantine,
isolation,
referred,
confirmedPositive,
visited: string,
homeQuarantine: string,
isolation: string,
referred: string,
confirmedPositive: string,
) {
cy.get("#num_patients_visited").clear().click().type(visited);
cy.get("#num_patients_home_quarantine")
Expand All @@ -244,7 +244,7 @@ class FacilityPage {
.type(confirmedPositive);
}

fillEntryDate(date) {
fillEntryDate(date: string) {
cy.get("#entry_date").click();
cy.get("#date-input").click().type(date);
}
Expand All @@ -253,13 +253,13 @@ class FacilityPage {
cy.get("#edit-button").click();
}

clickButtonsMultipleTimes(selector) {
clickButtonsMultipleTimes(selector: string) {
cy.get(selector).each(($button) => {
cy.wrap($button).click();
});
}

verifyTriageTableContains(value) {
verifyTriageTableContains(value: string) {
cy.get("#triage-table").contains(value);
}

Expand Down Expand Up @@ -430,7 +430,7 @@ class FacilityPage {
return cy.get("#district");
}

selectStateOnPincode(stateName) {
selectStateOnPincode(stateName: string) {
this.getStateElement()
.scrollIntoView()
.wait(2000)
Expand All @@ -444,7 +444,7 @@ class FacilityPage {
});
}

selectDistrictOnPincode(districtName) {
selectDistrictOnPincode(districtName: string) {
this.getDistrictElement()
.scrollIntoView()
.wait(2000)
Expand Down
4 changes: 2 additions & 2 deletions cypress/pageobject/Facility/FacilityHome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class FacilityHome {
cy.get("#facility-detailspage-cns").click();
}

selectLocation(location) {
selectLocation(location: string) {
cy.get("#location").click().type(location);
cy.get("li[role=option]").contains(location).click();
}
Expand Down Expand Up @@ -99,7 +99,7 @@ class FacilityHome {
return cy.url();
}

verifyURLContains(searchText) {
verifyURLContains(searchText: string) {
const encodedText = encodeURIComponent(searchText).replace(/%20/g, "+");
this.getURL().should("include", `search=${encodedText}`);
}
Expand Down
23 changes: 13 additions & 10 deletions cypress/pageobject/Facility/FacilityManage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ class FacilityManage {
cy.get("#upload-cover-image").should("be.visible");
}

uploadCoverImage(fileName) {
uploadCoverImage(fileName: string) {
cy.get("#upload-cover-image")
.selectFile(`cypress/fixtures/${fileName}`, { force: true })
.wait(100); // Adjust the wait time as needed
}

verifyTotalDoctorCapacity(expectedCapacity) {
verifyTotalDoctorCapacity(expectedCapacity: string) {
cy.get("#facility-doctor-totalcapacity").contains(expectedCapacity);
}

verifyFacilityBedCapacity(expectedCapacity) {
verifyFacilityBedCapacity(expectedCapacity: string) {
cy.get("#facility-bed-capacity-details").contains(expectedCapacity);
}

Expand Down Expand Up @@ -51,39 +51,42 @@ class FacilityManage {
cy.get("#middleware_address").should("be.visible");
}

clickButtonWithText(text) {
clickButtonWithText(text: string) {
cy.get("button#submit").contains(text).click();
}

checkErrorMessageVisibility(text) {
checkErrorMessageVisibility(text: string) {
cy.get(".error-text").contains(text).should("be.visible");
}

typeMiddlewareAddress(address) {
typeMiddlewareAddress(address: string) {
cy.get("#middleware_address").click().clear().click().type(address);
}

clearHfrId() {
cy.get("#hf_id").click().clear();
}

typeHfrId(address) {
typeHfrId(address: string) {
cy.get("#hf_id").click().clear().click().type(address);
}

verifySuccessMessageVisibilityAndContent(text, isRegex = false) {
verifySuccessMessageVisibilityAndContent(
text: string | RegExp,
isRegex = false,
) {
if (isRegex) {
cy.get(".pnotify-text").should("be.visible").contains(text);
} else {
cy.get(".pnotify-text").should("be.visible").and("contain.text", text);
}
}

verifyMiddlewareAddressValue(expectedValue) {
verifyMiddlewareAddressValue(expectedValue: string) {
cy.get("#middleware_address").should("have.value", expectedValue);
}

verifyHfrIdValue(expectedValue) {
verifyHfrIdValue(expectedValue: string) {
cy.get("#hf_id").should("have.value", expectedValue);
}

Expand Down
7 changes: 4 additions & 3 deletions cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ export class PatientConsultationPage {
cy.clickAndSelectOption("#route_to_facility", status);
}

typeAndMultiSelectSymptoms(input, symptoms) {
typeAndMultiSelectSymptoms(input: string, symptoms: string[]) {
cy.typeAndMultiSelectOption("#additional_symptoms", input, symptoms);
}

selectSymptomsDate(date: string) {
cy.clickAndTypeDate("#symptoms_onset_date", date);
}
Expand Down Expand Up @@ -48,7 +49,7 @@ export class PatientConsultationPage {
cy.get("#death_confirmed_doctor").click().type(doctor);
}

selectPatientDiagnosis(icdCode, statusId) {
selectPatientDiagnosis(icdCode: string, statusId: string) {
cy.searchAndSelectOption("#icd11-search", icdCode);
cy.get("#diagnosis-list")
.contains("Add as")
Expand Down Expand Up @@ -92,7 +93,7 @@ export class PatientConsultationPage {
cy.clickAndSelectOption("#principal-diagnosis-select", diagnosis);
}

verifyTextInConsultation(selector, text) {
verifyTextInConsultation(selector: string, text: string) {
cy.get(selector).scrollIntoView();
cy.get(selector).contains(text).should("be.visible");
}
Expand Down
34 changes: 17 additions & 17 deletions cypress/pageobject/Patient/PatientCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class PatientPage {
cy.wait("@getFacilities").its("response.statusCode").should("eq", 200);
}

visitPatient(patientName) {
visitPatient(patientName: string) {
cy.get("#name").click().type(patientName);
cy.intercept("GET", "**/api/v1/consultation/**").as("getPatient");
cy.get("#patient-name-list").contains(patientName).click();
Expand Down Expand Up @@ -165,16 +165,16 @@ export class PatientPage {
}

verifyPatientDashboardDetails(
gender,
age,
patientName,
phoneNumber,
emergencyPhoneNumber,
yearOfBirth,
bloodGroup,
occupation,
socioeconomicStatus = null,
domesticHealthcareSupport = null,
gender: string,
age: number,
patientName: string,
phoneNumber: string,
emergencyPhoneNumber: string,
yearOfBirth: string,
bloodGroup: string,
occupation: string,
socioeconomicStatus: string | null = null,
domesticHealthcareSupport: string | null = null,
isAntenatal = false,
isPostPartum = false,
) {
Expand Down Expand Up @@ -202,12 +202,12 @@ export class PatientPage {
}

verifyPatientLocationDetails(
patientAddress,
patientPincode,
patientState,
patientDistrict,
patientLocalbody,
patientWard,
patientAddress: string,
patientPincode: number,
patientState: string,
patientDistrict: string,
patientLocalbody: string,
patientWard: string,
) {
cy.get("[data-testid=patient-details]").then(($dashboard) => {
cy.url().should("include", "/facility/");
Expand Down
6 changes: 1 addition & 5 deletions cypress/pageobject/Patient/PatientHome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ class PatientHome {
}

verifyPatientExportRequest() {
cy.wait("@getPatients").then((interception) => {
expect(interception.request.url).to.include("/api/v1/patient/");
expect(interception.request.url).to.include("&csv");
expect(interception.response.statusCode).to.eq(200);
});
cy.wait("@getPatients").its("response.statusCode").should("eq", 200);
}

typePatientModifiedBeforeDate(startDate: string) {
Expand Down
10 changes: 5 additions & 5 deletions cypress/pageobject/Patient/PatientInsurance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class PatientInsurance {
}

verifyPatientPolicyDetails(
subscriberId,
policyId,
insurerId,
insurerName,
isHcxEnabled,
subscriberId: string,
policyId: string,
insurerId: string,
insurerName: string,
isHcxEnabled: string,
) {
cy.get("[data-testid=patient-details]").then(($dashboard) => {
cy.url().should("include", "/facility/");
Expand Down
Loading
Loading