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

chore(tests): Update RTL tests and misc improvements to helpers #7293

Merged
merged 5 commits into from
Jul 27, 2023

Conversation

maribethb
Copy link
Contributor

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide
  • I ran npm run format and npm run lint

The details

Resolves

Fixes an issue with RTL test in field_edit_tests where the test code was being executed before the page actually switched to RTL mode

Proposed Changes

  • Makes switchRTL pause in the browser before continuing to ensure RTL mode has loaded before continuing with the test
  • Added a missing await in the field edit tests so that that test does actually wait before continuing
  • Updates a helper function to use a selector including test instead of searching each category manually for text
  • Updates a random handful of locations to use waitForExist instead of pauses
  • Uses browser.pause instead of setTimeout in some places
  • awaits for browser.click() since that's how the examples do it
  • shortens some timeouts from 2000 to 200 ms

Behavior Before Change

field edit test wasn't actually running in rtl always

Behavior After Change

all tests pass, hopefully

Reason for Changes

Test Coverage

Documentation

Additional Information

@maribethb maribethb requested a review from a team as a code owner July 14, 2023 23:14
@github-actions github-actions bot added the PR: chore General chores (dependencies, typos, etc) label Jul 14, 2023
@@ -116,23 +116,14 @@ async function getBlockElementById(browser, id) {
/**
* @param browser The active WebdriverIO Browser object.
* @param categoryName The name of the toolbox category to find.
* @return A Promise that resolves to the root element of the toolbox
* category with the given name, as an interactable browser element.
* @return The root element of the toolbox category with the given name, as an interactable browser element.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was the previous doc wrong? As always, I'm shaky on Promises, but I thought that the return value of an async function is always a promise, and the only type question is what it resolves to.

If that's wrong, I also need to update the other functions in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, you're right, it does. I think I changed it because I added the await before returning so I was thinking the promise would be resolved before returning, but because it's async it just gets wrapped in another promise. @_@

Copy link
Collaborator

Choose a reason for hiding this comment

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

Cool--that matches my understanding.

tests/browser/test/test_setup.js Show resolved Hide resolved
@maribethb
Copy link
Contributor Author

This has been rebased and is ready for re-review

@@ -312,6 +303,7 @@ async function connect(
async function switchRTL(browser) {
const ltrForm = await browser.$('#options > select:nth-child(1)');
await ltrForm.selectByIndex(1);
browser.pause(500);
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing await

Copy link
Collaborator

@rachel-fenichel rachel-fenichel left a comment

Choose a reason for hiding this comment

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

lgtm once you add the missing await

@maribethb maribethb enabled auto-merge (squash) July 27, 2023 01:01
@maribethb maribethb merged commit 734b687 into google:develop Jul 27, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: chore General chores (dependencies, typos, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants