0
0
Fork 0

fix: refs #7717 fix catalog searchbar and worker tests(refs #7323)

This commit is contained in:
Jon Elias 2024-07-23 11:46:21 +02:00
parent 368b8404fa
commit ce6a94bab8
6 changed files with 49 additions and 55 deletions

View File

@ -106,21 +106,23 @@ watch(
const isLoading = ref(false);
async function search(evt) {
if (evt && $props.disableSubmitEvent) return;
try {
if (evt && $props.disableSubmitEvent) return;
store.filter.where = {};
isLoading.value = true;
const filter = { ...userParams.value, ...$props.modelValue };
store.userParamsChanged = true;
const { params: newParams } = await arrayData.addFilter({
params: filter,
});
userParams.value = newParams;
store.filter.where = {};
isLoading.value = true;
const filter = { ...userParams.value, ...$props.modelValue };
store.userParamsChanged = true;
const { params: newParams } = await arrayData.addFilter({
params: filter,
});
userParams.value = newParams;
if (!$props.showAll && !Object.values(filter).length) store.data = [];
isLoading.value = false;
emit('search');
if (!$props.showAll && !Object.values(filter).length) store.data = [];
emit('search');
} finally {
isLoading.value = false;
}
}
async function reload() {
@ -135,29 +137,31 @@ async function reload() {
}
async function clearFilters() {
isLoading.value = true;
store.userParamsChanged = true;
arrayData.reset(['skip', 'filter.skip', 'page']);
// Filtrar los params no removibles
const removableFilters = Object.keys(userParams.value).filter((param) =>
$props.unRemovableParams.includes(param)
);
const newParams = {};
// Conservar solo los params que no son removibles
for (const key of removableFilters) {
newParams[key] = userParams.value[key];
}
userParams.value = {};
userParams.value = { ...newParams }; // Actualizar los params con los removibles
await arrayData.applyFilter({ params: userParams.value });
try {
isLoading.value = true;
store.userParamsChanged = true;
arrayData.reset(['skip', 'filter.skip', 'page']);
// Filtrar los params no removibles
const removableFilters = Object.keys(userParams.value).filter((param) =>
$props.unRemovableParams.includes(param)
);
const newParams = {};
// Conservar solo los params que no son removibles
for (const key of removableFilters) {
newParams[key] = userParams.value[key];
}
userParams.value = {};
userParams.value = { ...newParams }; // Actualizar los params con los removibles
await arrayData.applyFilter({ params: userParams.value });
if (!$props.showAll) {
store.data = [];
if (!$props.showAll) {
store.data = [];
}
emit('clear');
emit('update:modelValue', userParams.value);
} finally {
isLoading.value = false;
}
isLoading.value = false;
emit('clear');
emit('update:modelValue', userParams.value);
}
const tagsList = computed(() => {

View File

@ -101,10 +101,6 @@ onMounted(() => {
async function search() {
const staticParams = Object.entries(store.userParams);
console.log('staticParams: ', staticParams);
// .filter(
// ([key, value]) => value && (props.staticParams || []).includes(key)
// );
arrayData.reset(['skip', 'page']);
if (props.makeFetch)

View File

@ -19,7 +19,7 @@ const props = defineProps({
<VnFilterPanel
:data-key="props.dataKey"
:search-button="true"
:unremovable-params="['from', 'to']"
:un-removable-params="['from', 'to']"
:hidden-tags="['from', 'to']"
>
<template #tags="{ tag, formatFn }">

View File

@ -1,5 +1,4 @@
<script setup>
import { useI18n } from 'vue-i18n';
import { computed } from 'vue';
import { useRoute } from 'vue-router';
import VnCard from 'components/common/VnCard.vue';
@ -17,18 +16,10 @@ const customRouteRedirectName = computed(() => {
const route = config[routeName.value];
if (route) return null;
return 'OrderList';
//Jon, asi es como lo dejamos
// if (routeName.value === 'OrderCatalog') return null;
// return 'OrderList';
});
const customFilterPanel = computed(() => {
const filterPanel = config[routeName.value] ?? OrderFilter;
return filterPanel;
//Jon, asi es como lo dejamos
// if (routeName.value === 'OrderCatalog') return null;
// return 'OrderList';
// if (routeName.value === 'OrderCatalog') return OrderCatalogFilter;
// return OrderFilter;
});
</script>

View File

@ -5,8 +5,14 @@ describe('WorkerList', () => {
cy.visit('/#/worker/list');
});
it('should open the worker summary', () => {
cy.get('.bg-header > :nth-child(2) > .full-width > :nth-child(1) >').type(
it('should opern the worker summary', () => {
cy.get(
':nth-child(1) > .text-right > .q-btn > .q-btn__content > .q-icon'
).click();
});
it('should go to the worker summary', () => {
cy.get('#searchbar > .q-field > .q-field__inner > .q-field__control').type(
'jessica jones{enter}'
);
});

View File

@ -2,7 +2,6 @@ describe('WorkerLocker', () => {
const workerId = 1109;
const lockerCode = '2F';
const input = '.q-card input';
const firstOpt = '[role="listbox"] .q-item:nth-child(1)';
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('productionBoss');
@ -11,9 +10,7 @@ describe('WorkerLocker', () => {
it('should allocates a locker', () => {
cy.get(input).click();
cy.get(input).type(lockerCode);
cy.get(firstOpt).click();
cy.saveCard();
cy.get(input).invoke('val').should('eq', lockerCode);
cy.get(input).type(`${lockerCode}{enter}`);
cy.get(input).should('have.value', lockerCode);
});
});