0
0
Fork 0

Compare commits

...

13 Commits

Author SHA1 Message Date
William Buezas 868c80a187 test: tests order catalog 2024-11-19 09:56:18 -03:00
Jon Elias 3c5472ad4a Merge pull request 'Fix: changed route.query' (!959) from Fix-OrderCatalogCategoryFilter into dev
Reviewed-on: verdnatura/salix-front#959
Reviewed-by: Javier Segarra <jsegarra@verdnatura.es>
2024-11-18 11:28:25 +00:00
Jon Elias 0c0b9ca648 fix: changed route.query 2024-11-18 12:27:07 +01:00
Alex Moreno dd490888cf merge test in dev 2024-11-18 11:23:36 +01:00
Alex Moreno 09be2d4d41 Merge pull request 'solveConflicts_test_to_dev' (!957) from solveConflicts_test_to_dev into dev
Reviewed-on: verdnatura/salix-front#957
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
2024-11-18 10:21:50 +00:00
Alex Moreno 1e7f2b3f4d Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix-front into test 2024-11-18 11:14:29 +01:00
Alex Moreno 009a6b09d6 Merge pull request 'feat(TicketSummary): add ticketDescritporMenu' (!956) from hotFix_ticketSummary_add_ticketDescriptorMenu into master
Reviewed-on: verdnatura/salix-front#956
Reviewed-by: Carlos Satorres <carlossa@verdnatura.es>
2024-11-18 10:11:42 +00:00
Alex Moreno 5b4299114b Merge branch 'master' into hotFix_ticketSummary_add_ticketDescriptorMenu 2024-11-18 10:00:54 +00:00
Javier Segarra 5ab28c13d0 Merge pull request 'HOTFIX: CustomerSummary BalanceDue' (!955) from hotFix_customerSumamry_balanceDue into master
Reviewed-on: verdnatura/salix-front#955
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
2024-11-18 10:00:08 +00:00
Javier Segarra f52095a2fc Merge branch 'test' into solveConflicts_test_to_dev 2024-11-18 10:57:49 +01:00
Alex Moreno 383f51c1b2 refactor(TicketDescritporMenu): url isEditable 2024-11-18 10:57:26 +01:00
Alex Moreno 09aad5914f feat(TicketSummary): add ticketDescritporMenu 2024-11-18 10:49:30 +01:00
Javier Segarra 9ea9239250 fix: customerSummary balanceDue label value 2024-11-18 10:41:25 +01:00
14 changed files with 285 additions and 148 deletions

View File

@ -83,7 +83,7 @@ async function fetch() {
<slot name="header" :entity="entity" dense>
<VnLv :label="`${entity.id} -`" :value="entity.name" />
</slot>
<slot name="header-right">
<slot name="header-right" :entity="entity">
<span></span>
</slot>
</div>

View File

@ -273,6 +273,7 @@ defineExpose({ search, sanitizer, userParams });
:key="chip.label"
:removable="!unremovableParams?.includes(chip.label)"
@remove="remove(chip.label)"
data-cy="vnFilterPanelChip"
>
<slot name="tags" :tag="chip" :format-fn="formatValue">
<div class="q-gutter-x-xs">

View File

@ -9,7 +9,7 @@ function parseJSON(str, fallback) {
}
export default function (route, param) {
// catch route query params
const params = parseJSON(route?.query?.params, {});
const params = parseJSON(route?.query?.table, {});
// extract and parse filter from params
const { filter: filterStr = '{}' } = params;

View File

@ -23,7 +23,7 @@ defineExpose({ states });
<template>
<FetchData url="ClaimStates" @on-fetch="(data) => (states = data)" auto-load />
<VnFilterPanel :data-key="props.dataKey" :search-button="true" search-url="table">
<VnFilterPanel :data-key="props.dataKey" :search-button="true">
<template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong>

View File

@ -4,7 +4,7 @@ import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import VnUserLink from 'src/components/ui/VnUserLink.vue';
import { toCurrency, toPercentage, toDate } from 'src/filters';
import { toCurrency, toPercentage, toDate, dashOrCurrency } from 'src/filters';
import CardSummary from 'components/ui/CardSummary.vue';
import { getUrl } from 'src/composables/getUrl';
import VnLv from 'src/components/ui/VnLv.vue';
@ -27,21 +27,16 @@ const $props = defineProps({
const entityId = computed(() => $props.id || route.params.id);
const customer = computed(() => summary.value.entity);
const summary = ref();
const clientUrl = ref();
onMounted(async () => {
clientUrl.value = (await getUrl('client/')) + entityId.value + '/';
});
const defaulterAmount = computed(() => customer.value.defaulters[0]?.amount);
const balanceDue = computed(() => {
return (
customer.value &&
customer.value.defaulters.length &&
customer.value.defaulters[0].amount
);
const amount = defaulterAmount.value;
if (!amount || amount < 0) {
return null;
}
return amount;
});
const balanceDueWarning = computed(() => (balanceDue.value ? 'negative' : ''));
const balanceDueWarning = computed(() => (defaulterAmount.value ? 'negative' : ''));
const claimRate = computed(() => {
return customer.value.claimsRatio?.claimingRate ?? 0;
@ -305,7 +300,7 @@ const sumRisk = ({ clientRisks }) => {
<VnLv
v-if="entity.defaulters"
:label="t('customer.summary.balanceDue')"
:value="toCurrency(balanceDue)"
:value="dashOrCurrency(balanceDue)()"
:class="balanceDueWarning"
:info="t('customer.summary.balanceDueInfo')"
/>

View File

@ -85,6 +85,7 @@ const getSelectedTagValues = async (tag) => {
:emit-value="false"
use-input
@update:model-value="($event) => getSelectedTagValues($event)"
data-cy="catalogFilterValueDialogTagSelect"
/>
<QBtn
icon="add_circle"
@ -126,6 +127,7 @@ const getSelectedTagValues = async (tag) => {
is-outlined
:is-clearable="false"
class="col"
data-cy="catalogFilterValueDialogValueInput"
/>
<QBtn
icon="delete"

View File

@ -120,7 +120,7 @@ watch(
/>
</QScrollArea>
</QDrawer>
<QPage class="column items-center q-pa-md">
<QPage class="column items-center q-pa-md" data-cy="orderCatalogPage">
<div class="full-width">
<VnPaginate
data-key="OrderCatalogList"
@ -130,6 +130,7 @@ watch(
@on-fetch="showFilter = true"
:update-router="false"
:auto-load="autoLoad"
data-cy="orderCatalogPage"
>
<template #body="{ rows }">
<div class="catalog-list">
@ -142,6 +143,7 @@ watch(
:item="row"
is-catalog
class="fill-icon"
data-cy="orderCatalogItem"
/>
</div>
</template>

View File

@ -189,6 +189,7 @@ onMounted(() => {
? resetCategory(params, searchFn)
: removeTagGroupParam(params, searchFn, valIndex)
"
data-cy="catalogFilterCustomTag"
>
<strong v-if="customTag.label === 'categoryFk'">
{{ t(selectedCategory?.name || '') }}
@ -217,6 +218,7 @@ onMounted(() => {
:name="category.icon"
class="category-icon"
@click="selectCategory(params, category, searchFn)"
data-cy="catalogFilterCategory"
>
<QTooltip>
{{ t(category.name) }}
@ -245,6 +247,7 @@ onMounted(() => {
searchFn();
}
"
data-cy="catalogFilterType"
>
<template #option="{ itemProps, opt }">
<QItem v-bind="itemProps">
@ -304,6 +307,7 @@ onMounted(() => {
searchFn
)
"
data-cy="catalogFilterValueSelect"
>
<template #prepend>
<QIcon name="search" />
@ -315,6 +319,7 @@ onMounted(() => {
flat
color="primary"
size="md"
data-cy="catalogFilterValueDialogBtn"
/>
<QPopupProxy>
<CatalogFilterValueDialog

View File

@ -16,12 +16,9 @@ import { useAcl } from 'src/composables/useAcl';
import { useValidator } from 'src/composables/useValidator';
import { toTimeFormat } from 'filters/date.js';
const $props = defineProps({
formData: {
type: Object,
required: true,
default: () => ({}),
},
const formData = defineModel({
type: Object,
required: true,
});
const emit = defineEmits(['updateForm']);
@ -40,7 +37,6 @@ const agenciesOptions = ref([]);
const zonesOptions = ref([]);
const addresses = ref([]);
const zoneSelectRef = ref();
const formData = ref($props.formData);
watch(
() => formData.value,
@ -69,47 +65,28 @@ const zoneWhere = computed(() => {
: {};
});
const getLanded = async (params) => {
try {
const validParams =
shipped.value && addressId.value && agencyModeId.value && warehouseId.value;
if (!validParams) return;
async function getLanded(params) {
getDate(`Agencies/getLanded`, params);
}
formData.value.zoneFk = null;
zonesOptions.value = [];
const { data } = await axios.get(`Agencies/getLanded`, { params });
if (data) {
formData.value.zoneFk = data.zoneFk;
formData.value.landed = data.landed;
formData.value.shipped = params.shipped;
}
} catch (error) {
console.error(error);
notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
async function getShipped(params) {
getDate(`Agencies/getShipped`, params);
}
async function getDate(query, params) {
for (const param in params) {
if (!params[param]) return;
}
};
const getShipped = async (params) => {
try {
const validParams =
landed.value && addressId.value && agencyModeId.value && warehouseId.value;
if (!validParams) return;
formData.value.zoneFk = null;
zonesOptions.value = [];
const { data } = await axios.get(query, { params });
if (!data) return notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
formData.value.zoneFk = null;
zonesOptions.value = [];
const { data } = await axios.get(`Agencies/getShipped`, { params });
if (data) {
formData.value.zoneFk = data.zoneFk;
formData.value.landed = params.landed;
formData.value.shipped = data.shipped;
} else {
notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
}
} catch (error) {
console.error(error);
notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
}
};
formData.value.zoneFk = data.zoneFk;
if (data.landed) formData.value.landed = data.landed;
if (data.shipped) formData.value.shipped = data.shipped;
}
const onChangeZone = async (zoneId) => {
formData.value.agencyModeFk = null;
@ -177,18 +154,26 @@ const clientId = computed({
},
});
const landed = computed({
get: () => formData.value?.landed,
set: (val) => {
formData.value.landed = val;
getShipped({
landed: val,
function addDateParams(obj) {
return {
...obj,
...{
addressFk: formData.value?.addressFk,
agencyModeFk: formData.value?.agencyModeFk,
warehouseFk: formData.value?.warehouseFk,
});
},
});
},
};
}
async function setLanded(landed) {
if (!landed) return;
getShipped(addDateParams({ landed }));
}
async function setShipped(shipped) {
if (!shipped) return;
getLanded(addDateParams({ shipped }));
}
const agencyModeId = computed({
get: () => formData.value.agencyModeFk,
@ -236,21 +221,6 @@ const warehouseId = computed({
},
});
const shipped = computed({
get: () => formData.value?.shipped,
set: (val) => {
if (new Date(formData.value?.shipped).toDateString() != val.toDateString())
val.setHours(0, 0, 0, 0);
formData.value.shipped = val;
getLanded({
shipped: val,
addressFk: formData.value?.addressFk,
agencyModeFk: formData.value?.agencyModeFk,
warehouseFk: formData.value?.warehouseFk,
});
},
});
const onFormModelInit = () => {
if (formData.value?.clientFk) clientAddressesList(formData.value?.clientFk);
};
@ -451,18 +421,21 @@ async function getZone(options) {
v-model="formData.shipped"
:required="true"
:rules="validate('ticketList.shipped')"
@update:model-value="setShipped"
/>
<VnInputTime
:label="t('basicData.shippedHour')"
v-model="formData.shipped"
:required="true"
:rules="validate('basicData.shippedHour')"
@update:model-value="setShipped"
/>
<VnInputDate
:label="t('basicData.landed')"
v-model="formData.landed"
:required="true"
:rules="validate('basicData.landed')"
@update:model-value="setLanded"
/>
</VnRow>
</QForm>

View File

@ -1,9 +1,9 @@
<script setup>
import axios from 'axios';
import { ref, toRefs } from 'vue';
import { computed, ref, toRefs } from 'vue';
import { useQuasar } from 'quasar';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import { useRouter } from 'vue-router';
import { usePrintService } from 'composables/usePrintService';
import SendEmailDialog from 'components/common/SendEmailDialog.vue';
import VnConfirm from 'components/ui/VnConfirm.vue';
@ -23,7 +23,6 @@ const props = defineProps({
required: true,
},
});
const route = useRoute();
const { push, currentRoute } = useRouter();
const { dialog, notify } = useQuasar();
@ -31,7 +30,7 @@ const { t } = useI18n();
const { openReport, sendEmail } = usePrintService();
const ticketSummary = useArrayData('TicketSummary');
const { ticket } = toRefs(props);
const ticketId = currentRoute.value.params.id;
const ticketId = computed(() => props.ticket.id ?? currentRoute.value.params.id);
const client = ref();
const showTransferDialog = ref(false);
const showTurnDialog = ref(false);
@ -68,7 +67,7 @@ const actions = {
setWeight: async () => {
try {
const invoiceIds = (
await axios.post(`Tickets/${ticketId}/setWeight`, {
await axios.post(`Tickets/${ticketId.value}/setWeight`, {
weight: weight.value,
})
).data;
@ -86,7 +85,7 @@ const actions = {
},
remove: async () => {
try {
await axios.post(`Tickets/${ticketId}/setDeleted`);
await axios.post(`Tickets/${ticketId.value}/setDeleted`);
notify({ message: t('Ticket deleted'), type: 'positive' });
notify({
@ -176,14 +175,14 @@ function showSmsDialog(template, customData) {
}
async function showSmsDialogWithChanges() {
const query = `TicketLogs/${ticketId}/getChanges`;
const query = `TicketLogs/${ticketId.value}/getChanges`;
const response = await axios.get(query);
showSmsDialog('orderChanges', { changes: response.data });
}
async function sendSms(body) {
await axios.post(`Tickets/${ticketId}/sendSms`, body);
await axios.post(`Tickets/${ticketId.value}/sendSms`, body);
notify({
message: 'Notification sent',
type: 'positive',
@ -256,7 +255,10 @@ async function transferClient(client) {
clientFk: client,
};
const { data } = await axios.patch(`Tickets/${ticketId}/transferClient`, params);
const { data } = await axios.patch(
`Tickets/${ticketId.value}/transferClient`,
params
);
if (data) window.location.reload();
}
@ -296,7 +298,10 @@ async function changeShippedHour(time) {
shipped: time,
};
const { data } = await axios.post(`Tickets/${ticketId}/updateEditableTicket`, params);
const { data } = await axios.post(
`Tickets/${ticketId.value}/updateEditableTicket`,
params
);
if (data) window.location.reload();
}
@ -313,7 +318,7 @@ function openRecalculateDialog() {
}
async function recalculateComponents() {
await axios.post(`Tickets/${ticketId}/recalculateComponents`);
await axios.post(`Tickets/${ticketId.value}/recalculateComponents`);
notify({
message: t('Data saved'),
type: 'positive',
@ -336,11 +341,11 @@ async function handleInvoiceOutData() {
}
async function docuwareDownload() {
await axios.get(`Tickets/${ticketId}/docuwareDownload`);
await axios.get(`Tickets/${ticketId.value}/docuwareDownload`);
}
async function hasDocuware() {
const { data } = await axios.post(`Docuwares/${ticketId}/checkFile`, {
const { data } = await axios.post(`Docuwares/${ticketId.value}/checkFile`, {
fileCabinet: 'deliveryNote',
signed: true,
});
@ -371,11 +376,7 @@ async function uploadDocuware(force) {
</script>
<template>
<FetchData
:url="
route.path.startsWith('/ticket')
? `Tickets/${ticketId}/isEditable`
: `Tickets/${ticket}/isEditable`
"
:url="`Tickets/${ticketId}/isEditable`"
auto-load
@on-fetch="handleFetchData"
/>
@ -396,8 +397,6 @@ async function uploadDocuware(force) {
<VnSelect
url="Clients"
:fields="['id', 'name']"
option-label="name"
option-value="id"
v-model="client"
:label="t('Client')"
auto-load

View File

@ -20,6 +20,7 @@ import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnToSummary from 'src/components/ui/VnToSummary.vue';
import TicketDescriptorMenu from './TicketDescriptorMenu.vue';
const route = useRoute();
const { notify } = useNotify();
@ -116,24 +117,36 @@ function toTicketUrl(section) {
{{ entity.nickname }}
</div>
</template>
<template #header-right>
<QBtnDropdown
ref="stateBtnDropdownRef"
color="black"
text-color="white"
:label="t('globals.changeState')"
:disable="!isEditable()"
>
<VnSelect
:options="editableStates"
hide-selected
option-label="name"
option-value="code"
hide-dropdown-icon
focus-on-mount
@update:model-value="changeState"
/>
</QBtnDropdown>
<template #header-right="{ entity }">
<div>
<QBtnDropdown
ref="stateBtnDropdownRef"
color="black"
text-color="white"
:label="t('globals.changeState')"
:disable="!isEditable()"
>
<VnSelect
:options="editableStates"
hide-selected
option-label="name"
option-value="code"
hide-dropdown-icon
focus-on-mount
@update:model-value="changeState"
/>
</QBtnDropdown>
<QBtn color="white" dense flat icon="more_vert" round size="md">
<QTooltip>
{{ t('components.cardDescriptor.moreOptions') }}
</QTooltip>
<QMenu>
<QList>
<TicketDescriptorMenu :ticket="entity" />
</QList>
</QMenu>
</QBtn>
</div>
</template>
<template #body="{ entity }">
<QCard class="vn-one">

View File

@ -1,7 +1,7 @@
<script setup>
import axios from 'axios';
import { computed, ref, onMounted } from 'vue';
import { useRoute } from 'vue-router';
import { useRoute, useRouter } from 'vue-router';
import { useStateStore } from 'stores/useStateStore';
import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
@ -18,12 +18,13 @@ import RightMenu from 'src/components/common/RightMenu.vue';
import TicketFilter from './TicketFilter.vue';
import VnInput from 'src/components/common/VnInput.vue';
import FetchData from 'src/components/FetchData.vue';
import CustomerDescriptorProxy from '../Customer/Card/CustomerDescriptorProxy.vue';
import ZoneDescriptorProxy from '../Zone/Card/ZoneDescriptorProxy.vue';
import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorProxy.vue';
import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue';
import { toTimeFormat } from 'src/filters/date';
import InvoiceOutDescriptorProxy from '../InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
import InvoiceOutDescriptorProxy from 'src/pages/InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
const route = useRoute();
const router = useRouter();
const { t } = useI18n();
const { viewSummary } = useSummaryDialog();
const tableRef = ref();
@ -40,23 +41,18 @@ from.setDate(from.getDate() - 7);
const to = Date.vnNew();
to.setHours(23, 59, 0, 0);
to.setDate(to.getDate() + 1);
const userParams = {
from: null,
to: null,
};
onMounted(() => {
initializeFromQuery();
stateStore.rightDrawer = true;
if (!route.query.createForm) return;
onClientSelected(JSON.parse(route.query.createForm));
});
// Método para inicializar las variables desde la query string
const initializeFromQuery = () => {
const query = route.query.table ? JSON.parse(route.query.table) : {};
// Asigna los valores a las variables correspondientes
from.value = query.from || from.toISOString();
to.value = query.to || to.toISOString();
Object.assign(userParams, { from, to });
@ -213,13 +209,19 @@ const columns = computed(() => [
{
title: t('components.smartCard.viewSummary'),
icon: 'preview',
isPrimary: true,
action: (row) => viewSummary(row.id, TicketSummary),
action: (row, evt) => {
if (evt && evt.ctrlKey) {
const url = router.resolve({
params: { id: row.id },
name: 'TicketCard',
}).href;
window.open(url, '_blank');
} else viewSummary(row.id, TicketSummary);
},
},
],
},
]);
function redirectToLines(id) {
const url = `#/ticket/${id}/sale`;
window.open(url, '_blank');
@ -456,24 +458,24 @@ function setReference(data) {
auto-load
/>
<VnSearchbar
data-key="Ticket"
data-key="TicketList"
:label="t('Search ticket')"
:info="t('You can search by ticket id or alias')"
/>
<RightMenu>
<template #right-panel>
<TicketFilter data-key="Ticket" />
<TicketFilter data-key="TicketList" />
</template>
</RightMenu>
<VnTable
ref="tableRef"
data-key="Ticket"
data-key="TicketList"
url="Tickets/filter"
:create="{
urlCreate: 'Tickets/new',
title: t('ticketList.createTicket'),
onDataSaved: ({ id }) => tableRef.redirect(id),
formInitialData: {},
formInitialData: { clientId: null },
}"
default-mode="table"
:order="['shippedDate DESC', 'shippedHour ASC', 'zoneLanding ASC', 'id']"
@ -575,17 +577,17 @@ function setReference(data) {
</span>
</template>
<template #column-stateFk="{ row }">
<span v-if="getColor(row)">
<QChip :class="getColor(row)" dense square>
{{ row.state }}
</QChip>
</span>
<span v-else-if="row.state === 'Entregado'">
<span v-if="row.refFk">
<span class="link" @click.stop>
{{ row.refFk }}
<InvoiceOutDescriptorProxy :id="row.invoiceOutId" />
</span>
</span>
<span v-else-if="getColor(row)">
<QChip :class="getColor(row)" dense square>
{{ row.state }}
</QChip>
</span>
<span v-else>
{{ row.state }}
</span>
@ -617,6 +619,7 @@ function setReference(data) {
option-value="id"
option-label="name"
hide-selected
required
@update:model-value="(client) => onClientSelected(data)"
:sort-by="'id ASC'"
>
@ -643,6 +646,7 @@ function setReference(data) {
option-label="nickname"
hide-selected
map-options
required
:disable="!data.clientId"
:sort-by="'isActive DESC'"
@update:model-value="() => fetchAvailableAgencies(data)"
@ -693,6 +697,7 @@ function setReference(data) {
option-value="id"
option-label="name"
hide-selected
required
@update:model-value="() => fetchAvailableAgencies(data)"
/>
</div>
@ -706,7 +711,6 @@ function setReference(data) {
option-value="agencyModeFk"
option-label="agencyMode"
hide-selected
:disable="!data.clientId || !data.landed || !data.warehouseId"
/>
</div>
</VnRow>
@ -842,7 +846,14 @@ function setReference(data) {
</QTooltip>
</QPageSticky>
</template>
<style scoped>
.disabled,
.disabled *,
[disabled],
[disabled] * {
cursor: pointer !important;
}
</style>
<i18n>
es:
Search ticket: Buscar ticket

View File

@ -0,0 +1,132 @@
/// <reference types="cypress" />
describe('OrderCatalog', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 720);
cy.visit('/#/order/8/catalog');
});
const checkCustomFilterTag = (filterName = 'Plant') => {
cy.dataCy('catalogFilterCustomTag').should('exist');
cy.dataCy('catalogFilterCustomTag').contains(filterName);
};
const checkFilterTag = (filterName = 'Plant') => {
cy.dataCy('vnFilterPanelChip').should('exist');
cy.dataCy('vnFilterPanelChip').contains(filterName);
};
const selectCategory = (categoryIndex = 1, categoryName = 'Plant') => {
cy.get(
`div.q-page-container div:nth-of-type(${categoryIndex}) > [data-cy='catalogFilterCategory']`
).should('exist');
cy.get(
`div.q-page-container div:nth-of-type(${categoryIndex}) > [data-cy='catalogFilterCategory']`
).click();
checkCustomFilterTag(categoryName);
};
const selectOptionFromValueFilter = (option) => {
cy.selectOption(
"div.q-page-container [data-cy='catalogFilterValueSelect']",
option
);
checkCustomFilterTag(option);
};
const selectTypeFilter = (option) => {
cy.selectOption("div.q-page-container [data-cy='catalogFilterType']", option);
checkFilterTag(option);
};
it('Shows empty state', () => {
cy.dataCy('orderCatalogPage').should('exist');
cy.dataCy('orderCatalogPage').contains('No data to display');
});
it('filter by category', () => {
selectCategory();
cy.dataCy('orderCatalogItem').should('exist');
});
it('filters by type', () => {
selectCategory();
selectTypeFilter('Anthurium');
});
it('filters by custom value select', () => {
selectCategory();
selectOptionFromValueFilter('Silver');
});
it('filters by custom value dialog', () => {
Cypress.on('uncaught:exception', (err) => {
if (err.message.includes('canceled')) {
return false;
}
});
selectCategory();
cy.dataCy('catalogFilterValueDialogBtn').should('exist');
cy.dataCy('catalogFilterValueDialogBtn').last().click();
cy.dataCy('catalogFilterValueDialogTagSelect').should('exist');
cy.selectOption("[data-cy='catalogFilterValueDialogTagSelect']", 'Tallos');
cy.dataCy('catalogFilterValueDialogValueInput').find('input').focus();
cy.dataCy('catalogFilterValueDialogValueInput').find('input').type('2');
cy.dataCy('catalogFilterValueDialogValueInput').find('input').type('{enter}');
checkCustomFilterTag('2');
});
it('removes a secondary tag', () => {
selectCategory();
selectTypeFilter('Anthurium');
cy.dataCy('vnFilterPanelChip').should('exist');
cy.get(
"div.q-page-container [data-cy='vnFilterPanelChip'] > i.q-chip__icon--remove"
)
.contains('cancel')
.should('exist');
cy.get(
"div.q-page-container [data-cy='vnFilterPanelChip'] > i.q-chip__icon--remove"
)
.contains('cancel')
.click();
cy.dataCy('vnFilterPanelChip').should('not.exist');
});
it('Removes category tag', () => {
selectCategory();
cy.get(
"div.q-page-container [data-cy='catalogFilterCustomTag'] > i.q-chip__icon--remove"
)
.contains('cancel')
.should('exist');
cy.get(
"div.q-page-container [data-cy='catalogFilterCustomTag'] > i.q-chip__icon--remove"
)
.contains('cancel')
.click();
cy.dataCy('catalogFilterCustomTag').should('not.exist');
});
it('removes all tags when category tag is removed', () => {
selectCategory();
selectTypeFilter('Anthurium');
// Verificamos que existan tags
cy.dataCy('vnFilterPanelChip').should('exist');
cy.dataCy('catalogFilterCustomTag').should('exist');
// Removemos la custom tag que en este caso seria la category tag
cy.get(
"div.q-page-container [data-cy='catalogFilterCustomTag'] > i.q-chip__icon--remove"
)
.contains('cancel')
.should('exist');
cy.get(
"div.q-page-container [data-cy='catalogFilterCustomTag'] > i.q-chip__icon--remove"
)
.contains('cancel')
.click();
// Verificamos que no existan tags
cy.dataCy('catalogFilterCustomTag').should('not.exist');
cy.dataCy('vnFilterPanelChip').should('not.exist');
});
});

View File

@ -311,3 +311,7 @@ Cypress.Commands.add('checkValueSelectForm', (id, search) => {
Cypress.Commands.add('searchByLabel', (label, value) => {
cy.get(`[label="${label}"] > .q-field > .q-field__inner`).type(`${value}{enter}`);
});
Cypress.Commands.add('dataCy', (dataTestId, attr = 'data-cy') => {
return cy.get(`[${attr}="${dataTestId}"]`);
});