Skip to content

Fixing two flaky Cypress tests#4324

Merged
olemartinorg merged 2 commits into
mainfrom
chore/fix-cypress-flaky-tests
Jul 22, 2026
Merged

Fixing two flaky Cypress tests#4324
olemartinorg merged 2 commits into
mainfrom
chore/fix-cypress-flaky-tests

Conversation

@olemartinorg

@olemartinorg olemartinorg commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Description

I saw a few tests that were flaky:

  1. options.ts - this test would sometimes fail because the length was 2 already when the page had loaded. That's because Cypress itself was too late to start the assertions, because preselectedOptionIndex works immediately when the page loads. Removing those assertions, since it's impossible for them to become 2 without having been 1 at some point anyway.
  2. tabbing.ts - This test ran into a failure mode where the whole body would be focused. I saw this happened before preselectedOptionIndex and the option effects had run, so I'm adding some assertions to make it wait to begin tabbing until the page has properly loaded first.

Related Issue(s)

  • closes #{issue number}

Verification/QA

  • Manual functionality testing
    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests
    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)
    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs
    • Has been added/updated
    • No functionality has been changed/added, so no documentation is needed
    • I will do that later/have created an issue
  • Support in Altinn Studio
    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board
    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels
    • I have added a kind/* and backport* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

Summary by CodeRabbit

  • Tests
    • Improved end-to-end test reliability when loading reference options.
    • Reduced timing-related flakiness in the change-name form’s keyboard navigation test.
    • Updated option-selection test expectations to reflect refreshed option requests.

Ole Martin Handeland added 2 commits July 21, 2026 15:42
…y when the page had loaded. That's because Cypress itself was too late to start the assertions, because preselectedOptionIndex works immediately when the page loads. Removing those assertions, since it's impossible for them to become 2 without having been 1 at some point anyway...
…e focused. I saw this happened before preselectedOptionIndex and the option effects had run, so I'm adding some assertions to make it wait to begin tabbing until the page has properly loaded first.
@olemartinorg olemartinorg added ignore-for-release Pull requests to be ignored in release notes backport-ignore This PR is a new feature and should not be cherry-picked onto release branches labels Jul 21, 2026
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a372a6e2-76af-470a-9c79-18d55aeac28b

📥 Commits

Reviewing files that changed from the base of the PR and between afdd6e6 and d0a04c9.

📒 Files selected for processing (2)
  • test/e2e/integration/frontend-test/options.ts
  • test/e2e/integration/frontend-test/tabbing.ts

📝 Walkthrough

Walkthrough

Two frontend end-to-end tests were updated: one relaxes initial option-fetch assertions, and the other waits for reference data to load before continuing.

Changes

Frontend E2E test updates

Layer / File(s) Summary
Option request assertion update
test/e2e/integration/frontend-test/options.ts
Removes initial option request count assertions while retaining verification of the preselected Altinn source.
Reference fetch synchronization
test/e2e/integration/frontend-test/tabbing.ts
Intercepts and waits for the references API request after navigating to the change-name form.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: fixing two flaky Cypress tests.
Description check ✅ Passed The description follows the template and fills the QA sections; only the related issue placeholder needs a real issue number.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/fix-cypress-flaky-tests

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

Comment @coderabbitai help to get the list of available commands.

@lassopicasso lassopicasso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice fix 🚀

@olemartinorg
olemartinorg merged commit 6ec2e34 into main Jul 22, 2026
15 checks passed
@olemartinorg
olemartinorg deleted the chore/fix-cypress-flaky-tests branch July 22, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-ignore This PR is a new feature and should not be cherry-picked onto release branches ignore-for-release Pull requests to be ignored in release notes

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants