-
Notifications
You must be signed in to change notification settings - Fork 627
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
added encounter-notes cypress test #10538
Changes from all commits
86096e7
b90f256
214961c
c5c6f6d
a4e432b
3dc1d7b
68529bb
75a7d64
b944f32
4b1605c
80e28e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,78 @@ | ||||||
import { FacilityCreation } from "@/pageObject/facility/FacilityCreation"; | ||||||
import { PatientEncounter } from "@/pageObject/Patients/PatientEncounter"; | ||||||
|
||||||
const facilityCreation = new FacilityCreation(); | ||||||
const patientEncounter = new PatientEncounter(); | ||||||
|
||||||
describe("Encounter Notes - Threads, Messages, and Notes", () => { | ||||||
beforeEach(() => { | ||||||
cy.loginByApi("devdoctor"); // logging in as doctor | ||||||
cy.visit("/"); | ||||||
facilityCreation.selectFacility("GHC Trikaripur"); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
use the facility GHC Payyanur |
||||||
}); | ||||||
|
||||||
it("create multiple threads and add messages", () => { | ||||||
patientEncounter | ||||||
.navigateToEncounters() | ||||||
.openFirstEncounterDetails() | ||||||
.openNotesTab() | ||||||
|
||||||
|
||||||
// first Thread | ||||||
cy.contains("button", "New Thread").click(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
as the per given guidelines, use the command function, cy.verifyandclickelement() to click on any button with text. Make sure you uses a proper data-cy test id's or element id , |
||||||
cy.get("input[placeholder='Enter discussion title...']").type("Test Discussion final"); | ||||||
cy.contains("button", "Create").click(); | ||||||
cy.get("form").within(() => { | ||||||
cy.get("textarea").type("This is a test message fianl!"); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
use combination of single line message as well as multi line text as well |
||||||
cy.get('button[type="submit"]').click(); | ||||||
}); | ||||||
|
||||||
|
||||||
|
||||||
// second thread | ||||||
cy.contains("button", "New Thread").click(); | ||||||
cy.get("input[placeholder='Enter discussion title...']").type("Test Discussion 100"); | ||||||
cy.contains("button", "Create").click(); | ||||||
cy.get("form").within(() => { | ||||||
cy.get("textarea").type("This is a test message 100!"); | ||||||
cy.get('button[type="submit"]').click(); | ||||||
}); | ||||||
|
||||||
cy.intercept("POST", "https://careapi.ohc.network/api/v1/auth/logout/").as("logoutRequest"); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Separate test cases for different user roles. The test case mixes doctor and nurse actions, which violates the single responsibility principle for tests. Consider splitting this into two separate test cases for better maintainability and clarity. - cy.intercept("POST", "https://careapi.ohc.network/api/v1/auth/logout/").as("logoutRequest");
-
-
-
- // logging as nurse
- cy.loginByApi("devnurse");
- cy.visit("/");
- facilityCreation.selectFacility("GHC Trikaripur");
- patientEncounter.navigateToEncounters().openFirstEncounterDetails().openNotesTab();
+ });
+
+ it("create multiple threads and add messages as nurse", () => {
+ cy.loginByApi("devnurse");
+ cy.visit("/");
+ facilityCreation.selectFacility("GHC Trikaripur");
+ patientEncounter
+ .navigateToEncounters()
+ .openFirstEncounterDetails()
+ .openNotesTab(); Also applies to: 45-49 🧰 Tools🪛 ESLint[error] 41-42: Replace (prettier/prettier) |
||||||
|
||||||
|
||||||
|
||||||
// logging as nurse | ||||||
cy.loginByApi("devnurse"); | ||||||
cy.visit("/"); | ||||||
facilityCreation.selectFacility("GHC Trikaripur"); | ||||||
patientEncounter.navigateToEncounters().openFirstEncounterDetails().openNotesTab(); | ||||||
}); | ||||||
|
||||||
it("create a new note in the Notes tab", () => { | ||||||
patientEncounter | ||||||
.navigateToEncounters() | ||||||
.openFirstEncounterDetails() | ||||||
.openNotesTab() | ||||||
|
||||||
// first thread in nurse login | ||||||
cy.contains("button", "New Thread").click(); | ||||||
cy.get("input[placeholder='Enter discussion title...']").type("Test Discussion 200"); | ||||||
cy.contains("button", "Create").click(); | ||||||
cy.get("form").within(() => { | ||||||
cy.get("textarea").type("This is a test message 200!"); | ||||||
cy.get('button[type="submit"]').click(); | ||||||
}); | ||||||
|
||||||
|
||||||
|
||||||
// second thread in nurse login | ||||||
cy.contains("button", "New Thread").click(); | ||||||
cy.get("input[placeholder='Enter discussion title...']").type("Test Discussion 300"); | ||||||
cy.contains("button", "Create").click(); | ||||||
cy.get("form").within(() => { | ||||||
cy.get("textarea").type("This is a test message 300!"); | ||||||
cy.get('button[type="submit"]').click(); | ||||||
}); | ||||||
}); | ||||||
}); |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -26,6 +26,28 @@ export class PatientEncounter { | |||||||||||||||||||||
return this; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
openSettingsTab() { | ||||||||||||||||||||||
cy.get('[data-sidebar="content"]').contains("Settings").click(); | ||||||||||||||||||||||
return this; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
openNotesTab() { | ||||||||||||||||||||||
cy.get('#encounter_tab_nav').contains("Notes").click(); | ||||||||||||||||||||||
return this; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
Comment on lines
+34
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Fix formatting issues. The method logic is correct, but there are some formatting issues to address. Apply this diff to fix the formatting: - openNotesTab() {
- cy.get('#encounter_tab_nav').contains("Notes").click();
+ openNotesTab() {
+ cy.get("#encounter_tab_nav").contains("Notes").click(); 📝 Committable suggestion
Suggested change
🧰 Tools🪛 ESLint[error] 35-35: Insert (prettier/prettier) [error] 36-36: Replace (prettier/prettier) |
||||||||||||||||||||||
|
||||||||||||||||||||||
addMessageToThread(message: string) { | ||||||||||||||||||||||
cy.get('textarea[placeholder="Type your message"]').type(message); | ||||||||||||||||||||||
// Click the submit button | ||||||||||||||||||||||
cy.get('button[type="submit"]').click(); | ||||||||||||||||||||||
} | ||||||||||||||||||||||
Comment on lines
+39
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve test maintainability and method chaining. The method has several areas for improvement:
Apply this diff to improve the method: addMessageToThread(message: string) {
- cy.get('textarea[placeholder="Type your message"]').type(message);
- // Click the submit button
- cy.get('button[type="submit"]').click();
+ cy.get('[data-cy="message-input"]').type(message);
+ cy.get('[data-cy="submit-message"]').click();
+ return this;
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||
|
||||||||||||||||||||||
startNewConversation() { | ||||||||||||||||||||||
cy.contains("button", "Start New Discussion").should("be.visible").click(); | ||||||||||||||||||||||
return this; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
// Questionnaire actions | ||||||||||||||||||||||
addQuestionnaire(questionnaireName: string) { | ||||||||||||||||||||||
cy.get('[data-cy="add-questionnaire-button"]').click(); | ||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.