{
:disable="!value"
is-outlined
class="col"
+ data-cy="catalogFilterValueDialogValueInput"
/>
-
+
diff --git a/src/pages/Order/Card/OrderCatalogFilter.vue b/src/pages/Order/Card/OrderCatalogFilter.vue
index 6202a6f90..1dd569fb5 100644
--- a/src/pages/Order/Card/OrderCatalogFilter.vue
+++ b/src/pages/Order/Card/OrderCatalogFilter.vue
@@ -178,6 +178,7 @@ function addOrder(value, field, params) {
? resetCategory(params, searchFn)
: removeTagGroupParam(params, searchFn, valIndex)
"
+ data-cy="catalogFilterCustomTag"
>
{{
@@ -211,6 +212,7 @@ function addOrder(value, field, params) {
:name="category.icon"
class="category-icon"
@click="selectCategory(params, category, searchFn)"
+ data-cy="catalogFilterCategory"
>
{{ t(category.name) }}
@@ -234,6 +236,7 @@ function addOrder(value, field, params) {
sort-by="name ASC"
:disable="!params.categoryFk"
@update:model-value="searchFn()"
+ data-cy="catalogFilterType"
>
@@ -285,6 +288,7 @@ function addOrder(value, field, params) {
:is-clearable="false"
v-model="searchByTag"
@keyup.enter="(val) => onSearchByTag(val, params)"
+ data-cy="catalogFilterValueInput"
>
@@ -297,6 +301,7 @@ function addOrder(value, field, params) {
color="primary"
size="md"
dense
+ data-cy="catalogFilterValueDialogBtn"
/>
{
});
async function fetchClientAddress(id, formData = {}) {
const { data } = await axios.get(`Clients/${id}`, {
- params: { filter: { include: { relation: 'addresses' } } },
+ params: {
+ filter: {
+ order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
+ include: { relation: 'addresses' },
+ },
+ },
});
addressesList.value = data.addresses;
formData.addressId = data.defaultAddressFk;
@@ -162,7 +168,7 @@ async function fetchAgencies({ landed, addressId }) {
const { data } = await axios.get('Agencies/landsThatDay', {
params: { addressFk: addressId, landed },
});
- agencyList.value = data;
+ agencyList.value = dataByOrder(data, 'agencyMode ASC');
}
const getDateColor = (date) => {
@@ -191,7 +197,7 @@ const getDateColor = (date) => {
urlCreate: 'Orders/new',
title: t('module.cerateOrder'),
onDataSaved: (url) => {
- tableRef.redirect(`${url}/catalog`);
+ tableRef.redirect(`${url}/catalog`);
},
formInitialData: {
active: true,
@@ -253,22 +259,27 @@ const getDateColor = (date) => {
@update:model-value="() => fetchAgencies(data)"
>
-
+
+
+
+
-
- {{
- `${
- !scope.opt?.isActive
- ? t('basicData.inactive')
- : ''
- } `
- }}
- {{ scope.opt?.nickname }}: {{ scope.opt?.street }},
- {{ scope.opt?.city }}
+
+ {{ scope.opt.nickname }}
+
+
+ {{ `${scope.opt.street}, ${scope.opt.city}` }}
diff --git a/src/pages/Ticket/TicketFilter.vue b/src/pages/Ticket/TicketFilter.vue
index 6f1cac83b..bde27f30e 100644
--- a/src/pages/Ticket/TicketFilter.vue
+++ b/src/pages/Ticket/TicketFilter.vue
@@ -212,81 +212,78 @@ const getGroupedStates = (data) => {
/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -340,7 +337,6 @@ es:
With problems: Con problemas
Invoiced: Facturado
Routed: Enrutado
- More options: Más opciones
Province: Provincia
Agency: Agencia
Warehouse: Almacén
diff --git a/src/pages/Ticket/TicketList.vue b/src/pages/Ticket/TicketList.vue
index 149a794a9..2fe4fcddc 100644
--- a/src/pages/Ticket/TicketList.vue
+++ b/src/pages/Ticket/TicketList.vue
@@ -274,7 +274,7 @@ const fetchAddresses = async (formData) => {
const filter = {
fields: ['nickname', 'street', 'city', 'id', 'isActive'],
- order: 'nickname ASC',
+ order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
};
const params = { filter: JSON.stringify(filter) };
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
@@ -590,7 +590,22 @@ function setReference(data) {
@update:model-value="() => fetchAvailableAgencies(data)"
>
-
+
+
+
+
+describe('OrderCatalog', () => {
+ beforeEach(() => {
+ cy.login('developer');
+ cy.viewport(1920, 720);
+ cy.visit('/#/order/8/catalog');
+ });
+
+ const checkCustomFilterTag = (filterName = 'Plant') => {
+ cy.dataCy('catalogFilterCustomTag').should('exist');
+ cy.dataCy('catalogFilterCustomTag').contains(filterName);
+ };
+
+ const checkFilterTag = (filterName = 'Plant') => {
+ cy.dataCy('vnFilterPanelChip').should('exist');
+ cy.dataCy('vnFilterPanelChip').contains(filterName);
+ };
+
+ const selectCategory = (categoryIndex = 1, categoryName = 'Plant') => {
+ cy.get(
+ `div.q-page-container div:nth-of-type(${categoryIndex}) > [data-cy='catalogFilterCategory']`
+ ).should('exist');
+ cy.get(
+ `div.q-page-container div:nth-of-type(${categoryIndex}) > [data-cy='catalogFilterCategory']`
+ ).click();
+ checkCustomFilterTag(categoryName);
+ };
+
+ const searchByCustomTagInput = (option) => {
+ cy.dataCy('catalogFilterValueInput').find('input').last().focus();
+ cy.dataCy('catalogFilterValueInput').find('input').last().type(option);
+ cy.dataCy('catalogFilterValueInput').find('input').last().type('{enter}');
+ checkCustomFilterTag(option);
+ };
+
+ const selectTypeFilter = (option) => {
+ cy.selectOption(
+ 'div.q-page-container div.list > div:nth-of-type(2) div:nth-of-type(3)',
+ option
+ );
+ checkFilterTag(option);
+ };
+
+ it('Shows empty state', () => {
+ cy.dataCy('orderCatalogPage').should('exist');
+ cy.dataCy('orderCatalogPage').contains('No data to display');
+ });
+
+ it('filter by category', () => {
+ selectCategory();
+ cy.dataCy('orderCatalogItem').should('exist');
+ });
+
+ it('filters by type', () => {
+ selectCategory();
+ selectTypeFilter('Anthurium');
+ });
+
+ it('filters by custom value select', () => {
+ selectCategory();
+ searchByCustomTagInput('Silver');
+ });
+
+ it('filters by custom value dialog', () => {
+ Cypress.on('uncaught:exception', (err) => {
+ if (err.message.includes('canceled')) {
+ return false;
+ }
+ });
+ selectCategory();
+ cy.dataCy('catalogFilterValueDialogBtn').should('exist');
+ cy.dataCy('catalogFilterValueDialogBtn').last().click();
+ cy.dataCy('catalogFilterValueDialogTagSelect').should('exist');
+ cy.selectOption("[data-cy='catalogFilterValueDialogTagSelect']", 'Tallos');
+ cy.dataCy('catalogFilterValueDialogValueInput').find('input').focus();
+ cy.dataCy('catalogFilterValueDialogValueInput').find('input').type('2');
+ cy.dataCy('catalogFilterValueDialogValueInput').find('input').type('{enter}');
+ checkCustomFilterTag('2');
+ });
+
+ it('removes a secondary tag', () => {
+ selectCategory();
+ selectTypeFilter('Anthurium');
+ cy.dataCy('vnFilterPanelChip').should('exist');
+ cy.get(
+ "div.q-page-container [data-cy='vnFilterPanelChip'] > i.q-chip__icon--remove"
+ )
+ .contains('cancel')
+ .should('exist');
+ cy.get(
+ "div.q-page-container [data-cy='vnFilterPanelChip'] > i.q-chip__icon--remove"
+ )
+ .contains('cancel')
+ .click();
+ cy.dataCy('vnFilterPanelChip').should('not.exist');
+ });
+
+ it('Removes category tag', () => {
+ selectCategory();
+ cy.get(
+ "div.q-page-container [data-cy='catalogFilterCustomTag'] > i.q-chip__icon--remove"
+ )
+ .contains('cancel')
+ .should('exist');
+ cy.get(
+ "div.q-page-container [data-cy='catalogFilterCustomTag'] > i.q-chip__icon--remove"
+ )
+ .contains('cancel')
+ .click();
+ cy.dataCy('catalogFilterCustomTag').should('not.exist');
+ });
+});
diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js
index 53f9d1d73..dbaa7871c 100755
--- a/test/cypress/support/commands.js
+++ b/test/cypress/support/commands.js
@@ -86,9 +86,10 @@ Cypress.Commands.add('getValue', (selector) => {
});
// Fill Inputs
-Cypress.Commands.add('selectOption', (selector, option) => {
+Cypress.Commands.add('selectOption', (selector, option, timeout) => {
cy.waitForElement(selector);
cy.get(selector).click();
+ cy.wait(timeout || 1000);
cy.get('.q-menu .q-item').contains(option).click();
});
Cypress.Commands.add('countSelectOptions', (selector, option) => {
diff --git a/test/vitest/__tests__/components/common/VnLinkPhone.spec.js b/test/vitest/__tests__/components/common/VnLinkPhone.spec.js
new file mode 100644
index 000000000..e460ab2fc
--- /dev/null
+++ b/test/vitest/__tests__/components/common/VnLinkPhone.spec.js
@@ -0,0 +1,29 @@
+import { describe, it, expect } from 'vitest';
+import parsePhone from 'src/filters/parsePhone';
+
+describe('parsePhone filter', () => {
+ it("adds prefix +34 if it doesn't have one", () => {
+ const resultado = parsePhone('123456789', '34');
+ expect(resultado).toBe('34123456789');
+ });
+
+ it('maintains prefix +34 if it is already correct', () => {
+ const resultado = parsePhone('+34123456789', '34');
+ expect(resultado).toBe('34123456789');
+ });
+
+ it('converts prefix 0034 to +34', () => {
+ const resultado = parsePhone('0034123456789', '34');
+ expect(resultado).toBe('34123456789');
+ });
+
+ it('converts prefix 34 without symbol to +34', () => {
+ const resultado = parsePhone('34123456789', '34');
+ expect(resultado).toBe('34123456789');
+ });
+
+ it('replaces incorrect prefix with the correct one', () => {
+ const resultado = parsePhone('+44123456789', '34');
+ expect(resultado).toBe('44123456789');
+ });
+});