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

Cypress Test for language selection and link redirection #9488

Closed
wants to merge 2 commits into from

Conversation

Kaushikgtm
Copy link

@Kaushikgtm Kaushikgtm commented Dec 18, 2024

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

  • New Features

    • Enhanced language selection and verification functionality on the login page.
    • New test cases to verify redirection links and localization of UI elements.
    • Support for multiple languages including Tamil, Malayalam, Marathi, Kannada, and Hindi.
  • Bug Fixes

    • Improved reliability of redirection links and sidebar item visibility across different languages.

@Kaushikgtm Kaushikgtm requested a review from a team as a code owner December 18, 2024 15:32
Copy link
Contributor

coderabbitai bot commented Dec 18, 2024

Walkthrough

This pull request enhances the Cypress testing suite by adding comprehensive language selection and link redirection tests for the login page. The changes focus on implementing new test cases in the redirect.cy.ts file and expanding the LoginPage page object with methods to verify language-specific functionalities. The modifications include testing GitHub link redirection, third-party license link verification, language switching, and validating localized button and sidebar texts across multiple languages.

Changes

File Change Summary
cypress/e2e/homepage_spec/redirect.cy.ts - Added locale imports for multiple languages (Tamil, Malayalam, Marathi, Kannada, Hindi)
- Created languageMappings and languageSidebars objects
- Updated beforeEach hook
- Added new test cases for link redirection and language switching
cypress/pageobject/Login/LoginPage.ts - Added LanguageMapping interface
- Introduced new methods for language selection and verification
- Added methods for clicking GitHub and license links
- Implemented language switching and text verification methods

Assessment against linked issues

Objective Addressed Explanation
Verify "Contribute on GitHub" link redirection [#9017]
Verify "Third Party Software License" link redirection [#9017]
Switch languages and verify login button text [#9017]
Verify sidebar items in selected languages [#9017]

Possibly related PRs

Suggested labels

needs review, tested

Suggested reviewers

  • nihal467
  • rithviknishad

Poem

🐰 A Rabbit's Test of Linguistic Delight

Clicking links with Cypress might,
Languages dancing left and right,
GitHub, licenses take their flight,
Buttons change with linguistic might,
Our tests now shine so very bright! 🌈

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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 18, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit d954b39
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/6762eb1b4813bc0008351a0e
😎 Deploy Preview https://deploy-preview-9488--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
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

🧹 Nitpick comments (3)
cypress/pageobject/Login/LoginPage.ts (2)

13-14: Remove trailing whitespace.
According to the static analysis hints, there's extra whitespace on line 14. Please run your formatter or linter to fix it.

🧰 Tools
🪛 eslint

[error] 14-14: Delete ·

(prettier/prettier)


112-128: Robust iteration for verifying button text per language.
The logic thoroughly checks each language's option and corresponding login text, enhancing test coverage. Consider also verifying that any necessary page transition or re-render is fully completed, such as waiting on a relevant API call, if the language switch triggers back-end requests.

🧰 Tools
🪛 eslint

[error] 112-112: Delete ··

(prettier/prettier)

cypress/e2e/homepage_spec/redirect.cy.ts (1)

50-57: Verification of 'Contribute on GitHub' redirect.
Simple and effective. Consider adding an assertion to confirm navigation to the correct domain if the subpath or domain changes in the future.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4a560f4 and d954b39.

📒 Files selected for processing (2)
  • cypress/e2e/homepage_spec/redirect.cy.ts (2 hunks)
  • cypress/pageobject/Login/LoginPage.ts (2 hunks)
🧰 Additional context used
🪛 eslint
cypress/pageobject/Login/LoginPage.ts

[error] 14-14: Delete ·

(prettier/prettier)


[error] 102-102: Delete ··

(prettier/prettier)


[error] 109-109: Delete ··

(prettier/prettier)


[error] 112-112: Delete ··

(prettier/prettier)


[error] 129-129: Delete ·

(prettier/prettier)


[error] 135-135: Delete ·

(prettier/prettier)

🔇 Additional comments (13)
cypress/pageobject/Login/LoginPage.ts (5)

3-10: Interface definition looks good.
This interface provides a clear structure for mapping language codes to localization text.


102-108: GitHub and License link methods are consistent.
Functions for redirecting to external pages look straightforward. Ensure proper handling of external link changes or potential cross-origin issues if the URLs ever change.

🧰 Tools
🪛 eslint

[error] 102-102: Delete ··

(prettier/prettier)


109-111: selectLanguage method is straightforward.
It uses the selector to pick a language code, adhering to Cypress best practices.

🧰 Tools
🪛 eslint

[error] 109-109: Delete ··

(prettier/prettier)


129-134: Private method for sidebar verification is neat.
Encapsulating sidebar checks promotes reusability.

🧰 Tools
🪛 eslint

[error] 129-129: Delete ·

(prettier/prettier)


135-150: Well-structured language switch for sidebars.
Mirrors the approach used for the login button, ensuring uniform coverage across UI elements.

🧰 Tools
🪛 eslint

[error] 135-135: Delete ·

(prettier/prettier)

cypress/e2e/homepage_spec/redirect.cy.ts (8)

2-6: Locale imports broaden test coverage.
Excellent coverage for multi-language tests. Ensure the JSON files exist in the specified paths to avoid missing file errors.


8-8: Consolidating locales in a single object.
This is an efficient approach to manage multiple languages programmatically.


11-13: languageMappings usage.
Generating language mappings dynamically is a succinct approach for verifying the login button text across languages.


15-20: Sidebar text mappings.
Similarly, grouping sidebar texts is a good way to organize localized content for tests.


24-24: Awaiting page load with 'cy.awaitUrl("/", true)'.
This ensures a stable state before continuing tests, reducing flaky tests.


59-65: Checks for third-party license link.
This test complements your link coverage.


67-73: Switching languages for login button.
Repeating the approach from your page object fosters DRY. Verifying text across multiple languages is a key step in i18n testing.


74-84: Sidebar items language verification.
This scenario thoroughly confirms that the sidebars adapt correctly to the chosen language.

@rithviknishad
Copy link
Member

#9258 (comment)

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.

Add New cypress Test for language selection and link redirection
2 participants