8713-testToMaster #1539

Merged
alexm merged 118 commits from 8713-testToMaster into master 2025-03-04 06:57:15 +00:00
3 changed files with 27 additions and 15 deletions
Showing only changes of commit f62f72832a - Show all commits

View File

@ -61,9 +61,12 @@ const $props = defineProps({
type: Object, type: Object,
default: null, default: null,
}, },
useSearchbar: { searchbarOptions: {
type: [Boolean, Function], type: Object,
default: false, default: () => ({
use: false,
validateFn: null,
}),
}, },
}); });
@ -99,19 +102,19 @@ defineExpose({ search, params: userParams, remove });
async function search(evt) { async function search(evt) {
try { try {
if ($props.useSearchbar) { if ($props.searchbarOptions.use) {
if (!searchbar.value) { if (!searchbar.value) {
return; return;
} }
if (typeof $props.useSearchbar === 'function') { if (typeof $props.searchbarOptions.validateFn === 'function') {
$props.useSearchbar(userParams.value); $props.searchbarOptions.validateFn(userParams.value);
}
if (!Object.keys(userParams.value).length) { if (!Object.keys(userParams.value).length) {
searchbar.value(); searchbar.value();
return; return;
} }
} }
}
if (evt && $props.disableSubmitEvent) return; if (evt && $props.disableSubmitEvent) return;
store.filter.where = {}; store.filter.where = {};

View File

@ -76,7 +76,7 @@ function validateDateRange(params) {
<VnFilterPanel <VnFilterPanel
:data-key="props.dataKey" :data-key="props.dataKey"
:search-button="true" :search-button="true"
:use-searchbar="validateDateRange" :searchbar-options="{ use: true, validateFn: validateDateRange }"
> >
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">

View File

@ -19,16 +19,16 @@ describe('TicketFilter', () => {
cy.on('uncaught:exception', () => { cy.on('uncaught:exception', () => {
return false; return false;
}); });
cy.get('.q-field__control-container > [data-cy="From_date"]').type( cy.get('.q-field__control-container > [data-cy="From_date"]')
'14-02-2025{enter}', .type(`${today()} `)
); .type('{enter}');
cy.get('.q-notification').should( cy.get('.q-notification').should(
'contain', 'contain',
`The date range must have both 'from' and 'to'`, `The date range must have both 'from' and 'to'`,
); );
cy.get('.q-field__control-container > [data-cy="To_date"]').type( cy.get('.q-field__control-container > [data-cy="To_date"]').type(
'16/02/2025{enter}', `${today()}{enter}`,
); );
cy.intercept('GET', /\/api\/Tickets\/filter/).as('ticketFilter'); cy.intercept('GET', /\/api\/Tickets\/filter/).as('ticketFilter');
cy.searchBtnFilterPanel(); cy.searchBtnFilterPanel();
@ -40,3 +40,12 @@ describe('TicketFilter', () => {
cy.location('href').should('contain', '#/ticket/999999'); cy.location('href').should('contain', '#/ticket/999999');
}); });
}); });
function today() {
// return new Date().toISOString().split('T')[0];
return new Intl.DateTimeFormat('es-ES', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}).format(new Date());
}