diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/vnLocation.spec.js index aeb938c6fc..0823e6e09f 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 4385698ec4..c57c1a3037 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 };