fix: add timeout and navigation wait for account creation test#135
Open
circleci-app[bot] wants to merge 2 commits intomainfrom
Open
fix: add timeout and navigation wait for account creation test#135circleci-app[bot] wants to merge 2 commits intomainfrom
circleci-app[bot] wants to merge 2 commits intomainfrom
Conversation
## Chunk™ has come up with the following:
- **Root cause:** The test "User can create account redirected to home" was failing due to a race condition where `cy.url().should('include', '/home')` executed before navigation completed after account creation. The `createAccount` command submitted the signup form but didn't wait for the backend signup process or redirect to finish, causing intermittent failures depending on server response times.
- **Proposed fix:** Added explicit 10-second timeout to the URL assertion in `create.cy.js:95` and added a navigation completion wait in the `createAccount` command in `commands.js:62` that waits for the URL to change from `/signup`, ensuring the signup process completes before subsequent assertions.
- **Verification:** Unable to run verification tests, so confidence in this fix is limited. Go to [Chunk settings](https://app.circleci.com/settings/organization/gh/AwesomeCICD/agents) to set up a `.circleci/cci-agent-setup.yml` file to ensure tests can be executed in subsequent runs. Read more in our [docs](https://discuss.circleci.com/t/product-launch-chunk-tasks-fixing-flaky-tests/53975/3#p-107197-unable-to-run-verification-tests-10)
**Root cause:** The `createAccount` Cypress command always waited for the URL to change away from `/signup`, which caused tests that expected to stay on the signup page (e.g., validation failure tests) to fail.
**Fix approach:** Modified the `createAccount` command to accept an optional `options` parameter with a `waitForNavigation` flag. When set to `false`, the command skips the URL change assertion, allowing tests for invalid form submissions to properly verify that the page stays on `/signup`.
**Changes made:**
- Updated `createAccount` command in `cypress/support/commands.js` to accept an optional `options` parameter
- Added conditional logic to only wait for navigation when `waitForNavigation !== false`
- Updated two test suites in `cypress/e2e/create.cy.js` to pass `{ waitForNavigation: false }` for invalid signup scenarios:
- "Signup is unsuccessful with 16 character username"
- "Signup is unsuccessful with non-alphanumeric username"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Chunk™ has come up with the following:
Root cause: The test "User can create account redirected to home" was failing due to a race condition where
cy.url().should('include', '/home')executed before navigation completed after account creation. ThecreateAccountcommand submitted the signup form but didn't wait for the backend signup process or redirect to finish, causing intermittent failures depending on server response times.Proposed fix: Added explicit 10-second timeout to the URL assertion in
create.cy.js:95and added a navigation completion wait in thecreateAccountcommand incommands.js:62that waits for the URL to change from/signup, ensuring the signup process completes before subsequent assertions..circleci/cci-agent-setup.ymlfile to ensure tests can be executed in subsequent runs. Read more in our docs Chunk™ also triggered a CI pipeline to check for other regressions.Previous CI run where test flaked
More Details
View more about this proposed fix in the CircleCI web app →
Chunk™ Feedback
Want to give feedback to make these PRs better? Click here →