Bugzilla – Attachment 174885 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.18 KB, created by
Jonathan Druart
on 2024-11-21 14:16:25 UTC
(
hide
)
Description:
Bug 38503: Generate correct values for date and date-time
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-11-21 14:16:25 UTC
Size:
2.18 KB
patch
obsolete
>From 401abad48be31330a09872e907dc4924f6a821e3 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 > >--- > 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 5ca38a99998..60c1c2118d7 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 855a55ba692..0f41eaef2a7 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.34.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