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

fix: Focus retention on inputs #36770

Merged
merged 14 commits into from
Oct 9, 2024
Merged

Conversation

hetunandu
Copy link
Member

@hetunandu hetunandu commented Oct 9, 2024

Description

Fix focus retention tests

Fixes #36673

Automation

/ok-to-test tags="@tag.IDE"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11248761306
Commit: 0638436
Cypress dashboard.
Tags: @tag.IDE
Spec:


Wed, 09 Oct 2024 06:49:03 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • Bug Fixes

    • Improved focus retention during entity selection in the editor.
    • Streamlined interaction with the left pane for selecting entities.
  • Tests

    • Updated test suite for focus retention, enhancing clarity and accuracy of test cases.
    • Removed redundant test case for tab persistence, renumbered remaining tests for better organization.

Copy link
Contributor

coderabbitai bot commented Oct 9, 2024

Walkthrough

The pull request modifies the test suite for focus retention in the application. It updates the test suite name and alters the methods used for selecting entities, emphasizing the left pane interaction. The before hook is changed to navigate to the home page, and the test cases are renumbered with some focus checks updated. The test case for checking tab persistence is removed, and new methods are added to streamline entity selection and interaction with the property pane.

Changes

File Path Change Summary
app/client/cypress/e2e/Regression/ClientSide/IDE/Focus_retentions_inputs_spec.js Updated test suite name and descriptions, modified selection methods, and removed a test case.
src/support/Pages/EditorNavigation.js Added methods: selectItem(entityName), switchSegment(segment), and PagePaneSegment.

Assessment against linked issues

Objective Addressed Explanation
Focus retention in the inputs is not consistent (#36673)

Possibly related issues

Possibly related PRs

Suggested labels

Bug, ok-to-test, IDE Product, IDE Pod, IDE Navigation, Test

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007

🎉 In the realm of code, where tests do play,
Focus retention shines bright today.
With methods refined and structure anew,
The editor's dance is smoother for you.
So let us rejoice in this testing spree,
For clarity and focus, we now decree! 🎉


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.

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.

@hetunandu hetunandu added the ok-to-test Required label for CI label Oct 9, 2024
@github-actions github-actions bot added Bug Something isn't working IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Low An issue that is neither critical nor breaks a user flow Needs Triaging Needs attention from maintainers to triage Production labels Oct 9, 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: 0

🧹 Outside diff range and nitpick comments (3)
app/client/cypress/e2e/Regression/ClientSide/IDE/Focus_retentions_inputs_spec.js (3)

50-50: Good job updating the test case with new methods!

Class, let's look at how your classmate has improved this test case. They've replaced EditorNavigation.SelectEntityByName() with PageLeftPane.selectItem(). This is like using a more precise tool in our science experiments. It's clearer and easier to understand.

However, I have a small suggestion to make it even better:

Consider adding a short comment before each PageLeftPane.selectItem() call to explain what entity is being selected. This will help your classmates understand the test flow more easily.

For example:

// Select REST API 1
PageLeftPane.selectItem("Rest_Api_1");

Keep up the good work!

Also applies to: 57-57, 64-64, 69-69, 79-81, 87-87


103-104: Excellent work on improving the second test case!

Class, pay attention to how your classmate has enhanced this test case. They've used PageLeftPane.switchSegment() and PageLeftPane.selectItem() to navigate through different parts of the application. This is like following a clear map in our classroom experiments.

The new assertions using agHelper.GetElement() are like double-checking our results, which is very important in scientific testing.

However, I have a small suggestion to make it even better:

Consider adding a short wait time after each PageLeftPane.selectItem() call to ensure the UI has fully updated before making assertions. You can use cy.wait(1000) for this. For example:

PageLeftPane.selectItem("Rest_Api_1");
cy.wait(1000); // Wait for UI to update
agHelper.GetElement(locators._queryName).should("have.text", "Rest_Api_1");

This will make our tests more reliable, just like how we wait for our chemical reactions to complete before observing the results. Keep up the excellent work!

Also applies to: 106-110, 119-132, 142-144, 151-151, 158-158, 161-161, 165-165


Line range hint 179-195: Good effort on the fourth test case, but let's make it even better!

Class, your classmate has made some good improvements to this test case. They've used EditorNavigation.SelectEntityByName() for selecting queries, which is consistent with our previous examples. The new assertions using agHelper.GetElement() are like double-checking our experiment results, which is excellent scientific practice.

However, I've noticed something we need to improve. Can anyone spot the issue? That's right - we're using xpath selectors in a few places. Remember our class rule: we should avoid using xpath selectors. Let's fix this together:

  1. Replace cy.xpath(queryLocators.querySettingsTab) with a more appropriate selector, preferably using data-* attributes.
  2. Instead of cy.xpath(queryLocators.queryTimeout), let's use a more reliable selector.

For example:

cy.get('[data-cy="query-settings-tab"]').click();
cy.get('[data-cy="query-timeout-input"]').should("be.focused");

By making these changes, our test will be more robust and easier to maintain, just like keeping our lab equipment in good condition. Keep up the good work, and remember to always follow our class rules!

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a4f9905 and 0638436.

📒 Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ClientSide/IDE/Focus_retentions_inputs_spec.js (8 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/client/cypress/e2e/Regression/ClientSide/IDE/Focus_retentions_inputs_spec.js (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
🔇 Additional comments (5)
app/client/cypress/e2e/Regression/ClientSide/IDE/Focus_retentions_inputs_spec.js (5)

9-11: Well done on updating the imports and test suite description!

Class, I'm pleased to see that you've made some thoughtful changes to the imports and the test suite description. The new imports for PageLeftPane and PagePaneSegment will be useful for our upcoming lessons on page navigation. The updated test suite name, "Focus Retention of Inputs," is much clearer and tells us exactly what we're testing. Good job on adding the @tag.IDE tag too - it's like putting the right label on your notebook!

Also applies to: 17-17


19-20: Excellent simplification of the test setup!

Children, take note of how your classmate has simplified the test setup. Instead of creating a new workspace, we're now using homePage.NavigateToHome(). This is like starting with a clean slate before each test, which is very important in our experiments. It's a great example of keeping things simple and following our class rules for Cypress tests. Well done!


Line range hint 170-177: Good job on updating the third test case!

Class, let's appreciate how your classmate has updated this test case. They've used EditorNavigation.SelectEntityByName() consistently for selecting datasources. This is like using the same measuring tool throughout an experiment, which helps us avoid confusion.

The test flow is clear and easy to follow, just like a well-written lab report. It checks if the datasource edit mode is maintained correctly, which is an important detail in our application.

Keep up the good work! Your attention to consistency is commendable.


Line range hint 197-211: Excellent work on the fifth test case!

Class, let's give a round of applause to your classmate for this well-crafted test case. They've done a fantastic job addressing two specific bugs: maintaining focus when the Escape key is pressed with autocomplete open, and when it's pressed in general.

The use of EditorNavigation.SelectEntityByName() for JSObject selection is consistent with our previous examples, which is great. It's like using the same scientific method across different experiments.

I'm particularly impressed with the use of cy.assertCursorOnCodeInput(). This is a very precise way of checking where our cursor is, just like using a microscope to observe tiny details in our lab work.

The step-by-step approach in this test case is clear and logical:

  1. Select the JSObject
  2. Assert the initial cursor position
  3. Type some text
  4. Check for autocomplete
  5. Press Escape and verify cursor position
  6. Press Escape again and verify cursor position

This methodical approach is exactly what we want to see in our scientific tests. Well done!


Line range hint 1-211: Overall, excellent improvements to our focus retention tests!

Class, let's take a moment to appreciate the hard work your classmate has put into improving these tests. They've made significant enhancements that will make our test suite more reliable and easier to maintain.

Here's a summary of the key improvements:

  1. Updated imports and test descriptions for better clarity
  2. Simplified test setup using homePage.NavigateToHome()
  3. Consistent use of PageLeftPane.selectItem() and PageLeftPane.switchSegment() for navigation
  4. Added more precise assertions using agHelper.GetElement()
  5. Addressed specific bug fixes related to focus retention

These changes are like upgrading our lab equipment - they'll help us conduct more accurate and efficient experiments in the future.

However, remember that there's always room for improvement:

  1. Consider adding short comments before entity selections for better readability
  2. Add small wait times after selections to ensure UI updates
  3. Replace xpath selectors with more reliable data-* attributes

Keep up the excellent work, and remember: in the world of testing, attention to detail is our best friend!

@hetunandu hetunandu enabled auto-merge (squash) October 9, 2024 10:02
@hetunandu hetunandu merged commit 7f31c9e into release Oct 9, 2024
46 checks passed
@hetunandu hetunandu deleted the fix/maintain-focus-retention-test branch October 9, 2024 10:03
@coderabbitai coderabbitai bot mentioned this pull request Oct 9, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Low An issue that is neither critical nor breaks a user flow Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Production
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Focus retention in the inputs is not consistent
2 participants