Bug 41362 - Allow Cypress tests to use KOHA_USER and KOHA_PASS as override
Summary: Allow Cypress tests to use KOHA_USER and KOHA_PASS as override
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Tomás Cohen Arazi (tcohen)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 40446
  Show dependency treegraph
 
Reported: 2025-12-03 13:31 UTC by Tomás Cohen Arazi (tcohen)
Modified: 2025-12-04 12:57 UTC (History)
4 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 41362: Allow Cypress tests to use KOHA_USER and KOHA_PASS as override (1.83 KB, patch)
2025-12-03 13:51 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 41362: Allow Cypress tests to use KOHA_USER and KOHA_PASS as override (1.86 KB, patch)
2025-12-04 02:08 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 Tomás Cohen Arazi (tcohen) 2025-12-03 13:31:11 UTC
Right now they have `koha:koha` hardcoded.
Comment 1 Tomás Cohen Arazi (tcohen) 2025-12-03 13:51:37 UTC
Created attachment 190116 [details] [review]
Bug 41362: Allow Cypress tests to use KOHA_USER and KOHA_PASS as override

The cypress.config.ts file had hardcoded API credentials (koha:koha)
which don't work in KTD environments that use different credentials.

This patch makes the config use KOHA_USER and KOHA_PASS environment
variables if set, falling back to koha:koha if not.

Test plan:
1. On a running KTD, run the cypress tests:
   $ ktd --shell
  k$ run_cypress
=> SUCCESS: Tests are run, no errors about credentials
2. Edit your KTD .env file, so KOHA_USER=tcohen, KOHA_PASS=tomasito
3. Shut your kTD down, and start a fresh one
4. Repeat 1
=> SUCCESS: The command shows `cypress run --env KOHA_USER=tcohen,KOHA_PASS=tomasito` is run.
=> FAIL: Some tests fail right away with invalid credentials error
5. Apply this patch
6. Repeat 1
=> SUCCESS: Same command as 4
=> SUCCESS: Tests don't fail for credentials
7. Sign off :-D

Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Comment 2 David Nind 2025-12-04 02:08:05 UTC
Created attachment 190144 [details] [review]
Bug 41362: Allow Cypress tests to use KOHA_USER and KOHA_PASS as override

The cypress.config.ts file had hardcoded API credentials (koha:koha)
which don't work in KTD environments that use different credentials.

This patch makes the config use KOHA_USER and KOHA_PASS environment
variables if set, falling back to koha:koha if not.

Test plan:
1. On a running KTD, run the cypress tests:
   $ ktd --shell
  k$ run_cypress
=> SUCCESS: Tests are run, no errors about credentials
2. Edit your KTD .env file, so KOHA_USER=tcohen, KOHA_PASS=tomasito
3. Shut your kTD down, and start a fresh one
4. Repeat 1
=> SUCCESS: The command shows `cypress run --env KOHA_USER=tcohen,KOHA_PASS=tomasito` is run.
=> FAIL: Some tests fail right away with invalid credentials error
5. Apply this patch
6. Repeat 1
=> SUCCESS: Same command as 4
=> SUCCESS: Tests don't fail for credentials
7. Sign off :-D

Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Comment 3 David Nind 2025-12-04 08:22:03 UTC Comment hidden (obsolete)
Comment 4 Jonathan Druart 2025-12-04 08:35:39 UTC
You are fixing only half of the problem, you also need bug 40446.
Comment 5 David Nind 2025-12-04 08:48:00 UTC
Testing notes (using KTD):

1. Just noting that these Cypress tests were failing for me, with everything up-to-date (before the patches were applied):

   - t/cypress/integration/Preservation/Settings.ts: fixed by Bug 41364 - Error in preservation module breadcrumb

   - t/cypress/integration/SIP2/Accounts.ts (originally failed, but now passing)

   - t/cypress/integration/Tools/ManageMarcImport_spec.ts: fixed by Bug 41368 - Tools/ManageMarcImport_spec.ts is failing

   - t/cypress/integration/t/api-client.ts (couldn't find a bug)

(Updated with correct path, and that Accounts.ts is now passing.)