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

Restructured the cy.viewport usage to more reusable way #11031

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

nihal467
Copy link
Member

@nihal467 nihal467 commented Mar 5, 2025

Proposed Changes

@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

  • Tests
    • Enhanced viewport configurations for end-to-end tests by replacing fixed dimensions with dynamic, centrally managed values.
    • Centralized common screen resolutions to improve consistency and maintainability during simulated device testing.

@nihal467 nihal467 requested a review from a team as a code owner March 5, 2025 07:31
Copy link
Contributor

coderabbitai bot commented Mar 5, 2025

Walkthrough

The pull request centralizes viewport configuration for Cypress E2E tests. A new file (cypress/utils/viewPort.ts) introduces a constant object with predefined viewport dimensions. Four test files have been updated to import this object and use its dynamic properties in the cy.viewport calls within their beforeEach hooks, replacing the previously hardcoded values.

Changes

File(s) Change Summary
cypress/e2e/facility_spec/…/facility_creation.cy.ts,
cypress/e2e/patient_spec/…/patient_details.cy.ts
Replaced hardcoded viewport dimensions with dynamic values from viewPort.laptopStandard and added the corresponding import statement.
cypress/e2e/patient_spec/…/patient_creation.cy.ts Updated viewport settings by replacing fixed dimensions with dynamic values from viewPort.desktop1080p and viewPort.desktop2k, along with adding the import.
cypress/e2e/patient_spec/…/patient_encounter.cy.ts Replaced fixed viewport dimensions with dynamic values from viewPort.desktop1080p and added the import statement.
cypress/utils/viewPort.ts New file defining a constant object with predefined viewport dimensions for various screen resolutions.

Sequence Diagram(s)

sequenceDiagram
    participant TS as Test Suite
    participant VP as viewPort Module
    participant CY as Cypress

    TS->>VP: Import viewport configuration
    VP-->>TS: Provide dynamic dimensions (e.g., width, height)
    TS->>CY: Call cy.viewport(dynamic width, dynamic height)
    CY-->>TS: Sets viewport using provided dimensions
Loading

Possibly related PRs

Suggested labels

needs review, tested

Suggested reviewers

  • rithviknishad
  • khavinshankar

Poem

I'm a little bunny, hopping through the code,
No more fixed viewports on my testing road.
Dynamic values now make my tests so sweet,
Centralized configs keep my pace upbeat.
With a twitch of my nose, success is in sight!
🐇 Happy coding under the moonlit light!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2cc959e and b1a22f5.

📒 Files selected for processing (5)
  • cypress/e2e/facility_spec/facility_creation.cy.ts (2 hunks)
  • cypress/e2e/patient_spec/patient_creation.cy.ts (2 hunks)
  • cypress/e2e/patient_spec/patient_details.cy.ts (1 hunks)
  • cypress/e2e/patient_spec/patient_encounter.cy.ts (1 hunks)
  • cypress/utils/viewPort.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • cypress/utils/viewPort.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)
🔇 Additional comments (8)
cypress/e2e/patient_spec/patient_details.cy.ts (2)

4-4: Good addition of centralized viewport configuration.

Adding the import for the viewPort utility improves code maintainability by centralizing viewport configurations.


12-12: Good refactoring of hardcoded viewport values.

Replacing hardcoded viewport dimensions with the centralized configuration from viewPort.laptopStandard improves maintainability and consistency across tests.

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

4-4: Good addition of centralized viewport configuration.

Adding the import for the viewPort utility improves code maintainability by centralizing viewport configurations.


18-18: Good refactoring of hardcoded viewport values.

Replacing hardcoded viewport dimensions with the centralized configuration from viewPort.laptopStandard improves maintainability and consistency across tests.

cypress/e2e/patient_spec/patient_encounter.cy.ts (2)

3-3: Good addition of centralized viewport configuration.

Adding the import for the viewPort utility improves code maintainability by centralizing viewport configurations.


10-10: Good refactoring of hardcoded viewport values.

Replacing hardcoded viewport dimensions with the centralized configuration from viewPort.desktop1080p improves maintainability. I notice this test uses a different viewport preset (desktop1080p) compared to some other tests that use laptopStandard, which is fine as long as this is intentional for this specific test's requirements.

cypress/e2e/patient_spec/patient_creation.cy.ts (2)

14-14: Good addition of centralized viewport configuration.

Adding the import for the viewPort utility improves code maintainability by centralizing viewport configurations.


105-105:

❓ Verification inconclusive

Verify the mixed viewport configuration.

This test is using width from desktop1080p but height from desktop2k, which creates a non-standard viewport aspect ratio. Was this intentional or should it use consistent dimensions from a single preset?


🏁 Script executed:

#!/bin/bash
# Search for other instances of viewPort usage to check if mixing presets is common

echo "Checking for viewPort usage patterns in Cypress tests:"
rg -A 1 "cy\.viewport\(viewPort\." --type ts cypress/

echo "Checking for definition of viewPort object to understand available presets:"
rg "viewPort\s*=\s*" --type ts cypress/ || rg "export const viewPort" --type ts cypress/

Length of output: 1255


Action: Confirm Mixed Viewport Configuration

It appears that this test is using a mixed preset—using viewPort.desktop1080p.width for the width and viewPort.desktop2k.height for the height—while all other test files (e.g., patient_encounter.cy.ts and facility_creation.cy.ts) consistently use both dimensions from a single preset. Please verify if this deviation was intentional. If it wasn’t, consider modifying it to use a consistent preset (for example, viewPort.desktop1080p.width and viewPort.desktop1080p.height) for clarity and consistency.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ 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 generate docstrings to generate docstrings for this 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.

@nihal467 nihal467 changed the title Restructured the viewport usage to more reusable way Restructured the cy.viewport usage to more reusable way Mar 5, 2025
Copy link

netlify bot commented Mar 5, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit b1a22f5
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67c7fdd285127c00084fa2b0
😎 Deploy Preview https://deploy-preview-11031.preview.ohc.network
📱 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

Deploying care-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: b1a22f5
Status: ✅  Deploy successful!
Preview URL: https://4fa4a520.care-fe.pages.dev
Branch Preview URL: https://view-port.care-fe.pages.dev

View logs

Copy link

cypress bot commented Mar 5, 2025

CARE    Run #5067

Run Properties:  status check passed Passed #5067  •  git commit b1a22f5c3a: Restructured the viewport usage to more reusable way
Project CARE
Branch Review view-port
Run status status check passed Passed #5067
Run duration 07m 24s
Commit git commit b1a22f5c3a: Restructured the viewport usage to more reusable way
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 12
View all changes introduced in this branch ↗︎

@khavinshankar khavinshankar merged commit b519313 into develop Mar 5, 2025
26 checks passed
@khavinshankar khavinshankar deleted the view-port branch March 5, 2025 09:09
Copy link

github-actions bot commented Mar 5, 2025

@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! 🙌

Spandan-Mishra pushed a commit to Spandan-Mishra/ohcare_fe that referenced this pull request Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cypress: Test for multiple viewports
2 participants