Bug 40043 - Agreements_spec.ts is failing randomly (2)
Summary: Agreements_spec.ts is failing randomly (2)
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-06-02 08:28 UTC by Jonathan Druart
Modified: 2025-06-02 18:54 UTC (History)
3 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 40043: Try to prevent Agreements_spec.ts to fail randomly (4.23 KB, patch)
2025-06-02 08:52 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 40043: Try to prevent Agreements_spec.ts to fail randomly (4.28 KB, patch)
2025-06-02 18:53 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2025-06-02 08:28:45 UTC
17:45:28 koha_1       |     <testcase name="Agreement CRUD operations Delete agreement" time="0.000" classname="Delete agreement">
17:46:28 koha_1       |       <failure message="Timed out retrying after 10050ms: `cy.click()` failed because the page updated while this command was executing. Cypress tried to locate elements based on this query:
17:46:28 koha_1       | 
17:46:28 koha_1       | &gt; &lt;a.show&gt;
17:46:28 koha_1       | 
17:46:28 koha_1       | We initially found matching element(s), but while waiting for them to become actionable, they disappeared from the page. Common situations why this happens:
17:46:28 koha_1       |   - Your JS framework re-rendered asynchronously
17:46:28 koha_1       |   - Your app code reacted to an event firing and removed the element
17:46:28 koha_1       | 
17:46:28 koha_1       | You can typically solve this by breaking up a chain. For example, rewrite:
17:46:28 koha_1       | 
17:46:28 koha_1       | &gt; `cy.get(&apos;button&apos;).click().click()`
17:46:28 koha_1       | 
17:46:28 koha_1       | to
17:46:28 koha_1       | 
17:46:28 koha_1       | &gt; `cy.get(&apos;button&apos;).as(&apos;btn&apos;).click()`
17:46:28 koha_1       | &gt; `cy.get(&apos;@btn&apos;).click()`
Comment 1 Jonathan Druart 2025-06-02 08:52:11 UTC
Created attachment 182901 [details] [review]
Bug 40043: Try to prevent Agreements_spec.ts to fail randomly

One test is failing with:
"""
https://on.cypress.io/element-has-detached-from-dom" type="CypressError"><![CDATA[CypressError: Timed out retrying after 10050ms: `cy.click()` failed because the page updated while this command was executing. Cypress tried to locate elements based on this query:

> <a.show>

We initially found matching element(s), but while waiting for them to become actionable, they disappeared from the page. Common situations why this happens:
  - Your JS framework re-rendered asynchronously
  - Your app code reacted to an event firing and removed the element

You can typically solve this by breaking up a chain. For example, rewrite:

> `cy.get('button').click().click()`

to

> `cy.get('button').as('btn').click()`
> `cy.get('@btn').click()`

https://on.cypress.io/element-has-detached-from-dom
    at retryActionability (http://localhost:8081/__cypress/runner/cypress_runner.js:112246:74)
    at tryCatcher (http://localhost:8081/__cypress/runner/cypress_runner.js:1807:23)
    at Promise.attempt.Promise.try (http://localhost:8081/__cypress/runner/cypress_runner.js:4315:29)
    at whenStable (http://localhost:8081/__cypress/runner/cypress_runner.js:143192:68)
    at <unknown> (http://localhost:8081/__cypress/runner/cypress_runner.js:143133:14)
    at tryCatcher (http://localhost:8081/__cypress/runner/cypress_runner.js:1807:23)
    at Promise._settlePromiseFromHandler (http://localhost:8081/__cypress/runner/cypress_runner.js:1519:31)
    at Promise._settlePromise (http://localhost:8081/__cypress/runner/cypress_runner.js:1576:18)
    at Promise._settlePromise0 (http://localhost:8081/__cypress/runner/cypress_runner.js:1621:10)
    at Promise._settlePromises (http://localhost:8081/__cypress/runner/cypress_runner.js:1701:18)
    at Promise._fulfill (http://localhost:8081/__cypress/runner/cypress_runner.js:1645:18)
    at <unknown> (http://localhost:8081/__cypress/runner/cypress_runner.js:5450:46)
From Your Spec Code:
    at Context.eval (webpack://koha/./t/cypress/integration/ERM/Agreements_spec.ts:630:18)]]></failure>
    </testcase>
  </testsuite>
"""

My guess is that it happens because we don't wait for the /agreements
response.

Test plan:
Test should still pass, we will see how Jenkins behave after it's
pushed.
Comment 2 David Nind 2025-06-02 18:53:10 UTC
Created attachment 182911 [details] [review]
Bug 40043: Try to prevent Agreements_spec.ts to fail randomly

One test is failing with:
"""
https://on.cypress.io/element-has-detached-from-dom" type="CypressError"><![CDATA[CypressError: Timed out retrying after 10050ms: `cy.click()` failed because the page updated while this command was executing. Cypress tried to locate elements based on this query:

> <a.show>

We initially found matching element(s), but while waiting for them to become actionable, they disappeared from the page. Common situations why this happens:
  - Your JS framework re-rendered asynchronously
  - Your app code reacted to an event firing and removed the element

You can typically solve this by breaking up a chain. For example, rewrite:

> `cy.get('button').click().click()`

to

> `cy.get('button').as('btn').click()`
> `cy.get('@btn').click()`

https://on.cypress.io/element-has-detached-from-dom
    at retryActionability (http://localhost:8081/__cypress/runner/cypress_runner.js:112246:74)
    at tryCatcher (http://localhost:8081/__cypress/runner/cypress_runner.js:1807:23)
    at Promise.attempt.Promise.try (http://localhost:8081/__cypress/runner/cypress_runner.js:4315:29)
    at whenStable (http://localhost:8081/__cypress/runner/cypress_runner.js:143192:68)
    at <unknown> (http://localhost:8081/__cypress/runner/cypress_runner.js:143133:14)
    at tryCatcher (http://localhost:8081/__cypress/runner/cypress_runner.js:1807:23)
    at Promise._settlePromiseFromHandler (http://localhost:8081/__cypress/runner/cypress_runner.js:1519:31)
    at Promise._settlePromise (http://localhost:8081/__cypress/runner/cypress_runner.js:1576:18)
    at Promise._settlePromise0 (http://localhost:8081/__cypress/runner/cypress_runner.js:1621:10)
    at Promise._settlePromises (http://localhost:8081/__cypress/runner/cypress_runner.js:1701:18)
    at Promise._fulfill (http://localhost:8081/__cypress/runner/cypress_runner.js:1645:18)
    at <unknown> (http://localhost:8081/__cypress/runner/cypress_runner.js:5450:46)
From Your Spec Code:
    at Context.eval (webpack://koha/./t/cypress/integration/ERM/Agreements_spec.ts:630:18)]]></failure>
    </testcase>
  </testsuite>
"""

My guess is that it happens because we don't wait for the /agreements
response.

Test plan:
Test should still pass, we will see how Jenkins behave after it's
pushed.

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 David Nind 2025-06-02 18:54:58 UTC
Testing notes (using KTD):

1. To run the tests: yarn cypress run --spec t/cypress/integration/ERM/Agreements_spec.ts