diff --git a/cypress/elements/account/left-menu/left-menu-selectors.js b/cypress/elements/account/left-menu/left-menu-selectors.js new file mode 100644 index 000000000..45728f0d2 --- /dev/null +++ b/cypress/elements/account/left-menu/left-menu-selectors.js @@ -0,0 +1,16 @@ +/* eslint-disable sort-keys */ +export const LEFT_MENU_SELECTORS = { + catalog: "[data-testid='catalog']", + + PRODUCTS_SELECTORS: { + products: "[data-testid='catalogue']", + createProductBtn: "[data-test='add-product']", + productNameInput: "[name='name']", + productTypeInput: "data-test='product-type'", + categoryInput: "[data-test='category']", + categoryDropdown: "[data-test='singleautocomplete-select-option']", + visibleRadioBtn: "[name='isPublished']", + saveBtn: "[data-test='button-bar-confirm']", + confirmationMsg: "[data-test='notification']" + } +}; diff --git a/cypress/elements/account/login-selectors.js b/cypress/elements/account/login-selectors.js index 884b83dbd..388f6b458 100644 --- a/cypress/elements/account/login-selectors.js +++ b/cypress/elements/account/login-selectors.js @@ -1,7 +1,9 @@ export const LOGIN_SELECTORS = { + accountSettings: "[data-test=accountSettingsButton]", emailAddressInput: "input[name='email']", emailPasswordInput: "input[name='password']", signInButton: "[data-test=submit]", + userMenu: "[data-test=userMenu]", warningCredentialMessage: "[data-test=loginErrorMessage]", welcomePage: "[data-test=welcomeHeader]" }; diff --git a/cypress/integration/login_form.js b/cypress/integration/login_form.js index 812a852a5..e4af3a27a 100644 --- a/cypress/integration/login_form.js +++ b/cypress/integration/login_form.js @@ -6,37 +6,33 @@ describe("User authorization", () => { cy.clearSessionData(); }); - describe("Login", () => { - it("should successfully log in an user", () => { - cy.visit("/"); - cy.loginUser(); - cy.get(LOGIN_SELECTORS.welcomePage); - }); - - it("should fail for wrong password", () => { - cy.visit("/") - .get(LOGIN_SELECTORS.emailAddressInput) - .type("admin@example.com") - .get(LOGIN_SELECTORS.emailPasswordInput) - .type("wrong-password") - .get(LOGIN_SELECTORS.signInButton) - .click() - .get(LOGIN_SELECTORS.warningCredentialMessage); - }); + it("should successfully log in an user", () => { + cy.visit("/"); + cy.loginUser(); + cy.get(LOGIN_SELECTORS.welcomePage); }); - describe("Logout", () => { - it("should successfully log out an user", () => { - cy.window().then(win => { - win.sessionStorage.clear(); - }); - cy.visit("/"); - cy.loginUser(); - cy.get("[data-test=userMenu]") - .click() - .get("[data-test=accountSettingsButton]") - .click(); - cy.location("pathname").should("contains", "/staff/"); + it("should fail for wrong password", () => { + cy.visit("/") + .get(LOGIN_SELECTORS.emailAddressInput) + .type("admin@example.com") + .get(LOGIN_SELECTORS.emailPasswordInput) + .type("wrong-password") + .get(LOGIN_SELECTORS.signInButton) + .click() + .get(LOGIN_SELECTORS.warningCredentialMessage); + }); + + it("should successfully log out an user", () => { + cy.window().then(win => { + win.sessionStorage.clear(); }); + cy.visit("/"); + cy.loginUser(); + cy.get(LOGIN_SELECTORS.userMenu) + .click() + .get(LOGIN_SELECTORS.accountSettings) + .click(); + cy.location("pathname").should("contains", "/staff/"); }); }); diff --git a/cypress/integration/products.js b/cypress/integration/products.js new file mode 100644 index 000000000..778e432aa --- /dev/null +++ b/cypress/integration/products.js @@ -0,0 +1,37 @@ +import { LEFT_MENU_SELECTORS } from "../elements/account/left-menu/left-menu-selectors"; +import { LOGIN_SELECTORS } from "../elements/account/login-selectors"; + +// +describe("Products", () => { + beforeEach(() => { + cy.clearSessionData(); + cy.visit("/"); + cy.loginUser(); + }); + + it("should add new visible product", () => { + cy.get(LEFT_MENU_SELECTORS.catalog) + .click() + .get(LEFT_MENU_SELECTORS.PRODUCTS_SELECTORS.products) + .click() + .get(LEFT_MENU_SELECTORS.PRODUCTS_SELECTORS.createProductBtn) + .click() + .get(LEFT_MENU_SELECTORS.PRODUCTS_SELECTORS.productNameInput) + .click() + .type("Visible test product") + .get(LEFT_MENU_SELECTORS.PRODUCTS_SELECTORS.productTypeInput) + .click() + .type("Cushion{'enter'}") + .get(LEFT_MENU_SELECTORS.PRODUCTS_SELECTORS.categoryInput) + .click() + .get(LEFT_MENU_SELECTORS.PRODUCTS_SELECTORS.categoryDropdown) + .first() + .click() + .get(LEFT_MENU_SELECTORS.PRODUCTS_SELECTORS.visibleRadioBtn) + .click() + .get(LEFT_MENU_SELECTORS.PRODUCTS_SELECTORS.saveBtn) + .click() + .get(LEFT_MENU_SELECTORS.PRODUCTS_SELECTORS.confirmationMsg) + .contains("Product save"); + }); +});