Bugzilla – Attachment 184093 Details for
Bug 40169
Cypress tests - mockData should not replace "_id" fields if passed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40169: mockData - Do not replace _id if passed
Bug-40169-mockData---Do-not-replace-id-if-passed.patch (text/plain), 2.02 KB, created by
Matt Blenkinsop
on 2025-07-15 13:29:31 UTC
(
hide
)
Description:
Bug 40169: mockData - Do not replace _id if passed
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2025-07-15 13:29:31 UTC
Size:
2.02 KB
patch
obsolete
>From 7e42c6b1a34fcb79f9f1cdba7caeabf515478295 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 16 Jun 2025 14:05:57 +0200 >Subject: [PATCH] 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 >--- > t/cypress/integration/t/mockData.ts | 10 ++++++++++ > t/cypress/plugins/mockData.js | 5 ++++- > 2 files changed, 14 insertions(+), 1 deletion(-) > >diff --git a/t/cypress/integration/t/mockData.ts b/t/cypress/integration/t/mockData.ts >index 1d6d21df0a2..33b20279c6e 100644 >--- a/t/cypress/integration/t/mockData.ts >+++ b/t/cypress/integration/t/mockData.ts >@@ -20,6 +20,16 @@ describe("Generate Random Patron", () => { > ); > }); > }); >+ >+ it("should not overwrite _id if passed", () => { >+ const home_library_id = "LIB4TEST"; >+ cy.task("buildSampleObject", { >+ object: "item", >+ values: { home_library_id }, >+ }).then(mockItem => { >+ expect(mockItem.home_library_id).to.equal(home_library_id); >+ }); >+ }); > }); > > describe("Generate Random Patrons", () => { >diff --git a/t/cypress/plugins/mockData.js b/t/cypress/plugins/mockData.js >index 0f9c292df81..c2025abeebf 100644 >--- a/t/cypress/plugins/mockData.js >+++ b/t/cypress/plugins/mockData.js >@@ -74,7 +74,10 @@ const generateDataFromSchema = (properties, values = {}) => { > }); > > Object.keys(ids).forEach(k => { >- if (mockData.hasOwnProperty(k + "_id")) { >+ if ( >+ mockData.hasOwnProperty(k + "_id") && >+ !values.hasOwnProperty(k + "_id") >+ ) { > mockData[k + "_id"] = ids[k]; > } > }); >-- >2.48.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40169
:
183350
|
183351
|
183378
|
183379
|
183925
|
183926
|
183927
|
184092
|
184093
|
184096
|
184097