Skip to content

Fix unstable concept page tests (mapping headers and copy functionality)#1906

Merged
miguelvaara merged 9 commits intomainfrom
issue1904-stabilize-the-unstable-behavior-of-mappings-tests-related-to-the-concept-page
Jan 28, 2026
Merged

Fix unstable concept page tests (mapping headers and copy functionality)#1906
miguelvaara merged 9 commits intomainfrom
issue1904-stabilize-the-unstable-behavior-of-mappings-tests-related-to-the-concept-page

Conversation

@miguelvaara
Copy link
Contributor

@miguelvaara miguelvaara commented Jan 20, 2026

Reasons for creating this PR

Inconsistently behaving tests make development harder and reduce confidence in the test results which can eventually impact the quality of the code and the application.

Link to relevant issue(s), if any

Description of the changes in this PR

Mostly added timeouts in appropriate places to ensure elements are fully loaded before being asserted and improved robustness and explicitness (e.g. .invoke())

Known problems or uncertainties in this PR

Checklist

  • phpUnit tests pass locally with my changes
  • I have added tests that show that the new code works, or tests are not relevant for this PR (e.g. only HTML/CSS changes)
  • The PR doesn't reduce accessibility of the front-end code (e.g. tab focus, scaling to different resolutions, use of .sr-only class, color contrast)
  • The PR doesn't introduce unintended code changes (e.g. empty lines or useless reindentation)

…ues in the output, not just pass/fail status, even when the test passes so that it is possible to observe what happens in cases of timeouts and incomplete strings
…for spinners and mapping properties and also add heading verification and wait fors for partial loads related to the Notation Clipboard
@miguelvaara
Copy link
Contributor Author

Notes and clarifications for the reviewer

Mapping-related tests were failing rather often with AssertionError.

Why? The object tested strings but a null was given (the issue was identified after temporarily adding logging).

The cause: race conditions in partial page loads where DOM elements were accessed before fully loaded.

Changes Made

concept-full-vs-partial.cy.js

  • Notation clipboard test
    Lines 79-81
    Ensures partial page load completes before copying notation. Previously copied wrong value (33.10 instead of 33.2).

  • Mapping stabilization wait
    Lines 150, 153-155
    Prevents race condition where mappings reload after initial spinner check.

  • Explicit mapping label wait
    Lines 160-161
    Ensures mapping labels exist before accessing their content.

  • Changed .contains() to .invoke('text').should('contain')
    Lines 158, 164, 166, 171 an 173
    More explicit assertions, consistent pattern and hopefylly easier debugging.

  • Hash namespace test
    Lines 192-193 sand 199-209
    The same pattern as labyrinths test - explicit label wait with 20 s timeout and explicit text checking.

Summa summarum:

  • All 4 unstable mapping tests now pass consistently
  • Notation clipboard test fixed (was expecting 33.2, got 33.10)
  • Minimal changes, only essential stabilization added
  • No functionality changes (only timing/reliability improvements)

concept.cy.js

  • Property override test - explicit text check and comment
    Lines 139-141 (added line 140, modified 141)
    The same more explicit text checking pattern. Added timeout lining up with other similiar parts. Improved commenting.

Summa Summarum:

Replaces .contains('text') with .invoke('text').should('contain', 'text') for explicit text checking and adds stabilization waits after spinner checks. Adds explicit waits for mapping labels (20 s timeout) and adds heading verification for partial page loads before accessing content.

  • All 4 unstable mapping tests now pass consistently
  • Notation clipboard test fixed (was expecting 33.2, got 33.10)
  • Property override test made consistent with the same pattern
  • Essential stabilization and consistency improvements

Post Scriptum:
.invoke('text') always asserts on the resolved final string, which makes it a better choice in tests where the expected output is not 100 percent certain. It is also less sensitive to DOM timing quirks and makes debugging easier.

@miguelvaara miguelvaara changed the title In tests related to the mapping relationships: include the actual val… Fix unstable concept page tests (mapping headers and copy functionality) Jan 22, 2026
@miguelvaara miguelvaara marked this pull request as ready for review January 22, 2026 07:40
@miguelvaara miguelvaara requested a review from osma January 22, 2026 07:40
@miguelvaara miguelvaara self-assigned this Jan 22, 2026
@miguelvaara miguelvaara moved this to Under review in Skosmos 3.x Backlog Jan 22, 2026
@miguelvaara miguelvaara added this to the 3.1 milestone Jan 22, 2026
Copy link
Member

@osma osma left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, it's good to get rid of the flaky tests.

I gave a couple of comments related to cy.wait() operations. I hope that we wouldn't have to use cy.wait() because it always slows down the tests and generally doesn't address the root cause.

I'm not a big fan of the "NOTE: we need to increase the timeout" comments, because it should be fairly obvious that when a large timeout is set, there is a reason for that and that reason is that something is slow. But if you think this makes the tests clearer, I'm OK with that.

…al reloading of the mapping + add a wait for the actual appearance of the copy-notation button
…r sign') to wait for the actual content, not just the element structure.
@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.32%. Comparing base (a5202dd) to head (33c09e1).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1906   +/-   ##
=========================================
  Coverage     70.32%   70.32%           
  Complexity     1658     1658           
=========================================
  Files            34       34           
  Lines          4364     4364           
=========================================
  Hits           3069     3069           
  Misses         1295     1295           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link

@miguelvaara miguelvaara merged commit 6d6781c into main Jan 28, 2026
16 checks passed
@github-project-automation github-project-automation bot moved this from Under review to Issue/PR closed in Skosmos 3.x Backlog Jan 28, 2026
@miguelvaara miguelvaara deleted the issue1904-stabilize-the-unstable-behavior-of-mappings-tests-related-to-the-concept-page branch January 28, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stabilize the unstable behavior of mappings tests related to the concept page

2 participants