Skip to content

Commit

Permalink
Add Requested Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidSumra committed Nov 7, 2024
1 parent f7e9ef3 commit 7f8a699
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 46 deletions.
42 changes: 24 additions & 18 deletions cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
import { SampleTestPage } from "pageobject/Sample/SampleTestCreate";
import { PatientPage } from "pageobject/Patient/PatientCreation";
import LoginPage from "pageobject/Login/LoginPage";
import { PatientConsultationPage } from "pageobject/Patient/PatientConsultation";
import { PatientPage } from "pageobject/Patient/PatientCreation";
import { SampleTestPage } from "pageobject/Sample/SampleTestCreate";

describe("Sample Test", () => {
const sampleTestPage = new SampleTestPage();
const patientPage = new PatientPage();
const loginPage = new LoginPage();
const patientConsultationPage = new PatientConsultationPage();

const patientName = "Dummy Patient 11";
const sampleTestType = "BA/ETA";
const icmrCategory = "Cat 0";
const icmrLabel = "Test Icmr Label";
const doctorName = "Dr. John Doe";
const doctorName = "Dr John Doe";
const atypicalDetails = "Patient showing unusual symptoms";
const diagnosis = "Suspected respiratory infection";
const etiologyIdentified = "Bacterial infection suspected";
const differentialDiagnosis = "Possibly a viral infection";
const fastTrackReason =
"The patient has a high risk of complications and requires immediate testing.";
const sampleTestStatus = "Request Submitted";
const expectedSampleTestType = "ba/eta";
const sampleTestResult = "Awaiting";

before(() => {
loginPage.loginAsDisctrictAdmin();
loginPage.loginAsDistrictAdmin();
cy.saveLocalStorage();
});

Expand All @@ -33,14 +38,12 @@ describe("Sample Test", () => {
// Ensure patient list API is loaded before proceeding
cy.awaitUrl("/patients");
patientPage.visitPatient(patientName);
cy.verifyAndClickElement("#patient-details", "Patient Details");
sampleTestPage.interceptPatientDetailsAPI();
patientConsultationPage.clickPatientDetails();
sampleTestPage.verifyPatientDetailsResponse();

// Ensure sample request API is loaded
// Visit SampleRequest Page
sampleTestPage.visitSampleRequestPage();

// Fill form fields using helper functions
// Fill Sample Test Request Form
sampleTestPage.selectSampleType(sampleTestType);
sampleTestPage.selectIcmrCategory(icmrCategory);
sampleTestPage.fillIcmrLabel(icmrLabel);
Expand All @@ -53,28 +56,31 @@ describe("Sample Test", () => {
sampleTestPage.checkHasSari();
sampleTestPage.checkHasAri();
sampleTestPage.checkIsUnusualCourse();

// Submit the form and verify notification
cy.submitButton("Confirm your request to send sample for testing");
cy.verifyNotification("Sample test created successfully");

// Check the updated request history
sampleTestPage.interceptSampleTestReq();
cy.verifyNotification("Sample test created successfully");
sampleTestPage.verifySampleTestReq();
sampleTestPage.checkRequestHistory(fastTrackReason);

// Ensure sample page API is loaded before proceeding
// Check the updated request history
sampleTestPage.checkRequestHistory(
sampleTestStatus,
expectedSampleTestType,
fastTrackReason,
sampleTestResult,
);
// Checking Reflection on Sample Page
cy.awaitUrl("/sample");

sampleTestPage.searchPatientSample(patientName);
sampleTestPage.interceptGetSampleTestReq();
sampleTestPage.searchPatientSample(patientName);
sampleTestPage.verifyGetSampleTestReq();
sampleTestPage.verifyPatientName(patientName);
sampleTestPage.interceptGetSampleTestReq();
sampleTestPage.clickOnSampleDetailsBtn();
sampleTestPage.verifyGetSampleTestReq();
sampleTestPage.verifyPatientTestDetails(
patientName,
fastTrackReason,
doctorName,
diagnosis,
differentialDiagnosis,
etiologyIdentified,
Expand Down
62 changes: 34 additions & 28 deletions cypress/pageobject/Sample/SampleTestCreate.ts
Original file line number Diff line number Diff line change
@@ -1,115 +1,121 @@
export class SampleTestPage {
visitSampleRequestPage() {
visitSampleRequestPage(): void {
cy.verifyAndClickElement("#sample-request-btn", "Request Sample Test");
}

selectSampleType(option: string) {
selectSampleType(option: string): void {
cy.clickAndSelectOption("#sample-type", option);
}

selectIcmrCategory(option: string) {
selectIcmrCategory(option: string): void {
cy.clickAndSelectOption("#icmr-category", option);
}

fillIcmrLabel(label: string) {
fillIcmrLabel(label: string): void {
cy.get("#icmr-label").should("be.visible").type(label);
}

fillFastTrackReason(value: string) {
fillFastTrackReason(value: string): void {
cy.get("#is_fast_track").should("be.visible").check();
cy.get("#fast_track").should("be.visible").type(value);
}

fillDoctorName(value: string) {
fillDoctorName(value: string): void {
cy.get("#doctor_name").should("be.visible").type(value);
}

fillAtypicalPresentation(value: string) {
fillAtypicalPresentation(value: string): void {
cy.get("#is_atypical_presentation").should("be.visible").check();
cy.get("#atypical_presentation").should("be.visible").type(value);
}

fillDiagnosis(value: string) {
fillDiagnosis(value: string): void {
cy.get("#diagnosis").should("be.visible").type(value);
}

fillEtiology(value: string) {
fillEtiology(value: string): void {
cy.get("#etiology_identified").should("be.visible").type(value);
}

fillDiffDiagnosis(value: string) {
fillDiffDiagnosis(value: string): void {
cy.get("#diff_diagnosis").should("be.visible").type(value);
}

checkHasSari() {
checkHasSari(): void {
cy.get("#has_sari").should("be.visible").check();
}

checkHasAri() {
checkHasAri(): void {
cy.get("#has_ari").should("be.visible").check();
}

checkIsUnusualCourse() {
checkIsUnusualCourse(): void {
cy.get("#is_unusual_course").should("be.visible").check();
}

checkRequestHistory(fastTrack: string) {
cy.verifyContentPresence("#sample-test-status", ["Request Submitted"]);
cy.verifyContentPresence("#sample-test-type", ["ba/eta"]);
checkRequestHistory(
sampleTestStatus: string,
sampleTestType: string,
fastTrack: string,
sampleTestResult: string,
): void {
cy.verifyContentPresence("#sample-test-status", [sampleTestStatus]);
cy.verifyContentPresence("#sample-test-type", [sampleTestType]);
cy.verifyContentPresence("#sample-test-fast-track", [fastTrack]);
cy.verifyContentPresence("#sample-test-result", ["Awaiting"]);
cy.verifyContentPresence("#sample-test-result", [sampleTestResult]);
}

searchPatientSample(patientName: string) {
searchPatientSample(patientName: string): void {
cy.get("#search_patient_name").should("be.visible").type(patientName);
}

verifyPatientName(patientName: string) {
verifyPatientName(patientName: string): void {
cy.verifyContentPresence("#sample-test-patient-name", [patientName]);
}

clickOnSampleDetailsBtn() {
clickOnSampleDetailsBtn(): void {
cy.get("#sample-details-btn").should("be.visible").first().click();
}

verifyPatientTestDetails(
patientName: string,
fastTrackReason: string,
doctorName: string,
diagnosis: string,
differentialDiagnosis: string,
etiologyIdentified: string,
) {
): void {
cy.verifyContentPresence("#patient_name", [patientName]);
cy.verifyContentPresence("#fast_track_reason", [fastTrackReason]);
cy.verifyContentPresence("#doctor_name", ["Dr John Doe"]);
cy.verifyContentPresence("#doctor_name", [doctorName]);
cy.verifyContentPresence("#diagnosis", [diagnosis]);
cy.verifyContentPresence("#diff_diagnosis", [differentialDiagnosis]);
cy.verifyContentPresence("#etiology_identified", [etiologyIdentified]);
}

interceptPatientDetailsAPI() {
interceptPatientDetailsAPI(): void {
cy.intercept("GET", "**/api/v1/patient/**").as("patientDetails");
}

verifyPatientDetailsResponse() {
verifyPatientDetailsResponse(): void {
cy.wait("@patientDetails").its("response.statusCode").should("eq", 200);
}

interceptSampleTestReq() {
interceptSampleTestReq(): void {
cy.intercept("GET", "**/api/v1/patient/*/test_sample/**").as(
"sampleDetails",
);
}

verifySampleTestReq() {
verifySampleTestReq(): void {
cy.wait("@sampleDetails").its("response.statusCode").should("eq", 200);
}

interceptGetSampleTestReq() {
interceptGetSampleTestReq(): void {
cy.intercept("GET", "**/api/v1/test_sample/**").as("getSampleTestReq");
}

verifyGetSampleTestReq() {
verifyGetSampleTestReq(): void {
cy.wait("@getSampleTestReq").its("response.statusCode").should("eq", 200);
}
}

0 comments on commit 7f8a699

Please sign in to comment.