Bug 40169 - Cypress tests - mockData should not replace "_id" fields if passed
Summary: Cypress tests - mockData should not replace "_id" fields if passed
Status: Pushed to oldstable
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: Matt Blenkinsop
URL:
Keywords:
Depends on: 38503
Blocks: 40174
  Show dependency treegraph
 
Reported: 2025-06-18 20:18 UTC by Jonathan Druart
Modified: 2025-07-31 14:48 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:
25.11.00,25.05.02,24.11.08
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
Bug 40169: mockData - Do not replace _id if passed (2.02 KB, patch)
2025-07-10 11:37 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 40169: Add a test (1.03 KB, patch)
2025-07-10 11:38 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 40169: mockData - Do not replace _id if passed (2.02 KB, patch)
2025-07-10 11:38 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 40169: Add a test (1.03 KB, patch)
2025-07-15 13:29 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 40169: mockData - Do not replace _id if passed (2.02 KB, patch)
2025-07-15 13:29 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 40169: Add a test (1.09 KB, patch)
2025-07-15 13:35 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 40169: mockData - Do not replace _id if passed (2.09 KB, patch)
2025-07-15 13:35 UTC, Matt Blenkinsop
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.
Comment 9 Jonathan Druart 2025-07-10 11:37:25 UTC
Created attachment 183925 [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>

Amended-by: Jonathan Druart
Remove .only
Comment 10 Jonathan Druart 2025-07-10 11:38:33 UTC
Created attachment 183926 [details] [review]
Bug 40169: Add a test

Signed-off-by: David Nind <david@davidnind.com>

Amended by: Jonathan Druart
Remove .only
Comment 11 Jonathan Druart 2025-07-10 11:38:35 UTC
Created attachment 183927 [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>

Amended-by: Jonathan Druart
Remove .only
Comment 12 Matt Blenkinsop 2025-07-15 13:29:29 UTC
Created attachment 184092 [details] [review]
Bug 40169: Add a test

Signed-off-by: David Nind <david@davidnind.com>

Amended by: Jonathan Druart
Remove .only
Comment 13 Matt Blenkinsop 2025-07-15 13:29:31 UTC
Created attachment 184093 [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>

Amended-by: Jonathan Druart
Remove .only
Comment 14 Matt Blenkinsop 2025-07-15 13:35:52 UTC
Created attachment 184096 [details] [review]
Bug 40169: Add a test

Signed-off-by: David Nind <david@davidnind.com>

Amended by: Jonathan Druart
Remove .only

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Comment 15 Matt Blenkinsop 2025-07-15 13:35:55 UTC
Created attachment 184097 [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>

Amended-by: Jonathan Druart
Remove .only

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Comment 16 Lucas Gass (lukeg) 2025-07-15 22:35:00 UTC
Nice work everyone!

Pushed to main for 25.11
Comment 17 Paul Derscheid 2025-07-24 08:20:28 UTC
Nice work everyone!

Pushed to 25.05.x
Comment 18 Fridolin Somers 2025-07-31 14:48:15 UTC
Pushed to 24.11.x for 24.11.08