Skip to content
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

Refactored Location Management Cypress Test #9301

Merged
merged 6 commits into from
Dec 5, 2024

Conversation

nihal467
Copy link
Member

@nihal467 nihal467 commented Dec 4, 2024

Proposed Changes

  • Fixes #issue_number
  • Change 1
  • Change 2
  • More?

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced error message verification in tests for facility creation and user management.
    • Added new test cases for deleting locations with linked assets and beds.
    • Introduced a new Cypress command for verifying error messages.
    • Improved accessibility in the Add Location Form, Bed Management, and Location Management components with new id attributes for form fields and elements.
  • Bug Fixes

    • Improved error handling and notifications for creating and modifying locations and beds.
    • Streamlined error message verification process during facility creation and triage operations.

@nihal467 nihal467 requested a review from a team as a code owner December 4, 2024 22:56
Copy link
Contributor

coderabbitai bot commented Dec 4, 2024

Walkthrough

The changes in this pull request involve significant modifications to the Cypress end-to-end test files related to facility creation and location management. Key updates include the removal of the UserCreationPage instance and its associated methods, replaced by a new cy.verifyErrorMessages() command for streamlined error verification. Additionally, the FacilityLocation and FacilityHome classes have been updated with new methods to enhance functionality and improve error handling. The AddLocationForm component has also been modified to improve accessibility through the addition of id attributes.

Changes

File Path Change Summary
cypress/e2e/facility_spec/FacilityCreation.cy.ts Removed UserCreationPage instance and replaced method calls with cy.verifyErrorMessages().
cypress/e2e/facility_spec/FacilityLocation.cy.ts Added new imports and methods for managing facility locations and beds, expanded existing tests, and improved error handling logic.
cypress/pageobject/Facility/FacilityHome.ts Removed verifyAndCloseNotifyModal method, indicating a change in modal handling.
cypress/pageobject/Facility/FacilityLocation.ts Removed loadLocationManagementPage method and added multiple new methods for better management of locations and beds. Updated existing methods to utilize a new utility function for improved reliability.
cypress/pageobject/Users/UserCreation.ts Removed verifyErrorMessages method, indicating a shift in error handling for user creation.
cypress/support/commands.ts Introduced a new command verifyErrorMessages for enhanced error message verification capabilities.
cypress/support/index.ts Added verifyErrorMessages method to the Chainable interface in Cypress.
src/components/Facility/AddLocationForm.tsx Added id attributes to form fields for improved accessibility and identification, while maintaining existing validation and submission logic.
src/components/Facility/BedManagement.tsx Added id attribute to the main <div> of the BedCard component for improved accessibility.
src/components/Facility/LocationManagement.tsx Added id attributes to various elements within the Location component for better accessibility and identification.
cypress/e2e/facility_spec/FacilityHomepage.cy.ts Replaced method call for closing a notification modal with a standardized approach, maintaining overall test structure and functionality.
cypress/e2e/users_spec/UsersCreation.cy.ts Updated error message verification methods to use cy.verifyErrorMessages() instead of userCreationPage.verifyErrorMessages().
cypress/pageobject/Asset/AssetCreation.ts Updated enterAssetDetails method parameters from required to optional, enhancing flexibility in asset creation.

Possibly related issues

Possibly related PRs

Suggested labels

needs review, tested

Suggested reviewers

  • rithviknishad

Poem

🐰 In the land of tests so bright,
Error messages now take flight.
With a hop and a skip, we streamline the way,
Making sure each message has its say.
No more pages to create and verify,
Just clear commands that soar high! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Dec 4, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit fb1d9eb
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/6751290374f55300088cc5b0
😎 Deploy Preview https://deploy-preview-9301--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

cloudflare-workers-and-pages bot commented Dec 4, 2024

Deploying care-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: fb1d9eb
Status: ✅  Deploy successful!
Preview URL: https://0e38543c.care-fe.pages.dev
Branch Preview URL: https://location-manage-test.care-fe.pages.dev

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (9)
cypress/e2e/facility_spec/FacilityLocation.cy.ts (2)

Line range hint 87-90: Correct method name spelling for verifyAddLocationSuccessfulMessage

The method verifyAddLocationSuccessfulMesssage has an extra 's' in 'Message'. This typo could cause issues when invoking the method.

Apply this diff to correct the method name:

- verifyAddLocationSuccessfulMesssage() {
+ verifyAddLocationSuccessfulMessage() {
    cy.verifyNotification("Location created successfully");
    cy.closeNotification();
}

Ensure all calls to this method are updated accordingly.


102-105: Correct method name spelling for verifyAddSingleBedSuccessfulMessage

The method verifyAddSingleBedSuccessfulMesssage has an extra 's' in 'Message'. This typo could lead to errors when the method is called.

Apply this diff to correct the method name:

- verifyAddSingleBedSuccessfulMesssage() {
+ verifyAddSingleBedSuccessfulMessage() {
    cy.verifyNotification("1 Bed created successfully");
    cy.closeNotification();
}

Update all references to this method accordingly.

cypress/pageobject/Facility/FacilityLocation.ts (4)

14-16: Review the necessity of both typeLocationName and enterLocationName methods

Having both typeLocationName and enterLocationName methods might be redundant and could cause confusion. Consider consolidating them into a single method.

Optionally, merge these methods to improve code maintainability:

- typeLocationName(locationName: string) {
-   cy.get("#location-name").type(locationName);
- }
...
enterLocationName(name: string) {
-   cy.get("input[id=name]").type(name);
+   cy.get("#location-name").type(name);
}

Update all references to use the consolidated method.


87-90: Correct method name spelling for verifyAddLocationSuccessfulMessage

As mentioned earlier, correct the spelling of verifyAddLocationSuccessfulMesssage to verifyAddLocationSuccessfulMessage.

Apply this diff:

- verifyAddLocationSuccessfulMesssage() {
+ verifyAddLocationSuccessfulMessage() {
    cy.verifyNotification("Location created successfully");
    cy.closeNotification();
}

97-100: Ensure consistency in method naming

Confirm that all success message verification methods follow a consistent naming convention, such as using verify<Action><Entity>SuccessfulMessage.

This enhances readability and maintainability of the code.


164-165: Simplify clickDeleteLocation method

The clickDeleteLocation method uses cy.verifyAndClickElement, which checks for visibility before clicking. Ensure that this is necessary, or consider simplifying if not required.

If visibility checks are redundant, you might simplify the method:

clickDeleteLocation() {
-   cy.verifyAndClickElement("#delete-location-button", "Delete");
+   cy.get("#delete-location-button").click();
}
cypress/support/commands.ts (1)

233-243: Enhance error handling in verifyErrorMessages command

The verifyErrorMessages command effectively checks for expected error messages. However, consider handling cases where the .error-text elements are not found, which could lead to false positives.

You might add an assertion to ensure that error elements are present:

cy.get(selector).should('exist').then(($errors) => {
  const displayedErrorMessages = $errors
    .map((_, el) => Cypress.$(el).text())
    .get();
  errorMessages.forEach((errorMessage) => {
    expect(displayedErrorMessages).to.include(errorMessage);
  });
});

This ensures the command fails appropriately when no error messages are displayed.

cypress/e2e/facility_spec/FacilityCreation.cy.ts (2)

124-124: LGTM with a suggestion for error message constants

The error verification is correctly implemented. Consider moving the error message arrays to a separate constants file for better maintainability and reuse across tests.

Example structure:

// cypress/fixtures/errorMessages.ts
export const FACILITY_FORM_ERRORS = {
  EMPTY_FORM: [
    "Required",
    "Required",
    "Invalid Pincode",
    // ... rest of the messages
  ],
  // ... other error message groups
};

Line range hint 1-424: Consider improving test organization and constants

The test file is well-structured with comprehensive coverage of facility creation scenarios. To further improve maintainability:

  1. Consider extracting test data and error messages to fixture files
  2. Group related test scenarios using context blocks
  3. Consider adding data-testid attributes for more reliable selectors

Example structure:

// Group related scenarios
context('Facility Creation - Happy Path', () => {
  it('with multiple bed and doctor capacity', () => {...});
  it('with single bed and doctor capacity', () => {...});
});

context('Facility Creation - Error Cases', () => {
  it('with no bed and doctor capacity', () => {...});
  it('with different district', () => {...});
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a57480c and 57f4c43.

📒 Files selected for processing (8)
  • cypress/e2e/facility_spec/FacilityCreation.cy.ts (3 hunks)
  • cypress/e2e/facility_spec/FacilityLocation.cy.ts (5 hunks)
  • cypress/pageobject/Facility/FacilityHome.ts (0 hunks)
  • cypress/pageobject/Facility/FacilityLocation.ts (4 hunks)
  • cypress/pageobject/Users/UserCreation.ts (0 hunks)
  • cypress/support/commands.ts (1 hunks)
  • cypress/support/index.ts (1 hunks)
  • src/components/Facility/AddLocationForm.tsx (1 hunks)
💤 Files with no reviewable changes (2)
  • cypress/pageobject/Users/UserCreation.ts
  • cypress/pageobject/Facility/FacilityHome.ts
🧰 Additional context used
📓 Learnings (2)
cypress/e2e/facility_spec/FacilityCreation.cy.ts (2)
Learnt from: kihan2518B
PR: ohcnetwork/care_fe#8956
File: cypress/e2e/facility_spec/FacilityCreation.cy.ts:261-261
Timestamp: 2024-12-04T18:58:47.241Z
Learning: In `cypress/e2e/facility_spec/FacilityCreation.cy.ts`, the test case titled "Create a new facility with no bed and doctor capacity" includes steps to select bed types and specializations before validation. This is done intentionally to verify that error messages are shown properly when no capacity is specified.
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9145
File: cypress/e2e/facility_spec/FacilityCreation.cy.ts:177-180
Timestamp: 2024-11-18T10:44:30.303Z
Learning: In `cypress/e2e/facility_spec/FacilityCreation.cy.ts`, when testing bed and staff capacity individually for additional error verification, we prefer to use separate method calls to handle bed and staff capacity, rather than using `facilityPage.createNewFacility(testFacilityData)` which also handles bed management.
cypress/e2e/facility_spec/FacilityLocation.cy.ts (3)
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9145
File: cypress/e2e/facility_spec/FacilityCreation.cy.ts:177-180
Timestamp: 2024-11-18T10:44:30.303Z
Learning: In `cypress/e2e/facility_spec/FacilityCreation.cy.ts`, when testing bed and staff capacity individually for additional error verification, we prefer to use separate method calls to handle bed and staff capacity, rather than using `facilityPage.createNewFacility(testFacilityData)` which also handles bed management.
Learnt from: kihan2518B
PR: ohcnetwork/care_fe#8956
File: cypress/e2e/facility_spec/FacilityCreation.cy.ts:261-261
Timestamp: 2024-12-04T18:58:47.241Z
Learning: In `cypress/e2e/facility_spec/FacilityCreation.cy.ts`, the test case titled "Create a new facility with no bed and doctor capacity" includes steps to select bed types and specializations before validation. This is done intentionally to verify that error messages are shown properly when no capacity is specified.
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9145
File: cypress/e2e/facility_spec/FacilityHomepage.cy.ts:229-317
Timestamp: 2024-11-18T10:46:56.271Z
Learning: In `cypress/e2e/facility_spec/FacilityHomepage.cy.ts`, when verifying the bed capacity badge reflection, the badge remains the same during multiple actions and only updates after a bed is attached to a patient during consultation. Therefore, it's appropriate to keep the test case consolidated rather than splitting it into smaller tests.
🔇 Additional comments (9)
cypress/e2e/facility_spec/FacilityLocation.cy.ts (4)

92-95: Correct method name spelling for verifyEditBedSuccessfulMessage

Similar to the previous comment, the method verifyEditBedSuccessfulMessage is correctly spelled here, but double-check for consistency across the codebase.

Please ensure that all method names are consistently spelled throughout the codebase.


97-100: Correct method name spelling for verifyEditLocationSuccessfulMessage

The method name is correctly spelled here. Just confirm consistency across all method calls.


83-83: Ensure proper method call after submitting bed

After calling facilityLocation.clickSubmitBedsButton(), ensure that verifyAddSingleBedSuccessfulMessage() is called with the corrected method name.

Double-check that the method verifyAddSingleBedSuccessfulMessage() is called to verify the successful addition of a bed.


Line range hint 243-243: Verify error handling in verifyErrorMessages command

Ensure that the verifyErrorMessages command correctly handles scenarios where expected error messages are not displayed, providing useful feedback for test failures.

Consider adding assertions or additional logging in case of missing error messages to aid in debugging test failures.

cypress/support/index.ts (1)

48-48: Add new method to Chainable interface for error message verification

The addition of verifyErrorMessages(errorMessages: string[]): Chainable<Subject>; extends the Chainable interface appropriately.

src/components/Facility/AddLocationForm.tsx (1)

165-165: Ensure consistent id attributes for form fields

The addition of id="location-name" to the TextFormField improves accessibility and facilitates testing. Ensure that all form fields have consistent and meaningful id attributes.

cypress/e2e/facility_spec/FacilityCreation.cy.ts (3)

88-88: LGTM: Simplified error message verification

The change to use cy.verifyErrorMessages() custom command improves code maintainability by centralizing error message verification logic.


271-271: LGTM: Intentional validation of bed capacity errors

The error verification is correctly implemented and aligns with the test's intention to validate empty bed capacity form submission.


276-276: LGTM: Verify custom command implementation

The error verification is correctly implemented. Let's verify the custom command implementation to ensure consistent behavior.

✅ Verification successful

Let me check the implementation of the custom command to ensure it's properly defined.


LGTM: Custom command implementation is correct and consistent

The cy.verifyErrorMessages command is properly implemented to check error messages using the .error-text selector. The command is used consistently across facility tests to verify various error scenarios including bed, doctor, triage, and location validations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of cy.verifyErrorMessages custom command

# Search for the custom command definition
echo "Searching for verifyErrorMessages command definition..."
rg -l "Cypress.Commands.add.*verifyErrorMessages" cypress/support/

# Search for all usages of the command
echo "Searching for all usages of verifyErrorMessages..."
rg "cy\.verifyErrorMessages" cypress/e2e/

Length of output: 976


Script:

#!/bin/bash
# Get the implementation of verifyErrorMessages command
echo "Content of commands.ts:"
cat cypress/support/commands.ts

Length of output: 7237

});

it("Delete location with linked assets", () => {
const locationName = `ICU-${uuidv4().substring(0, 2)}}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix syntax error in locationName constant

There is an extra closing curly brace }} in the template string for locationName.

Apply this diff to correct the constant:

- const locationName = `ICU-${uuidv4().substring(0, 2)}}`;
+ const locationName = `ICU-${uuidv4().substring(0, 2)}`;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const locationName = `ICU-${uuidv4().substring(0, 2)}}`;
const locationName = `ICU-${uuidv4().substring(0, 2)}`;

Comment on lines 122 to 123
const locationName = `ICU-${uuidv4().substring(0, 2)}}`;
const locationModifiedName = `ICU-${uuidv4().substring(0, 2)}}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix syntax error in locationName and locationModifiedName constants

Similar to the previous issue, there are extra closing curly braces }} in the template strings for locationName and locationModifiedName.

Apply this diff to correct the constants:

- const locationName = `ICU-${uuidv4().substring(0, 2)}}`;
+ const locationName = `ICU-${uuidv4().substring(0, 2)}`;
- const locationModifiedName = `ICU-${uuidv4().substring(0, 2)}}`;
+ const locationModifiedName = `ICU-${uuidv4().substring(0, 2)}`;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const locationName = `ICU-${uuidv4().substring(0, 2)}}`;
const locationModifiedName = `ICU-${uuidv4().substring(0, 2)}}`;
const locationName = `ICU-${uuidv4().substring(0, 2)}`;
const locationModifiedName = `ICU-${uuidv4().substring(0, 2)}`;

Comment on lines 171 to 174
const locationName = `ICU-${uuidv4().substring(0, 2)}}`;
const facilityName = "Dummy Facility 12";
const bedName = `Bed-${uuidv4().substring(0, 2)}}`;
// Select a new facility
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix syntax error in locationName and bedName constants

Again, there are extra closing curly braces }} in the template strings for locationName and bedName.

Apply this diff to correct the constants:

- const locationName = `ICU-${uuidv4().substring(0, 2)}}`;
+ const locationName = `ICU-${uuidv4().substring(0, 2)}`;
- const bedName = `Bed-${uuidv4().substring(0, 2)}}`;
+ const bedName = `Bed-${uuidv4().substring(0, 2)}`;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const locationName = `ICU-${uuidv4().substring(0, 2)}}`;
const facilityName = "Dummy Facility 12";
const bedName = `Bed-${uuidv4().substring(0, 2)}}`;
// Select a new facility
const locationName = `ICU-${uuidv4().substring(0, 2)}`;
const facilityName = "Dummy Facility 12";
const bedName = `Bed-${uuidv4().substring(0, 2)}`;
// Select a new facility

Comment on lines 55 to 58
const locationName = `ICU-${uuidv4().substring(0, 2)}}`;
const facilityName = "Dummy Request Fulfilment Center";
const bedName = `Bed-${uuidv4().substring(0, 2)}}`;
const duplicateBedName = `Duplicate-${uuidv4().substring(0, 2)}}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix syntax errors in template strings

The constants locationName, bedName, duplicateBedName, and multipleBedName have an extra closing curly brace }} in their template strings, which will cause a syntax error.

Apply this diff to correct the template strings:

- const locationName = `ICU-${uuidv4().substring(0, 2)}}`;
+ const locationName = `ICU-${uuidv4().substring(0, 2)}`;
- const bedName = `Bed-${uuidv4().substring(0, 2)}}`;
+ const bedName = `Bed-${uuidv4().substring(0, 2)}`;
- const duplicateBedName = `Duplicate-${uuidv4().substring(0, 2)}}`;
+ const duplicateBedName = `Duplicate-${uuidv4().substring(0, 2)}`;
- const multipleBedName = `Multi-${uuidv4().substring(0, 2)}}`;
+ const multipleBedName = `Multi-${uuidv4().substring(0, 2)}`;

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines 182 to 183
facilityLocation.enterLocationName(locationName);
facilityLocation.selectLocationType(locationType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Ensure consistent use of selector in enterLocationName method

The enterLocationName method uses the selector cy.get("input[id=name]"), which may not match the updated id in the form. Based on changes in the form component, the input field for the location name now has id="location-name". Update the selector to reflect this change.

Apply this diff to update the selector:

enterLocationName(name: string) {
-   cy.get("input[id=name]").type(name);
+   cy.get("#location-name").type(name);
}

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines 68 to 70
facilityLocation.clickAddNewLocationButton();
facilityLocation.typeLocationName(locationName);
facilityLocation.selectLocationType(locationType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve method usage consistency

You're using facilityLocation.typeLocationName(locationName) to enter the location name. However, in other parts of the code, you're using enterLocationName. For consistency and to avoid confusion, consider using a single method for entering the location name.

Apply this diff to standardize the method:

- facilityLocation.typeLocationName(locationName);
+ facilityLocation.enterLocationName(locationName);

Alternatively, update the method in the FacilityLocation class to keep typeLocationName and remove enterLocationName.

Committable suggestion skipped: line range outside the PR's diff.

Copy link

cypress bot commented Dec 4, 2024

CARE    Run #4000

Run Properties:  status check passed Passed #4000  •  git commit fb1d9ebc67: Refactored Location Management Cypress Test
Project CARE
Branch Review location-manage-test
Run status status check passed Passed #4000
Run duration 05m 16s
Commit git commit fb1d9ebc67: Refactored Location Management Cypress Test
Committer Mohammed Nihal
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 144
View all changes introduced in this branch ↗︎

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (4)
cypress/e2e/facility_spec/FacilityLocation.cy.ts (4)

Line range hint 19-24: Consider moving test data to a separate fixture file

The error message constants could be moved to a separate fixture file to improve maintainability and reusability across tests.

Create a new file cypress/fixtures/errorMessages.ts:

export const LOCATION_ERROR_MESSAGES = [
  "Name is required",
  "Location Type is required",
];

export const BED_ERROR_MESSAGES = [
  "Please enter a name",
  "Please select a bed type",
];

Line range hint 54-119: Consider splitting the test case into smaller, focused tests

This test case handles multiple scenarios: single bed creation, bed duplication, bed editing, and multiple bed creation. Consider splitting it into separate test cases for better maintainability and clarity:

  1. "Add single bed and verify error messages"
  2. "Verify bed duplication handling"
  3. "Edit existing bed"
  4. "Create multiple beds and verify pagination"

151-154: Verify notification message content

Consider adding an assertion to verify the exact content of the notification message matches the expected error message.

const DUPLICATE_LOCATION_ERROR = "Name - Asset location with this name and facility already exists.";
cy.verifyNotification(DUPLICATE_LOCATION_ERROR).should('have.text', DUPLICATE_LOCATION_ERROR);

Line range hint 230-248: Move asset creation to a custom command

Consider moving the asset creation logic to a custom command to improve reusability and reduce test complexity.

Create a new command in cypress/support/commands.ts:

Cypress.Commands.add('createLinkedAsset', (facilityName: string, locationName: string, assetDetails: AssetDetails) => {
  assetPage.createAsset();
  assetPage.selectFacility(facilityName);
  assetPage.selectLocation(locationName);
  assetPage.enterAssetDetails(
    assetDetails.name,
    assetDetails.description,
    assetDetails.status,
    assetDetails.qrId,
    assetDetails.manufacturer,
    assetDetails.warrantyExpiry,
    assetDetails.supportName,
    assetDetails.supportPhone,
    assetDetails.supportEmail,
    assetDetails.vendorName,
    assetDetails.serialNumber,
    assetDetails.purchaseDate,
    assetDetails.note
  );
  assetPage.clickassetupdatebutton();
});

Then use it in the test:

cy.createLinkedAsset(facilityName, locationName, {
  name: "Test Asset linked to Facility",
  description: "Test Description",
  status: "Working",
  qrId: qr_id_1,
  manufacturer: "Manufacturer's Name",
  warrantyExpiry: "2025-12-25",
  supportName: "Customer Support's Name",
  supportPhone: phone_number,
  supportEmail: "[email protected]",
  vendorName: "Vendor's Name",
  serialNumber: serialNumber,
  purchaseDate: "25122021",
  note: "Test note for asset creation!"
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 57f4c43 and bfc28bb.

📒 Files selected for processing (1)
  • cypress/e2e/facility_spec/FacilityLocation.cy.ts (5 hunks)
🧰 Additional context used
📓 Learnings (1)
cypress/e2e/facility_spec/FacilityLocation.cy.ts (3)
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9145
File: cypress/e2e/facility_spec/FacilityCreation.cy.ts:177-180
Timestamp: 2024-11-18T10:44:30.303Z
Learning: In `cypress/e2e/facility_spec/FacilityCreation.cy.ts`, when testing bed and staff capacity individually for additional error verification, we prefer to use separate method calls to handle bed and staff capacity, rather than using `facilityPage.createNewFacility(testFacilityData)` which also handles bed management.
Learnt from: kihan2518B
PR: ohcnetwork/care_fe#8956
File: cypress/e2e/facility_spec/FacilityCreation.cy.ts:261-261
Timestamp: 2024-12-04T18:58:47.241Z
Learning: In `cypress/e2e/facility_spec/FacilityCreation.cy.ts`, the test case titled "Create a new facility with no bed and doctor capacity" includes steps to select bed types and specializations before validation. This is done intentionally to verify that error messages are shown properly when no capacity is specified.
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9145
File: cypress/e2e/facility_spec/FacilityHomepage.cy.ts:229-317
Timestamp: 2024-11-18T10:46:56.271Z
Learning: In `cypress/e2e/facility_spec/FacilityHomepage.cy.ts`, when verifying the bed capacity badge reflection, the badge remains the same during multiple actions and only updates after a bed is attached to a patient during consultation. Therefore, it's appropriate to keep the test case consolidated rather than splitting it into smaller tests.
🔇 Additional comments (2)
cypress/e2e/facility_spec/FacilityLocation.cy.ts (2)

59-59: ⚠️ Potential issue

Fix syntax error in template string

There's an extra closing brace in the template string.

- const multipleBedName = `Multi-${uuidv4().substring(0, 2)}}`;
+ const multipleBedName = `Multi-${uuidv4().substring(0, 2)}`;

Likely invalid or redundant comment.


123-123: ⚠️ Potential issue

Fix syntax error in template string

There's an extra closing brace in the template string.

- const locationModifiedName = `ICU-${uuidv4().substring(0, 2)}}`;
+ const locationModifiedName = `ICU-${uuidv4().substring(0, 2)}`;

Likely invalid or redundant comment.

@nihal467 nihal467 self-assigned this Dec 5, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (3)
src/components/Facility/LocationManagement.tsx (1)

242-245: Consider making the id more specific

The addition of the id attribute improves accessibility and testability. However, since this is a list item representing a single location card, consider making the id more specific by including the location's id:

 <div
   className="flex h-full w-full flex-col rounded border border-secondary-300 bg-white p-6 shadow-sm transition-all duration-200 ease-in-out hover:border-primary-400"
-  id="location-cards"
+  id={`location-card-${id}`}
 >

This would:

  1. Make each location card uniquely identifiable
  2. Make it easier to target specific locations in tests
  3. Follow a more semantic naming convention
cypress/pageobject/Facility/FacilityLocation.ts (1)

184-190: Add response verification to bed deletion.

The deleteBedWithName method should verify the deletion was successful.

Consider adding response verification by using the existing deleteBedRequest and deleteBedResponse methods:

 deleteBedWithName(text: string) {
+  this.deleteBedRequest();
   cy.get("#bed-card")
     .contains(text)
     .parents("#bed-card")
     .within(() => {
       cy.get("#delete-bed-button").click();
     });
+  this.deleteBedResponse();
 }
cypress/e2e/facility_spec/FacilityLocation.cy.ts (1)

Line range hint 19-24: Consider using fixtures for error messages.

Error messages are currently hardcoded in the test file. Consider moving them to a fixture file for better maintainability.

Create a fixture file cypress/fixtures/errorMessages.json:

{
  "location": {
    "name": "Name is required",
    "type": "Location Type is required"
  },
  "bed": {
    "name": "Please enter a name",
    "type": "Please select a bed type"
  }
}

Then update the test file to use the fixture:

let errorMessages: any;

before(() => {
  cy.fixture('errorMessages').then((messages) => {
    errorMessages = messages;
  });
  loginPage.loginByRole("districtAdmin");
  cy.saveLocalStorage();
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between bfc28bb and 52796a2.

📒 Files selected for processing (4)
  • cypress/e2e/facility_spec/FacilityLocation.cy.ts (5 hunks)
  • cypress/pageobject/Facility/FacilityLocation.ts (4 hunks)
  • src/components/Facility/BedManagement.tsx (1 hunks)
  • src/components/Facility/LocationManagement.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/components/Facility/BedManagement.tsx
🧰 Additional context used
📓 Learnings (2)
cypress/e2e/facility_spec/FacilityLocation.cy.ts (3)
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9145
File: cypress/e2e/facility_spec/FacilityCreation.cy.ts:177-180
Timestamp: 2024-11-18T10:44:30.303Z
Learning: In `cypress/e2e/facility_spec/FacilityCreation.cy.ts`, when testing bed and staff capacity individually for additional error verification, we prefer to use separate method calls to handle bed and staff capacity, rather than using `facilityPage.createNewFacility(testFacilityData)` which also handles bed management.
Learnt from: kihan2518B
PR: ohcnetwork/care_fe#8956
File: cypress/e2e/facility_spec/FacilityCreation.cy.ts:261-261
Timestamp: 2024-12-04T18:58:47.241Z
Learning: In `cypress/e2e/facility_spec/FacilityCreation.cy.ts`, the test case titled "Create a new facility with no bed and doctor capacity" includes steps to select bed types and specializations before validation. This is done intentionally to verify that error messages are shown properly when no capacity is specified.
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9145
File: cypress/e2e/facility_spec/FacilityHomepage.cy.ts:229-317
Timestamp: 2024-11-18T10:46:56.271Z
Learning: In `cypress/e2e/facility_spec/FacilityHomepage.cy.ts`, when verifying the bed capacity badge reflection, the badge remains the same during multiple actions and only updates after a bed is attached to a patient during consultation. Therefore, it's appropriate to keep the test case consolidated rather than splitting it into smaller tests.
cypress/pageobject/Facility/FacilityLocation.ts (1)
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9145
File: cypress/e2e/facility_spec/FacilityCreation.cy.ts:177-180
Timestamp: 2024-11-18T10:44:30.303Z
Learning: In `cypress/e2e/facility_spec/FacilityCreation.cy.ts`, when testing bed and staff capacity individually for additional error verification, we prefer to use separate method calls to handle bed and staff capacity, rather than using `facilityPage.createNewFacility(testFacilityData)` which also handles bed management.
🔇 Additional comments (5)
cypress/pageobject/Facility/FacilityLocation.ts (2)

8-13: LGTM! Well-structured navigation method.

The navigateToFacilityLocationManagement method provides a clear and reusable way to navigate to the facility location management section.


103-116: LGTM! Well-structured success message verification methods.

The success message verification methods follow a consistent pattern:

  1. Verify the notification message
  2. Close the notification
cypress/e2e/facility_spec/FacilityLocation.cy.ts (3)

Line range hint 167-275: LGTM! Well-structured deletion test cases.

The test cases for location deletion:

  • Cover both linked beds and assets scenarios
  • Follow a clear pattern of setup, action, and verification
  • Include proper cleanup

119-119: ⚠️ Potential issue

Fix syntax error in template string.

There's an extra closing curly brace in the template string for locationModifiedName.

Apply this diff to fix the syntax error:

-const locationModifiedName = `ICU-${uuidv4().substring(0, 2)}}`;
+const locationModifiedName = `ICU-${uuidv4().substring(0, 2)}`;

Likely invalid or redundant comment.


59-59: ⚠️ Potential issue

Fix syntax error in template string.

There's an extra closing curly brace in the template string for multipleBedName.

Apply this diff to fix the syntax error:

-const multipleBedName = `Multi-${uuidv4().substring(0, 2)}}`;
+const multipleBedName = `Multi-${uuidv4().substring(0, 2)}`;

Likely invalid or redundant comment.

cypress/e2e/facility_spec/FacilityLocation.cy.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (5)
cypress/e2e/facility_spec/FacilityHomepage.cy.ts (1)

Line range hint 1-215: Consider architectural improvements for better maintainability.

The test suite could benefit from the following improvements:

  1. Extract repeated setup code (like filter selections) into shared helper functions
  2. Move magic strings (like "Dummy Facility 40", error messages) to a constants file
  3. Split the test file into smaller, more focused files (e.g., separate files for facility search, notifications, exports)
  4. Follow the single responsibility principle for test cases (e.g., separate facility details navigation from live monitoring tests)

Would you like me to provide specific examples of how to implement these improvements?

cypress/pageobject/Facility/FacilityLocation.ts (1)

16-26: Consider adding a TypeScript interface for location details.

The method is well-structured with optional parameters, but could benefit from a dedicated interface to improve type safety and documentation.

interface LocationDetails {
  name?: string;
  description?: string;
  type?: string;
  middleware?: string;
}

fillLocationDetails(details: LocationDetails) {
  if (details.name) this.typeLocationName(details.name);
  if (details.description) this.fillDescription(details.description);
  if (details.type) this.selectLocationType(details.type);
  if (details.middleware) this.fillMiddlewareAddress(details.middleware);
}
cypress/pageobject/Asset/AssetCreation.ts (1)

35-81: Consider using a parameter object pattern for better maintainability.

The method has many optional parameters which could be better organized using a parameter object pattern.

interface AssetDetails {
  name?: string;
  description?: string;
  workingStatus?: string;
  qrId?: string;
  manufacturer?: string;
  warranty?: string;
  support?: {
    name?: string;
    phone?: string;
    email?: string;
  };
  vendor?: {
    name?: string;
  };
  serialNumber?: string;
  lastServicedOn?: string;
  notes?: string;
}

enterAssetDetails(details: AssetDetails) {
  if (details.name) cy.get("[data-testid=asset-name-input] input").type(details.name);
  if (details.description) cy.get("[data-testid=asset-description-input] textarea").type(details.description);
  // ... rest of the implementation
}
cypress/e2e/facility_spec/FacilityLocation.cy.ts (2)

59-64: Consider removing undefined parameters for better readability.

The fillLocationDetails call includes multiple undefined parameters that could be omitted if the method supports default parameters.

-facilityLocation.fillLocationDetails(
-  locationName,
-  undefined,
-  locationType,
-  undefined,
-);
+facilityLocation.fillLocationDetails(locationName, null, locationType);

51-278: Consider extracting common test patterns into helper functions.

The test cases share common patterns for:

  • Location creation and cleanup
  • Bed creation and cleanup
  • Asset creation and cleanup

Consider creating helper functions to reduce code duplication and improve maintainability.

Example helper function:

const createAndVerifyLocation = (facilityName: string, locationName: string, locationType: string) => {
  facilityLocation.navigateToFacilityLocationManagement(facilityName);
  facilityLocation.clickAddNewLocationButton();
  facilityLocation.fillLocationDetails(locationName, null, locationType);
  facilityLocation.clickAddLocationButton();
  facilityLocation.verifyAddLocationSuccessfulMesssage();
};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 52796a2 and f1c80b3.

📒 Files selected for processing (5)
  • cypress/e2e/facility_spec/FacilityHomepage.cy.ts (1 hunks)
  • cypress/e2e/facility_spec/FacilityLocation.cy.ts (3 hunks)
  • cypress/e2e/users_spec/UsersCreation.cy.ts (2 hunks)
  • cypress/pageobject/Asset/AssetCreation.ts (1 hunks)
  • cypress/pageobject/Facility/FacilityLocation.ts (5 hunks)
🧰 Additional context used
📓 Learnings (2)
cypress/pageobject/Facility/FacilityLocation.ts (1)
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9145
File: cypress/e2e/facility_spec/FacilityCreation.cy.ts:177-180
Timestamp: 2024-11-18T10:44:30.303Z
Learning: In `cypress/e2e/facility_spec/FacilityCreation.cy.ts`, when testing bed and staff capacity individually for additional error verification, we prefer to use separate method calls to handle bed and staff capacity, rather than using `facilityPage.createNewFacility(testFacilityData)` which also handles bed management.
cypress/e2e/facility_spec/FacilityLocation.cy.ts (1)
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9145
File: cypress/e2e/facility_spec/FacilityCreation.cy.ts:177-180
Timestamp: 2024-11-18T10:44:30.303Z
Learning: In `cypress/e2e/facility_spec/FacilityCreation.cy.ts`, when testing bed and staff capacity individually for additional error verification, we prefer to use separate method calls to handle bed and staff capacity, rather than using `facilityPage.createNewFacility(testFacilityData)` which also handles bed management.
🔇 Additional comments (10)
cypress/e2e/facility_spec/FacilityHomepage.cy.ts (2)

183-185: 🛠️ Refactor suggestion

Improve test reliability by avoiding fixed waits.

The cy.wait(2000) before closing the modal could lead to flaky tests. Instead:

  1. Wait for specific UI elements or network requests to complete
  2. Use Cypress's built-in retry-ability and assertions

Replace the fixed wait with a more reliable approach:

-    cy.wait(2000);
-    cy.clickCancelButton("Cancel");
+    // Wait for the notification to be fully displayed
+    cy.get('.notification').should('be.visible');
+    // Ensure the modal is in a closeable state
+    cy.get('.modal-dialog').should('be.visible')
+      .and('not.have.class', 'loading');
+    cy.clickCancelButton("Cancel");
+    // Verify the modal is actually closed
+    cy.get('.modal-dialog').should('not.exist');

Likely invalid or redundant comment.


184-184: LGTM! Consider standardizing other modal interactions.

The change to use cy.clickCancelButton("Cancel") is a good improvement as it:

  • Uses a standardized Cypress command for modal interactions
  • Makes the test more maintainable and readable
  • Reduces dependency on page object methods

Let's verify if there are other modal interactions that could be standardized:

✅ Verification successful

Modal interaction standardization is already in progress

The change to use cy.clickCancelButton() is part of an ongoing standardization effort:

  • The command is properly implemented in cypress/support/commands.ts with a consistent approach
  • It's already being used in multiple places: HcxClaims, FacilityHomepage, and FacilityLocation
  • The remaining modal interactions in FacilityNotify are for different operations (input/verification) rather than modal dismissal
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for potential modal interaction patterns that could be standardized
rg -l 'verifyAndCloseNotifyModal|closeModal|dismissModal' 'cypress/e2e' 'cypress/pageobject'

# Search for existing usage of clickCancelButton to ensure consistency
rg 'cy\.clickCancelButton' 'cypress/e2e' 'cypress/pageobject'

Length of output: 384


Script:

#!/bin/bash
# Let's search for modal-related patterns in the codebase to understand the full context
rg -A 3 'verifyAndCloseNotifyModal|closeModal|dismissModal|Modal\.close|Modal\.dismiss' 'cypress/e2e' 'cypress/pageobject'

# Also search for any custom commands related to modal interactions
rg -A 3 'Cypress\.Commands\.add.*[Mm]odal' 'cypress/support'

Length of output: 181


Script:

#!/bin/bash
# Let's try a broader search for modal-related code
rg -A 3 -i 'modal' 'cypress/pageobject' 'cypress/e2e'

# Also search for the implementation of clickCancelButton command
rg -A 3 'clickCancelButton' 'cypress/support'

Length of output: 1441

cypress/pageobject/Facility/FacilityLocation.ts (2)

8-14: LGTM! Well-structured navigation method.

The method effectively encapsulates the navigation steps using page object methods, improving code reusability and maintainability.


113-120: LGTM! Well-implemented bed management interaction.

The method properly scopes the element selection using within() and uses clear selectors.

cypress/e2e/users_spec/UsersCreation.cy.ts (1)

139-139: LGTM! Good migration to custom Cypress commands.

The change from page object method to custom Cypress command cy.verifyErrorMessages improves consistency and follows Cypress best practices.

Also applies to: 180-180

cypress/e2e/facility_spec/FacilityLocation.cy.ts (5)

Line range hint 1-40: LGTM! Well-structured test setup.

The import statements are properly organized, and the test setup includes appropriate viewport configuration and localStorage management.


122-127: Consider removing undefined parameters for better readability.

Similar to the previous test, the fillLocationDetails call includes unnecessary undefined parameters.


160-160: ⚠️ Potential issue

Fix syntax error in template string.

There's an extra closing brace in the template string for locationModifiedName.

-const locationModifiedName = `ICU-${uuidv4().substring(0, 2)}}`;
+const locationModifiedName = `ICU-${uuidv4().substring(0, 2)}`;

Likely invalid or redundant comment.


217-217: ⚠️ Potential issue

Fix syntax error in template string.

There's an extra closing brace in the template string for multipleBedName.

-const multipleBedName = `Multi-${uuidv4().substring(0, 2)}}`;
+const multipleBedName = `Multi-${uuidv4().substring(0, 2)}`;

Likely invalid or redundant comment.


275-278: 🛠️ Refactor suggestion

Verify the number of beds created.

The test creates multiple beds but doesn't verify if all beds were created successfully. Consider adding verification for the number of beds.

 facilityLocation.clickSubmitBedsButton();
+// Verify all beds were created
+cy.get('[data-testid="bed-card"]').should('have.length', numberOfBeds);
 // Verify Pagination in the page
 pageNavigation.navigateToNextPage();

cypress/e2e/facility_spec/FacilityLocation.cy.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (1)
cypress/e2e/facility_spec/FacilityLocation.cy.ts (1)

78-79: Consider using assetPage method for notification verification.

For consistency with other asset-related operations, consider encapsulating the notification verification within the AssetPage class.

-cy.verifyNotification("Asset created successfully");
-cy.closeNotification();
+assetPage.verifySuccessNotification("Asset created successfully");
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f1c80b3 and fb1d9eb.

📒 Files selected for processing (3)
  • cypress/e2e/assets_spec/AssetsCreation.cy.ts (3 hunks)
  • cypress/e2e/facility_spec/FacilityLocation.cy.ts (3 hunks)
  • cypress/pageobject/Asset/AssetCreation.ts (1 hunks)
🧰 Additional context used
📓 Learnings (1)
cypress/e2e/facility_spec/FacilityLocation.cy.ts (1)
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9145
File: cypress/e2e/facility_spec/FacilityCreation.cy.ts:177-180
Timestamp: 2024-11-18T10:44:30.303Z
Learning: In `cypress/e2e/facility_spec/FacilityCreation.cy.ts`, when testing bed and staff capacity individually for additional error verification, we prefer to use separate method calls to handle bed and staff capacity, rather than using `facilityPage.createNewFacility(testFacilityData)` which also handles bed management.
🔇 Additional comments (8)
cypress/e2e/facility_spec/FacilityLocation.cy.ts (6)

Line range hint 1-37: LGTM! Clean import structure and well-organized constants.

The imports are properly organized and the test constants are well-defined with clear, descriptive names.


51-102: LGTM! Well-structured test with proper cleanup.

The test thoroughly verifies the business logic for location deletion with linked assets, including proper setup and cleanup steps.


104-145: LGTM! Well-implemented test for bed-related constraints.

The test properly verifies location deletion constraints when beds are present, with appropriate setup and cleanup steps.


202-268: LGTM! Comprehensive bed management test.

The test thoroughly covers all aspects of bed management including single bed creation, multiple beds, duplication handling, and pagination.


150-150: ⚠️ Potential issue

Fix syntax error in template string.

There's an extra closing brace in the template string for locationModifiedName.

-const locationModifiedName = `ICU-${uuidv4().substring(0, 2)}}`;
+const locationModifiedName = `ICU-${uuidv4().substring(0, 2)}`;

Likely invalid or redundant comment.


207-207: ⚠️ Potential issue

Fix syntax error in template string.

There's an extra closing brace in the template string for multipleBedName.

-const multipleBedName = `Multi-${uuidv4().substring(0, 2)}}`;
+const multipleBedName = `Multi-${uuidv4().substring(0, 2)}`;

Likely invalid or redundant comment.

cypress/pageobject/Asset/AssetCreation.ts (1)

34-95: LGTM! Well-structured refactor of enterAssetDetails method.

The refactoring to use an object parameter with optional properties improves code maintainability and readability. The implementation properly handles conditional typing of each field.

cypress/e2e/assets_spec/AssetsCreation.cy.ts (1)

Line range hint 46-156: LGTM! Properly updated to use new enterAssetDetails structure.

The test cases have been correctly updated to use the new object parameter structure for enterAssetDetails, maintaining consistency throughout the file.

Comment on lines +34 to +62
enterAssetDetails({
name,
description,
workingStatus,
qrId,
manufacturer,
warranty,
supportName,
supportPhone,
supportEmail,
vendorName,
serialNumber,
lastServicedOn,
notes,
}: {
name?: string;
description?: string;
workingStatus?: string;
qrId?: string;
manufacturer?: string;
warranty?: string;
supportName?: string;
supportPhone?: string;
supportEmail?: string;
vendorName?: string;
serialNumber?: string;
lastServicedOn?: string;
notes?: string;
}) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to separate out the type, so it could be reused something like AssetCreateForm.

This can be done later too when needed.

@khavinshankar khavinshankar merged commit 3b04654 into develop Dec 5, 2024
61 checks passed
@khavinshankar khavinshankar deleted the location-manage-test branch December 5, 2024 04:54
Copy link

github-actions bot commented Dec 5, 2024

@nihal467 Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants