{{ t(`filterPanel.${tag.label}`) }}:
diff --git a/src/pages/Zone/locale/en.yml b/src/pages/Zone/locale/en.yml
index bf7d8f0de..ba4982311 100644
--- a/src/pages/Zone/locale/en.yml
+++ b/src/pages/Zone/locale/en.yml
@@ -61,6 +61,8 @@ eventsPanel:
events: Events
everyday: Everyday
delete: Delete
+ deleteTitle: This item will be deleted
+ deleteSubtitle: Are you sure you want to continue?
eventsExclusionForm:
addExclusion: Add exclusion
editExclusion: Edit exclusion
@@ -76,6 +78,7 @@ eventsInclusionForm:
rangeOfDates: Range of dates
from: From
to: To
+ day: Day
upcomingDeliveries:
province: Province
closing: Closing
diff --git a/src/pages/Zone/locale/es.yml b/src/pages/Zone/locale/es.yml
index 91541bea3..d0bab83f4 100644
--- a/src/pages/Zone/locale/es.yml
+++ b/src/pages/Zone/locale/es.yml
@@ -61,6 +61,8 @@ eventsPanel:
events: Eventos
everyday: Todos los días
delete: Eliminar
+ deleteTitle: Eliminar evento
+ deleteSubtitle: ¿Seguro que quieres eliminar este evento?
eventsExclusionForm:
addExclusion: Añadir exclusión
editExclusion: Editar exclusión
@@ -76,5 +78,6 @@ eventsInclusionForm:
rangeOfDates: Rango de fechas
from: Desde
to: Hasta
+ day: Día
upcomingDeliveries:
province: Provincia
diff --git a/src/router/modules/travel.js b/src/router/modules/travel.js
index 627692be8..dff693d2f 100644
--- a/src/router/modules/travel.js
+++ b/src/router/modules/travel.js
@@ -75,9 +75,9 @@ export default {
},
{
name: 'TravelHistory',
- path: 'history',
+ path: 'log',
meta: {
- title: 'history',
+ title: 'log',
icon: 'history',
},
component: () => import('src/pages/Travel/Card/TravelLog.vue'),
diff --git a/src/router/modules/worker.js b/src/router/modules/worker.js
index d1feff23d..925019734 100644
--- a/src/router/modules/worker.js
+++ b/src/router/modules/worker.js
@@ -24,6 +24,7 @@ export default {
'WorkerDms',
'WorkerTimeControl',
'WorkerLocker',
+ 'WorkerPit',
'WorkerBalance',
'WorkerFormation',
'WorkerMedical',
@@ -216,6 +217,15 @@ export default {
},
component: () => import('src/pages/Worker/Card/WorkerMedical.vue'),
},
+ {
+ name: 'WorkerPit',
+ path: 'pit',
+ meta: {
+ title: 'pit',
+ icon: 'lock',
+ },
+ component: () => import('src/pages/Worker/Card/WorkerPit.vue'),
+ },
{
name: 'WorkerOperator',
path: 'operator',
diff --git a/src/router/modules/zone.js b/src/router/modules/zone.js
index 1f27cc76f..c5ebe762e 100644
--- a/src/router/modules/zone.js
+++ b/src/router/modules/zone.js
@@ -106,7 +106,7 @@ export default {
},
{
name: 'ZoneHistory',
- path: 'history',
+ path: 'log',
meta: {
title: 'log',
icon: 'history',
diff --git a/src/utils/dataByOrder.js b/src/utils/dataByOrder.js
index 1bdedb8a1..eb4a4f586 100644
--- a/src/utils/dataByOrder.js
+++ b/src/utils/dataByOrder.js
@@ -1,6 +1,7 @@
function orderData(data, order) {
if (typeof order === 'function') return data.sort(data);
if (typeof order === 'string') order = [order];
+ if (!Array.isArray(data)) return [];
if (Array.isArray(order)) {
let orderComp = [];
diff --git a/test/cypress/integration/Order/orderCatalog.spec.js b/test/cypress/integration/Order/orderCatalog.spec.js
new file mode 100644
index 000000000..45eda6f1f
--- /dev/null
+++ b/test/cypress/integration/Order/orderCatalog.spec.js
@@ -0,0 +1,112 @@
+///
+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/integration/client/clientBasicData.spec.js b/test/cypress/integration/client/clientBasicData.spec.js
index 7b0a19828..bed28dc22 100644
--- a/test/cypress/integration/client/clientBasicData.spec.js
+++ b/test/cypress/integration/client/clientBasicData.spec.js
@@ -3,11 +3,17 @@ describe('Client basic data', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
- cy.visit('#/customer/1110/basic-data', {
- timeout: 5000,
- });
+ cy.visit('#/customer/1102/basic-data');
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
+ cy.dataCy('customerPhone').find('input').should('be.visible');
+ cy.dataCy('customerPhone').find('input').type('123456789');
+ cy.get('.q-btn-group > .q-btn--standard').click();
+ cy.intercept('PATCH', '/api/Clients/1102', (req) => {
+ const { body } = req;
+ cy.wrap(body).should('have.property', 'phone', '123456789');
+ });
+ cy.get('.q-notification__message').should('have.text', 'Data saved');
});
});
diff --git a/test/cypress/integration/client/clientBillingData.spec.js b/test/cypress/integration/client/clientBillingData.spec.js
index 00af82e39..16e8fc0fc 100644
--- a/test/cypress/integration/client/clientBillingData.spec.js
+++ b/test/cypress/integration/client/clientBillingData.spec.js
@@ -8,6 +8,6 @@ describe('Client billing data', () => {
});
});
it('Should load layout', () => {
- cy.get('.q-card').should('be.visible');
+ cy.get('.q-page').should('be.visible');
});
});
diff --git a/test/cypress/integration/client/clientFiscalData.spec.js b/test/cypress/integration/client/clientFiscalData.spec.js
index e337c26f8..05e0772e9 100644
--- a/test/cypress/integration/client/clientFiscalData.spec.js
+++ b/test/cypress/integration/client/clientFiscalData.spec.js
@@ -3,11 +3,16 @@ describe('Client fiscal data', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
- cy.visit('#/customer/1110/fiscal-data', {
+ cy.visit('#/customer/1107/fiscal-data', {
timeout: 5000,
});
});
- it('Should load layout', () => {
+ it('Should change required value when change customer', () => {
cy.get('.q-card').should('be.visible');
+ cy.dataCy('sageTaxTypeFk').filter('input').should('not.have.attr', 'required');
+ cy.get('#searchbar input').clear();
+ cy.get('#searchbar input').type('1{enter}');
+ cy.get('.q-item > .q-item__label').should('have.text', ' #1');
+ cy.dataCy('sageTaxTypeFk').filter('input').should('have.attr', 'required');
});
});
diff --git a/test/cypress/integration/client/clientList.spec.js b/test/cypress/integration/client/clientList.spec.js
index 431ac0548..ce07deb16 100644
--- a/test/cypress/integration/client/clientList.spec.js
+++ b/test/cypress/integration/client/clientList.spec.js
@@ -17,13 +17,15 @@ describe('Client list', () => {
it('Client list create new client', () => {
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
+ const randomInt = Math.floor(Math.random() * 90) + 10;
+
const data = {
- Name: { val: 'Name 1' },
- 'Social name': { val: 'TEST 1' },
- 'Tax number': { val: '20852113Z' },
- 'Web user': { val: 'user_test_1' },
- Street: { val: 'C/ STREET 1' },
- Email: { val: 'user.test@1.com' },
+ Name: { val: `Name ${randomInt}` },
+ 'Social name': { val: `TEST ${randomInt}` },
+ 'Tax number': { val: `20852${randomInt}3Z` },
+ 'Web user': { val: `user_test_${randomInt}` },
+ Street: { val: `C/ STREET ${randomInt}` },
+ Email: { val: `user.test${randomInt}@cypress.com` },
'Sales person': { val: 'employee', type: 'select' },
Location: { val: '46000, Valencia(Province one), España', type: 'select' },
'Business type': { val: 'Otros', type: 'select' },
@@ -32,7 +34,7 @@ describe('Client list', () => {
cy.get('.q-mt-lg > .q-btn--standard').click();
- cy.checkNotification('created');
+ cy.checkNotification('Data created');
cy.url().should('include', '/summary');
});
it('Client list search client', () => {
@@ -54,8 +56,8 @@ describe('Client list', () => {
cy.openActionDescriptor('Create ticket');
cy.waitForElement('#formModel');
cy.waitForElement('.q-form');
- cy.checkValueSelectForm(1, search);
- cy.checkValueSelectForm(2, search);
+ cy.checkValueForm(1, search);
+ cy.checkValueForm(2, search);
});
it('Client founded create order', () => {
const search = 'Jessica Jones';
diff --git a/test/cypress/integration/client/clientSms.spec.js b/test/cypress/integration/client/clientSms.spec.js
new file mode 100644
index 000000000..731522a5c
--- /dev/null
+++ b/test/cypress/integration/client/clientSms.spec.js
@@ -0,0 +1,12 @@
+///
+describe('Client notes', () => {
+ beforeEach(() => {
+ cy.viewport(1280, 720);
+ cy.login('developer');
+ cy.visit('#/customer/1101/sms');
+ });
+ it('Should load layout', () => {
+ cy.get('.q-page').should('be.visible');
+ cy.get('.q-page > :nth-child(2) > :nth-child(1)').should('be.visible');
+ });
+});
diff --git a/test/cypress/integration/client/clientWebAccess.spec.js b/test/cypress/integration/client/clientWebAccess.spec.js
index 47f9efa4c..6803336a3 100644
--- a/test/cypress/integration/client/clientWebAccess.spec.js
+++ b/test/cypress/integration/client/clientWebAccess.spec.js
@@ -3,11 +3,26 @@ describe('Client web-access', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
- cy.visit('#/customer/1110/web-access', {
- timeout: 5000,
- });
});
- it('Should load layout', () => {
+ it('Should test buttons ', () => {
+ cy.visit('#/customer/1101/web-access');
+ cy.get('.q-page').should('be.visible');
+ cy.get('#formModel').should('be.visible');
cy.get('.q-card').should('be.visible');
+ cy.get('.q-btn-group > :nth-child(1)').should('not.be.disabled');
+ cy.get('.q-checkbox__inner').click();
+ cy.get('.q-btn-group > .q-btn--standard.q-btn--actionable').should(
+ 'not.be.disabled'
+ );
+ cy.get('.q-btn-group > .q-btn--flat').should('not.be.disabled');
+ cy.get('.q-btn-group > :nth-child(1)').click();
+ cy.get('.q-dialog__inner > .q-card > :nth-child(1)')
+ .should('be.visible')
+ .find('.text-h6')
+ .should('have.text', 'Change password');
+ });
+ it('Should disabled buttons', () => {
+ cy.visit('#/customer/1110/web-access');
+ cy.get('.q-btn-group > :nth-child(1)').should('be.disabled');
});
});
diff --git a/test/cypress/integration/client/credit-management/clientCreditContracts.spec.js b/test/cypress/integration/client/credit-management/clientCreditContracts.spec.js
index 3c35d5ed0..1c2f935fc 100644
--- a/test/cypress/integration/client/credit-management/clientCreditContracts.spec.js
+++ b/test/cypress/integration/client/credit-management/clientCreditContracts.spec.js
@@ -1,5 +1,5 @@
///
-describe('Client credit opinion', () => {
+describe('Client credit contracts', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
@@ -8,6 +8,6 @@ describe('Client credit opinion', () => {
});
});
it('Should load layout', () => {
- cy.get('.q-card').should('be.visible');
+ cy.get('.q-page').should('be.visible');
});
});
diff --git a/test/cypress/integration/client/others/clientUnpaid.spec.js b/test/cypress/integration/client/others/clientUnpaid.spec.js
index 9972ba0e9..ab6bc18bf 100644
--- a/test/cypress/integration/client/others/clientUnpaid.spec.js
+++ b/test/cypress/integration/client/others/clientUnpaid.spec.js
@@ -3,11 +3,17 @@ describe('Client unpaid', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
- cy.visit('#/customer/1110/others/unpaid', {
- timeout: 5000,
- });
});
- it('Should load layout', () => {
+ it('Should add unpaid', () => {
+ cy.visit('#/customer/1102/others/unpaid');
cy.get('.q-card').should('be.visible');
+ cy.get('.q-checkbox__inner').click();
+ cy.dataCy('customerUnpaidAmount').find('input').type('100');
+ cy.dataCy('customerUnpaidDate').find('input').type('01/01/2001');
+ cy.get('.q-btn-group > .q-btn--standard').click();
+ cy.reload();
+ cy.get('.q-checkbox__inner')
+ .should('be.visible')
+ .and('not.have.class', 'q-checkbox__inner--active');
});
});
diff --git a/test/cypress/integration/item/ItemFixedPrice.spec.js b/test/cypress/integration/item/ItemFixedPrice.spec.js
new file mode 100644
index 000000000..824ecf7a0
--- /dev/null
+++ b/test/cypress/integration/item/ItemFixedPrice.spec.js
@@ -0,0 +1,63 @@
+///
+function goTo(n = 1) {
+ return `.q-virtual-scroll__content > :nth-child(${n})`;
+}
+const firstRow = goTo();
+`.q-virtual-scroll__content > :nth-child(2)`;
+describe('Handle Items FixedPrice', () => {
+ beforeEach(() => {
+ cy.viewport(1280, 720);
+ cy.login('developer');
+ cy.visit('/#/item/fixed-price', { timeout: 5000 });
+ cy.waitForElement('.q-table');
+ cy.get(
+ '.q-header > .q-toolbar > :nth-child(1) > .q-btn__content > .q-icon'
+ ).click();
+ });
+ it('filter', function () {
+ cy.get('.category-filter > :nth-child(1) > .q-btn__content > .q-icon').click();
+ cy.selectOption('.list > :nth-child(2)', 'Alstroemeria');
+ cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content > .q-icon').click();
+
+ cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
+ cy.selectOption(`${firstRow} > :nth-child(2)`, '#13');
+ cy.get(`${firstRow} > :nth-child(4)`).find('input').type(1);
+ cy.get(`${firstRow} > :nth-child(5)`).find('input').type('2');
+ cy.selectOption(`${firstRow} > :nth-child(9)`, 'Warehouse One');
+ cy.get('.q-notification__message').should('have.text', 'Data saved');
+ /* ==== End Cypress Studio ==== */
+ });
+ it('Create and delete ', function () {
+ cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content > .q-icon').click();
+ cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
+ cy.selectOption(`${firstRow} > :nth-child(2)`, '#11');
+ cy.get(`${firstRow} > :nth-child(4)`).type('1');
+ cy.get(`${firstRow} > :nth-child(5)`).type('2');
+ cy.selectOption(`${firstRow} > :nth-child(9)`, 'Warehouse One');
+ cy.get('.q-notification__message').should('have.text', 'Data saved');
+ cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content > .q-icon').click();
+ cy.get(`${firstRow} > .text-right > .q-btn > .q-btn__content > .q-icon`).click();
+ cy.get(
+ '.q-card__actions > .q-btn--unelevated > .q-btn__content > .block'
+ ).click();
+ cy.get('.q-notification__message').should('have.text', 'Data saved');
+ });
+
+ it('Massive edit', function () {
+ cy.get(' .bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner ').click();
+ cy.get('#subToolbar > .q-btn--standard').click();
+ cy.selectOption("[data-cy='field-to-edit']", 'Min price');
+ cy.dataCy('value-to-edit').find('input').type('1');
+ cy.get('.countLines').should('have.text', ' 1 ');
+ cy.get('.q-mt-lg > .q-btn--standard').click();
+ cy.get('.q-notification__message').should('have.text', 'Data saved');
+ });
+ it('Massive remove', function () {
+ cy.get(' .bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner ').click();
+ cy.get('#subToolbar > .q-btn--flat').click();
+ cy.get(
+ '.q-card__actions > .q-btn--unelevated > .q-btn__content > .block'
+ ).click();
+ cy.get('.q-notification__message').should('have.text', 'Data saved');
+ });
+});
diff --git a/test/cypress/integration/ticket/ticketList.spec.js b/test/cypress/integration/ticket/ticketList.spec.js
index bbdbcea92..c1d1a0655 100644
--- a/test/cypress/integration/ticket/ticketList.spec.js
+++ b/test/cypress/integration/ticket/ticketList.spec.js
@@ -37,7 +37,7 @@ describe('TicketList', () => {
cy.dataCy('ticketSummary').should('exist');
});
- it('Client list create new client', () => {
+ it.only('Client list create new client', () => {
cy.dataCy('vnTableCreateBtn').should('exist');
cy.dataCy('vnTableCreateBtn').click();
const data = {
@@ -47,7 +47,8 @@ describe('TicketList', () => {
Landed: { val: '01-01-2024', type: 'date' },
};
cy.fillInForm(data);
- cy.get('.q-mt-lg > .q-btn--standard').click();
+ cy.dataCy('Agency_select').click();
+ cy.dataCy('FormModelPopup_save').click();
cy.checkNotification('Data created');
cy.url().should('match', /\/ticket\/\d+\/summary/);
});
diff --git a/test/cypress/integration/vnComponent/VnAccountNumber.spec.js b/test/cypress/integration/vnComponent/VnAccountNumber.spec.js
new file mode 100644
index 000000000..000c2151d
--- /dev/null
+++ b/test/cypress/integration/vnComponent/VnAccountNumber.spec.js
@@ -0,0 +1,39 @@
+describe('VnInput Component', () => {
+ beforeEach(() => {
+ cy.login('developer');
+ cy.viewport(1920, 1080);
+ cy.visit('/#/supplier/1/fiscal-data');
+ cy.domContentLoad();
+ });
+
+ it('should replace character at cursor position in insert mode', () => {
+ // Simula escribir en el input
+ cy.dataCy('supplierFiscalDataAccount').clear();
+ cy.dataCy('supplierFiscalDataAccount').type('4100000001');
+ // Coloca el cursor en la posición 0
+ cy.dataCy('supplierFiscalDataAccount').type('{movetostart}');
+ // Escribe un número y verifica que se reemplace correctamente
+ cy.dataCy('supplierFiscalDataAccount').type('999');
+ cy.dataCy('supplierFiscalDataAccount')
+ .should('have.value', '9990000001');
+ });
+
+ it('should replace character at cursor position in insert mode', () => {
+ // Simula escribir en el input
+ cy.dataCy('supplierFiscalDataAccount').clear();
+ cy.dataCy('supplierFiscalDataAccount').type('4100000001');
+ // Coloca el cursor en la posición 0
+ cy.dataCy('supplierFiscalDataAccount').type('{movetostart}');
+ // Escribe un número y verifica que se reemplace correctamente en la posicion incial
+ cy.dataCy('supplierFiscalDataAccount').type('999');
+ cy.dataCy('supplierFiscalDataAccount')
+ .should('have.value', '9990000001');
+ });
+
+ it('should respect maxlength prop', () => {
+ cy.dataCy('supplierFiscalDataAccount').clear();
+ cy.dataCy('supplierFiscalDataAccount').type('123456789012345');
+ cy.dataCy('supplierFiscalDataAccount')
+ .should('have.value', '1234567890'); // asumiendo que maxlength es 10
+ });
+});
diff --git a/test/cypress/integration/vnComponent/vnBreadcrumbs.spec.js b/test/cypress/integration/vnComponent/VnBreadcrumbs.spec.js
similarity index 95%
rename from test/cypress/integration/vnComponent/vnBreadcrumbs.spec.js
rename to test/cypress/integration/vnComponent/VnBreadcrumbs.spec.js
index 3c839c1c7..e996a65d5 100644
--- a/test/cypress/integration/vnComponent/vnBreadcrumbs.spec.js
+++ b/test/cypress/integration/vnComponent/VnBreadcrumbs.spec.js
@@ -3,6 +3,7 @@ describe('VnBreadcrumbs', () => {
const firstCard = '.q-infinite-scroll > :nth-child(1)';
const lastBreadcrumb = '.q-breadcrumbs--last > .q-breadcrumbs__el';
beforeEach(() => {
+ cy.viewport(1920, 1080);
cy.login('developer');
cy.visit('/');
});
diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/VnLocation.spec.js
similarity index 69%
rename from test/cypress/integration/vnComponent/vnLocation.spec.js
rename to test/cypress/integration/vnComponent/VnLocation.spec.js
index aeb938c6f..82d12a1e4 100644
--- a/test/cypress/integration/vnComponent/vnLocation.spec.js
+++ b/test/cypress/integration/vnComponent/VnLocation.spec.js
@@ -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';
@@ -41,11 +43,9 @@ describe('VnLocation', () => {
province
);
cy.get(
- `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(3) > .q-icon`
+ `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(3) `
).click();
- cy.get(
- `#q-portal--dialog--5 > .q-dialog > ${createForm.prefix} > .vn-row > .q-select > ${createForm.sufix} > :nth-child(1) input`
- ).should('have.value', province);
+ cy.dataCy('locationProvince').should('have.value', province);
});
});
describe('Worker Create', () => {
@@ -99,38 +99,80 @@ describe('VnLocation', () => {
});
it('Create postCode', () => {
- const postCode = '1234475';
+ const postCode = Math.floor(100000 + Math.random() * 900000);
const province = 'Valencia';
cy.get(createLocationButton).click();
cy.get('.q-card > h1').should('have.text', 'New postcode');
- cy.get(dialogInputs).eq(0).clear();
- cy.get(dialogInputs).eq(0).type(postCode);
cy.selectOption(
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix}`,
province
);
+ cy.get(dialogInputs).eq(0).clear();
+ cy.get(dialogInputs).eq(0).type(postCode);
cy.get('.q-mt-lg > .q-btn--standard').click();
cy.get(`${createForm.prefix}`).should('not.exist');
cy.waitForElement('.q-form');
checkVnLocation(postCode, province);
});
- it('Create city', () => {
- const postCode = '9011';
- const province = 'Saskatchew';
+
+ it('Create city without country', () => {
+ 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(province);
- cy.get('#q-portal--dialog--3 .q-btn--standard').click();
- cy.get('#q-portal--dialog--1 .q-btn--standard').click();
+ cy.dataCy('City_icon').click();
+ cy.selectOption('[data-cy="locationProvince"]:last', 'Province one');
+ cy.dataCy('cityName').type(province);
+ cy.dataCy('FormModelPopup_save').eq(1).click();
+ cy.dataCy('FormModelPopup_save').eq(0).click();
+
cy.waitForElement('.q-form');
checkVnLocation(postCode, province);
});
+ it('Create city with country', () => {
+ const cityName = 'Saskatchew'.concat(Math.random(1 * 100));
+ cy.get(createLocationButton).click();
+ cy.selectOption(
+ `${createForm.prefix} > :nth-child(5) > :nth-child(3) `,
+ 'Italia'
+ );
+ cy.dataCy('City_icon').click();
+ cy.selectOption('[data-cy="locationProvince"]:last', 'Province four');
+ cy.countSelectOptions('[data-cy="locationProvince"]:last', 1);
+
+ cy.dataCy('cityName').type(cityName);
+ cy.dataCy('FormModelPopup_save').eq(1).click();
+ });
+
+ it('Create province without country', () => {
+ const provinceName = 'Saskatchew'.concat(Math.random(1 * 100));
+ cy.get(createLocationButton).click();
+ cy.dataCy('Province_icon').click();
+ cy.selectOption('[data-cy="autonomyProvince"] ', 'Autonomy one');
+ cy.countSelectOptions('[data-cy="autonomyProvince"]', 4);
+ cy.dataCy('provinceName').type(provinceName);
+
+ cy.dataCy('FormModelPopup_save').eq(1).click();
+ });
+
+ it('Create province with country', () => {
+ const provinceName = 'Saskatchew'.concat(Math.random(1 * 100));
+ cy.get(createLocationButton).click();
+ cy.selectOption(
+ `${createForm.prefix} > :nth-child(5) > :nth-child(3) `,
+ 'España'
+ );
+ cy.dataCy('Province_icon').click();
+
+ cy.selectOption('[data-cy="autonomyProvince"] ', 'Autonomy one');
+ cy.countSelectOptions('[data-cy="autonomyProvince"]', 2);
+
+ cy.dataCy('provinceName').type(provinceName);
+ cy.dataCy('FormModelPopup_save').eq(1).click();
+ });
+
function checkVnLocation(postCode, province) {
cy.get(`${createForm.prefix}`).should('not.exist');
cy.get('.q-form > .q-card > .vn-row:nth-child(6)')
diff --git a/test/cypress/integration/vnComponent/vnLog.spec.js b/test/cypress/integration/vnComponent/VnLog.spec.js
similarity index 100%
rename from test/cypress/integration/vnComponent/vnLog.spec.js
rename to test/cypress/integration/vnComponent/VnLog.spec.js
diff --git a/test/cypress/integration/vnComponent/vnSearchBar.spec.js b/test/cypress/integration/vnComponent/VnSearchBar.spec.js
similarity index 100%
rename from test/cypress/integration/vnComponent/vnSearchBar.spec.js
rename to test/cypress/integration/vnComponent/VnSearchBar.spec.js
diff --git a/test/cypress/integration/worker/workerPda.spec.js b/test/cypress/integration/worker/workerPda.spec.js
index fe8efa834..dc1ca6224 100644
--- a/test/cypress/integration/worker/workerPda.spec.js
+++ b/test/cypress/integration/worker/workerPda.spec.js
@@ -1,6 +1,5 @@
describe('WorkerPda', () => {
- const deviceProductionField =
- '.vn-row > .q-field > .q-field__inner > .q-field__control > .q-field__control-container';
+ const select = '[data-cy="pda-dialog-select"]';
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
@@ -9,7 +8,8 @@ describe('WorkerPda', () => {
it('assign pda', () => {
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
- cy.get(deviceProductionField).type('{downArrow}{enter}');
+ cy.get(select).click();
+ cy.get(select).type('{downArrow}{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created');
});
diff --git a/test/cypress/integration/worker/workerPit.spec.js b/test/cypress/integration/worker/workerPit.spec.js
new file mode 100644
index 000000000..cc3a87637
--- /dev/null
+++ b/test/cypress/integration/worker/workerPit.spec.js
@@ -0,0 +1,40 @@
+describe('WorkerPit', () => {
+ const familySituationInput = '[data-cy="Family Situation_input"]';
+ const familySituation = '1';
+ const childPensionInput = '[data-cy="Child Pension_input"]';
+ const childPension = '120';
+ const spouseNifInput = '[data-cy="Spouse Pension_input"]';
+ const spouseNif = '65117125P';
+ const spousePensionInput = '[data-cy="Spouse Pension_input"]';
+ const spousePension = '120';
+ const addRelative = '[data-cy="addRelative"]';
+ const isDescendantSelect = '[data-cy="Descendant/Ascendant_select"]';
+ const birthedInput = '[data-cy="Birth Year_input"]';
+ const birthed = '2002';
+ const adoptionYearInput = '[data-cy="Adoption Year_input"]';
+ const adoptionYear = '2004';
+ const saveRelative = '[data-cy="workerPitRelativeSaveBtn"]';
+ const savePIT = '#st-actions > .q-btn-group > .q-btn--standard';
+
+ beforeEach(() => {
+ cy.viewport(1920, 1080);
+ cy.login('developer');
+ cy.visit(`/#/worker/1107/pit`);
+ });
+
+ it('complete PIT', () => {
+ cy.get(familySituationInput).type(familySituation);
+ cy.get(childPensionInput).type(childPension);
+ cy.get(spouseNifInput).type(spouseNif);
+ cy.get(spousePensionInput).type(spousePension);
+ cy.get(savePIT).click();
+ });
+
+ it('complete relative', () => {
+ cy.get(addRelative).click();
+ cy.get(isDescendantSelect).type('{downArrow}{downArrow}{enter}');
+ cy.get(birthedInput).type(birthed);
+ cy.get(adoptionYearInput).type(adoptionYear);
+ cy.get(saveRelative).click();
+ });
+});
diff --git a/test/cypress/integration/zone/zoneBasicData.spec.js b/test/cypress/integration/zone/zoneBasicData.spec.js
index c6151a49b..de85dac94 100644
--- a/test/cypress/integration/zone/zoneBasicData.spec.js
+++ b/test/cypress/integration/zone/zoneBasicData.spec.js
@@ -8,7 +8,7 @@ describe('ZoneBasicData', () => {
});
it('should throw an error if the name is empty', () => {
- cy.get('.q-card > :nth-child(1)').clear();
+ cy.get('[data-cy="zone-basic-data-name"] input').type('{selectall}{backspace}');
cy.get('.q-btn-group > .q-btn--standard').click();
cy.get(notification).should('contains.text', "can't be blank");
});
diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js
index 728342304..2b13a7144 100755
--- a/test/cypress/support/commands.js
+++ b/test/cypress/support/commands.js
@@ -86,11 +86,17 @@ 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) => {
+ 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');
@@ -104,14 +110,14 @@ Cypress.Commands.add('fillInForm', (obj, form = '.q-form > .q-card') => {
const { type, val } = field;
switch (type) {
case 'select':
- cy.wrap(el).type(val);
+ cy.get(el).click();
cy.get('.q-menu .q-item').contains(val).click();
break;
case 'date':
- cy.wrap(el).type(val.split('-').join(''));
+ cy.get(el).type(val.split('-').join(''));
break;
case 'time':
- cy.wrap(el).click();
+ cy.get(el).click();
cy.get('.q-time .q-time__clock').contains(val.h).click();
cy.get('.q-time .q-time__clock').contains(val.m).click();
cy.get('.q-time .q-time__link').contains(val.x).click();
@@ -254,6 +260,7 @@ Cypress.Commands.add('writeSearchbar', (value) => {
value
);
});
+
Cypress.Commands.add('validateContent', (selector, expectedValue) => {
cy.get(selector).should('have.text', expectedValue);
});
@@ -275,16 +282,38 @@ Cypress.Commands.add('clickButtonsDescriptor', (id) => {
.click();
});
+Cypress.Commands.add('openActionDescriptor', (opt) => {
+ cy.openActionsDescriptor();
+ const listItem = '[role="menu"] .q-list .q-item';
+ cy.contains(listItem, opt).click();
+ 1;
+});
+
+Cypress.Commands.add('clickButtonsDescriptor', (id) => {
+ cy.get(`.actions > .q-card__actions> .q-btn:nth-child(${id})`)
+ .invoke('removeAttr', 'target')
+ .click();
+});
+
+Cypress.Commands.add('openActionDescriptor', (opt) => {
+ cy.openActionsDescriptor();
+ const listItem = '[role="menu"] .q-list .q-item';
+ cy.contains(listItem, opt).click();
+ 1;
+});
+
+Cypress.Commands.add('clickButtonsDescriptor', (id) => {
+ cy.get(`.actions > .q-card__actions> .q-btn:nth-child(${id})`)
+ .invoke('removeAttr', 'target')
+ .click();
+});
+
Cypress.Commands.add('openUserPanel', () => {
cy.get(
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image'
).click();
});
-Cypress.Commands.add('openActions', (row) => {
- cy.get('tbody > tr').eq(row).find('.actions > .q-btn').click();
-});
-
Cypress.Commands.add('checkNotification', (text) => {
cy.get('.q-notification')
.should('be.visible')
@@ -295,10 +324,14 @@ Cypress.Commands.add('checkNotification', (text) => {
});
});
+Cypress.Commands.add('openActions', (row) => {
+ cy.get('tbody > tr').eq(row).find('.actions > .q-btn').click();
+});
+
Cypress.Commands.add('checkValueForm', (id, search) => {
- cy.get(
- `.grid-create > :nth-child(${id}) > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > .q-field__input`
- ).should('have.value', search);
+ cy.get(`.grid-create > :nth-child(${id}) `)
+ .find('input')
+ .should('have.value', search);
});
Cypress.Commands.add('checkValueSelectForm', (id, search) => {
@@ -311,6 +344,6 @@ Cypress.Commands.add('searchByLabel', (label, value) => {
cy.get(`[label="${label}"] > .q-field > .q-field__inner`).type(`${value}{enter}`);
});
-Cypress.Commands.add('dataCy', (dataTestId, attr = 'data-cy') => {
- return cy.get(`[${attr}="${dataTestId}"]`);
+Cypress.Commands.add('dataCy', (tag, attr = 'data-cy') => {
+ return cy.get(`[${attr}="${tag}"]`);
});
diff --git a/test/cypress/support/index.js b/test/cypress/support/index.js
index 4385698ec..c57c1a303 100644
--- a/test/cypress/support/index.js
+++ b/test/cypress/support/index.js
@@ -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 };
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..a34ef90a5
--- /dev/null
+++ b/test/vitest/__tests__/components/common/VnLinkPhone.spec.js
@@ -0,0 +1,50 @@
+import { describe, it, expect, beforeAll, vi } from 'vitest';
+import { axios } from 'app/test/vitest/helper';
+import parsePhone from 'src/filters/parsePhone';
+
+describe('parsePhone filter', () => {
+ beforeAll(async () => {
+ vi.spyOn(axios, 'get').mockReturnValue({ data: { prefix: '34' } });
+ });
+
+ it('no phone', async () => {
+ const phone = await parsePhone(null, '34');
+ expect(phone).toBe(undefined);
+ });
+
+ it("adds prefix +34 if it doesn't have one", async () => {
+ const phone = await parsePhone('123456789', '34');
+ expect(phone).toBe('34123456789');
+ });
+
+ it('maintains prefix +34 if it is already correct', async () => {
+ const phone = await parsePhone('+34123456789', '34');
+ expect(phone).toBe('34123456789');
+ });
+
+ it('converts prefix 0034 to +34', async () => {
+ const phone = await parsePhone('0034123456789', '34');
+ expect(phone).toBe('34123456789');
+ });
+
+ it('converts prefix 34 without symbol to +34', async () => {
+ const phone = await parsePhone('34123456789', '34');
+ expect(phone).toBe('34123456789');
+ });
+
+ it('replaces incorrect prefix with the correct one', async () => {
+ const phone = await parsePhone('+44123456789', '34');
+ expect(phone).toBe('44123456789');
+ });
+
+ it('adds default prefix on error', async () => {
+ vi.spyOn(axios, 'get').mockImplementation((url) => {
+ if (url.includes('Prefixes'))
+ return Promise.reject(new Error('Network error'));
+ else if (url.includes('PbxConfigs'))
+ return Promise.resolve({ data: { defaultPrefix: '39' } });
+ });
+ const phone = await parsePhone('123456789', '34');
+ expect(phone).toBe('39123456789');
+ });
+});
diff --git a/test/vitest/__tests__/composables/downloadFile.spec.js b/test/vitest/__tests__/composables/downloadFile.spec.js
index f611479bf..f53b56b3e 100644
--- a/test/vitest/__tests__/composables/downloadFile.spec.js
+++ b/test/vitest/__tests__/composables/downloadFile.spec.js
@@ -1,25 +1,36 @@
-import { vi, describe, expect, it } from 'vitest';
+import { vi, describe, expect, it, beforeAll, afterAll } from 'vitest';
import { axios } from 'app/test/vitest/helper';
import { downloadFile } from 'src/composables/downloadFile';
import { useSession } from 'src/composables/useSession';
-
const session = useSession();
const token = session.getToken();
describe('downloadFile', () => {
+ const baseUrl = 'http://localhost:9000';
+ let defaulCreateObjectURL;
+
+ beforeAll(() => {
+ defaulCreateObjectURL = window.URL.createObjectURL;
+ window.URL.createObjectURL = vi.fn(() => 'blob:http://localhost:9000/blob-id');
+ });
+
+ afterAll(() => (window.URL.createObjectURL = defaulCreateObjectURL));
+
it('should open a new window to download the file', async () => {
- const url = 'http://localhost:9000';
-
- vi.spyOn(axios, 'get').mockResolvedValueOnce({ data: url });
-
- const mockWindowOpen = vi.spyOn(window, 'open');
+ const res = {
+ data: new Blob(['file content'], { type: 'application/octet-stream' }),
+ headers: { 'content-disposition': 'attachment; filename="test-file.txt"' },
+ };
+ vi.spyOn(axios, 'get').mockImplementation((url) => {
+ if (url == 'Urls/getUrl') return Promise.resolve({ data: baseUrl });
+ else if (url.includes('downloadFile')) return Promise.resolve(res);
+ });
await downloadFile(1);
- expect(mockWindowOpen).toHaveBeenCalledWith(
- `${url}/api/dms/1/downloadFile?access_token=${token}`
+ expect(axios.get).toHaveBeenCalledWith(
+ `${baseUrl}/api/dms/1/downloadFile?access_token=${token}`,
+ { responseType: 'blob' }
);
-
- mockWindowOpen.mockRestore();
});
});
diff --git a/test/vitest/helper.js b/test/vitest/helper.js
index 4bfae5dc8..ce057c7c3 100644
--- a/test/vitest/helper.js
+++ b/test/vitest/helper.js
@@ -44,7 +44,18 @@ vi.mock('vue-router', () => ({
vi.mock('axios');
vi.spyOn(useValidator, 'useValidator').mockImplementation(() => {
- return { validate: vi.fn() };
+ return {
+ validate: vi.fn(),
+ validations: () => ({
+ format: vi.fn(),
+ presence: vi.fn(),
+ required: vi.fn(),
+ length: vi.fn(),
+ numericality: vi.fn(),
+ min: vi.fn(),
+ custom: vi.fn(),
+ }),
+ };
});
class FormDataMock {