Bug 40169 - Cypress tests - mockData should not replace "_id" fields if passed
Summary: Cypress tests - mockData should not replace "_id" fields if passed
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: 38503
Blocks:
  Show dependency treegraph
 
Reported: 2025-06-18 20:18 UTC by Jonathan Druart
Modified: 2025-06-19 11:18 UTC (History)
1 user (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 40169: Add a test (966 bytes, patch)
2025-06-18 20:24 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 40169: mockData - Do not replace _id if passed (1.90 KB, patch)
2025-06-18 20:24 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 40169: Add a test (1012 bytes, patch)
2025-06-19 11:17 UTC, David Nind
Details | Diff | Splinter Review
Bug 40169: mockData - Do not replace _id if passed (1.94 KB, patch)
2025-06-19 11:17 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-18 20:18:27 UTC

    
Comment 1 Jonathan Druart 2025-06-18 20:24:19 UTC
Created attachment 183350 [details] [review]
Bug 40169: Add a test
Comment 2 Jonathan Druart 2025-06-18 20:24:21 UTC
Created attachment 183351 [details] [review]
Bug 40169: mockData - Do not replace _id if passed

If we build an object and pass a primary key (ie. suffixed by _id) we
should not replace it.

Test plan:
The test highlights the problem, it won't affect existing tests.
0. Apply only the first patch (Cypress tests)
1. Run yarn cypress run t/cypress/integration/t/mockData.ts
=> It fails
2. Apply this patch
=> It passes
Comment 3 David Nind 2025-06-18 23:34:17 UTC
I had failed tests before and after the patches were applied:

1. Failed tests before the patches were applied:
   - ERM/DataProviders_spec.ts
   - ERM/UsageReports_spec.ts

2. Failed tests with both the patches applied:
   - ERM/DataProviders_spec.ts 
   - ERM/UsageReports_spec.ts
   - KohaTable/Holdings_spec.ts
Comment 4 Jonathan Druart 2025-06-19 07:14:39 UTC
(In reply to David Nind from comment #3)
> I had failed tests before and after the patches were applied:
> 
> 1. Failed tests before the patches were applied:
>    - ERM/DataProviders_spec.ts
>    - ERM/UsageReports_spec.ts
> 
> 2. Failed tests with both the patches applied:
>    - ERM/DataProviders_spec.ts 
>    - ERM/UsageReports_spec.ts
>    - KohaTable/Holdings_spec.ts

Can you try again after a reset_all please? They all pass for me.

If still failing, could you paste the output?
Comment 5 Jonathan Druart 2025-06-19 07:16:29 UTC
(In reply to Jonathan Druart from comment #4)
> (In reply to David Nind from comment #3)
> > I had failed tests before and after the patches were applied:
> > 
> > 1. Failed tests before the patches were applied:
> >    - ERM/DataProviders_spec.ts
> >    - ERM/UsageReports_spec.ts
> > 
> > 2. Failed tests with both the patches applied:
> >    - ERM/DataProviders_spec.ts 
> >    - ERM/UsageReports_spec.ts
> >    - KohaTable/Holdings_spec.ts
> 
> Can you try again after a reset_all please? They all pass for me.
> 
> If still failing, could you paste the output?

Hum, the 2 ERM tests are indeed failing on main, and with this patch (so not related).
Comment 6 David Nind 2025-06-19 11:17:42 UTC
Created attachment 183378 [details] [review]
Bug 40169: Add a test

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 David Nind 2025-06-19 11:17:45 UTC
Created attachment 183379 [details] [review]
Bug 40169: mockData - Do not replace _id if passed

If we build an object and pass a primary key (ie. suffixed by _id) we
should not replace it.

Test plan:
The test highlights the problem, it won't affect existing tests.
0. Apply only the first patch (Cypress tests)
1. Run yarn cypress run t/cypress/integration/t/mockData.ts
=> It fails
2. Apply this patch
=> It passes

Signed-off-by: David Nind <david@davidnind.com>
Comment 8 David Nind 2025-06-19 11:18:43 UTC
The tests (excluding the ERM ones) now pass.

Doing a reset_all seems to have done the trick.