Conversation
Summary of ChangesHello @sepidehdehghani992, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the E2E test coverage for medication-related functionalities. It introduces new page objects for medication requests and prescription modals, centralizing element locators and interaction logic. This foundational work enables the addition of a comprehensive set of tests that validate various aspects of medication prescription and display within the application, ensuring a more robust and reliable user experience. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds a comprehensive set of E2E tests for medication-related features, including medication requests and prescribing medication within an encounter. The page object model is well-utilized, and the tests cover various scenarios, including positive and negative paths. My feedback focuses on improving test stability by addressing the use of potentially brittle test IDs and enhancing code maintainability by improving encapsulation and reducing redundancy.
| (this as any)[key] = page.getByTestId(id); | ||
| } | ||
|
|
||
| this.pageHeading = page.getByTestId('topbarheading-go4f'); |
There was a problem hiding this comment.
The test ID 'topbarheading-go4f' appears to have a generated suffix, which makes it brittle and prone to breaking if the component's rendering changes. For better test stability, please use a static, meaningful data-testid. Additionally, for consistency, this locator should be defined within the testIds object along with the others.
| const testIds = { | ||
| medicationInput: 'medication-field-medicationId-8k3m-input', | ||
| isOngoingCheckbox: 'medication-field-isOngoing-7j2p-controlcheck', | ||
| isPrnCheckbox: 'medication-field-isPrn-9n4q-controlcheck', | ||
| isVariableDoseCheckbox: 'medication-field-isVariableDose-5h8x-controlcheck', | ||
| isPhoneOrderCheckbox: 'medication-field-isPhoneOrder-2e4r-controlcheck', | ||
| doseAmountInput: 'medication-field-doseAmount-3t6w', | ||
| unitsSelect: 'medication-field-units-2r9v-select', | ||
| frequencyInput: 'medication-field-frequency-4c7z-input', | ||
| routeSelect: 'medication-field-route-6d1b-select', | ||
| prescriptionDateInput: 'medication-field-date-8m5k', | ||
| startDateTimeInput: 'medication-field-startDate-1a9s', | ||
| durationValueInput: 'medication-field-durationValue-7p2n', | ||
| durationUnitSelect: 'medication-field-durationUnit-4q8f-select', | ||
| prescriberInput: 'medication-field-prescriberId-3x5h-input', | ||
| indicationInput: 'medication-field-indication-9w6y', | ||
| notesInput: 'medication-field-notes-5b3t', | ||
| dischargeQuantityInput: 'medication-field-quantity-6j9m', | ||
| finaliseAndPrintButton: 'medication-button-finaliseAndPrint-8v2q', | ||
| finaliseButton: 'medication-button-finalise-7x3d', | ||
| } as const; |
There was a problem hiding this comment.
The test IDs used in this page object contain suffixes that appear to be auto-generated (e.g., -8k3m, -7j2p, -3t6w). These IDs are likely to be unstable and may change with unrelated code modifications, leading to brittle tests that are difficult to maintain. It is strongly recommended to work with the development team to establish stable, meaningful data-testid attributes for key elements. This will significantly improve the long-term stability and reliability of the test suite. This concern applies to other page objects in this PR as well.
|
|
||
| // Check if the PrescriptionTypeModal appeared (has "Continue" button) | ||
| const continueButton = this.page.getByRole('button', { name: 'Continue', exact: true }); | ||
| const finaliseButton = this.page.getByTestId('medication-button-finalise-7x3d'); |
There was a problem hiding this comment.
This line hardcodes the test ID 'medication-button-finalise-7x3d', which is an implementation detail of NewPrescriptionModal. This breaks encapsulation and makes the code harder to maintain. If the test ID in NewPrescriptionModal changes, this will also need to be updated, and it's easy to miss. A better approach would be to avoid duplicating this information. For example, you could expose it as a static property on NewPrescriptionModal.
| const values = await modal.fillRequiredFields(); | ||
| await modal.finaliseButton.click(); | ||
| await modal.waitForModalToClose(); |
There was a problem hiding this comment.
This block of code duplicates the logic found in the modal.fillAndFinalise() method. Leveraging the existing abstraction will make the test more concise and easier to read.
| const values = await modal.fillRequiredFields(); | |
| await modal.finaliseButton.click(); | |
| await modal.waitForModalToClose(); | |
| const values = await modal.fillAndFinalise(); |
Changes
15 basic medication tests
Deploys
Tests
Remember to...