diff --git a/cypress.config.js b/cypress.config.js index 1100b59b1..c21fd5819 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -34,5 +34,7 @@ module.exports = defineConfig({ require('cypress-mochawesome-reporter/plugin')(on); // implement node event listeners here }, + viewportWidth: 1280, + viewportHeight: 720, }, }); diff --git a/package.json b/package.json index 9d14e8727..8f482a57d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-front", - "version": "25.04.0", + "version": "25.06.0", "description": "Salix frontend", "productName": "Salix", "author": "Verdnatura", diff --git a/src/components/common/VnSection.vue b/src/components/common/VnSection.vue index 510865530..16ea79047 100644 --- a/src/components/common/VnSection.vue +++ b/src/components/common/VnSection.vue @@ -52,7 +52,8 @@ const sectionValue = computed(() => $props.section ?? $props.dataKey); const isMainSection = computed(() => { const isSame = sectionValue.value == route.name; if (!isSame && arrayData) { - arrayData.reset(['userParams', 'userFilter']); + arrayData.reset(['userParams', 'filter']); + arrayData.setCurrentFilter(); } return isSame; }); diff --git a/src/components/common/VnSelect.vue b/src/components/common/VnSelect.vue index a3e85655d..43134dbff 100644 --- a/src/components/common/VnSelect.vue +++ b/src/components/common/VnSelect.vue @@ -232,12 +232,15 @@ async function fetchFilter(val) { } else defaultWhere = { [key]: getVal(val) }; const where = { ...(val ? defaultWhere : {}), ...$props.where }; $props.exprBuilder && Object.assign(where, $props.exprBuilder(key, val)); - const fetchOptions = { where, include, limit }; - if (fields) fetchOptions.fields = fields; - if (sortBy) fetchOptions.order = sortBy; + const filterOptions = { where, include, limit }; + if (fields) filterOptions.fields = fields; + if (sortBy) filterOptions.order = sortBy; arrayData.resetPagination(); - const { data } = await arrayData.applyFilter({ filter: fetchOptions }); + const { data } = await arrayData.applyFilter( + { filter: filterOptions }, + { updateRouter: false } + ); setOptions(data); return data; } diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index bfaa76588..a5ca97b70 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -113,23 +113,20 @@ onMounted(() => { }); async function search() { - const staticParams = Object.keys(store.userParams ?? {}).length - ? store.userParams - : store.defaultParams; arrayData.resetPagination(); - const filter = { - params: { - search: searchText.value, - }, - filter: props.filter, - }; + let filter = { params: { search: searchText.value } }; if (!props.searchRemoveParams || !searchText.value) { - filter.params = { - ...staticParams, - search: searchText.value, + filter = { + params: { + ...store.userParams, + search: searchText.value, + }, + filter: store.filter, }; + } else { + arrayData.reset(['currentFilter', 'userParams']); } if (props.whereFilter) { diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index 6fb22a340..d76053ce9 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -33,10 +33,11 @@ export function useArrayData(key, userOptions) { : JSON.parse(params?.filter ?? '{}'); delete params.filter; - store.userParams = { ...store.userParams, ...params }; + store.userParams = params; store.filter = { ...filter, ...store.userFilter }; if (filter?.order) store.order = filter.order; } + setCurrentFilter(); }); if (key && userOptions) setOptions(); @@ -78,11 +79,7 @@ export function useArrayData(key, userOptions) { cancelRequest(); canceller = new AbortController(); - const { params, limit } = getCurrentFilter(); - - store.currentFilter = JSON.parse(JSON.stringify(params)); - delete store.currentFilter.filter.include; - store.currentFilter.filter = JSON.stringify(store.currentFilter.filter); + const { params, limit } = setCurrentFilter(); let exprFilter; if (store?.exprBuilder) { @@ -107,7 +104,7 @@ export function useArrayData(key, userOptions) { store.hasMoreData = limit && response.data.length >= limit; if (!append && !isDialogOpened() && updateRouter) { - if (updateStateParams(response.data)?.redirect) return; + if (updateStateParams(response.data)?.redirect && !store.keepData) return; } store.isLoading = false; canceller = null; @@ -142,12 +139,12 @@ export function useArrayData(key, userOptions) { } } - async function applyFilter({ filter, params }) { + async function applyFilter({ filter, params }, fetchOptions = {}) { if (filter) store.userFilter = filter; store.filter = {}; if (params) store.userParams = { ...params }; - const response = await fetch({}); + const response = await fetch(fetchOptions); return response; } @@ -276,14 +273,14 @@ export function useArrayData(key, userOptions) { } function getCurrentFilter() { + if (!Object.keys(store.userParams).length) + store.userParams = store.defaultParams ?? {}; + const filter = { limit: store.limit, + ...store.userFilter, }; - let userParams = { ...store.userParams }; - - Object.assign(filter, store.userFilter); - let where; if (filter?.where || store.filter?.where) where = Object.assign(filter?.where ?? {}, store.filter?.where ?? {}); @@ -291,7 +288,7 @@ export function useArrayData(key, userOptions) { filter.where = where; const params = { filter }; - Object.assign(params, userParams); + Object.assign(params, store.userParams); if (params.filter) params.filter.skip = store.skip; if (store?.order && typeof store?.order == 'string') store.order = [store.order]; if (store.order?.length) params.filter.order = [...store.order]; @@ -300,6 +297,14 @@ export function useArrayData(key, userOptions) { return { filter, params, limit: filter.limit }; } + function setCurrentFilter() { + const { params, limit } = getCurrentFilter(); + store.currentFilter = JSON.parse(JSON.stringify(params)); + delete store.currentFilter.filter.include; + store.currentFilter.filter = JSON.stringify(store.currentFilter.filter); + return { params, limit }; + } + function processData(data, { map = true, append = true }) { if (!append) { store.data = []; @@ -333,6 +338,7 @@ export function useArrayData(key, userOptions) { applyFilter, addFilter, getCurrentFilter, + setCurrentFilter, addFilterWhere, addOrder, deleteOrder, diff --git a/src/composables/useFilterParams.js b/src/composables/useFilterParams.js index 2878e4b76..07dcdf99b 100644 --- a/src/composables/useFilterParams.js +++ b/src/composables/useFilterParams.js @@ -29,8 +29,12 @@ export function useFilterParams(key) { orders.value = orderObject; } - function setUserParams(watchedParams) { - if (!watchedParams || Object.keys(watchedParams).length == 0) return; + function setUserParams(watchedParams = {}) { + if (Object.keys(watchedParams).length == 0) { + params.value = {}; + orders.value = {}; + return; + } if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams); if (typeof watchedParams?.filter == 'string') diff --git a/src/pages/Ticket/TicketFilter.vue b/src/pages/Ticket/TicketFilter.vue index 7dcb834d2..4b50892b0 100644 --- a/src/pages/Ticket/TicketFilter.vue +++ b/src/pages/Ticket/TicketFilter.vue @@ -7,6 +7,7 @@ import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue'; import VnInput from 'src/components/common/VnInput.vue'; import VnInputDate from 'components/common/VnInputDate.vue'; import VnSelect from 'src/components/common/VnSelect.vue'; +import VnSelectWorker from 'src/components/common/VnSelectWorker.vue'; const { t } = useI18n(); const props = defineProps({ @@ -81,15 +82,12 @@ const getGroupedStates = (data) => { - { cy.viewport(1920, 1080); cy.login('developer'); cy.visit(`/#/invoice-out/list`); - cy.typeSearchbar('{enter}'); }); it('should generate the invoice PDF', () => { @@ -19,13 +18,12 @@ describe('InvoiceOut summary', () => { cy.dataCy('VnConfirm_confirm').click(); cy.checkNotification('The invoice PDF document has been regenerated'); }); - it('should refund the invoice ', () => { cy.typeSearchbar('T1111111{enter}'); cy.dataCy('descriptor-more-opts').click(); cy.get('.q-menu > .q-list > :nth-child(7)').click(); cy.get('#q-portal--menu--3 > .q-menu > .q-list > :nth-child(2)').click(); - cy.checkNotification('The following refund ticket have been created 1000000'); + cy.checkNotification('The following refund ticket have been created'); }); it('should delete an invoice ', () => { @@ -35,8 +33,7 @@ describe('InvoiceOut summary', () => { cy.dataCy('VnConfirm_confirm').click(); cy.checkNotification('InvoiceOut deleted'); }); - // https://redmine.verdnatura.es/issues/8415 - it.skip('should transfer the invoice ', () => { + it('should transfer the invoice ', () => { cy.typeSearchbar('T1111111{enter}'); cy.dataCy('descriptor-more-opts').click(); cy.get('.q-menu > .q-list > :nth-child(1)').click(); diff --git a/test/cypress/integration/ticket/ticketSale.spec.js b/test/cypress/integration/ticket/ticketSale.spec.js index 7bc53f010..aed8dc85a 100644 --- a/test/cypress/integration/ticket/ticketSale.spec.js +++ b/test/cypress/integration/ticket/ticketSale.spec.js @@ -1,7 +1,5 @@ /// -const c = require('croppie'); - describe('TicketSale', () => { beforeEach(() => { cy.login('developer'); diff --git a/test/cypress/integration/vnComponent/VnLocation.spec.js b/test/cypress/integration/vnComponent/VnLocation.spec.js index 09665a816..751b3a065 100644 --- a/test/cypress/integration/vnComponent/VnLocation.spec.js +++ b/test/cypress/integration/vnComponent/VnLocation.spec.js @@ -49,12 +49,12 @@ describe('VnLocation', () => { beforeEach(() => { cy.viewport(1280, 720); cy.login('developer'); - cy.visit('/#/worker/create', { timeout: 5000 }); + cy.visit('/#/worker/list', { timeout: 5000 }); + cy.dataCy('vnTableCreateBtn').click(); cy.waitForElement('.q-card'); cy.get(inputLocation).click(); }); - // https://redmine.verdnatura.es/issues/8436 - it.skip('Show all options', function () { + it('Show all options', function () { cy.get(locationOptions).should('have.length.at.least', 5); }); it('input filter location as "al"', function () { diff --git a/test/cypress/integration/worker/workerList.spec.js b/test/cypress/integration/worker/workerList.spec.js index c1c37fd32..0a45441c1 100644 --- a/test/cypress/integration/worker/workerList.spec.js +++ b/test/cypress/integration/worker/workerList.spec.js @@ -10,8 +10,8 @@ describe('WorkerList', () => { it('should open the worker summary', () => { cy.get(inputName).type('jessica{enter}'); - cy.get(searchBtn).click(); cy.intercept('GET', /\/api\/Workers\/summary+/).as('worker'); + cy.get(searchBtn).click(); cy.wait('@worker').then(() => cy.get(descriptorTitle).should('include.text', 'Jessica') );