From 8b3a9db78143f19136a619b8043d4744c4a90fab Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 3 Dec 2024 13:00:16 +0100 Subject: [PATCH 01/70] feat: refs #8220 created items e2e --- src/components/RegularizeStockForm.vue | 1 + src/components/common/VnSelectDialog.vue | 1 + src/pages/Item/Card/ItemBotanical.vue | 2 +- src/pages/Item/Card/ItemTags.vue | 2 +- src/pages/Item/ItemListFilter.vue | 2 + src/pages/Item/ItemTypeList.vue | 4 +- .../integration/item/itemBotanical.spec.js | 35 ++++++++++++++++ .../integration/item/itemSummary.spec.js | 25 ++++++++++++ test/cypress/integration/item/itemTag.spec.js | 37 +++++++++++++++++ test/cypress/integration/item/itemTax.spec.js | 18 +++++++++ .../cypress/integration/item/itemType.spec.js | 40 +++++++++++++++++++ 11 files changed, 162 insertions(+), 5 deletions(-) create mode 100644 test/cypress/integration/item/itemBotanical.spec.js create mode 100644 test/cypress/integration/item/itemSummary.spec.js create mode 100644 test/cypress/integration/item/itemTag.spec.js create mode 100644 test/cypress/integration/item/itemTax.spec.js create mode 100644 test/cypress/integration/item/itemType.spec.js diff --git a/src/components/RegularizeStockForm.vue b/src/components/RegularizeStockForm.vue index f34386fc4..3cd18d1c8 100644 --- a/src/components/RegularizeStockForm.vue +++ b/src/components/RegularizeStockForm.vue @@ -55,6 +55,7 @@ const onDataSaved = (data) => { v-model.number="data.quantity" type="number" autofocus + data-cy="regularizeStockInput" /> diff --git a/src/components/common/VnSelectDialog.vue b/src/components/common/VnSelectDialog.vue index 350aa9272..a19c3e30c 100644 --- a/src/components/common/VnSelectDialog.vue +++ b/src/components/common/VnSelectDialog.vue @@ -50,6 +50,7 @@ const isAllowedToCreate = computed(() => { :style="{ 'font-variation-settings': `'FILL' ${1}`, }" + :data-cy="`SelectDialogAddIcon-${$attrs.label || 'default'}`" > {{ tooltip }} diff --git a/src/pages/Item/Card/ItemBotanical.vue b/src/pages/Item/Card/ItemBotanical.vue index c4b561772..57774f75e 100644 --- a/src/pages/Item/Card/ItemBotanical.vue +++ b/src/pages/Item/Card/ItemBotanical.vue @@ -1,5 +1,5 @@ + diff --git a/test/cypress/integration/item/itemList.spec.js b/test/cypress/integration/item/itemList.spec.js new file mode 100644 index 000000000..0a1f803aa --- /dev/null +++ b/test/cypress/integration/item/itemList.spec.js @@ -0,0 +1,34 @@ +/// + +describe('Item list', () => { + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('developer'); + cy.visit(`/#/item/list`); + cy.get('#searchbar input').type('{enter}'); + }); + + it('should filter the items and redirect to the summary', () => { + cy.dataCy('ItemFilterCategorySelect').type('Plant'); + cy.get('.q-menu .q-item').contains('Plant').click(); + cy.dataCy('ItemFilterTypeSelect').type('Anthurium'); + cy.get('.q-menu .q-item').contains('Anthurium').click(); + cy.get('.q-virtual-scroll__content > :nth-child(4) > :nth-child(4)').click(); + }); + + it('should create an item', () => { + const data = { + Description: { val: `Test item` }, + Type: { val: `Crisantemo`, type: 'select' }, + Intrastat: { val: `Coral y materiales similares`, type: 'select' }, + Origin: { val: `SPA`, type: 'select' }, + }; + cy.dataCy('vnTableCreateBtn').click(); + cy.fillInForm(data); + cy.dataCy('FormModelPopup_save').click(); + cy.checkNotification('Data created'); + cy.get( + ':nth-child(2) > .q-drawer > .q-drawer__content > .q-scrollarea > .q-scrollarea__container > .q-scrollarea__content' + ).should('be.visible'); + }); +}); From cb0422d83f8b0cf17175f6be948bba1f5ea4684a Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 13 Dec 2024 14:16:27 +0100 Subject: [PATCH 06/70] feat: refs #7957 open in new tab --- src/components/ui/VnSearchbar.vue | 6 ++++++ src/composables/useArrayData.js | 13 +++++++++---- src/pages/Monitor/Ticket/MonitorTicketSearchbar.vue | 1 + src/pages/Monitor/locale/en.yml | 2 +- src/pages/Monitor/locale/es.yml | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index ccf87c6d6..830029e8e 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -67,6 +67,10 @@ const props = defineProps({ type: Function, default: undefined, }, + newTab: { + type: Boolean, + default: false, + }, }); const searchText = ref(); @@ -109,6 +113,7 @@ async function search() { search: searchText.value, }, ...{ filter: props.filter }, + newTab: props.newTab, }; if (props.whereFilter) { @@ -117,6 +122,7 @@ async function search() { }; delete filter.params.search; } + await arrayData.applyFilter(filter); } diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index da62eee3e..098991fe8 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -4,6 +4,7 @@ import axios from 'axios'; import { useArrayDataStore } from 'stores/useArrayDataStore'; import { buildFilter } from 'filters/filterPanel'; import { isDialogOpened } from 'src/filters'; +import useOpenURL from './useOpenURL'; const arrayDataStore = useArrayDataStore(); @@ -65,7 +66,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { } } - async function fetch({ append = false, updateRouter = true }) { + async function fetch({ append = false, updateRouter = true, newTab = false }) { if (!store.url) return; cancelRequest(); @@ -110,6 +111,8 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { params.filter.where = { ...params.filter.where, ...exprFilter }; params.filter = JSON.stringify(params.filter); + if (newTab) return updateStateParams(true); + store.isLoading = true; const response = await axios.get(store.url, { signal: canceller.signal, @@ -154,12 +157,12 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { } } - async function applyFilter({ filter, params }) { + async function applyFilter({ filter, params, newTab }) { if (filter) store.userFilter = filter; store.filter = {}; if (params) store.userParams = { ...params }; - const response = await fetch({}); + const response = await fetch({ newTab }); return response; } @@ -255,12 +258,14 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { if (Object.values(store.userParams).length) await fetch({}); } - function updateStateParams() { + function updateStateParams(newTab) { if (!route?.path) return; const newUrl = { path: route.path, query: { ...(route.query ?? {}) } }; if (store?.searchUrl) newUrl.query[store.searchUrl] = JSON.stringify(store.currentFilter); + if (newTab) useOpenURL(router.resolve(newUrl).href); + if (store.navigate) { const { customRouteRedirectName, searchText } = store.navigate; if (customRouteRedirectName) diff --git a/src/pages/Monitor/Ticket/MonitorTicketSearchbar.vue b/src/pages/Monitor/Ticket/MonitorTicketSearchbar.vue index f1c347588..9116a6449 100644 --- a/src/pages/Monitor/Ticket/MonitorTicketSearchbar.vue +++ b/src/pages/Monitor/Ticket/MonitorTicketSearchbar.vue @@ -8,5 +8,6 @@ import VnSearchbar from 'components/ui/VnSearchbar.vue'; :redirect="false" :label="$t('searchBar.label')" :info="$t('searchBar.info')" + :new-tab="true" /> diff --git a/src/pages/Monitor/locale/en.yml b/src/pages/Monitor/locale/en.yml index e61a24979..fd15a5eb9 100644 --- a/src/pages/Monitor/locale/en.yml +++ b/src/pages/Monitor/locale/en.yml @@ -41,5 +41,5 @@ salesTicketsTable: packing: ITP searchBar: label: Search tickets - info: Search tickets by id or alias + info: Up to 5 characters search by client id, more than 5 search by ticket id or alias refreshInfo: Toggle auto-refresh every 2 minutes diff --git a/src/pages/Monitor/locale/es.yml b/src/pages/Monitor/locale/es.yml index 30afb1904..2e1ec7a51 100644 --- a/src/pages/Monitor/locale/es.yml +++ b/src/pages/Monitor/locale/es.yml @@ -41,5 +41,5 @@ salesTicketsTable: packing: ITP searchBar: label: Buscar tickets - info: Buscar tickets por identificador o alias + info: Hasta 5 caracteres busca por id de cliente, más de 5 busca por id de ticket o alias refreshInfo: Conmuta el refresco automático cada 2 minutos From 0cce5b93cd94b246282b844c768832c2ff68c9a6 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 13 Dec 2024 17:20:28 +0100 Subject: [PATCH 07/70] refactor: refs #7957 remove blank --- src/components/ui/VnSearchbar.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index 830029e8e..148e8b684 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -122,7 +122,6 @@ async function search() { }; delete filter.params.search; } - await arrayData.applyFilter(filter); } From a6815f4e3d8c677508d8120398d27ff9071146af Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 16 Dec 2024 10:21:20 +0100 Subject: [PATCH 08/70] fix: refs #7957 rollback --- src/pages/Monitor/Ticket/MonitorTicketSearchbar.vue | 1 - src/pages/Monitor/locale/en.yml | 2 +- src/pages/Monitor/locale/es.yml | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/Monitor/Ticket/MonitorTicketSearchbar.vue b/src/pages/Monitor/Ticket/MonitorTicketSearchbar.vue index 9116a6449..f1c347588 100644 --- a/src/pages/Monitor/Ticket/MonitorTicketSearchbar.vue +++ b/src/pages/Monitor/Ticket/MonitorTicketSearchbar.vue @@ -8,6 +8,5 @@ import VnSearchbar from 'components/ui/VnSearchbar.vue'; :redirect="false" :label="$t('searchBar.label')" :info="$t('searchBar.info')" - :new-tab="true" /> diff --git a/src/pages/Monitor/locale/en.yml b/src/pages/Monitor/locale/en.yml index fd15a5eb9..e61a24979 100644 --- a/src/pages/Monitor/locale/en.yml +++ b/src/pages/Monitor/locale/en.yml @@ -41,5 +41,5 @@ salesTicketsTable: packing: ITP searchBar: label: Search tickets - info: Up to 5 characters search by client id, more than 5 search by ticket id or alias + info: Search tickets by id or alias refreshInfo: Toggle auto-refresh every 2 minutes diff --git a/src/pages/Monitor/locale/es.yml b/src/pages/Monitor/locale/es.yml index 2e1ec7a51..30afb1904 100644 --- a/src/pages/Monitor/locale/es.yml +++ b/src/pages/Monitor/locale/es.yml @@ -41,5 +41,5 @@ salesTicketsTable: packing: ITP searchBar: label: Buscar tickets - info: Hasta 5 caracteres busca por id de cliente, más de 5 busca por id de ticket o alias + info: Buscar tickets por identificador o alias refreshInfo: Conmuta el refresco automático cada 2 minutos From 6e655b37a1379e843ede24a944ea42d65c2f0f69 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 16 Dec 2024 10:22:01 +0100 Subject: [PATCH 09/70] fix: refs #7957 rollback --- src/components/ui/VnSearchbar.vue | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index 148e8b684..ccf87c6d6 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -67,10 +67,6 @@ const props = defineProps({ type: Function, default: undefined, }, - newTab: { - type: Boolean, - default: false, - }, }); const searchText = ref(); @@ -113,7 +109,6 @@ async function search() { search: searchText.value, }, ...{ filter: props.filter }, - newTab: props.newTab, }; if (props.whereFilter) { From a2b3a493fd930b5e55c1ca3acafb22e698a72d9e Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 16 Dec 2024 10:24:31 +0100 Subject: [PATCH 10/70] perf: refs #8220 use searchbar selector in e2e tests --- test/cypress/integration/item/itemBarcodes.spec.js | 2 +- test/cypress/integration/item/itemBotanical.spec.js | 2 +- test/cypress/integration/item/itemList.spec.js | 2 +- test/cypress/integration/item/itemSummary.spec.js | 2 +- test/cypress/integration/item/itemTag.spec.js | 3 +-- test/cypress/integration/item/itemTax.spec.js | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/test/cypress/integration/item/itemBarcodes.spec.js b/test/cypress/integration/item/itemBarcodes.spec.js index d9add4d4c..a3fadfa16 100644 --- a/test/cypress/integration/item/itemBarcodes.spec.js +++ b/test/cypress/integration/item/itemBarcodes.spec.js @@ -4,7 +4,7 @@ describe('Item shelving', () => { cy.viewport(1920, 1080); cy.login('developer'); cy.visit(`/#/item/list`); - cy.get('#searchbar input').type('1{enter}'); + cy.typeSearchbar('1{enter}'); }); it('should throw an error if the barcode exists', () => { diff --git a/test/cypress/integration/item/itemBotanical.spec.js b/test/cypress/integration/item/itemBotanical.spec.js index e726fb8c3..a98040f88 100644 --- a/test/cypress/integration/item/itemBotanical.spec.js +++ b/test/cypress/integration/item/itemBotanical.spec.js @@ -4,7 +4,7 @@ describe('Item botanical', () => { cy.viewport(1920, 1080); cy.login('developer'); cy.visit(`/#/item/list`); - cy.get('#searchbar input').type('1{enter}'); + cy.typeSearchbar('1{enter}'); }); it('should modify the botanical', () => { diff --git a/test/cypress/integration/item/itemList.spec.js b/test/cypress/integration/item/itemList.spec.js index 0a1f803aa..4706093e6 100644 --- a/test/cypress/integration/item/itemList.spec.js +++ b/test/cypress/integration/item/itemList.spec.js @@ -5,7 +5,7 @@ describe('Item list', () => { cy.viewport(1920, 1080); cy.login('developer'); cy.visit(`/#/item/list`); - cy.get('#searchbar input').type('{enter}'); + cy.typeSearchbar('{enter}'); }); it('should filter the items and redirect to the summary', () => { diff --git a/test/cypress/integration/item/itemSummary.spec.js b/test/cypress/integration/item/itemSummary.spec.js index 24b689686..0da9b1643 100644 --- a/test/cypress/integration/item/itemSummary.spec.js +++ b/test/cypress/integration/item/itemSummary.spec.js @@ -4,7 +4,7 @@ describe('Item summary', () => { cy.viewport(1920, 1080); cy.login('developer'); cy.visit(`/#/item/list`); - cy.get('#searchbar input').type('1{enter}'); + cy.typeSearchbar('1{enter}'); }); it('should clone the item', () => { diff --git a/test/cypress/integration/item/itemTag.spec.js b/test/cypress/integration/item/itemTag.spec.js index 07cd21aef..a3bd152d8 100644 --- a/test/cypress/integration/item/itemTag.spec.js +++ b/test/cypress/integration/item/itemTag.spec.js @@ -4,10 +4,9 @@ describe('Item tag', () => { cy.viewport(1920, 1080); cy.login('developer'); cy.visit(`/#/item/list`); - cy.get('#searchbar input').type('1{enter}'); + cy.typeSearchbar('1{enter}'); }); - // falla la notificacion it('should throw an error adding an existent tag', () => { cy.get('[href="#/item/1/tags"]').click(); cy.get('.q-page-sticky > div').click(); diff --git a/test/cypress/integration/item/itemTax.spec.js b/test/cypress/integration/item/itemTax.spec.js index 1de0183d7..9bb79f40f 100644 --- a/test/cypress/integration/item/itemTax.spec.js +++ b/test/cypress/integration/item/itemTax.spec.js @@ -4,7 +4,7 @@ describe('Item tax', () => { cy.viewport(1920, 1080); cy.login('developer'); cy.visit(`/#/item/list`); - cy.get('#searchbar input').type('1{enter}'); + cy.typeSearchbar('1{enter}'); }); it('should modify the tax for Spain', () => { From 4cf13a83a45f68a589f1b4952cbc90e4d8bda382 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 16 Dec 2024 11:54:57 +0100 Subject: [PATCH 11/70] fix: refs #7957 rollback --- src/composables/useArrayData.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index 098991fe8..b37fa1377 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -3,8 +3,6 @@ import { useRouter, useRoute } from 'vue-router'; import axios from 'axios'; import { useArrayDataStore } from 'stores/useArrayDataStore'; import { buildFilter } from 'filters/filterPanel'; -import { isDialogOpened } from 'src/filters'; -import useOpenURL from './useOpenURL'; const arrayDataStore = useArrayDataStore(); @@ -66,7 +64,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { } } - async function fetch({ append = false, updateRouter = true, newTab = false }) { + async function fetch({ append = false, updateRouter = true }) { if (!store.url) return; cancelRequest(); @@ -111,8 +109,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { params.filter.where = { ...params.filter.where, ...exprFilter }; params.filter = JSON.stringify(params.filter); - if (newTab) return updateStateParams(true); - store.isLoading = true; const response = await axios.get(store.url, { signal: canceller.signal, @@ -127,7 +123,8 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { for (const row of response.data) store.data.push(row); } else { store.data = response.data; - if (!isDialogOpened()) updateRouter && updateStateParams(); + if (!document.querySelectorAll('[role="dialog"][aria-modal="true"]').length) + updateRouter && updateStateParams(); } store.isLoading = false; @@ -157,12 +154,12 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { } } - async function applyFilter({ filter, params, newTab }) { + async function applyFilter({ filter, params }) { if (filter) store.userFilter = filter; store.filter = {}; if (params) store.userParams = { ...params }; - const response = await fetch({ newTab }); + const response = await fetch({}); return response; } @@ -258,14 +255,12 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { if (Object.values(store.userParams).length) await fetch({}); } - function updateStateParams(newTab) { + function updateStateParams() { if (!route?.path) return; const newUrl = { path: route.path, query: { ...(route.query ?? {}) } }; if (store?.searchUrl) newUrl.query[store.searchUrl] = JSON.stringify(store.currentFilter); - if (newTab) useOpenURL(router.resolve(newUrl).href); - if (store.navigate) { const { customRouteRedirectName, searchText } = store.navigate; if (customRouteRedirectName) From 4a4cb1cf3f84238382147f444f1ebcb86c62c05d Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 16 Dec 2024 16:02:43 +0100 Subject: [PATCH 12/70] feat: refs #7957 enhance search functionality and improve data filtering logic --- src/components/ui/VnSearchbar.vue | 70 +++++++++++++++++++++++-------- src/composables/useArrayData.js | 49 ++++++++++++---------- 2 files changed, 80 insertions(+), 39 deletions(-) diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index ccf87c6d6..89a587b31 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -1,14 +1,16 @@ \ No newline at end of file diff --git a/src/pages/Worker/WorkerList.vue b/src/pages/Worker/WorkerList.vue index 365ea94de..6883a149f 100644 --- a/src/pages/Worker/WorkerList.vue +++ b/src/pages/Worker/WorkerList.vue @@ -189,7 +189,7 @@ async function autofillBic(worker) { + [ name: 'itemFk', ...defaultColumnAttrs, isId: true, - cardVisible: true, columnField: { component: 'input', type: 'number', @@ -65,14 +64,12 @@ const columns = computed(() => [ name: 'name', ...defaultColumnAttrs, create: true, - cardVisible: true, }, { label: t('item.fixedPrice.groupingPrice'), field: 'rate2', name: 'rate2', ...defaultColumnAttrs, - cardVisible: true, component: 'input', type: 'number', }, @@ -81,7 +78,6 @@ const columns = computed(() => [ field: 'rate3', name: 'rate3', ...defaultColumnAttrs, - cardVisible: true, component: 'input', type: 'number', }, @@ -91,7 +87,6 @@ const columns = computed(() => [ field: 'minPrice', name: 'minPrice', ...defaultColumnAttrs, - cardVisible: true, component: 'input', type: 'number', }, @@ -100,7 +95,6 @@ const columns = computed(() => [ field: 'started', name: 'started', format: ({ started }) => toDate(started), - cardVisible: true, ...defaultColumnAttrs, columnField: { component: 'date', @@ -116,7 +110,6 @@ const columns = computed(() => [ field: 'ended', name: 'ended', ...defaultColumnAttrs, - cardVisible: true, columnField: { component: 'date', class: 'shrink', @@ -251,11 +244,14 @@ const upsertPrice = async (props, resetMinPrice = false) => { } if (!changes.updates && !changes.creates) return; const data = await upsertFixedPrice(row); - tableRef.value.CrudModelRef.formData[props.rowIndex] = data; + Object.assign(tableRef.value.CrudModelRef.formData[props.rowIndex], data); + notify(t('globals.dataSaved'), 'positive'); + tableRef.value.reload(); }; async function upsertFixedPrice(row) { const { data } = await axios.patch('FixedPrices/upsertFixedPrice', row); + data.hasMinPrice = data.hasMinPrice ? 1 : 0; return data; } @@ -395,18 +391,11 @@ function handleOnDataSave({ CrudModelRef }) { From d1466746de4eca3920f10103b814d3d95f4bfd46 Mon Sep 17 00:00:00 2001 From: provira Date: Fri, 3 Jan 2025 08:33:38 +0100 Subject: [PATCH 37/70] feat: refs #7078 created test for VnJsonValue --- .../common/__tests__/VnJsonValue.spec.js | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/components/common/__tests__/VnJsonValue.spec.js diff --git a/src/components/common/__tests__/VnJsonValue.spec.js b/src/components/common/__tests__/VnJsonValue.spec.js new file mode 100644 index 000000000..19e563a1f --- /dev/null +++ b/src/components/common/__tests__/VnJsonValue.spec.js @@ -0,0 +1,87 @@ +import { mount } from '@vue/test-utils'; +import { describe, it, expect } from 'vitest'; +import VnJsonValue from 'src/components/common/VnJsonValue.vue'; + +const createWrapper = (props) => { + return mount(VnJsonValue, { + props, + }); +}; + +describe('VnJsonValue', () => { + it('renders null value correctly', async () => { + const wrapper = createWrapper({ value: null }); + const span = wrapper.find('span'); + expect(span.text()).toBe('∅'); + expect(span.classes()).toContain('json-null'); + }); + + it('renders boolean true correctly', async () => { + const wrapper = createWrapper({ value: true }); + const span = wrapper.find('span'); + expect(span.text()).toBe('✓'); + expect(span.classes()).toContain('json-true'); + }); + + it('renders boolean false correctly', async () => { + const wrapper = createWrapper({ value: false }); + const span = wrapper.find('span'); + expect(span.text()).toBe('✗'); + expect(span.classes()).toContain('json-false'); + }); + + it('renders a short string correctly', async () => { + const wrapper = createWrapper({ value: 'Hello' }); + const span = wrapper.find('span'); + expect(span.text()).toBe('Hello'); + expect(span.classes()).toContain('json-string'); + }); + + it('renders a long string correctly with ellipsis', async () => { + const longString = 'a'.repeat(600); + const wrapper = createWrapper({ value: longString }); + const span = wrapper.find('span'); + expect(span.text()).toContain('...'); + expect(span.text().length).toBeLessThanOrEqual(515); + expect(span.attributes('title')).toBe(longString); + expect(span.classes()).toContain('json-string'); + }); + + it('renders a number correctly', async () => { + const wrapper = createWrapper({ value: 123.4567 }); + const span = wrapper.find('span'); + expect(span.text()).toBe('123.457'); + expect(span.classes()).toContain('json-number'); + }); + + it('renders an integer correctly', async () => { + const wrapper = createWrapper({ value: 42 }); + const span = wrapper.find('span'); + expect(span.text()).toBe('42'); + expect(span.classes()).toContain('json-number'); + }); + + it('renders a date correctly', async () => { + const date = new Date('2023-01-01'); + const wrapper = createWrapper({ value: date }); + const span = wrapper.find('span'); + expect(span.text()).toBe('2023-01-01'); + expect(span.classes()).toContain('json-object'); + }); + + it('renders an object correctly', async () => { + const obj = { key: 'value' }; + const wrapper = createWrapper({ value: obj }); + const span = wrapper.find('span'); + expect(span.text()).toBe(obj.toString()); + expect(span.classes()).toContain('json-object'); + }); + + it('updates value when prop changes', async () => { + const wrapper = createWrapper({ value: true }); + await wrapper.setProps({ value: 123 }); + const span = wrapper.find('span'); + expect(span.text()).toBe('123'); + expect(span.classes()).toContain('json-number'); + }); +}); From 9a631a61f90711e281244ddcb7ae2b8d93c96a55 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 3 Jan 2025 10:46:43 +0100 Subject: [PATCH 38/70] fix: refs #8197 redirection --- src/components/common/VnSection.vue | 14 ++++++++++++-- src/components/ui/VnSearchbar.vue | 1 + src/pages/Order/Card/OrderSummary.vue | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/common/VnSection.vue b/src/components/common/VnSection.vue index e69e586b5..f55826a22 100644 --- a/src/components/common/VnSection.vue +++ b/src/components/common/VnSection.vue @@ -4,6 +4,7 @@ import VnSearchbar from 'components/ui/VnSearchbar.vue'; import VnTableFilter from '../VnTable/VnTableFilter.vue'; import { onBeforeMount, computed } from 'vue'; import { useArrayData } from 'src/composables/useArrayData'; +import { useRoute } from 'vue-router'; const $props = defineProps({ section: { @@ -40,8 +41,17 @@ const $props = defineProps({ }, }); -const sectionValue = computed(() => $props.section ?? $props.dataKey); +const route = useRoute(); let arrayData; +const sectionValue = computed(() => $props.section ?? $props.dataKey); +const isMainSection = computed(() => { + const isSame = sectionValue.value == route.name; + if (!isSame && arrayData) { + arrayData.reset(['userParams', 'userFilter']); + } + return isSame; +}); + onBeforeMount(() => { if ($props.dataKey) arrayData = useArrayData($props.dataKey, { @@ -74,6 +84,6 @@ onBeforeMount(() => { - + diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index 4e284d8e4..a2d3b9ee1 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -126,6 +126,7 @@ async function search() { delete filter.params.search; } await arrayData.applyFilter(filter); + searchText.value = undefined; }