Skip to content

test(fix): the autocollect liveness probe must not double the context path - #800

Merged
baptistegrimaud merged 1 commit into
mainfrom
fix/autocollect-live-probe-url
Sep 22, 2026
Merged

baptistegrimaud merged 1 commit into
mainfrom
fix/autocollect-live-probe-url

Conversation

@baptistegrimaud

@baptistegrimaud baptistegrimaud commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Closes #795.

Summary

cacheDependencyAutocollectTest builds its live-file liveness probe with an explicit JAHIA_CONTEXT prefix. Cypress appends a relative request URL to baseUrl, and baseUrl already carries the servlet context path, so the prefix is applied twice. Dropping it fixes the request.

Why

The SN-custom-context nightly matrix entry has failed on this test every night since #783 landed, while the plain SN entry passes. Both jobs report to the same dedup key on #795, so the issue alternates between reopened and closed and reads as a flaky test. It is not flaky: it is a deterministic failure on one matrix entry.

tests/cypress/plugins/env.js sets config.baseUrl = process.env.JAHIA_URL, and tests/docker-compose.yml sets JAHIA_URL=http://jahia:8080${CONTEXT_PATH}. On the custom-context entry that makes baseUrl http://jahia:8080/custom-context, and JAHIA_CONTEXT resolves to /custom-context from the same variable. The probe therefore requested /custom-context/custom-context/files/live/sites/javascriptTestSite/files/autocollected-renamed.jpg. No servlet matches that path, so Jahia's URL rewriting routed it to the render servlet, which read custom-context as the locale and answered 400 Bad Request — Unknown locale. The Jahia log of run 35672431011 shows the doubled path directly:

INFO  [o.j.b.Render] - Rendered [/custom-context/cms/render/live/custom-context/files/live/sites/javascriptTestSite/files/autocollected-renamed.jpg] ...
WARN  [o.j.b.e.ErrorLoggingFilter] - [Error code: 400]: Unknown locale

The error the CI reporter surfaced is the second Cypress attempt, not this one: before() does not re-run on a retry, so attempt 2 started with the rename already applied and failed on the first assertion instead. That is why the failure looked like a cache-flush bug.

Every other use of JAHIA_CONTEXT in the suite asserts against rendered markup, where the context legitimately appears. This was the only place it was used to build a request URL.

Changes

  • tests/cypress/e2e/ui/cacheDependencyAutocollectTest.cy.ts: request the liveness probe with a relative URL and let baseUrl supply the context path; drop the now-unused JAHIA_CONTEXT import, and note why the prefix must not come back.

Validation

The nightly SN-custom-context matrix entry is what exercises this; the plain SN entry cannot reproduce it, because there the context path is empty and the doubled prefix is invisible. Verified against the CI artifacts of runs 35548225994 and 35672431011, which both carry the doubled URL in results/jahia.log. CI on this PR runs the suite in both contexts.

Documentation

No documentation change: the fix is confined to one test.

ADR

None.

Notes

No changelog fragment: test-only change, no user-visible impact.

Two follow-ups this PR deliberately leaves alone, so the fix stays one line:

  • The test is not idempotent under a Cypress retry. before() does not re-run, so a failure in the middle of the test leaves the rename in place and the retry reports a misleading assertion. That is why this failure was mis-read for several nights.
  • .should("eq", 200) after cy.request reads as a retry that does not exist, since .should cannot re-issue cy.request. It is harmless here, because failOnStatusCode already fails the test on a non-2xx.

Relates to #795.

…t path

Cypress appends a relative request URL to baseUrl, and baseUrl already carries the servlet context path. Prefixing JAHIA_CONTEXT produced /custom-context/custom-context/files/live/... on the SN-custom-context matrix entry, which no servlet matches, so URL rewriting routed it to the render servlet and it answered 400 Unknown locale.
@github-actions

Copy link
Copy Markdown

🦜 Chachalog

No changelog entries detected. Learn more about Chachalog.

Create a new entry online or run npx chachalog@0.5.6 prompt to create a new entry locally.

@pkg-pr-new

pkg-pr-new Bot commented Sep 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

yarn add https://pkg.pr.new/@jahia/create-module@800.tgz
yarn add https://pkg.pr.new/@jahia/javascript-modules-library@800.tgz
yarn add https://pkg.pr.new/@jahia/vite-plugin@800.tgz

commit: 7f01ec7

@baptistegrimaud
baptistegrimaud marked this pull request as ready for review September 22, 2026 07:37
@baptistegrimaud baptistegrimaud changed the title fix(tests): the autocollect liveness probe must not double the context path tests: the autocollect liveness probe must not double the context path Sep 22, 2026
@baptistegrimaud baptistegrimaud changed the title tests: the autocollect liveness probe must not double the context path test(fix): the autocollect liveness probe must not double the context path Sep 22, 2026
@baptistegrimaud
baptistegrimaud merged commit d4d236a into main Sep 22, 2026
41 of 42 checks passed
@baptistegrimaud
baptistegrimaud deleted the fix/autocollect-live-probe-url branch September 22, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

javascript-modules-engine-SN-custom-context - 1/167 FAILED test during test execution

1 participant