0
0
Fork 0

test: order catalog tests

This commit is contained in:
William Buezas 2024-11-25 09:18:11 -03:00
parent 651b67e98f
commit 0e55f7abdc
6 changed files with 138 additions and 2 deletions

View File

@ -249,6 +249,7 @@ function sanitizer(params) {
: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

@ -50,7 +50,7 @@ const getSelectedTagValues = async (tag) => {
<template>
<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" data-cy="catalogFilterValueDialog">
<VnSelect
:label="t('params.tag')"
v-model="selectedTag"
@ -64,6 +64,7 @@ const getSelectedTagValues = async (tag) => {
:emit-value="false"
use-input
@update:model-value="getSelectedTagValues"
data-cy="catalogFilterValueDialogTagSelect"
/>
<div
v-for="(value, index) in tagValues"
@ -94,6 +95,7 @@ const getSelectedTagValues = async (tag) => {
:disable="!value"
is-outlined
class="col"
data-cy="catalogFilterValueDialogValueInput"
/>
<QBtn
icon="delete"

View File

@ -98,7 +98,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="dataKey"
@ -106,6 +106,7 @@ watch(
:limit="50"
:user-params="catalogParams"
:auto-load="autoLoad"
data-cy="orderCatalogPage"
>
<template #body="{ rows }">
<div class="catalog-list">
@ -118,6 +119,7 @@ watch(
:item="row"
is-catalog
class="fill-icon"
data-cy="orderCatalogItem"
/>
</div>
</template>

View File

@ -179,6 +179,7 @@ function addOrder(value, field, params) {
? resetCategory(params, searchFn)
: removeTagGroupParam(params, searchFn, valIndex)
"
data-cy="catalogFilterCustomTag"
>
<strong v-if="customTag.label === 'categoryFk' && categoryList">
{{
@ -212,6 +213,7 @@ function addOrder(value, field, params) {
:name="category.icon"
class="category-icon"
@click="selectCategory(params, category, searchFn)"
data-cy="catalogFilterCategory"
>
<QTooltip>
{{ t(category.name) }}
@ -235,6 +237,7 @@ function addOrder(value, field, params) {
sort-by="name ASC"
:disable="!params.categoryFk"
@update:model-value="searchFn()"
data-cy="catalogFilterType"
>
<template #option="{ itemProps, opt }">
<QItem v-bind="itemProps">
@ -286,6 +289,7 @@ function addOrder(value, field, params) {
:is-clearable="false"
v-model="searchByTag"
@keyup.enter="(val) => onSearchByTag(val, params)"
data-cy="catalogFilterValueInput"
>
<template #prepend>
<QIcon name="search" />
@ -298,6 +302,7 @@ function addOrder(value, field, params) {
color="primary"
size="md"
dense
data-cy="catalogFilterValueDialogBtn"
/>
<QPopupProxy>
<CatalogFilterValueDialog

View File

@ -0,0 +1,122 @@
/// <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 searchByCustomTagInput = (option) => {
cy.dataCy('catalogFilterValueInput').find('input').last().focus();
cy.dataCy('catalogFilterValueInput').find('input').last().type(option);
cy.dataCy('catalogFilterValueInput').find('input').last().type('{enter}');
checkCustomFilterTag(option);
};
const selectTypeFilter = (option) => {
cy.selectOption(
'div.q-page-container div.list > div:nth-of-type(2) div:nth-of-type(3)',
option
);
checkFilterTag(option);
};
it('Shows empty state', () => {
// PASS;
cy.dataCy('orderCatalogPage').should('exist');
cy.dataCy('orderCatalogPage').contains('No data to display');
});
it('filter by category', () => {
// PASS;
selectCategory();
cy.dataCy('orderCatalogItem').should('exist');
});
it('filters by type', () => {
// PASS;
selectCategory();
selectTypeFilter('Anthurium');
});
it('filters by custom value select', () => {
// PASS
selectCategory();
searchByCustomTagInput('Silver');
});
it('filters by custom value dialog', () => {
// PASS
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='catalogFilterValueDialog'] > label > div > div > div",
'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', () => {
// PASS
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', () => {
// PASS
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');
});
});

View File

@ -262,3 +262,7 @@ Cypress.Commands.add('openUserPanel', () => {
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image'
).click();
});
Cypress.Commands.add('dataCy', (dataTestId, attr = 'data-cy') => {
return cy.get(`[${attr}="${dataTestId}"]`);
});