-
Notifications
You must be signed in to change notification settings - Fork 646
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
Test: Add cypress tests for encounter notes #11154
base: develop
Are you sure you want to change the base?
Test: Add cypress tests for encounter notes #11154
Conversation
WalkthroughThis pull request introduces automated Cypress tests for the "Encounter Notes" feature and extends the PatientEncounter page object with new methods for intercepting API calls, managing threads, and sending messages. In addition, several UI components across encounter-related pages and the user dashboard have been updated with Changes
Sequence Diagram(s)sequenceDiagram
participant T as Test Runner
participant P as PatientEncounter PageObject
participant API as Backend API
T->>P: openEncounterAndSaveId()
T->>P: openEncounterById(encounterId)
T->>P: openEncounterNotesTab()
T->>P: clickNewThreadButton()
T->>P: typeThreadTitle(title)
T->>P: clickCreateThreadButton()
T->>P: typeMessage(message)
T->>P: sendMessage(message)
P->>API: POST /api/v1/patient/*/thread/*/note/
API-->>P: 200 OK
T->>P: verifyMessagesInChat(messages)
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
cypress/pageObject/Patients/PatientEncounter.ts (1)
2-2
: Potentially unused property.
private routes = {};
is currently empty. If not intended for future use or extension, consider removing it to avoid confusion.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
cypress/e2e/patient_spec/encounter_notes.cy.ts
(1 hunks)cypress/pageObject/Patients/PatientEncounter.ts
(2 hunks)src/pages/Encounters/EncounterList.tsx
(1 hunks)src/pages/Encounters/EncounterShow.tsx
(1 hunks)src/pages/Encounters/tabs/EncounterNotesTab.tsx
(7 hunks)src/pages/UserDashboard.tsx
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: cypress-run (1)
🔇 Additional comments (29)
src/pages/UserDashboard.tsx (1)
78-87
: Good addition of test selector for sign-out button.Adding the
data-cy
attribute to the sign-out button enhances testability and aligns with the PR objectives of improving test coverage for user interactions.src/pages/Encounters/EncounterList.tsx (1)
694-697
: Well implemented test selector for encounter cards.The dynamic
data-cy
attribute with the encounter ID provides a reliable way to target specific encounter cards in automated tests, which is essential for the encounter notes test scenarios.src/pages/Encounters/EncounterShow.tsx (1)
172-177
: Good addition of test selectors for encounter tabs.The dynamic
data-cy
attribute for tabs makes it straightforward to target specific tabs in automated tests, particularly useful for navigating to the notes tab in the test scenarios.cypress/e2e/patient_spec/encounter_notes.cy.ts (5)
1-7
: Well structured test file with proper imports and page object initialization.The imports and page object instantiations follow good practices for maintainable test code.
8-28
: Comprehensive test data setup with realistic scenarios.The test data is well-structured with unique thread titles (using timestamps) and a variety of message types, including longer text to test multi-line handling. This provides good coverage for real-world usage patterns.
30-38
: Proper test setup with environment configuration.The
beforeEach
hook appropriately sets up the environment for each test with viewport configuration, login, and facility selection.
39-68
: Well-structured first test case for thread creation and message isolation.This test case effectively validates the core functionality of creating multiple threads and ensuring messages stay within their respective threads. The fluent API pattern with chained methods improves readability and maintainability.
70-94
: Good test for multi-user interaction with threads.This test case verifies that different user roles can access and contribute to existing threads, which is crucial for collaborative functionality. The verification of the encounter ID ensures test continuity between the two test cases.
src/pages/Encounters/tabs/EncounterNotesTab.tsx (7)
103-103
: Consistent Cypress locator for thread selection.This newly added
data-cy="thread-title"
attribute follows a clear naming pattern, aligning well with your existing Cypress locators.
255-255
: Good addition for targeted testing.The
data-cy="new-thread-title-input"
attribute provides a reliable hook for end-to-end testing, ensuring an unambiguous way to locate the field.
268-268
: Creates clear separation of responsibilities.Marking the create thread trigger with
data-cy="create-thread-button"
helps your tests differentiate it from other buttons in the dialog.
486-486
: Clear CTA locator for new thread creation.The
data-cy="new-thread-button"
attribute is consistent with your established naming scheme, facilitating script-driven UI actions.
621-624
: Useful chat identification.Adding
data-cy="chat-messages"
to the container simplifies message verification in Cypress, preventing false positives when searching for text in other areas.
676-677
: Explicit locator for the chat input.The
data-cy="encounter-notes-chat-message-input"
attribute ensures clarity when referencing this input field in tests, reducing risk of collisions with other textareas.
687-687
: Concise button locator for message submission.The
data-cy="send-chat-message-button"
locator is clear and aids in reliably triggering the send message flow during automated tests.cypress/pageObject/Patients/PatientEncounter.ts (14)
92-93
: Informative section comment.Keeping a high-level comment block like
/*** ENCOUNTER_NOTES ***/
can help maintain structure, especially in files with multiple functionalities.
94-98
: Effective request interception.Utilizing
intercept("POST", "/api/v1/patient/*/thread/*/note/")
is a solid approach for validating new chat messages in a targeted manner during tests.
100-114
: Smart technique for encounter ID retrieval.Storing the ID in
Cypress.env("encounterId")
ensures reusability across tests and fosters more flexible scenarios.
116-126
: Direct encounter selection by ID.Selecting the card via
[data-cy="encounter-card-${encounterId}"]
is a straightforward approach to handle multiple encounters in test workflows.
128-132
: Notes tab navigation aligns with naming.
openEncounterNotesTab()
is self-explanatory and leverages data-cy for reliability, which is consistent with the rest of the suite.
134-137
: Easily recognizable "New" thread action.The method name
clickNewThreadButton()
is intuitive and reused effectively for consistent end-to-end tests.
139-142
: Straightforward thread title input.
typeThreadTitle
provides a readable abstraction for setting the thread's name, keeping your test steps concise.
144-151
: Clear button click with verification.
clickCreateThreadButton
ensures both visibility and clickable readiness, reducing flaky tests.
153-164
: Message sending flow with response verification.Validating a
200
status code confirms success, but consider handling non-200 success codes (e.g., 201) if the API can return them.Do you expect strictly
200
responses, or might other2xx
codes be returned?
165-173
: Batch messages for thorough test coverage.
addNewChatMessages
elegantly encapsulates multiple message creation in a single flow.
175-178
: Verifying expected chat contents.
verifyMessagesInChat
usescy.verifyContentPresence
effectively, helping isolate any mismatches or missing messages early.
180-185
: Ensures message integrity across threads.
verifyMessagesNotExistInChat
helps confirm a message does not appear where it shouldn't, fortifying your concurrency and isolation tests.
187-194
: Straightforward thread switching.
changeThread
fosters readability in tests that involve multiple discussion threads in the same encounter.
196-201
: Covers sign-out scenarios.Including a
logout()
method ensures your test suite can gracefully reset the test state without manually repeating sign-out steps.
@nihal467 |
Proposed Changes
Next Steps
Screencast.from.2025-03-09.04-31-17.webm
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
New Features
Enhancements