Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix-front into dev
gitea/salix-front/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2024-11-21 10:26:38 +01:00
commit fdc71a13ff
10 changed files with 167 additions and 212 deletions

View File

@ -1,6 +1,5 @@
<script setup> <script setup>
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { defineProps } from 'vue';
const props = defineProps({ const props = defineProps({
routeName: { routeName: {

View File

@ -170,7 +170,7 @@ onMounted(async () => {
from.value = getDate(_from, 'from'); from.value = getDate(_from, 'from');
const _to = Date.vnNew(); const _to = Date.vnNew();
_to.setDate(_to.getDate() + 10); _to.setDate(_to.getDate() + 10);
to.value = getDate(Date.vnNew(), 'to'); to.value = getDate(_to, 'to');
updateFilter(); updateFilter();

View File

@ -2,7 +2,7 @@
import { ref } from 'vue'; import { ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import axios from 'axios'; import axios from 'axios';
import VnSelect from 'components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
const props = defineProps({ const props = defineProps({
@ -31,47 +31,26 @@ const applyTags = () => {
emit('applyTags', tagInfo); emit('applyTags', tagInfo);
}; };
const removeTagGroupParam = (valIndex = null) => {
if (!valIndex) {
tagValues.value = [{}];
} else {
(tagValues.value || []).splice(valIndex, 1);
}
};
const getSelectedTagValues = async (tag) => { const getSelectedTagValues = async (tag) => {
try { if (!tag?.id) return;
if (!tag?.id) return; const filter = {
const filter = { fields: ['value'],
fields: ['value'], order: 'value ASC',
order: 'value ASC', limit: 30,
limit: 30, };
};
const url = `Tags/${tag?.id}/filterValue`; const url = `Tags/${tag?.id}/filterValue`;
const params = { filter: JSON.stringify(filter) }; const params = { filter: JSON.stringify(filter) };
const { data } = await axios.get(url, { const { data } = await axios.get(url, {
params, params,
}); });
tagOptions.value = data; tagOptions.value = data;
} catch (err) {
console.error('Error getting selected tag values');
}
}; };
</script> </script>
<template> <template>
<QForm @submit="applyTags(tagValues)" class="all-pointer-events"> <QForm @submit="applyTags()" class="all-pointer-events">
<QCard class="q-pa-sm column q-pa-lg"> <QCard class="q-pa-sm column q-pa-lg">
<QBtn
round
color="primary"
style="position: absolute; z-index: 1; right: 0; top: 0"
icon="search"
type="submit"
>
</QBtn>
<VnSelect <VnSelect
:label="t('params.tag')" :label="t('params.tag')"
v-model="selectedTag" v-model="selectedTag"
@ -84,17 +63,7 @@ const getSelectedTagValues = async (tag) => {
rounded rounded
:emit-value="false" :emit-value="false"
use-input use-input
@update:model-value="($event) => getSelectedTagValues($event)" @update:model-value="getSelectedTagValues"
/>
<QBtn
icon="add_circle"
shortcut="+"
flat
class="filter-icon q-mb-md"
size="md"
dense
:disabled="!selectedTag || !tagValues[0].value"
@click="tagValues.unshift({})"
/> />
<div <div
v-for="(value, index) in tagValues" v-for="(value, index) in tagValues"
@ -106,7 +75,7 @@ const getSelectedTagValues = async (tag) => {
v-if="!selectedTag?.isFree && tagOptions" v-if="!selectedTag?.isFree && tagOptions"
:label="t('components.itemsFilterPanel.value')" :label="t('components.itemsFilterPanel.value')"
v-model="value.value" v-model="value.value"
:options="tagOptions || []" :options="tagOptions"
option-value="value" option-value="value"
option-label="value" option-label="value"
dense dense
@ -124,7 +93,6 @@ const getSelectedTagValues = async (tag) => {
:label="t('components.itemsFilterPanel.value')" :label="t('components.itemsFilterPanel.value')"
:disable="!value" :disable="!value"
is-outlined is-outlined
:is-clearable="false"
class="col" class="col"
/> />
<QBtn <QBtn
@ -135,11 +103,25 @@ const getSelectedTagValues = async (tag) => {
rounded rounded
flat flat
class="filter-icon col-2" class="filter-icon col-2"
:disabled="!value.value" @click="tagValues.splice(index, 1)"
@click="removeTagGroupParam(index)"
/> />
</div> </div>
</div> </div>
<QBtn
icon="add_circle"
shortcut="+"
flat
class="filter-icon q-mb-md"
size="md"
dense
@click="tagValues.push({})"
/>
<QBtn
color="primary"
icon="search"
type="submit"
:label="$t('globals.search')"
/>
</QCard> </QCard>
</QForm> </QForm>
</template> </template>

View File

@ -4,18 +4,19 @@ import { useRoute, useRouter } from 'vue-router';
import { onBeforeMount, onMounted, onUnmounted, ref, computed, watch } from 'vue'; import { onBeforeMount, onMounted, onUnmounted, ref, computed, watch } from 'vue';
import axios from 'axios'; import axios from 'axios';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import VnPaginate from 'components/ui/VnPaginate.vue'; import VnPaginate from 'src/components/ui/VnPaginate.vue';
import CatalogItem from 'components/ui/CatalogItem.vue'; import CatalogItem from 'src/components/ui/CatalogItem.vue';
import OrderCatalogFilter from 'pages/Order/Card/OrderCatalogFilter.vue'; import OrderCatalogFilter from 'src/pages/Order/Card/OrderCatalogFilter.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue'; import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import getParamWhere from 'src/filters/getParamWhere'; import getParamWhere from 'src/filters/getParamWhere';
import { useArrayData } from 'composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const stateStore = useStateStore(); const stateStore = useStateStore();
const { t } = useI18n(); const { t } = useI18n();
const arrayData = useArrayData('OrderCatalogList'); const dataKey = 'OrderCatalogList';
const arrayData = useArrayData(dataKey);
const store = arrayData.store; const store = arrayData.store;
const showFilter = ref(null); const showFilter = ref(null);
const tags = ref([]); const tags = ref([]);
@ -102,7 +103,7 @@ watch(
<template> <template>
<VnSearchbar <VnSearchbar
data-key="OrderCatalogList" :data-key="dataKey"
:user-params="catalogParams" :user-params="catalogParams"
:static-params="['orderFk', 'orderBy']" :static-params="['orderFk', 'orderBy']"
:redirect="false" :redirect="false"
@ -113,7 +114,7 @@ watch(
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above> <QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
<QScrollArea v-if="showFilter" class="fit text-grey-8"> <QScrollArea v-if="showFilter" class="fit text-grey-8">
<OrderCatalogFilter <OrderCatalogFilter
data-key="OrderCatalogList" :data-key="dataKey"
:tag-value="tagValue" :tag-value="tagValue"
:tags="tags" :tags="tags"
:initial-catalog-params="catalogParams" :initial-catalog-params="catalogParams"
@ -123,7 +124,7 @@ watch(
<QPage class="column items-center q-pa-md"> <QPage class="column items-center q-pa-md">
<div class="full-width"> <div class="full-width">
<VnPaginate <VnPaginate
data-key="OrderCatalogList" :data-key="dataKey"
url="Orders/CatalogFilter" url="Orders/CatalogFilter"
:limit="50" :limit="50"
:user-params="catalogParams" :user-params="catalogParams"

View File

@ -32,11 +32,12 @@ const route = useRoute();
const arrayData = useArrayData(props.dataKey); const arrayData = useArrayData(props.dataKey);
const currentParams = ref({});
const categoryList = ref(null); const categoryList = ref(null);
const selectedCategoryFk = ref(null); const selectedCategoryFk = ref(null);
const typeList = ref([]); const typeList = ref([]);
const selectedTypeFk = ref(null); const selectedTypeFk = ref(null);
const generalSearchParam = ref(null); const searchByTag = ref(null);
const vnFilterPanelRef = ref(); const vnFilterPanelRef = ref();
const orderByList = ref([ const orderByList = ref([
@ -52,26 +53,30 @@ const orderWayList = ref([
const orderBySelected = ref('relevancy DESC, name'); const orderBySelected = ref('relevancy DESC, name');
const orderWaySelected = ref('ASC'); const orderWaySelected = ref('ASC');
onMounted(() => {
selectedCategoryFk.value = getParamWhere(route, 'categoryFk');
selectedTypeFk.value = getParamWhere(route, 'typeFk');
});
const resetCategory = (params, search) => { const resetCategory = (params, search) => {
selectedCategoryFk.value = null; selectedCategoryFk.value = null;
typeList.value = null; typeList.value = null;
params.categoryFk = null; params.categoryFk = null;
params.typeFk = null; params.typeFk = null;
arrayData.store.userFilter = null; arrayData.store.userFilter = null;
removeTagGroupParam(params, search); removeTagGroupParam(search);
}; };
const selectCategory = (params, category, search) => { const selectCategory = (params, category, search) => {
if (params.categoryFk === category?.id) { if (params.categoryFk === category?.id) {
resetCategory(params, search); resetCategory(params, search);
params.categoryFk = null; return;
} else {
selectedCategoryFk.value = category?.id;
params.categoryFk = category?.id;
params.typeFk = null;
selectedTypeFk.value = null;
loadTypes(category?.id);
} }
selectedCategoryFk.value = category?.id;
params.categoryFk = category?.id;
params.typeFk = null;
selectedTypeFk.value = null;
loadTypes(category?.id);
search(); search();
}; };
@ -115,13 +120,23 @@ const applyTags = (tagInfo, params, search) => {
search(); search();
}; };
const removeTagGroupParam = (params, search, valIndex = null) => { async function onSearchByTag(value) {
if (!valIndex) { if (!value.target.value) return;
params.tagGroups = null; if (!currentParams.value?.tagGroups) {
search(); currentParams.value.tagGroups = [];
}
currentParams.value.tagGroups.push({
values: [{ value: value.target.value }],
});
searchByTag.value = null;
}
const removeTagGroupParam = (search, valIndex) => {
if (!valIndex && valIndex !== 0) {
currentParams.value.tagGroups = null;
} else { } else {
params.tagGroups.splice(valIndex, 1); currentParams.value.tagGroups.splice(valIndex, 1);
search();
} }
}; };
@ -142,6 +157,12 @@ const getCategoryClass = (category, params) => {
} }
}; };
const clearFilter = (key) => {
if (key === 'categoryFk') {
resetCategory();
}
};
function addOrder(value, field, params) { function addOrder(value, field, params) {
let { orderBy } = params; let { orderBy } = params;
orderBy = JSON.parse(orderBy); orderBy = JSON.parse(orderBy);
@ -157,7 +178,7 @@ onMounted(() => {
</script> </script>
<template> <template>
<FetchData url="ItemCategories" limit="30" auto-load @on-fetch="setCategoryList" /> <FetchData url="ItemCategories" auto-load @on-fetch="setCategoryList" />
<VnFilterPanel <VnFilterPanel
ref="vnFilterPanelRef" ref="vnFilterPanelRef"
:data-key="props.dataKey" :data-key="props.dataKey"
@ -166,7 +187,8 @@ onMounted(() => {
:expr-builder="exprBuilder" :expr-builder="exprBuilder"
:custom-tags="['tagGroups', 'categoryFk']" :custom-tags="['tagGroups', 'categoryFk']"
:redirect="false" :redirect="false"
search-url="params" @remove="clearFilter"
v-model="currentParams"
> >
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<strong v-if="tag.label === 'typeFk'"> <strong v-if="tag.label === 'typeFk'">
@ -188,7 +210,7 @@ onMounted(() => {
@remove=" @remove="
customTag.label === 'categoryFk' customTag.label === 'categoryFk'
? resetCategory(params, searchFn) ? resetCategory(params, searchFn)
: removeTagGroupParam(params, searchFn, valIndex) : removeTagGroupParam(searchFn, valIndex)
" "
> >
<strong v-if="customTag.label === 'categoryFk'"> <strong v-if="customTag.label === 'categoryFk'">
@ -288,46 +310,39 @@ onMounted(() => {
</QItemSection> </QItemSection>
</QItem> </QItem>
<QSeparator /> <QSeparator />
<QItem class="q-mt-lg q-pa-none">
<QItem class="q-mt-lg"> <VnInput
<VnSelect
:label="t('components.itemsFilterPanel.value')" :label="t('components.itemsFilterPanel.value')"
:options="props.tagValue"
dense dense
outlined outlined
rounded rounded
:is-clearable="false" :is-clearable="false"
v-model="generalSearchParam" v-model="searchByTag"
@update:model-value=" @keyup.enter="(val) => onSearchByTag(val, params)"
applyTags(
{ values: [{ value: generalSearchParam }] },
params,
searchFn
)
"
> >
<template #prepend> <template #prepend>
<QIcon name="search" /> <QIcon name="search" />
</template> </template>
<template #after> <template #append>
<QBtn <QBtn
icon="add_circle" icon="add_circle"
shortcut="+" shortcut="+"
flat flat
color="primary" color="primary"
size="md" size="md"
dense
/> />
<QPopupProxy> <QPopupProxy>
<CatalogFilterValueDialog <CatalogFilterValueDialog
style="display: inline-block" style="display: inline-block"
:tags="tags" :tags="tags"
@apply-tags=" @apply-tags="
($event) => applyTags($event, params, searchFn) ($event) => applyTags($event, currentParams, searchFn)
" "
/> />
</QPopupProxy> </QPopupProxy>
</template> </template>
</VnSelect> </VnInput>
</QItem> </QItem>
<QSeparator /> <QSeparator />
</template> </template>

View File

@ -24,7 +24,6 @@ function notIsLocations(ifIsFalse, ifIsTrue) {
:descriptor="ZoneDescriptor" :descriptor="ZoneDescriptor"
:filter-panel="notIsLocations(ZoneFilterPanel, undefined)" :filter-panel="notIsLocations(ZoneFilterPanel, undefined)"
:search-data-key="notIsLocations('ZoneList', undefined)" :search-data-key="notIsLocations('ZoneList', undefined)"
:custom-url="`Zones/${route.params?.id}/getLeaves`"
:searchbar-props="{ :searchbar-props="{
url: notIsLocations('Zones', 'ZoneLocations'), url: notIsLocations('Zones', 'ZoneLocations'),
label: notIsLocations(t('list.searchZone'), t('list.searchLocation')), label: notIsLocations(t('list.searchZone'), t('list.searchLocation')),

View File

@ -39,8 +39,7 @@ const url = computed(() => `Zones/${route.params.id}/getLeaves`);
const arrayData = useArrayData(datakey, { const arrayData = useArrayData(datakey, {
url: url.value, url: url.value,
}); });
const { store } = arrayData; const store = arrayData.store;
const storeData = computed(() => store.data);
const defaultNode = { const defaultNode = {
id: null, id: null,
@ -66,8 +65,20 @@ const onNodeExpanded = async (nodeKeysArray) => {
if (!nodeKeysSet.has(null)) return; if (!nodeKeysSet.has(null)) return;
const wasExpanded = !previousExpandedNodes.value.has(lastNodeKey); const wasExpanded = !previousExpandedNodes.value.has(lastNodeKey);
if (wasExpanded) await fetchNodeLeaves(lastNodeKey); if (wasExpanded && treeRef.value) {
else { const node = treeRef.value?.getNodeByKey(lastNodeKey);
const params = { parentId: node.id };
const response = await axios.get(`Zones/${route.params.id}/getLeaves`, {
params,
});
if (response.data) {
node.childs = response.data.map((n) => {
if (n.sons > 0) n.childs = [{}];
return n;
});
}
await fetchNodeLeaves(lastNodeKey, true);
} else {
const difference = new Set( const difference = new Set(
[...previousExpandedNodes.value].filter((x) => !nodeKeysSet.has(x)) [...previousExpandedNodes.value].filter((x) => !nodeKeysSet.has(x))
); );
@ -83,41 +94,21 @@ const formatNodeSelected = (node) => {
if (node.selected === 1) node.selected = true; if (node.selected === 1) node.selected = true;
else if (node.selected === 0) node.selected = false; else if (node.selected === 0) node.selected = false;
if (node.childs && node.childs.length > 0) {
expanded.value.push(node.id);
node.childs.forEach((childNode) => {
formatNodeSelected(childNode);
});
}
if (node.sons > 0 && !node.childs) node.childs = [{}]; if (node.sons > 0 && !node.childs) node.childs = [{}];
}; };
const fetchNodeLeaves = async (nodeKey) => { const fetchNodeLeaves = async (nodeKey) => {
try { if (!treeRef.value) return;
const node = treeRef.value?.getNodeByKey(nodeKey); const node = treeRef.value?.getNodeByKey(nodeKey);
if (!node || node.sons === 0) return; if (node.selected === 1) node.selected = true;
else if (node.selected === 0) node.selected = false;
if (!node || node.sons === 0) return;
const params = { parentId: node.id }; state.set('Tree', node);
const response = await axios.get(`Zones/${route.params.id}/getLeaves`, {
params,
});
if (response.data) {
node.childs = response.data.map((n) => {
formatNodeSelected(n);
return n;
});
}
state.set('Tree', node);
} catch (err) {
console.error('Error fetching department leaves', err);
throw new Error();
}
}; };
function getNodeIds(node) { function getNodeIds(node) {
if (!node) return [];
let ids = []; let ids = [];
if (node.id) ids.push(node.id); if (node.id) ids.push(node.id);
@ -128,60 +119,46 @@ function getNodeIds(node) {
return ids; return ids;
} }
watch(storeData, async (val) => { watch(
// Se triggerea cuando se actualiza el store.data, el cual es el resultado del fetch de la searchbar () => store.data,
if (!nodes.value[0]) nodes.value = [defaultNode]; async (val) => {
nodes.value[0].childs = [...val]; if (!val) return;
const fetchedNodeKeys = val.flatMap(getNodeIds); // // Se triggerea cuando se actualiza el store.data, el cual es el resultado del fetch de la searchbar
state.set('Tree', [...fetchedNodeKeys]); if (!nodes.value[0]) nodes.value = [defaultNode];
nodes.value[0].childs = [...val];
const fetchedNodeKeys = val.flatMap(getNodeIds);
state.set('Tree', [...fetchedNodeKeys]);
if (store.userParams?.search === '') { if (!store.userParams?.search) {
val.forEach((n) => { val.forEach((n) => {
formatNodeSelected(n); formatNodeSelected(n);
}); });
} else { store.data = null;
for (let n of state.get('Tree')) await fetchNodeLeaves(n); expanded.value = [null];
expanded.value = [null, ...fetchedNodeKeys]; } else {
} for (let n of state.get('Tree')) {
previousExpandedNodes.value = new Set(expanded.value); await fetchNodeLeaves(n);
}); }
expanded.value = [null, ...fetchedNodeKeys];
}
previousExpandedNodes.value = new Set(expanded.value);
},
{ immediate: true }
);
const reFetch = async () => { const reFetch = async () => {
const { data } = await arrayData.fetch({ append: false }); const { data } = await arrayData.fetch({ append: false });
nodes.value = data; nodes.value = data;
expanded.value = [null];
}; };
onMounted(async () => { onMounted(async () => {
if (store.userParams?.search && !props.showSearchBar) { if (store.userParams?.search) await arrayData.fetch({});
await reFetch();
return;
}
const stateTree = state.get('Tree');
const tree = stateTree ? [...state.get('Tree')] : [null];
const lastStateTree = state.get('TreeState');
if (tree) {
for (let n of tree) {
await fetchNodeLeaves(n);
}
if (lastStateTree) {
tree.push(lastStateTree);
await fetchNodeLeaves(lastStateTree);
}
}
setTimeout(() => {
if (lastStateTree) {
document.getElementById(lastStateTree).scrollIntoView();
}
}, 1000);
expanded.value.unshift(null);
previousExpandedNodes.value = new Set(expanded.value);
}); });
onUnmounted(() => { onUnmounted(() => {
state.set('Tree', undefined); state.set('Tree', undefined);
arrayData.destroy();
}); });
</script> </script>

View File

@ -6,7 +6,11 @@ describe('Client list', () => {
cy.visit('/#/customer/list', { cy.visit('/#/customer/list', {
timeout: 5000, timeout: 5000,
onBeforeLoad(win) { onBeforeLoad(win) {
cy.stub(win, 'open'); cy.stub(win, 'open')
.callsFake((url) => {
return win.open.wrappedMethod.call(win, url, '_self');
})
.as('Open');
}, },
}); });
}); });
@ -20,9 +24,9 @@ describe('Client list', () => {
'Web user': { val: 'user_test_1' }, 'Web user': { val: 'user_test_1' },
Street: { val: 'C/ STREET 1' }, Street: { val: 'C/ STREET 1' },
Email: { val: 'user.test@1.com' }, Email: { val: 'user.test@1.com' },
'Business type': { val: 'Otros', type: 'select' }, 'Sales person': { val: 'employee', type: 'select' },
'Sales person': { val: 'salesboss', type: 'select' },
Location: { val: '46000, Valencia(Province one), España', type: 'select' }, Location: { val: '46000, Valencia(Province one), España', type: 'select' },
'Business type': { val: 'Otros', type: 'select' },
}; };
cy.fillInForm(data); cy.fillInForm(data);
@ -47,17 +51,19 @@ describe('Client list', () => {
it('Client founded create ticket', () => { it('Client founded create ticket', () => {
const search = 'Jessica Jones'; const search = 'Jessica Jones';
cy.searchByLabel('Name', search); cy.searchByLabel('Name', search);
cy.clickButtonsDescriptor(2); cy.openActionDescriptor('Create ticket');
cy.waitForElement('#formModel'); cy.waitForElement('#formModel');
cy.waitForElement('.q-form'); cy.waitForElement('.q-form');
cy.checkValueForm(1, search); cy.checkValueSelectForm(1, search);
cy.checkValueSelectForm(2, search);
}); });
it('Client founded create order', () => { it('Client founded create order', () => {
const search = 'Jessica Jones'; const search = 'Jessica Jones';
cy.searchByLabel('Name', search); cy.searchByLabel('Name', search);
cy.clickButtonsDescriptor(4); cy.openActionDescriptor('New order');
cy.waitForElement('#formModel'); cy.waitForElement('#formModel');
cy.waitForElement('.q-form'); cy.waitForElement('.q-form');
cy.checkValueForm(1, search);
cy.checkValueForm(2, search); cy.checkValueForm(2, search);
}); });
}); });

View File

@ -7,6 +7,9 @@ describe('VnLocation', () => {
prefix: '.q-dialog__inner > .column > #formModel > .q-card', prefix: '.q-dialog__inner > .column > #formModel > .q-card',
sufix: ' .q-field__inner > .q-field__control', sufix: ' .q-field__inner > .q-field__control',
}; };
const countrySelector = `${createForm.prefix} > :nth-child(5) > :nth-child(3) > ${createForm.sufix}`;
const provinceSelector = `${createForm.prefix} > :nth-child(5) > :nth-child(2) > ${createForm.sufix}`;
const citySelector = `${createForm.prefix} > :nth-child(4) > :nth-child(2) > ${createForm.sufix}`;
describe('CreateFormDialog ', () => { describe('CreateFormDialog ', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1280, 720); cy.viewport(1280, 720);
@ -16,46 +19,23 @@ describe('VnLocation', () => {
cy.get(createLocationButton).click(); cy.get(createLocationButton).click();
}); });
it('should filter provinces based on selected country', () => { it('should filter provinces based on selected country', () => {
// Select a country const country = 'Ecuador';
cy.selectOption( cy.selectOption(countrySelector, country);
`${createForm.prefix} > :nth-child(5) > .q-field:nth-child(5)> ${createForm.sufix}`, cy.get(countrySelector).should('have.length', 1);
'Ecuador' cy.get(citySelector).should('have.length', 1);
);
// Verify that provinces are filtered
cy.get(
`${createForm.prefix} > :nth-child(5) > .q-field:nth-child(3)> ${createForm.sufix}`
).should('have.length', 1);
// Verify that towns are filtered
cy.get(
`${createForm.prefix} > :nth-child(4) > .q-field:nth-child(3)> ${createForm.sufix}`
).should('have.length', 1);
}); });
it('should filter towns based on selected province', () => { it('should filter towns based on selected province', () => {
// Select a country const country = 'Ecuador';
cy.selectOption( cy.selectOption(countrySelector, country);
`${createForm.prefix} > :nth-child(5) > .q-field:nth-child(3)> ${createForm.sufix}`, cy.get(provinceSelector).should('have.length', 1);
'Ecuador' cy.get(citySelector).should('have.length', 1);
);
// Verify that provinces are filtered
cy.get(
`${createForm.prefix} > :nth-child(5) > .q-field:nth-child(3)> ${createForm.sufix}`
).should('have.length', 1);
// Verify that towns are filtered
cy.get(
`${createForm.prefix} > :nth-child(4) > .q-field:nth-child(3)> ${createForm.sufix}`
).should('have.length', 1);
}); });
it('should pass selected country', () => { it('should pass selected country', () => {
// Select a country
const country = 'Ecuador'; const country = 'Ecuador';
const province = 'Province five'; const province = 'Province five';
cy.selectOption(
`${createForm.prefix} > :nth-child(5) > .q-field:nth-child(5)> ${createForm.sufix}`, cy.selectOption(countrySelector, country);
country
);
cy.selectOption( cy.selectOption(
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix}`, `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix}`,
province province
@ -80,13 +60,11 @@ describe('VnLocation', () => {
cy.get(locationOptions).should('have.length.at.least', 5); cy.get(locationOptions).should('have.length.at.least', 5);
}); });
it('input filter location as "al"', function () { it('input filter location as "al"', function () {
// cy.get(inputLocation).click();
cy.get(inputLocation).clear(); cy.get(inputLocation).clear();
cy.get(inputLocation).type('al'); cy.get(inputLocation).type('al');
cy.get(locationOptions).should('have.length.at.least', 4); cy.get(locationOptions).should('have.length.at.least', 4);
}); });
it('input filter location as "ecuador"', function () { it('input filter location as "ecuador"', function () {
// cy.get(inputLocation).click();
cy.get(inputLocation).clear(); cy.get(inputLocation).clear();
cy.get(inputLocation).type('ecuador'); cy.get(inputLocation).type('ecuador');
cy.get(locationOptions).should('have.length.at.least', 1); cy.get(locationOptions).should('have.length.at.least', 1);
@ -142,7 +120,6 @@ describe('VnLocation', () => {
const province = 'Saskatchew'; const province = 'Saskatchew';
cy.get(createLocationButton).click(); cy.get(createLocationButton).click();
cy.get(dialogInputs).eq(0).type(postCode); cy.get(dialogInputs).eq(0).type(postCode);
// city create button
cy.get( cy.get(
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) > .q-icon` `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) > .q-icon`
).click(); ).click();
@ -151,7 +128,6 @@ describe('VnLocation', () => {
cy.get('#q-portal--dialog--3 .q-btn--standard').click(); cy.get('#q-portal--dialog--3 .q-btn--standard').click();
cy.get('#q-portal--dialog--1 .q-btn--standard').click(); cy.get('#q-portal--dialog--1 .q-btn--standard').click();
cy.waitForElement('.q-form'); cy.waitForElement('.q-form');
checkVnLocation(postCode, province); checkVnLocation(postCode, province);
}); });

View File

@ -297,13 +297,13 @@ Cypress.Commands.add('checkNotification', (text) => {
Cypress.Commands.add('checkValueForm', (id, search) => { Cypress.Commands.add('checkValueForm', (id, search) => {
cy.get( cy.get(
`.grid-create > :nth-child(${id}) > .q-field__inner>.q-field__control> .q-field__control-container>.q-field__native >.q-field__input` `.grid-create > :nth-child(${id}) > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > .q-field__input`
).should('have.value', search); ).should('have.value', search);
}); });
Cypress.Commands.add('checkValueSelectForm', (id, search) => { Cypress.Commands.add('checkValueSelectForm', (id, search) => {
cy.get( cy.get(
`.grid-create > :nth-child(${id}) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container>.q-field__native>.q-field__input` `.grid-create > :nth-child(${id}) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > .q-field__input`
).should('have.value', search); ).should('have.value', search);
}); });