Bugzilla – Attachment 175894 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: Generate correct values for date and date-time
Bug-38503-Generate-correct-values-for-date-and-dat.patch (text/plain), 2.23 KB, created by
Victor Grousset/tuxayo
on 2024-12-22 09:47:24 UTC
(
hide
)
Description:
Bug 38503: Generate correct values for date and date-time
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2024-12-22 09:47:24 UTC
Size:
2.23 KB
patch
obsolete
>From 1a8230826028235f9c31cf4482eb64f216928ba4 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 21 Nov 2024 15:13:10 +0100 >Subject: [PATCH] Bug 38503: Generate correct values for date and date-time > >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > t/cypress/integration/t/mockData.ts | 5 +++++ > t/cypress/plugins/mockData.js | 10 +++++++++- > 2 files changed, 14 insertions(+), 1 deletion(-) > >diff --git a/t/cypress/integration/t/mockData.ts b/t/cypress/integration/t/mockData.ts >index 5ca38a9999..60c1c2118d 100644 >--- a/t/cypress/integration/t/mockData.ts >+++ b/t/cypress/integration/t/mockData.ts >@@ -13,6 +13,11 @@ describe("Generate Random Patron", () => { > }).then(mockPatron => { > expect(mockPatron.surname).to.equal("test_surname"); > expect(mockPatron.overdues_count).to.be.a("number"); >+ expect(mockPatron.date_of_birth).to.match(/^\d{4}-\d{2}-\d{2}$/); >+ // TODO We are not testing for timezone part >+ expect(mockPatron.updated_on).to.match( >+ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/ >+ ); > }); > }); > }); >diff --git a/t/cypress/plugins/mockData.js b/t/cypress/plugins/mockData.js >index 855a55ba69..0f41eaef2a 100644 >--- a/t/cypress/plugins/mockData.js >+++ b/t/cypress/plugins/mockData.js >@@ -24,6 +24,10 @@ const generateMockData = type => { > return [faker.lorem.word(), faker.lorem.word()]; > case "number": > return faker.number.float(); >+ case "date": >+ return new Date().toISOString().split("T")[0]; >+ case "date-time": >+ return new Date().toISOString(); > default: > return faker.lorem.word(); > } >@@ -35,7 +39,11 @@ const generateDataFromSchema = (properties, values = {}) => { > if (values.hasOwnProperty(key)) { > mockData[key] = values[key]; > } else { >- mockData[key] = generateMockData(value.type); >+ let type = >+ value?.format == "date" || value?.format == "date-time" >+ ? value.format >+ : value.type; >+ mockData[key] = generateMockData(type); > } > }); > return mockData; >-- >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