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/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/vitest/__tests__/components/common/VnLinkPhone.spec.js b/test/vitest/__tests__/components/common/VnLinkPhone.spec.js
index e460ab2fc..a34ef90a5 100644
--- a/test/vitest/__tests__/components/common/VnLinkPhone.spec.js
+++ b/test/vitest/__tests__/components/common/VnLinkPhone.spec.js
@@ -1,29 +1,50 @@
-import { describe, it, expect } from 'vitest';
+import { describe, it, expect, beforeAll, vi } from 'vitest';
+import { axios } from 'app/test/vitest/helper';
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');
+ beforeAll(async () => {
+ vi.spyOn(axios, 'get').mockReturnValue({ data: { prefix: '34' } });
});
- it('maintains prefix +34 if it is already correct', () => {
- const resultado = parsePhone('+34123456789', '34');
- expect(resultado).toBe('34123456789');
+ it('no phone', async () => {
+ const phone = await parsePhone(null, '34');
+ expect(phone).toBe(undefined);
});
- it('converts prefix 0034 to +34', () => {
- const resultado = parsePhone('0034123456789', '34');
- expect(resultado).toBe('34123456789');
+ it("adds prefix +34 if it doesn't have one", async () => {
+ const phone = await parsePhone('123456789', '34');
+ expect(phone).toBe('34123456789');
});
- it('converts prefix 34 without symbol to +34', () => {
- const resultado = parsePhone('34123456789', '34');
- expect(resultado).toBe('34123456789');
+ it('maintains prefix +34 if it is already correct', async () => {
+ const phone = await parsePhone('+34123456789', '34');
+ expect(phone).toBe('34123456789');
});
- it('replaces incorrect prefix with the correct one', () => {
- const resultado = parsePhone('+44123456789', '34');
- expect(resultado).toBe('44123456789');
+ 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');
});
});