0
0
Fork 0

Merge pull request 'Randomize functions and example' (!994) from cypress_randomizeValue into dev

Reviewed-on: verdnatura/salix-front#994
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
Reviewed-by: Carlos Satorres <carlossa@verdnatura.es>
This commit is contained in:
Javier Segarra 2024-11-25 13:07:55 +00:00
commit 28c9aceb80
2 changed files with 25 additions and 2 deletions

View File

@ -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';
@ -117,14 +119,19 @@ describe('VnLocation', () => {
});
it('Create city without country', () => {
const cityName = 'Saskatchew'.concat(Math.random(1 * 100));
const postCode = randomNumber();
const province = randomString({ length: 4 });
cy.get(createLocationButton).click();
cy.get(dialogInputs).eq(0).type(postCode);
cy.get(
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) > .q-icon`
).click();
cy.selectOption('#q-portal--dialog--3 .q-select', 'one');
cy.get('#q-portal--dialog--3 .q-input').type(cityName);
cy.get('#q-portal--dialog--3 .q-input').type(province);
cy.get('#q-portal--dialog--3 .q-btn--standard').click();
cy.get('#q-portal--dialog--1 .q-btn--standard').click();
cy.waitForElement('.q-form');
checkVnLocation(postCode, province);
});
it('Create province without country', () => {

View File

@ -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 };