parent
e8ad185873
commit
69e6f0f467
|
@ -56,10 +56,10 @@ async function onCityCreated(newTown, formData) {
|
|||
}
|
||||
|
||||
function setTown(newTown, data) {
|
||||
if (!newTown) return;
|
||||
town.value = newTown;
|
||||
data.provinceFk = newTown.provinceFk;
|
||||
data.countryFk = newTown.province.countryFk;
|
||||
if (!newTown) return;
|
||||
town.value = newTown;
|
||||
}
|
||||
|
||||
async function setProvince(id, data) {
|
||||
|
@ -73,7 +73,7 @@ async function onProvinceCreated(data) {
|
|||
await provincesFetchDataRef.value.fetch({
|
||||
where: { countryFk: postcodeFormData.countryFk },
|
||||
});
|
||||
postcodeFormData.provinceFk.value = data.id;
|
||||
postcodeFormData.provinceFk = data.id;
|
||||
}
|
||||
|
||||
watch(
|
||||
|
@ -158,6 +158,13 @@ async function handleCountries(data) {
|
|||
auto-load
|
||||
url="Towns/location"
|
||||
/>
|
||||
<FetchData
|
||||
ref="CountriesFetchDataRef"
|
||||
:sort-by="['name ASC']"
|
||||
@on-fetch="handleCountries"
|
||||
auto-load
|
||||
url="Countries"
|
||||
/>
|
||||
|
||||
<FormModelPopup
|
||||
url-create="postcodes"
|
||||
|
@ -169,6 +176,7 @@ async function handleCountries(data) {
|
|||
@on-data-saved="onDataSaved"
|
||||
>
|
||||
<template #form-inputs="{ data, validate }">
|
||||
{{ data }}
|
||||
<VnRow>
|
||||
<VnInput
|
||||
:label="t('Postcode')"
|
||||
|
@ -202,6 +210,7 @@ async function handleCountries(data) {
|
|||
</template>
|
||||
<template #form>
|
||||
<CreateNewCityForm
|
||||
data-cy="create-new-city-btn"
|
||||
:country-fk="data.countryFk"
|
||||
:province-selected="data.provinceFk"
|
||||
@on-data-saved="
|
||||
|
@ -220,12 +229,12 @@ async function handleCountries(data) {
|
|||
v-model="data.provinceFk"
|
||||
:clearable="true"
|
||||
@on-province-created="onProvinceCreated"
|
||||
data-cy="create-new-province-btn"
|
||||
/>
|
||||
<VnSelect
|
||||
url="Countries"
|
||||
:sort-by="['name ASC']"
|
||||
:label="t('Country')"
|
||||
@update:options="handleCountries"
|
||||
:options="countriesOptions"
|
||||
hide-selected
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
|
|
|
@ -137,24 +137,91 @@ describe('VnLocation', () => {
|
|||
|
||||
checkVnLocation(postCode, province);
|
||||
});
|
||||
it('Create city', () => {
|
||||
const postCode = '9011';
|
||||
const province = 'Saskatchew';
|
||||
it.only('Create city without country', () => {
|
||||
// const postCode = '9011';
|
||||
const cityName = 'Saskatchew'.concat(Math.random(1 * 100));
|
||||
cy.get(createLocationButton).click();
|
||||
cy.get(dialogInputs).eq(0).type(postCode);
|
||||
// cy.get(dialogInputs).eq(0).type(postCode);
|
||||
// city create button
|
||||
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(province);
|
||||
cy.get('#q-portal--dialog--3 .q-input').type(cityName);
|
||||
cy.get('#q-portal--dialog--3 .q-btn--standard').click();
|
||||
cy.get('#q-portal--dialog--1 .q-btn--standard').click();
|
||||
cy.waitForElement('.q-form');
|
||||
// cy.get('#q-portal--dialog--1 .q-btn--standard').click();
|
||||
// cy.waitForElement('.q-form');
|
||||
|
||||
checkVnLocation(postCode, province);
|
||||
// checkVnLocation(postCode, province);
|
||||
});
|
||||
it.only('Create province without country', () => {
|
||||
// const postCode = '9011';
|
||||
const provinceName = 'Saskatchew'.concat(Math.random(1 * 100));
|
||||
cy.get(createLocationButton).click();
|
||||
// cy.get(dialogInputs).eq(0).type(postCode);
|
||||
cy.get(
|
||||
`${createForm.prefix} > :nth-child(5) > .q-select > ${createForm.sufix} > :nth-child(2) `
|
||||
)
|
||||
.eq(0)
|
||||
.click();
|
||||
cy.selectOption('#q-portal--dialog--3 .q-select', 'one');
|
||||
cy.countSelectOptions('#q-portal--dialog--3 .q-select', 4);
|
||||
cy.get('#q-portal--dialog--3 .q-input').type(provinceName);
|
||||
|
||||
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.only('Create city with country', () => {
|
||||
// const postCode = '9011';
|
||||
const cityName = 'Saskatchew'.concat(Math.random(1 * 100));
|
||||
cy.get(createLocationButton).click();
|
||||
// cy.get(dialogInputs).eq(0).type(postCode);
|
||||
// city create button
|
||||
cy.selectOption(
|
||||
`${createForm.prefix} > :nth-child(5) > :nth-child(3) `,
|
||||
'Italia'
|
||||
);
|
||||
cy.get(
|
||||
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) > .q-icon`
|
||||
).click();
|
||||
cy.selectOption('#q-portal--dialog--4 .q-select', 'Province four');
|
||||
cy.countSelectOptions('#q-portal--dialog--4 .q-select', 1);
|
||||
|
||||
cy.get('#q-portal--dialog--4 .q-input').type(cityName);
|
||||
cy.get('#q-portal--dialog--4 .q-btn--standard').click();
|
||||
// cy.get('#q-portal--dialog--1 .q-btn--standard').click();
|
||||
// cy.waitForElement('.q-form');
|
||||
|
||||
// checkVnLocation(postCode, province);
|
||||
});
|
||||
it.only('Create province with country', () => {
|
||||
// const postCode = '9011';
|
||||
const provinceName = 'Saskatchew'.concat(Math.random(1 * 100));
|
||||
cy.get(createLocationButton).click();
|
||||
// cy.get(dialogInputs).eq(0).type(postCode);
|
||||
cy.selectOption(
|
||||
`${createForm.prefix} > :nth-child(5) > :nth-child(3) `,
|
||||
'España'
|
||||
);
|
||||
cy.get(
|
||||
`${createForm.prefix} > :nth-child(5) > .q-select > ${createForm.sufix} > :nth-child(2) `
|
||||
)
|
||||
.eq(0)
|
||||
.click();
|
||||
|
||||
cy.selectOption('#q-portal--dialog--4 .q-select', 'one');
|
||||
cy.countSelectOptions('#q-portal--dialog--4 .q-select', 2);
|
||||
|
||||
cy.get('#q-portal--dialog--4 .q-input').type(provinceName);
|
||||
cy.get('#q-portal--dialog--4 .q-btn--standard').click();
|
||||
// cy.get('#q-portal--dialog--1 .q-btn--standard').click();
|
||||
// cy.waitForElement('.q-form');
|
||||
|
||||
// checkVnLocation(postCode, province);
|
||||
});
|
||||
function checkVnLocation(postCode, province) {
|
||||
cy.get(`${createForm.prefix}`).should('not.exist');
|
||||
cy.get('.q-form > .q-card > .vn-row:nth-child(6)')
|
||||
|
|
|
@ -91,6 +91,11 @@ Cypress.Commands.add('selectOption', (selector, option) => {
|
|||
cy.get(selector).click();
|
||||
cy.get('.q-menu .q-item').contains(option).click();
|
||||
});
|
||||
Cypress.Commands.add('countSelectOptions', (selector, option) => {
|
||||
cy.waitForElement(selector);
|
||||
cy.get(selector).click();
|
||||
cy.get('.q-menu .q-item').should('have.length', option);
|
||||
});
|
||||
|
||||
Cypress.Commands.add('fillInForm', (obj, form = '.q-form > .q-card') => {
|
||||
cy.waitForElement('.q-form > .q-card');
|
||||
|
|
Loading…
Reference in New Issue