From c4f2ea032c312f00d4d5d96908bd101298221890 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sun, 24 Nov 2024 17:01:54 +0100 Subject: [PATCH 1/2] feat: randomize functions and example --- .../integration/vnComponent/vnLocation.spec.js | 8 +++++--- test/cypress/support/index.js | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/vnLocation.spec.js index aeb938c6f..0823e6e09 100644 --- a/test/cypress/integration/vnComponent/vnLocation.spec.js +++ b/test/cypress/integration/vnComponent/vnLocation.spec.js @@ -1,3 +1,5 @@ +const { randomNumber, randomString } = require('../../support'); + describe('VnLocation', () => { const locationOptions = '[role="listbox"] > div.q-virtual-scroll__content > .q-item'; const dialogInputs = '.q-dialog label input'; @@ -115,9 +117,9 @@ describe('VnLocation', () => { checkVnLocation(postCode, province); }); - it('Create city', () => { - const postCode = '9011'; - const province = 'Saskatchew'; + it.only('Create city', () => { + const postCode = randomNumber(); + const province = randomString({ length: 4 }); cy.get(createLocationButton).click(); cy.get(dialogInputs).eq(0).type(postCode); cy.get( diff --git a/test/cypress/support/index.js b/test/cypress/support/index.js index 4385698ec..c57c1a303 100644 --- a/test/cypress/support/index.js +++ b/test/cypress/support/index.js @@ -15,3 +15,19 @@ import './commands'; +function randomString(options = { length: 10 }) { + let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; + return randomizeValue(possible, options); +} + +function randomNumber(options = { length: 10 }) { + let possible = '0123456789'; + return randomizeValue(possible, options); +} + +function randomizeValue(characterSet, options) { + return Array.from({ length: options.length }, () => + characterSet.charAt(Math.floor(Math.random() * characterSet.length)) + ).join(''); +} +export { randomString, randomNumber, randomizeValue }; From b62935494abc7c21271a464f9a5fb3adb5a34b01 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 25 Nov 2024 11:19:21 +0000 Subject: [PATCH 2/2] test: remove only --- test/cypress/integration/vnComponent/vnLocation.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/vnLocation.spec.js index 0823e6e09..50dabf229 100644 --- a/test/cypress/integration/vnComponent/vnLocation.spec.js +++ b/test/cypress/integration/vnComponent/vnLocation.spec.js @@ -117,7 +117,7 @@ describe('VnLocation', () => { checkVnLocation(postCode, province); }); - it.only('Create city', () => { + it('Create city', () => { const postCode = randomNumber(); const province = randomString({ length: 4 }); cy.get(createLocationButton).click();