From c016e9690430830e6e20ce8fcfa02db0d404163a Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 15 Jul 2024 10:44:28 +0200 Subject: [PATCH] fix: refs #7354 fix VnSearchbar search for zone section & finished basic tests --- src/components/common/VnCard.vue | 2 + src/components/ui/VnSearchbar.vue | 39 ++++++++++++---- src/pages/Zone/Card/ZoneCard.vue | 26 +++-------- src/pages/Zone/Card/ZoneWarehouses.vue | 2 +- src/pages/Zone/ZoneFilterPanel.vue | 1 + src/pages/Zone/ZoneList.vue | 8 ++++ src/pages/Zone/ZoneMain.vue | 43 ------------------ .../integration/zone/zoneBasicData.spec.js | 23 ++++++++++ .../integration/zone/zoneCreate.spec.js | 45 +++++++++++++++++++ .../cypress/integration/zone/zoneList.spec.js | 19 ++++++++ .../integration/zone/zoneWarehouse.spec.js | 34 ++++++++++++++ test/cypress/support/commands.js | 6 +++ 12 files changed, 175 insertions(+), 73 deletions(-) create mode 100644 test/cypress/integration/zone/zoneBasicData.spec.js create mode 100644 test/cypress/integration/zone/zoneCreate.spec.js create mode 100644 test/cypress/integration/zone/zoneList.spec.js create mode 100644 test/cypress/integration/zone/zoneWarehouse.spec.js diff --git a/src/components/common/VnCard.vue b/src/components/common/VnCard.vue index 17fa74317..a352a6849 100644 --- a/src/components/common/VnCard.vue +++ b/src/components/common/VnCard.vue @@ -20,6 +20,7 @@ const props = defineProps({ searchUrl: { type: String, default: undefined }, searchbarLabel: { type: String, default: '' }, searchbarInfo: { type: String, default: '' }, + searchKey: { type: String, default: 'search' }, searchCustomRouteRedirect: { type: String, default: undefined }, searchRedirect: { type: Boolean, default: true }, searchMakeFetch: { type: Boolean, default: true }, @@ -72,6 +73,7 @@ if (props.baseUrl) { :info="props.searchbarInfo" :custom-route-redirect-name="searchCustomRouteRedirect" :redirect="searchRedirect" + :search-key="searchKey" /> diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index 0c7a8a3f6..6dd2f5f4b 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -61,15 +61,23 @@ const props = defineProps({ }, customRouteRedirectName: { type: String, - default: '', + default: null, }, makeFetch: { type: Boolean, default: true, }, + searchKey: { + type: String, + default: 'search', + }, + isQueryFilter: { + type: Boolean, + default: false, + }, }); -const searchText = ref(''); +const searchText = ref(); let arrayDataProps = { ...props }; if (props.redirect) arrayDataProps = { @@ -105,13 +113,26 @@ async function search() { ); arrayData.reset(['skip', 'page']); - if (props.makeFetch) - await arrayData.applyFilter({ - params: { - ...Object.fromEntries(staticParams), - search: searchText.value, - }, - }); + if (props.isQueryFilter) { + if (props.makeFetch) + await arrayData.applyFilter({ + params: { + ...Object.fromEntries(staticParams), + }, + filter: { + where: { + name: searchText.value == '' ? undefined : searchText.value, + }, + }, + }); + } else { + if (props.makeFetch) + await arrayData.applyFilter({ + params: { + ...Object.fromEntries(staticParams), + }, + }); + } }