Skip to content

Commit

Permalink
Add TestSuit to request for sample test
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidSumra committed Nov 1, 2024
1 parent 36b1ceb commit 66bfe4a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 42 deletions.
22 changes: 12 additions & 10 deletions cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SampleTestPage } from "pageobject/Sample/SampleTestCreate";

describe("Sample Test", () => {
const sampleTestPage = new SampleTestPage();
const smapleTestType = "BA/ETA",
const sampleTestType = "BA/ETA",
icmrCategory = "Cat 0",
icmrLabel = "Test Icmr Label";

Expand All @@ -14,27 +14,29 @@ describe("Sample Test", () => {
beforeEach(() => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/patients");
});

it("request for new sample test", () => {
it("should request a new sample test", () => {
sampleTestPage.visitPatientPage();
sampleTestPage.visitPatientDashboardPage();
sampleTestPage.visitSampleRequestPage();

// Filling the form fields
sampleTestPage.selectSampleType(smapleTestType);
// Fill form fields
sampleTestPage.selectSampleType(sampleTestType);
sampleTestPage.selectIcmrCategory(icmrCategory);
sampleTestPage.typeIcmrLabel(icmrLabel);

// Submit Form
// Submit the form
sampleTestPage.submitForm();

// checking for sample request
// Check for sample request notification and history
sampleTestPage.clickOnNotification();
sampleTestPage.checkRequestHistory();
});

// it("check smaple request on sample page", () => {
// cy.awaitUrl("/sample")
// })
it("should verify sample request on sample page", () => {
sampleTestPage.visitSamplePage();
sampleTestPage.searchPatientSample(sampleTestPage.patientName);
sampleTestPage.patientSampleMustExist();
});
});
67 changes: 35 additions & 32 deletions cypress/pageobject/Sample/SampleTestCreate.ts
Original file line number Diff line number Diff line change
@@ -1,70 +1,73 @@
export class SampleTestPage {
sampleTestReportHistory = 0;
patientName = ""; // to search patient in sample page
patientName = ""; // to search for patient in sample page

visitPatientPage() {
cy.awaitUrl("/patients");
}

visitPatientDashboardPage() {
cy.wait(1000);
cy.get(".patient-stable-ring").should("be.visible");
cy.get(".patient-stable-ring").first().click();
cy.get(".patient-stable-ring").first().scrollIntoView();
cy.get(".patient-stable-ring").should("be.visible").first().click();
cy.get("#patient-name")
.invoke("text")
.then((patientName) => {
// Trim any excess whitespace
this.patientName = patientName.trim();
});
cy.get("#patient-details").should("be.visible");
cy.get("#patient-details").click();
cy.get("#patient-details").should("be.visible").click();
}

visitSampleRequestPage() {
cy.get("body").then(($body) => {
if ($body.find("#sample-test-history").length > 0) {
cy.get("#sample-test-history")
.its("length")
.then((count) => {
this.sampleTestReportHistory = count;
});
} else {
// Element does not exist, set to 0
this.sampleTestReportHistory = 0;
}
});

cy.get("#sample-request-btn").should("be.visible");
cy.get("#sample-request-btn").click();
cy.get("#sample-test-history").scrollIntoView();
cy.get("#sample-test-history")
.its("length")
.then((count) => {
this.sampleTestReportHistory = count || 0;
});
cy.get("#sample-request-btn").scrollIntoView();
cy.get("#sample-request-btn").should("be.visible").click();
}

selectSampleType(option: string) {
cy.get("#sample-type").should("be.visible");
cy.get("#sample-type").click();
cy.get("#sample-type").should("be.visible").click();
cy.get("[role='option']").contains(option).click();
}

selectIcmrCategory(option: string) {
cy.get("#icmr-category").should("be.visible");
cy.get("#icmr-category").click();
cy.get("#icmr-category").should("be.visible").click();
cy.get("[role='option']").contains(option).click();
}

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

submitForm() {
cy.get("#sample-test-submit-btn").should("be.visible");
cy.get("#sample-test-submit-btn").click();
cy.get("#sample-test-submit-btn").scrollIntoView();
cy.get("#sample-test-submit-btn").should("be.visible").click();
}

clickOnNotification() {
cy.get(".pnotify-container").should("be.visible");
cy.get(".pnotify-container").click();
cy.get(".pnotify-container").should("be.visible").click();
}

checkRequestHistory() {
cy.get("#sample-test-history").scrollIntoView();
cy.get("#sample-test-history").should(
"have.length",
this.sampleTestReportHistory + 1,
);
}

visitSamplePage() {
cy.awaitUrl("/sample");
}

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

patientSampleMustExist() {
cy.get("#sample-card").should("be.visible");
}
}
2 changes: 2 additions & 0 deletions src/components/Patient/SampleViewAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export default function SampleViewAdmin() {
? "border-primary-700 bg-primary-100"
: "bg-white"
}`}
id="sample-card"
>
<div className="flex h-full flex-col justify-between px-6 py-4">
<div>
Expand Down Expand Up @@ -345,6 +346,7 @@ export default function SampleViewAdmin() {
<div className="flex w-full flex-col gap-3">
<SearchInput
name="patient_name"
id="search_patient_name"
value={qParams.patient_name}
onChange={(e) => updateQuery({ [e.name]: e.value })}
placeholder="Search patient"
Expand Down

0 comments on commit 66bfe4a

Please sign in to comment.