Bug 42733: Add tests

Apply tests patch only, run:
yarn cypress run --spec t/cypress/integration/Tools/ManageMarcImport_spec.ts

Confirm it fails with the same error as Jenkins:
Timed out retrying after 10000ms: `cy.wait()` timed out waiting `10000ms` for the 2nd request to the route: `jobPoll`. No request ever occurred.

Apply fix patch. Run again.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Pedro Amorim 2026-06-01 12:44:17 +00:00 committed by Lucas Gass
parent 74cf164d32
commit 125416a92d
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 18 additions and 2 deletions

View File

@ -68,12 +68,28 @@ describe("loads the manage MARC import page", () => {
.select("ignore", { force: true })
.should("have.value", "ignore");
cy.intercept("GET", "/api/v1/jobs/*").as("jobPoll");
// CI reproduction — simulates Apache returning 503 on the
// first job poll (as happens during reset_all while Apache is restarting).
// Without the job_progress.js .fail() fix: no retry fires, the 2nd request
// never occurs, and cy.wait() times out — reproducing the exact CI error.
// With the fix: .fail() retries, the 2nd poll goes through, test passes.
let pollCount = 0;
cy.intercept("GET", "/api/v1/jobs/*", req => {
pollCount++;
if (pollCount === 1) {
req.reply({ statusCode: 503, body: {} });
} else {
req.continue();
}
}).as("jobPoll");
cy.get("#mainformsubmit").click();
const waitForJobFinished = () => {
cy.wait("@jobPoll").then(interception => {
if (interception.response?.body?.status !== "finished") {
const status = interception.response?.body?.status;
expect(status, "Background job failed").not.to.eq("failed");
if (status !== "finished") {
waitForJobFinished();
}
});