Bugzilla – Attachment 175216 Details for
Bug 38503
Add a Cypress task to generate objects based on its swagger def spec
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38503: Allow to pass values
Bug-38503-Allow-to-pass-values.patch (text/plain), 2.59 KB, created by
Victor Grousset/tuxayo
on 2024-12-05 05:53:26 UTC
(
hide
)
Description:
Bug 38503: Allow to pass values
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2024-12-05 05:53:26 UTC
Size:
2.59 KB
patch
obsolete
>From 6268fa44aee230eaa8fb7d80394e790c88270260 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 21 Nov 2024 14:08:19 +0100 >Subject: [PATCH] Bug 38503: Allow to pass values > >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > t/cypress/integration/t/mockData.ts | 8 ++++++++ > t/cypress/plugins/mockData.js | 16 ++++++++++------ > 2 files changed, 18 insertions(+), 6 deletions(-) > >diff --git a/t/cypress/integration/t/mockData.ts b/t/cypress/integration/t/mockData.ts >index 6624909173..cdc1c08ec5 100644 >--- a/t/cypress/integration/t/mockData.ts >+++ b/t/cypress/integration/t/mockData.ts >@@ -6,6 +6,14 @@ describe("Generate Random Patron", () => { > expect(mockPatron).to.have.property("patron_id"); > }); > }); >+ it("should generate a random patron with predefined values", () => { >+ cy.task("buildSampleObject", { >+ object: "patron", >+ values: { surname: "test_surname" }, >+ }).then(mockPatron => { >+ expect(mockPatron.surname).to.equal("test_surname"); >+ }); >+ }); > }); > > describe("Generate Random Patrons", () => { >diff --git a/t/cypress/plugins/mockData.js b/t/cypress/plugins/mockData.js >index 5bb9bb75b2..02ec1a7aba 100644 >--- a/t/cypress/plugins/mockData.js >+++ b/t/cypress/plugins/mockData.js >@@ -26,27 +26,31 @@ const generateMockData = type => { > } > }; > >-const generateDataFromSchema = properties => { >+const generateDataFromSchema = (properties, values = {}) => { > const mockData = {}; > Object.entries(properties).forEach(([key, value]) => { >- mockData[key] = generateMockData(value.type); >+ if (values.hasOwnProperty(key)) { >+ mockData[key] = values[key]; >+ } else { >+ mockData[key] = generateMockData(value.type); >+ } > }); > return mockData; > }; > >-const buildSampleObjects = ({ object, count = 1 }) => { >+const buildSampleObjects = ({ object, values, count = 1 }) => { > if (!objects.hasOwnProperty(object)) { > throw new Error(`Object type not supported: ${object}`); > } > const yamlPath = `api/v1/swagger/definitions/${objects[object].spec}.yaml`; > const schema = readYamlFile(yamlPath); > return Array.from({ length: count }, () => >- generateDataFromSchema(schema.properties) >+ generateDataFromSchema(schema.properties, values) > ); > }; > >-const buildSampleObject = object => { >- return buildSampleObjects({ object })[0]; >+const buildSampleObject = ({ object, values = {} }) => { >+ return buildSampleObjects({ object, values })[0]; > }; > > module.exports = { >-- >2.47.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 38503
:
174872
|
174873
|
174874
|
174875
|
174876
|
174884
|
174885
|
174921
|
174922
|
175173
|
175175
|
175212
|
175213
|
175214
|
175215
|
175216
|
175217
|
175218
|
175219
|
175220
|
175221
|
175222
|
175888
|
175889
|
175890
|
175891
|
175892
|
175893
|
175894
|
175895
|
175896
|
176073
|
176074
|
176075
|
176076
|
176077
|
176078
|
176079
|
176080
|
176081
|
176775
|
176776
|
176792