#7356 - Ticket module improves #1405

Merged
jsegarra merged 42 commits from warmfix_ticketList into test 2025-03-03 13:37:03 +00:00
16 changed files with 244 additions and 75 deletions

View File

@ -17,9 +17,9 @@ describe('getAddresses', () => {
expect(axios.get).toHaveBeenCalledWith(`Clients/${clientId}/addresses`, { expect(axios.get).toHaveBeenCalledWith(`Clients/${clientId}/addresses`, {
params: { params: {
filter: JSON.stringify({ filter: JSON.stringify({
fields: ['nickname', 'street', 'city', 'id'], fields: ['nickname', 'street', 'city', 'id', 'isActive'],
where: { isActive: true }, where: { isActive: true },
order: 'nickname ASC', order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
}), }),
}, },
}); });
@ -30,4 +30,4 @@ describe('getAddresses', () => {
expect(axios.get).not.toHaveBeenCalled(); expect(axios.get).not.toHaveBeenCalled();
}); });
}); });

View File

@ -1,15 +1,15 @@
import axios from 'axios'; import axios from 'axios';
export async function getAddresses(clientId, _filter = {}) { export async function getAddresses(clientId, _filter = {}) {
if (!clientId) return; if (!clientId) return;
const filter = { const filter = {
..._filter, ..._filter,
fields: ['nickname', 'street', 'city', 'id'], fields: ['nickname', 'street', 'city', 'id', 'isActive'],
Review

Se corrige un problema en un refactor de hace tiempo

Se corrige un problema en un refactor de hace tiempo
where: { isActive: true }, where: { isActive: true },
order: 'nickname ASC', order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
}; };
const params = { filter: JSON.stringify(filter) }; const params = { filter: JSON.stringify(filter) };
return await axios.get(`Clients/${clientId}/addresses`, { return await axios.get(`Clients/${clientId}/addresses`, {
params, params,
}); });
}; }

View File

@ -155,11 +155,23 @@ onMounted(() => {
}); });
async function fetchClientAddress(id, formData = {}) { async function fetchClientAddress(id, formData = {}) {
const { data } = await axios.get( const { data } = await axios.get(`Clients/${id}/addresses`, {
`Clients/${id}/addresses?filter[order]=isActive DESC` params: {
); filter: JSON.stringify({
include: [
{
relation: 'client',
scope: {
fields: ['defaultAddressFk'],
},
},
],
order: ['isActive DESC'],
}),
},
});
addressOptions.value = data; addressOptions.value = data;
formData.addressId = data.defaultAddressFk; formData.addressId = data[0].client.defaultAddressFk;
fetchAgencies(formData); fetchAgencies(formData);
} }
@ -167,7 +179,13 @@ async function fetchAgencies({ landed, addressId }) {
if (!landed || !addressId) return (agencyList.value = []); if (!landed || !addressId) return (agencyList.value = []);
const { data } = await axios.get('Agencies/landsThatDay', { const { data } = await axios.get('Agencies/landsThatDay', {
params: { addressFk: addressId, landed }, params: {
filter: JSON.stringify({
order: ['agencyMode DESC', 'agencyModeFk ASC'],
}),
addressFk: addressId,
landed,
},
}); });
agencyList.value = data; agencyList.value = data;
} }
@ -258,6 +276,7 @@ const getDateColor = (date) => {
</template> </template>
</VnSelect> </VnSelect>
<VnSelect <VnSelect
:disable="!data.clientFk"
v-model="data.addressId" v-model="data.addressId"
:options="addressOptions" :options="addressOptions"
:label="t('module.address')" :label="t('module.address')"
@ -284,6 +303,9 @@ const getDateColor = (date) => {
{{ scope.opt?.street }}, {{ scope.opt?.street }},
{{ scope.opt?.city }} {{ scope.opt?.city }}
</QItemLabel> </QItemLabel>
<QItemLabel caption>
{{ `#${scope.opt?.id}` }}
</QItemLabel>
</QItemSection> </QItemSection>
</QItem> </QItem>
</template> </template>

View File

@ -27,14 +27,17 @@ describe('getAgencies', () => {
landed: 'true', landed: 'true',
}; };
const filter = { const filter = {
fields: ['nickname', 'street', 'city', 'id'], fields: ['name', 'street', 'city', 'id'],
where: { isActive: true }, where: { isActive: true },
order: 'nickname ASC', order: ['name ASC'],
}; };
await getAgencies(formData, null, filter); await getAgencies(formData, null, filter);
expect(axios.get).toHaveBeenCalledWith('Agencies/getAgenciesWithWarehouse', generateParams(formData, filter)); expect(axios.get).toHaveBeenCalledWith(
'Agencies/getAgenciesWithWarehouse',
generateParams(formData, filter),
);
}); });
it('should not call API when formData is missing required landed field', async () => { it('should not call API when formData is missing required landed field', async () => {
@ -64,19 +67,19 @@ describe('getAgencies', () => {
it('should return options and agency when default agency is found', async () => { it('should return options and agency when default agency is found', async () => {
const formData = { warehouseId: '123', addressId: '456', landed: 'true' }; const formData = { warehouseId: '123', addressId: '456', landed: 'true' };
const client = { defaultAddress: { agencyModeFk: 'Agency1' } }; const client = { defaultAddress: { agencyModeFk: 'Agency1' } };
const { options, agency } = await getAgencies(formData, client); const { options, agency } = await getAgencies(formData, client);
expect(options).toEqual(response.data); expect(options).toEqual(response.data);
expect(agency).toEqual(response.data[0]); expect(agency).toEqual(response.data[0]);
}); });
it('should return options and agency when client is not provided', async () => { it('should return options and agency when client is not provided', async () => {
const formData = { warehouseId: '123', addressId: '456', landed: 'true' }; const formData = { warehouseId: '123', addressId: '456', landed: 'true' };
const { options, agency } = await getAgencies(formData); const { options, agency } = await getAgencies(formData);
expect(options).toEqual(response.data); expect(options).toEqual(response.data);
expect(agency).toBeNull(); expect(agency).toBeNull();
}); });
}); });

View File

@ -1,14 +1,14 @@
import axios from 'axios'; import axios from 'axios';
import agency from 'src/router/modules/agency';
export async function getAgencies(formData, client, _filter = {}) { export async function getAgencies(formData, client, _filter = {}) {
if (!formData.warehouseId || !formData.addressId || !formData.landed) return; if (!formData.warehouseId || !formData.addressId || !formData.landed) return;
const filter = { const filter = {
..._filter ..._filter,
order: ['name ASC'],
}; };
let defaultAgency = null; let agency = null;
let params = { let params = {
filter: JSON.stringify(filter), filter: JSON.stringify(filter),
warehouseFk: formData.warehouseId, warehouseFk: formData.warehouseId,
@ -16,11 +16,15 @@ export async function getAgencies(formData, client, _filter = {}) {
landed: formData.landed, landed: formData.landed,
}; };
const { data } = await axios.get('Agencies/getAgenciesWithWarehouse', { params }); const { data: options } = await axios.get('Agencies/getAgenciesWithWarehouse', {
params,
});
if(data && client) { if (options && client) {
defaultAgency = data.find((agency) => agency.agencyModeFk === client.defaultAddress.agencyModeFk ); agency = options.find(
}; ({ agencyModeFk }) => agencyModeFk === client.defaultAddress.agencyModeFk,
);
return {options: data, agency: defaultAgency} }
return { options, agency };
} }

View File

@ -105,6 +105,9 @@ const columns = computed(() => [
name: 'created', name: 'created',
align: 'left', align: 'left',
cardVisible: true, cardVisible: true,
columnFilter: {
component: 'date',
},
format: (row) => toDateTimeFormat(row.created), format: (row) => toDateTimeFormat(row.created),
}, },
{ {
@ -201,7 +204,7 @@ const getExpeditionState = async (expedition) => {
const openGrafana = (expeditionFk) => { const openGrafana = (expeditionFk) => {
useOpenURL( useOpenURL(
`https://grafana.verdnatura.es/d/de1njb6p5answd/control-de-expediciones?orgId=1&var-expeditionFk=${expeditionFk}` `https://grafana.verdnatura.es/d/de1njb6p5answd/control-de-expediciones?orgId=1&var-expeditionFk=${expeditionFk}`,
); );
}; };
@ -287,7 +290,7 @@ onMounted(async () => {
openConfirmationModal( openConfirmationModal(
'', '',
t('expedition.removeExpeditionSubtitle'), t('expedition.removeExpeditionSubtitle'),
deleteExpedition deleteExpedition,
) )
" "
> >
@ -302,7 +305,6 @@ onMounted(async () => {
url="Expeditions/filter" url="Expeditions/filter"
search-url="expeditions" search-url="expeditions"
:columns="columns" :columns="columns"
:filter="expeditionsFilter"
v-model:selected="selectedRows" v-model:selected="selectedRows"
:table="{ :table="{
'row-key': 'id', 'row-key': 'id',
@ -316,6 +318,8 @@ onMounted(async () => {
return { id: value }; return { id: value };
case 'packageItemName': case 'packageItemName':
return { packagingItemFk: value }; return { packagingItemFk: value };
case 'created':
return { 'e.created': { gte: value } };
} }
} }
" "

View File

@ -42,7 +42,7 @@ const transferRef = ref(null);
/> />
</div> </div>
<div v-else> <div style="display: flex; flex-direction: row" v-else>
<TicketTransfer <TicketTransfer
ref="transferRef" ref="transferRef"
:ticket="$props.ticket" :ticket="$props.ticket"

View File

@ -142,7 +142,7 @@ onMounted(() => (stateStore.rightDrawer = true));
<template #column-concept="{ row }"> <template #column-concept="{ row }">
<span>{{ row.item.name }}</span> <span>{{ row.item.name }}</span>
<span class="color-vn-label q-pl-md">{{ row.item.subName }}</span> <span class="color-vn-label q-pl-md">{{ row.item.subName }}</span>
<FetchedTags :item="row.item" /> <FetchedTags :item="row.item" :columns="6" />
</template> </template>
<template #column-volume="{ rowIndex }"> <template #column-volume="{ rowIndex }">
<span>{{ packingTypeVolume?.[rowIndex]?.volume }}</span> <span>{{ packingTypeVolume?.[rowIndex]?.volume }}</span>

View File

@ -46,7 +46,12 @@ const getGroupedStates = (data) => {
" "
auto-load auto-load
/> />
<FetchData url="AgencyModes" @on-fetch="(data) => (agencies = data)" auto-load /> <FetchData
url="AgencyModes"
:sort-by="['name ASC']"
@on-fetch="(data) => (agencies = data)"
auto-load
/>
<FetchData url="Warehouses" @on-fetch="(data) => (warehouses = data)" auto-load /> <FetchData url="Warehouses" @on-fetch="(data) => (warehouses = data)" auto-load />
<VnFilterPanel :data-key="props.dataKey" :search-button="true"> <VnFilterPanel :data-key="props.dataKey" :search-button="true">
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
@ -74,10 +79,20 @@ const getGroupedStates = (data) => {
</QItem> </QItem>
<QItem> <QItem>
<QItemSection> <QItemSection>
<VnInputDate v-model="params.from" :label="t('From')" is-outlined /> <VnInputDate
v-model="params.from"
:label="t('From')"
is-outlined
data-cy="From_date"
/>
</QItemSection> </QItemSection>
<QItemSection> <QItemSection>
<VnInputDate v-model="params.to" :label="t('To')" is-outlined /> <VnInputDate
v-model="params.to"
:label="t('To')"
is-outlined
data-cy="To_date"
/>
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem> <QItem>

View File

@ -1,6 +1,6 @@
<script setup> <script setup>
import axios from 'axios'; import axios from 'axios';
import { computed, ref, onBeforeMount } from 'vue'; import { computed, ref, onBeforeMount, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
@ -69,6 +69,8 @@ const companiesOptions = ref([]);
const accountingOptions = ref([]); const accountingOptions = ref([]);
const amountToReturn = ref(); const amountToReturn = ref();
const dataKey = 'TicketList'; const dataKey = 'TicketList';
const filterPanelRef = ref(null);
const formInitialData = ref({});
const columns = computed(() => [ const columns = computed(() => [
{ {
@ -119,12 +121,16 @@ const columns = computed(() => [
{ {
align: 'left', align: 'left',
name: 'shipped', name: 'shipped',
component: 'time',
columnFilter: false,
label: t('ticketList.hour'), label: t('ticketList.hour'),
format: (row) => toTimeFormat(row.shipped), format: (row) => toTimeFormat(row.shipped),
}, },
{ {
align: 'left', align: 'left',
name: 'zoneLanding', name: 'zoneLanding',
component: 'time',
columnFilter: false,
label: t('ticketList.closure'), label: t('ticketList.closure'),
format: (row, dashIfEmpty) => dashIfEmpty(toTimeFormat(row.zoneLanding)), format: (row, dashIfEmpty) => dashIfEmpty(toTimeFormat(row.zoneLanding)),
}, },
@ -144,9 +150,16 @@ const columns = computed(() => [
}, },
{ {
align: 'left', align: 'left',
name: 'province', name: 'provinceFk',
label: t('ticketList.province'), label: t('ticketList.province'),
columnClass: 'expand', component: 'select',
attrs: {
url: 'Provinces',
},
columnField: {
component: null,
},
format: (row, dashIfEmpty) => dashIfEmpty(row.province),
}, },
{ {
align: 'left', align: 'left',
@ -180,9 +193,19 @@ const columns = computed(() => [
}, },
{ {
align: 'left', align: 'left',
name: 'warehouse', name: 'warehouseFk',
label: t('ticketList.warehouse'), label: t('globals.warehouse'),
columnClass: 'expand', component: 'select',
attrs: {
url: 'warehouses',
fields: ['id', 'name'],
},
format: (row) => row.warehouse,
columnField: {
component: null,
},
cardVisible: false,
create: false,
}, },
{ {
align: 'left', align: 'left',
@ -422,6 +445,22 @@ function setReference(data) {
dialogData.value.value.description = newDescription; dialogData.value.value.description = newDescription;
} }
watch(
() => route.query.table,
(newValue) => {
if (newValue) {
const clientId = +JSON.parse(newValue)?.clientFk;
if (!clientId) return;
formInitialData.value = {
clientId,
};
if (tableRef.value) tableRef.value.create.formInitialData = { clientId };
onClientSelected({ clientId });
}
},
{ immediate: true },
);
</script> </script>
<template> <template>
@ -456,7 +495,7 @@ function setReference(data) {
urlCreate: 'Tickets/new', urlCreate: 'Tickets/new',
title: t('ticketList.createTicket'), title: t('ticketList.createTicket'),
onDataSaved: ({ id }) => tableRef.redirect(id), onDataSaved: ({ id }) => tableRef.redirect(id),
formInitialData: { clientId: null }, formInitialData,
}" }"
default-mode="table" default-mode="table"
:columns="columns" :columns="columns"
@ -538,11 +577,9 @@ function setReference(data) {
:label="t('ticketList.client')" :label="t('ticketList.client')"
v-model="data.clientId" v-model="data.clientId"
:options="clientsOptions" :options="clientsOptions"
option-value="id"
option-label="name"
hide-selected hide-selected
required required
@update:model-value="(client) => onClientSelected(data)" @update:model-value="() => onClientSelected(data)"
:sort-by="'id ASC'" :sort-by="'id ASC'"
> >
<template #option="scope"> <template #option="scope">
@ -564,7 +601,6 @@ function setReference(data) {
:label="t('basicData.address')" :label="t('basicData.address')"
v-model="data.addressId" v-model="data.addressId"
:options="addressesOptions" :options="addressesOptions"
option-value="id"
option-label="nickname" option-label="nickname"
hide-selected hide-selected
map-options map-options
@ -610,6 +646,9 @@ function setReference(data) {
{{ scope.opt?.city }} {{ scope.opt?.city }}
</span> </span>
</QItemLabel> </QItemLabel>
<QItemLabel caption>
{{ `#${scope.opt?.id}` }}
</QItemLabel>
</QItemSection> </QItemSection>
</QItem> </QItem>
</template> </template>
@ -633,8 +672,6 @@ function setReference(data) {
:label="t('globals.warehouse')" :label="t('globals.warehouse')"
v-model="data.warehouseId" v-model="data.warehouseId"
:options="warehousesOptions" :options="warehousesOptions"
option-value="id"
option-label="name"
hide-selected hide-selected
required required
@update:model-value="() => fetchAvailableAgencies(data)" @update:model-value="() => fetchAvailableAgencies(data)"
@ -694,7 +731,6 @@ function setReference(data) {
:label="t('ticketList.company')" :label="t('ticketList.company')"
v-model="dialogData.companyFk" v-model="dialogData.companyFk"
:options="companiesOptions" :options="companiesOptions"
option-value="id"
option-label="code" option-label="code"
hide-selected hide-selected
> >
@ -705,7 +741,6 @@ function setReference(data) {
:label="t('ticketList.bank')" :label="t('ticketList.bank')"
v-model="dialogData.bankFk" v-model="dialogData.bankFk"
:options="accountingOptions" :options="accountingOptions"
option-value="id"
option-label="bank" option-label="bank"
hide-selected hide-selected
@update:model-value="setReference" @update:model-value="setReference"

View File

@ -18,7 +18,7 @@ describe('Client consignee', () => {
const addressName = 'test'; const addressName = 'test';
cy.dataCy('Consignee_input').type(addressName); cy.dataCy('Consignee_input').type(addressName);
cy.dataCy('Location_select').click(); cy.dataCy('Location_select').click();
cy.get('[role="listbox"] .q-item:nth-child(1)').click(); cy.getOption();
cy.dataCy('Street address_input').type('TEST ADDRESS'); cy.dataCy('Street address_input').type('TEST ADDRESS');
cy.get('.q-btn-group > .q-btn--standard').click(); cy.get('.q-btn-group > .q-btn--standard').click();
cy.location('href').should('contain', '#/customer/1107/address'); cy.location('href').should('contain', '#/customer/1107/address');

View File

@ -0,0 +1,51 @@
/// <reference types="cypress" />
describe('TicketFilter', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/list');
cy.domContentLoad();
});
it('use search button', function () {
cy.waitForElement('.q-page');
cy.intercept('GET', /\/api\/Tickets\/filter/).as('ticketFilter');
cy.searchBtnFilterPanel();
cy.waitRequest('@ticketFilter', ({ request }) => {
Review

No acabo de ver la funcion cy.waitRequest.
Usando lo nativo mejor el codigo

cy.wait('@ticketFilter').then({ request }) => {
...
})
No acabo de ver la funcion cy.waitRequest. Usando lo nativo mejor el codigo ``` cy.wait('@ticketFilter').then({ request }) => { ... }) ```
Review

el sentido de este comando es delegar la lógica de interceptar peticiones desde un sitio en vez de que cada uno pueda hacerlo variable.
Por unificar, vamos, ya que al fin y al cabo, le pasas el alias y el cb

el sentido de este comando es delegar la lógica de interceptar peticiones desde un sitio en vez de que cada uno pueda hacerlo variable. Por unificar, vamos, ya que al fin y al cabo, le pasas el alias y el cb
Review

Sigo sin ver un commnado personalizado, que con codigo nativo se lee mas claro

Sigo sin ver un commnado personalizado, que con codigo nativo se lee mas claro
const { query } = request;
expect(query).to.have.property('from');
expect(query).to.have.property('to');
});
cy.on('uncaught:exception', () => {
return false;
});
cy.get('.q-field__control-container > [data-cy="From_date"]')
.type(`${today()} `)
.type('{enter}');
cy.get('.q-notification').should(
'contain',
`The date range must have both 'from' and 'to'`,
);
cy.get('.q-field__control-container > [data-cy="To_date"]').type(
`${today()}{enter}`,
);
cy.intercept('GET', /\/api\/Tickets\/filter/).as('ticketFilter');
cy.searchBtnFilterPanel();
cy.wait('@ticketFilter').then(({ request }) => {
const { query } = request;
expect(query).to.have.property('from');
expect(query).to.have.property('to');
});
cy.location('href').should('contain', '#/ticket/999999');
});
});
function today(date) {
// return new Date().toISOString().split('T')[0];
return new Intl.DateTimeFormat('es-ES', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}).format(date ?? new Date());
}

View File

@ -1,16 +1,16 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
describe('TicketList', () => { describe('TicketList', () => {
const firstRow = 'tbody > :nth-child(1)'; const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)';
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('developer');
cy.viewport(1920, 1080); cy.viewport(1920, 1080);
cy.visit('/#/ticket/list'); cy.visit('/#/ticket/list');
cy.domContentLoad();
}); });
const searchResults = (search) => { const searchResults = (search) => {
cy.dataCy('vn-searchbar').find('input').focus(); if (search) cy.typeSearchbar().type(search);
if (search) cy.dataCy('vn-searchbar').find('input').type(search);
cy.dataCy('vn-searchbar').find('input').type('{enter}'); cy.dataCy('vn-searchbar').find('input').type('{enter}');
cy.dataCy('ticketListTable').should('exist'); cy.dataCy('ticketListTable').should('exist');
cy.get(firstRow).should('exist'); cy.get(firstRow).should('exist');
@ -27,7 +27,7 @@ describe('TicketList', () => {
cy.window().then((win) => { cy.window().then((win) => {
cy.stub(win, 'open').as('windowOpen'); cy.stub(win, 'open').as('windowOpen');
}); });
cy.get(firstRow).find('.q-btn:first').click(); cy.get(firstRow).should('be.visible').find('.q-btn:first').click();
cy.get('@windowOpen').should('be.calledWithMatch', /\/ticket\/\d+\/sale/); cy.get('@windowOpen').should('be.calledWithMatch', /\/ticket\/\d+\/sale/);
}); });
@ -38,6 +38,31 @@ describe('TicketList', () => {
cy.get('.summaryBody').should('exist'); cy.get('.summaryBody').should('exist');
}); });
it('filter client and create ticket', () => {
cy.intercept('GET', /\/api\/Tickets\/filter/).as('ticketSearchbar');
searchResults();
cy.wait('@ticketSearchbar').then(({ request }) => {
const { query } = request;
expect(query).to.have.property('from');
expect(query).to.have.property('to');
expect(query).to.not.have.property('clientFk');
});
cy.intercept('GET', /\/api\/Tickets\/filter/).as('ticketFilter');
cy.dataCy('Customer ID_input').clear('1');
cy.dataCy('Customer ID_input').type('1101{enter}');
cy.wait('@ticketFilter').then(({ request }) => {
const { query } = request;
expect(query).to.not.have.property('from');
expect(query).to.not.have.property('to');
expect(query).to.have.property('clientFk');
});
cy.get('[data-cy="vnTableCreateBtn"] > .q-btn__content > .q-icon').click();
cy.dataCy('Customer_select').should('have.value', 'Bruce Wayne');
cy.dataCy('Address_select').click();
cy.getOption().click();
cy.dataCy('Address_select').should('have.value', 'Bruce Wayne');
});
it('Client list create new client', () => { it('Client list create new client', () => {
cy.dataCy('vnTableCreateBtn').should('exist'); cy.dataCy('vnTableCreateBtn').should('exist');
cy.dataCy('vnTableCreateBtn').click(); cy.dataCy('vnTableCreateBtn').click();

View File

@ -18,7 +18,7 @@ describe('UserPanel', () => {
cy.get(userWarehouse).should('have.value', 'VNL').click(); cy.get(userWarehouse).should('have.value', 'VNL').click();
// Actualizo la opción // Actualizo la opción
getOption(3); cy.getOption(3);
//Compruebo la notificación //Compruebo la notificación
cy.get('.q-notification').should('be.visible'); cy.get('.q-notification').should('be.visible');
@ -26,7 +26,7 @@ describe('UserPanel', () => {
//Restauro el valor //Restauro el valor
cy.get(userWarehouse).click(); cy.get(userWarehouse).click();
getOption(2); cy.getOption(2);
}); });
it('should notify when update user company', () => { it('should notify when update user company', () => {
const userCompany = const userCompany =
@ -39,7 +39,7 @@ describe('UserPanel', () => {
cy.get(userCompany).should('have.value', 'Warehouse One').click(); cy.get(userCompany).should('have.value', 'Warehouse One').click();
//Actualizo la opción //Actualizo la opción
getOption(2); cy.getOption(2);
//Compruebo la notificación //Compruebo la notificación
cy.get('.q-notification').should('be.visible'); cy.get('.q-notification').should('be.visible');
@ -47,12 +47,6 @@ describe('UserPanel', () => {
//Restauro el valor //Restauro el valor
cy.get(userCompany).click(); cy.get(userCompany).click();
getOption(1); cy.getOption(1);
}); });
}); });
function getOption(index) {
cy.waitForElement('[role="listbox"]');
const option = `[role="listbox"] .q-item:nth-child(${index})`;
cy.get(option).click();
}

View File

@ -40,7 +40,7 @@ describe('VnLocation', () => {
cy.selectOption(countrySelector, country); cy.selectOption(countrySelector, country);
cy.dataCy('locationProvince').type(`${province}{enter}`); cy.dataCy('locationProvince').type(`${province}{enter}`);
cy.get( cy.get(
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(3) ` `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(3) `,
).click(); ).click();
cy.dataCy('locationProvince').should('have.value', province); cy.dataCy('locationProvince').should('have.value', province);
}); });
@ -87,9 +87,9 @@ describe('VnLocation', () => {
.get(':nth-child(1)') .get(':nth-child(1)')
.should('have.length.at.least', 2); .should('have.length.at.least', 2);
cy.get( cy.get(
firstOption.concat(' > .q-item__section > .q-item__label--caption') firstOption.concat(' > .q-item__section > .q-item__label--caption'),
).should('have.text', postCodeLabel); ).should('have.text', postCodeLabel);
cy.get(firstOption).click(); cy.getOption();
cy.get('.q-btn-group > .q-btn--standard > .q-btn__content > .q-icon').click(); cy.get('.q-btn-group > .q-btn--standard > .q-btn__content > .q-icon').click();
cy.reload(); cy.reload();
cy.waitForElement('.q-form'); cy.waitForElement('.q-form');
@ -103,7 +103,7 @@ describe('VnLocation', () => {
cy.get('.q-card > h1').should('have.text', 'New postcode'); cy.get('.q-card > h1').should('have.text', 'New postcode');
cy.selectOption( cy.selectOption(
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix}`, `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix}`,
province province,
); );
cy.get(dialogInputs).eq(0).clear(); cy.get(dialogInputs).eq(0).clear();
cy.get(dialogInputs).eq(0).type(postCode); cy.get(dialogInputs).eq(0).type(postCode);
@ -156,7 +156,7 @@ describe('VnLocation', () => {
cy.get(createLocationButton).click(); cy.get(createLocationButton).click();
cy.selectOption( cy.selectOption(
`${createForm.prefix} > :nth-child(5) > :nth-child(3) `, `${createForm.prefix} > :nth-child(5) > :nth-child(3) `,
'España' 'España',
); );
cy.dataCy('Province_icon').click(); cy.dataCy('Province_icon').click();

View File

@ -381,6 +381,22 @@ Cypress.Commands.add('clickButtonWith', (type, value) => {
Cypress.Commands.add('clickButtonWithIcon', (iconClass) => { Cypress.Commands.add('clickButtonWithIcon', (iconClass) => {
cy.get(`.q-icon.${iconClass}`).parent().click(); cy.get(`.q-icon.${iconClass}`).parent().click();
}); });
Cypress.Commands.add('clickButtonWithText', (buttonText) => { Cypress.Commands.add('clickButtonWithText', (buttonText) => {
cy.get('.q-btn').contains(buttonText).click(); cy.get('.q-btn').contains(buttonText).click();
}); });
Cypress.Commands.add('getOption', (index = 1) => {
cy.waitForElement('[role="listbox"]');
cy.get(`[role="listbox"] .q-item:nth-child(${index})`).click();
});
Cypress.Commands.add('searchBtnFilterPanel', () => {
cy.get(
'.q-scrollarea__content > .q-btn--standard > .q-btn__content > .q-icon',
).click();
});
Cypress.Commands.add('waitRequest', (alias, cb) => {
cy.wait(alias).then(cb);
});