forked from verdnatura/salix-front
test: order catalog tests
This commit is contained in:
parent
651b67e98f
commit
0e55f7abdc
|
@ -249,6 +249,7 @@ function sanitizer(params) {
|
||||||
:key="chip.label"
|
:key="chip.label"
|
||||||
:removable="!unremovableParams?.includes(chip.label)"
|
:removable="!unremovableParams?.includes(chip.label)"
|
||||||
@remove="remove(chip.label)"
|
@remove="remove(chip.label)"
|
||||||
|
data-cy="vnFilterPanelChip"
|
||||||
>
|
>
|
||||||
<slot name="tags" :tag="chip" :format-fn="formatValue">
|
<slot name="tags" :tag="chip" :format-fn="formatValue">
|
||||||
<div class="q-gutter-x-xs">
|
<div class="q-gutter-x-xs">
|
||||||
|
|
|
@ -50,7 +50,7 @@ const getSelectedTagValues = async (tag) => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<QForm @submit="applyTags()" 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" data-cy="catalogFilterValueDialog">
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('params.tag')"
|
:label="t('params.tag')"
|
||||||
v-model="selectedTag"
|
v-model="selectedTag"
|
||||||
|
@ -64,6 +64,7 @@ const getSelectedTagValues = async (tag) => {
|
||||||
:emit-value="false"
|
:emit-value="false"
|
||||||
use-input
|
use-input
|
||||||
@update:model-value="getSelectedTagValues"
|
@update:model-value="getSelectedTagValues"
|
||||||
|
data-cy="catalogFilterValueDialogTagSelect"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
v-for="(value, index) in tagValues"
|
v-for="(value, index) in tagValues"
|
||||||
|
@ -94,6 +95,7 @@ const getSelectedTagValues = async (tag) => {
|
||||||
:disable="!value"
|
:disable="!value"
|
||||||
is-outlined
|
is-outlined
|
||||||
class="col"
|
class="col"
|
||||||
|
data-cy="catalogFilterValueDialogValueInput"
|
||||||
/>
|
/>
|
||||||
<QBtn
|
<QBtn
|
||||||
icon="delete"
|
icon="delete"
|
||||||
|
|
|
@ -98,7 +98,7 @@ watch(
|
||||||
/>
|
/>
|
||||||
</QScrollArea>
|
</QScrollArea>
|
||||||
</QDrawer>
|
</QDrawer>
|
||||||
<QPage class="column items-center q-pa-md">
|
<QPage class="column items-center q-pa-md" data-cy="orderCatalogPage">
|
||||||
<div class="full-width">
|
<div class="full-width">
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
:data-key="dataKey"
|
:data-key="dataKey"
|
||||||
|
@ -106,6 +106,7 @@ watch(
|
||||||
:limit="50"
|
:limit="50"
|
||||||
:user-params="catalogParams"
|
:user-params="catalogParams"
|
||||||
:auto-load="autoLoad"
|
:auto-load="autoLoad"
|
||||||
|
data-cy="orderCatalogPage"
|
||||||
>
|
>
|
||||||
<template #body="{ rows }">
|
<template #body="{ rows }">
|
||||||
<div class="catalog-list">
|
<div class="catalog-list">
|
||||||
|
@ -118,6 +119,7 @@ watch(
|
||||||
:item="row"
|
:item="row"
|
||||||
is-catalog
|
is-catalog
|
||||||
class="fill-icon"
|
class="fill-icon"
|
||||||
|
data-cy="orderCatalogItem"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -179,6 +179,7 @@ function addOrder(value, field, params) {
|
||||||
? resetCategory(params, searchFn)
|
? resetCategory(params, searchFn)
|
||||||
: removeTagGroupParam(params, searchFn, valIndex)
|
: removeTagGroupParam(params, searchFn, valIndex)
|
||||||
"
|
"
|
||||||
|
data-cy="catalogFilterCustomTag"
|
||||||
>
|
>
|
||||||
<strong v-if="customTag.label === 'categoryFk' && categoryList">
|
<strong v-if="customTag.label === 'categoryFk' && categoryList">
|
||||||
{{
|
{{
|
||||||
|
@ -212,6 +213,7 @@ function addOrder(value, field, params) {
|
||||||
:name="category.icon"
|
:name="category.icon"
|
||||||
class="category-icon"
|
class="category-icon"
|
||||||
@click="selectCategory(params, category, searchFn)"
|
@click="selectCategory(params, category, searchFn)"
|
||||||
|
data-cy="catalogFilterCategory"
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ t(category.name) }}
|
{{ t(category.name) }}
|
||||||
|
@ -235,6 +237,7 @@ function addOrder(value, field, params) {
|
||||||
sort-by="name ASC"
|
sort-by="name ASC"
|
||||||
:disable="!params.categoryFk"
|
:disable="!params.categoryFk"
|
||||||
@update:model-value="searchFn()"
|
@update:model-value="searchFn()"
|
||||||
|
data-cy="catalogFilterType"
|
||||||
>
|
>
|
||||||
<template #option="{ itemProps, opt }">
|
<template #option="{ itemProps, opt }">
|
||||||
<QItem v-bind="itemProps">
|
<QItem v-bind="itemProps">
|
||||||
|
@ -286,6 +289,7 @@ function addOrder(value, field, params) {
|
||||||
:is-clearable="false"
|
:is-clearable="false"
|
||||||
v-model="searchByTag"
|
v-model="searchByTag"
|
||||||
@keyup.enter="(val) => onSearchByTag(val, params)"
|
@keyup.enter="(val) => onSearchByTag(val, params)"
|
||||||
|
data-cy="catalogFilterValueInput"
|
||||||
>
|
>
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<QIcon name="search" />
|
<QIcon name="search" />
|
||||||
|
@ -298,6 +302,7 @@ function addOrder(value, field, params) {
|
||||||
color="primary"
|
color="primary"
|
||||||
size="md"
|
size="md"
|
||||||
dense
|
dense
|
||||||
|
data-cy="catalogFilterValueDialogBtn"
|
||||||
/>
|
/>
|
||||||
<QPopupProxy>
|
<QPopupProxy>
|
||||||
<CatalogFilterValueDialog
|
<CatalogFilterValueDialog
|
||||||
|
|
|
@ -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');
|
||||||
|
});
|
||||||
|
});
|
|
@ -262,3 +262,7 @@ Cypress.Commands.add('openUserPanel', () => {
|
||||||
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image'
|
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image'
|
||||||
).click();
|
).click();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Cypress.Commands.add('dataCy', (dataTestId, attr = 'data-cy') => {
|
||||||
|
return cy.get(`[${attr}="${dataTestId}"]`);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue