Add presets tests for products list view (#3506)
This commit is contained in:
parent
799ba9bbfc
commit
375aea0fff
7 changed files with 90 additions and 2 deletions
37
cypress/e2e/products/productsList/productPresets.js
Normal file
37
cypress/e2e/products/productsList/productPresets.js
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/// <reference types="cypress"/>
|
||||||
|
/// <reference types="../../../support"/>
|
||||||
|
|
||||||
|
import { PRODUCTS_LIST } from "../../../elements/catalog/products/products-list";
|
||||||
|
import { urlList } from "../../../fixtures/urlList";
|
||||||
|
import { ensureCanvasStatic } from "../../../support/customCommands/sharedElementsOperations/canvas";
|
||||||
|
import {
|
||||||
|
addPresetWithName,
|
||||||
|
confirmActivePresetName,
|
||||||
|
confirmGridRowsContainsText,
|
||||||
|
searchItems,
|
||||||
|
} from "../../../support/pages/catalog/presetsAndSearch";
|
||||||
|
|
||||||
|
describe("As a user I should be able to save selected filters with search queries under the given name", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
cy.visit(urlList.products);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(
|
||||||
|
"should be able to add preset. TC: SALEOR_3802",
|
||||||
|
{ tags: ["@productsList", "@allEnv", "@stable"] },
|
||||||
|
() => {
|
||||||
|
ensureCanvasStatic(PRODUCTS_LIST.dataGridTable).then(() => {
|
||||||
|
cy.assertCanvasRowsNumber(PRODUCTS_LIST.dataGridTable, 21);
|
||||||
|
});
|
||||||
|
const presetName = "hoodie";
|
||||||
|
|
||||||
|
searchItems(presetName);
|
||||||
|
addPresetWithName(presetName);
|
||||||
|
ensureCanvasStatic(PRODUCTS_LIST.dataGridTable).then(() => {
|
||||||
|
confirmGridRowsContainsText(presetName);
|
||||||
|
confirmActivePresetName(presetName);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
|
@ -1,5 +1,12 @@
|
||||||
import { ADDRESS_SELECTORS } from "./addressForm";
|
import { ADDRESS_SELECTORS } from "./addressForm";
|
||||||
import { BUTTON_SELECTORS } from "./button-selectors";
|
import { BUTTON_SELECTORS } from "./button-selectors";
|
||||||
|
import { PRESETS, SEARCH } from "./presetsAndSearch";
|
||||||
import { SHARED_ELEMENTS } from "./sharedElements";
|
import { SHARED_ELEMENTS } from "./sharedElements";
|
||||||
|
|
||||||
export { ADDRESS_SELECTORS, BUTTON_SELECTORS, SHARED_ELEMENTS };
|
export {
|
||||||
|
ADDRESS_SELECTORS,
|
||||||
|
BUTTON_SELECTORS,
|
||||||
|
PRESETS,
|
||||||
|
SEARCH,
|
||||||
|
SHARED_ELEMENTS,
|
||||||
|
};
|
||||||
|
|
9
cypress/elements/shared/presetsAndSearch.js
Normal file
9
cypress/elements/shared/presetsAndSearch.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
export const PRESETS = {
|
||||||
|
addPresetButton: "[data-test-id='add-preset-button']",
|
||||||
|
presetNameTextField: '[data-test-id="preset-name-text-field"]',
|
||||||
|
savePresetNameButton: '[data-test-id="save-preset-button"]',
|
||||||
|
activePresetName: '[data-test-id="show-saved-filters-button"]',
|
||||||
|
};
|
||||||
|
export const SEARCH = {
|
||||||
|
searchInput: "[data-test-id='search-input']",
|
||||||
|
};
|
30
cypress/support/pages/catalog/presetsAndSearch.js
Normal file
30
cypress/support/pages/catalog/presetsAndSearch.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import { PRODUCTS_LIST } from "../../../elements/catalog/products/products-list";
|
||||||
|
import { PRESETS, SEARCH } from "../../../elements/shared";
|
||||||
|
|
||||||
|
export function searchItems(name) {
|
||||||
|
return cy
|
||||||
|
.addAliasToGraphRequest("ProductList")
|
||||||
|
.get(SEARCH.searchInput)
|
||||||
|
.type(name)
|
||||||
|
.wait("@ProductList");
|
||||||
|
}
|
||||||
|
export function addPresetWithName(name) {
|
||||||
|
return cy
|
||||||
|
.get(PRESETS.addPresetButton)
|
||||||
|
.click()
|
||||||
|
.get(PRESETS.presetNameTextField)
|
||||||
|
.type(name)
|
||||||
|
.get(PRESETS.savePresetNameButton)
|
||||||
|
.click()
|
||||||
|
.wait("@ProductList");
|
||||||
|
}
|
||||||
|
export function confirmGridRowsContainsText(name) {
|
||||||
|
return cy
|
||||||
|
.get(PRODUCTS_LIST.dataGridTable)
|
||||||
|
.find("tbody")
|
||||||
|
.find("tr")
|
||||||
|
.should("contain.text", name);
|
||||||
|
}
|
||||||
|
export function confirmActivePresetName(name) {
|
||||||
|
return cy.get(PRESETS.activePresetName).should("contain.text", name);
|
||||||
|
}
|
|
@ -29,6 +29,7 @@ const SearchInput: React.FC<SearchInputProps> = props => {
|
||||||
value={search}
|
value={search}
|
||||||
onChange={handleSearchChange}
|
onChange={handleSearchChange}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
|
data-test-id="search-input"
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|
|
@ -174,6 +174,7 @@ export const FilterPresetsSelect = ({
|
||||||
{renderDropdown()}
|
{renderDropdown()}
|
||||||
{showUpdateButton && (
|
{showUpdateButton && (
|
||||||
<Button
|
<Button
|
||||||
|
data-test-id="update-preset-button"
|
||||||
className={sprinkles({
|
className={sprinkles({
|
||||||
marginLeft: 6,
|
marginLeft: 6,
|
||||||
})}
|
})}
|
||||||
|
@ -188,6 +189,7 @@ export const FilterPresetsSelect = ({
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<Tooltip.Trigger>
|
<Tooltip.Trigger>
|
||||||
<Button
|
<Button
|
||||||
|
data-test-id="add-preset-button"
|
||||||
className={sprinkles({
|
className={sprinkles({
|
||||||
marginLeft: 6,
|
marginLeft: 6,
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -71,16 +71,18 @@ const SaveFilterTabDialog: React.FC<SaveFilterTabDialogProps> = ({
|
||||||
value={data.name}
|
value={data.name}
|
||||||
onChange={change}
|
onChange={change}
|
||||||
error={errors}
|
error={errors}
|
||||||
|
data-test-id="preset-name-text-field"
|
||||||
helperText={errors ? "This field is required" : null}
|
helperText={errors ? "This field is required" : null}
|
||||||
/>
|
/>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<BackButton onClick={onClose}>
|
<BackButton onClick={onClose} data-test-id="cancel-preset-button">
|
||||||
<FormattedMessage {...buttonMessages.cancel} />
|
<FormattedMessage {...buttonMessages.cancel} />
|
||||||
</BackButton>
|
</BackButton>
|
||||||
<ConfirmButton
|
<ConfirmButton
|
||||||
transitionState={confirmButtonState}
|
transitionState={confirmButtonState}
|
||||||
onClick={submit}
|
onClick={submit}
|
||||||
|
data-test-id="save-preset-button"
|
||||||
>
|
>
|
||||||
<FormattedMessage {...buttonMessages.save} />
|
<FormattedMessage {...buttonMessages.save} />
|
||||||
</ConfirmButton>
|
</ConfirmButton>
|
||||||
|
|
Loading…
Reference in a new issue