forked from verdnatura/salix-front
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:
commit
28c9aceb80
|
@ -1,3 +1,5 @@
|
||||||
|
const { randomNumber, randomString } = require('../../support');
|
||||||
|
|
||||||
describe('VnLocation', () => {
|
describe('VnLocation', () => {
|
||||||
const locationOptions = '[role="listbox"] > div.q-virtual-scroll__content > .q-item';
|
const locationOptions = '[role="listbox"] > div.q-virtual-scroll__content > .q-item';
|
||||||
const dialogInputs = '.q-dialog label input';
|
const dialogInputs = '.q-dialog label input';
|
||||||
|
@ -117,14 +119,19 @@ describe('VnLocation', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Create city without country', () => {
|
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(createLocationButton).click();
|
||||||
|
cy.get(dialogInputs).eq(0).type(postCode);
|
||||||
cy.get(
|
cy.get(
|
||||||
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) > .q-icon`
|
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) > .q-icon`
|
||||||
).click();
|
).click();
|
||||||
cy.selectOption('#q-portal--dialog--3 .q-select', 'one');
|
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--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', () => {
|
it('Create province without country', () => {
|
||||||
|
|
|
@ -15,3 +15,19 @@
|
||||||
|
|
||||||
import './commands';
|
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 };
|
||||||
|
|
Loading…
Reference in New Issue