forked from verdnatura/salix-front
Merge pull request 'test: Order catalog tests' (!1008) from wbuezas/salix-front-mindshore-fork2:feature/CatalogTests into dev
Reviewed-on: verdnatura/salix-front#1008 Reviewed-by: Javier Segarra <jsegarra@verdnatura.es>
This commit is contained in:
commit
827f6032b6
|
@ -273,6 +273,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">
|
||||
|
|
|
@ -49,7 +49,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"
|
||||
|
@ -63,6 +63,7 @@ const getSelectedTagValues = async (tag) => {
|
|||
:emit-value="false"
|
||||
use-input
|
||||
@update:model-value="getSelectedTagValues"
|
||||
data-cy="catalogFilterValueDialogTagSelect"
|
||||
/>
|
||||
<div
|
||||
v-for="(value, index) in tagValues"
|
||||
|
@ -93,6 +94,7 @@ const getSelectedTagValues = async (tag) => {
|
|||
:disable="!value"
|
||||
is-outlined
|
||||
class="col"
|
||||
data-cy="catalogFilterValueDialogValueInput"
|
||||
/>
|
||||
<QBtn
|
||||
icon="delete"
|
||||
|
|
|
@ -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"
|
||||
|
@ -118,6 +118,7 @@ watch(
|
|||
:item="row"
|
||||
is-catalog
|
||||
class="fill-icon"
|
||||
data-cy="orderCatalogItem"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -178,6 +178,7 @@ function addOrder(value, field, params) {
|
|||
? resetCategory(params, searchFn)
|
||||
: removeTagGroupParam(params, searchFn, valIndex)
|
||||
"
|
||||
data-cy="catalogFilterCustomTag"
|
||||
>
|
||||
<strong v-if="customTag.label === 'categoryFk' && categoryList">
|
||||
{{
|
||||
|
@ -211,6 +212,7 @@ function addOrder(value, field, params) {
|
|||
:name="category.icon"
|
||||
class="category-icon"
|
||||
@click="selectCategory(params, category, searchFn)"
|
||||
data-cy="catalogFilterCategory"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t(category.name) }}
|
||||
|
@ -234,6 +236,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">
|
||||
|
@ -285,6 +288,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" />
|
||||
|
@ -297,6 +301,7 @@ function addOrder(value, field, params) {
|
|||
color="primary"
|
||||
size="md"
|
||||
dense
|
||||
data-cy="catalogFilterValueDialogBtn"
|
||||
/>
|
||||
<QPopupProxy>
|
||||
<CatalogFilterValueDialog
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
/// <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', () => {
|
||||
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();
|
||||
searchByCustomTagInput('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');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue