Test navigation refactor (#3294)

* naviagtion aka permissions refactor
This commit is contained in:
wojteknowacki 2023-03-09 09:18:07 +01:00 committed by GitHub
parent 5de9526350
commit bf532939e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
81 changed files with 885 additions and 293 deletions

View file

@ -4,7 +4,7 @@
import faker from "faker";
import { APP_DETAILS } from "../elements/apps/appDetails";
import { APPS_LIST } from "../elements/apps/appsList";
import { APPS_LIST_SELECTORS } from "../elements/apps/appsList";
import { WEBHOOK_DETAILS } from "../elements/apps/webhookDetails";
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
import { appDetailsUrl, urlList } from "../fixtures/urlList";
@ -108,8 +108,8 @@ describe("As a staff user I want to manage apps", () => {
() => {
const randomAppName = `${startsWith}${faker.datatype.number()}`;
cy.visit(urlList.apps)
.get(APPS_LIST.createLocalAppButton)
cy.visit(urlList.webhooksAndEvents)
.get(APPS_LIST_SELECTORS.createLocalAppButton)
.click()
.get(APP_DETAILS.nameInput)
.type(randomAppName)

View file

@ -4,10 +4,10 @@
import faker from "faker";
import {
CATEGORIES_LIST,
CATEGORIES_LIST_SELECTORS,
categoryRow,
} from "../../elements/catalog/categories/categories-list";
import { CATEGORY_DETAILS } from "../../elements/catalog/categories/category-details";
import { CATEGORY_DETAILS_SELECTORS } from "../../elements/catalog/categories/category-details";
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
import { categoryDetailsUrl, urlList } from "../../fixtures/urlList";
@ -89,7 +89,7 @@ describe("As an admin I want to manage categories", () => {
const categoryName = `${startsWith}${faker.datatype.number()}`;
cy.visit(urlList.categories)
.get(CATEGORIES_LIST.addCategoryButton)
.get(CATEGORIES_LIST_SELECTORS.addCategoryButton)
.click();
createCategory({ name: categoryName, description: categoryName })
.its("response.body.data.categoryCreate.category")
@ -111,11 +111,11 @@ describe("As an admin I want to manage categories", () => {
const categoryName = `${startsWith}${faker.datatype.number()}`;
cy.visit(categoryDetailsUrl(category.id))
.get(CATEGORY_DETAILS.createSubcategoryButton)
.get(CATEGORY_DETAILS_SELECTORS.createSubcategoryButton)
.click();
createCategory({ name: categoryName, description: categoryName })
.visit(categoryDetailsUrl(category.id))
.contains(CATEGORY_DETAILS.categoryChildrenRow, categoryName)
.contains(CATEGORY_DETAILS_SELECTORS.categoryChildrenRow, categoryName)
.scrollIntoView()
.should("be.visible");
getCategory(category.id).then(categoryResp => {
@ -129,9 +129,9 @@ describe("As an admin I want to manage categories", () => {
{ tags: ["@category", "@allEnv", "@stable"] },
() => {
cy.visit(categoryDetailsUrl(category.id))
.get(CATEGORY_DETAILS.productsTab)
.get(CATEGORY_DETAILS_SELECTORS.productsTab)
.click()
.get(CATEGORY_DETAILS.addProducts)
.get(CATEGORY_DETAILS_SELECTORS.addProducts)
.click()
.url()
.should("include", urlList.addProduct);
@ -143,9 +143,9 @@ describe("As an admin I want to manage categories", () => {
{ tags: ["@category", "@allEnv", "@stable"] },
() => {
cy.visit(categoryDetailsUrl(category.id))
.get(CATEGORY_DETAILS.productsTab)
.get(CATEGORY_DETAILS_SELECTORS.productsTab)
.click();
cy.contains(CATEGORY_DETAILS.productRow, product.name)
cy.contains(CATEGORY_DETAILS_SELECTORS.productRow, product.name)
.find(BUTTON_SELECTORS.checkbox)
.click()
.get(BUTTON_SELECTORS.deleteIcon)
@ -154,7 +154,7 @@ describe("As an admin I want to manage categories", () => {
.get(BUTTON_SELECTORS.submit)
.click()
.confirmationMessageShouldDisappear();
cy.contains(CATEGORY_DETAILS.productRow, product.name)
cy.contains(CATEGORY_DETAILS_SELECTORS.productRow, product.name)
.should("not.exist")
.waitForRequestAndCheckIfNoErrors("@productBulkDelete");
getCategory(category.id).then(categoryResp => {

View file

@ -61,7 +61,7 @@ describe("Tests on inactive channel", () => {
{ tags: ["@channel", "@allEnv", "@stable"] },
() => {
cy.visit(urlList.orders)
.get(ORDERS_SELECTORS.createOrder)
.get(ORDERS_SELECTORS.createOrderButton)
.click()
.get(CHANNEL_FORM_SELECTORS.channelSelect)
.click()

View file

@ -3,8 +3,8 @@
import faker from "faker";
import { CUSTOMER_DETAILS } from "../../elements/customer/customer-details";
import { CUSTOMERS_LIST } from "../../elements/customer/customers-list";
import { CUSTOMER_DETAILS_SELECTORS } from "../../elements/customer/customer-details";
import { CUSTOMERS_LIST_SELECTORS } from "../../elements/customer/customers-list";
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
import { customerDetailsUrl, urlList } from "../../fixtures/urlList";
@ -43,18 +43,18 @@ describe("Tests for customer", () => {
const note = faker.lorem.paragraph();
cy.visit(urlList.customers)
.get(CUSTOMERS_LIST.createCustomerButton)
.get(CUSTOMERS_LIST_SELECTORS.createCustomerButton)
.click()
.get(SHARED_ELEMENTS.progressBar)
.should("not.be.visible")
.get(CUSTOMER_DETAILS.customerAddressNameInput)
.get(CUSTOMER_DETAILS_SELECTORS.customerAddressNameInput)
.type(randomName)
.get(CUSTOMER_DETAILS.customerAddressLastNameInput)
.get(CUSTOMER_DETAILS_SELECTORS.customerAddressLastNameInput)
.type(randomName)
.get(CUSTOMER_DETAILS.emailInput)
.get(CUSTOMER_DETAILS_SELECTORS.emailInput)
.type(email)
.fillUpAddressForm(address)
.get(CUSTOMER_DETAILS.noteInput)
.get(CUSTOMER_DETAILS_SELECTORS.noteInput)
.type(note)
.addAliasToGraphRequest("CreateCustomer")
.get(BUTTON_SELECTORS.confirm)
@ -90,9 +90,9 @@ describe("Tests for customer", () => {
createCustomer(email, randomName).then(({ user }) => {
cy.visit(customerDetailsUrl(user.id))
.get(CUSTOMER_DETAILS.manageAddressesButton)
.get(CUSTOMER_DETAILS_SELECTORS.manageAddressesButton)
.click()
.get(CUSTOMER_DETAILS.addAddressButton)
.get(CUSTOMER_DETAILS_SELECTORS.addAddressButton)
.click()
.addAliasToGraphRequest("CreateCustomerAddress")
.fillUpAddressFormAndSubmit(secondAddress)
@ -114,14 +114,14 @@ describe("Tests for customer", () => {
createCustomer(email, randomName, address).then(({ user }) => {
cy.visit(customerDetailsUrl(user.id))
.get(CUSTOMER_DETAILS.manageAddressesButton)
.get(CUSTOMER_DETAILS_SELECTORS.manageAddressesButton)
.click()
.waitForProgressBarToNotExist()
.get(BUTTON_SELECTORS.showMoreButton)
.should("be.enabled")
.first()
.click()
.get(CUSTOMER_DETAILS.deleteAddressMenuItem)
.get(CUSTOMER_DETAILS_SELECTORS.deleteAddressMenuItem)
.click()
.addAliasToGraphRequest("RemoveCustomerAddress")
.get(BUTTON_SELECTORS.submit)
@ -149,14 +149,14 @@ describe("Tests for customer", () => {
})
.then(() => {
cy.visit(customerDetailsUrl(user.id))
.get(CUSTOMER_DETAILS.manageAddressesButton)
.get(CUSTOMER_DETAILS_SELECTORS.manageAddressesButton)
.click()
.waitForProgressBarToNotExist()
.get(BUTTON_SELECTORS.showMoreButton)
.should("be.enabled")
.click()
.addAliasToGraphRequest("SetCustomerDefaultAddress")
.get(CUSTOMER_DETAILS.setAddressAsDefaultShipping)
.get(CUSTOMER_DETAILS_SELECTORS.setAddressAsDefaultShipping)
.click()
.wait("@SetCustomerDefaultAddress");
getCustomer(user.id);
@ -167,7 +167,7 @@ describe("Tests for customer", () => {
.should("be.enabled")
.click()
.addAliasToGraphRequest("SetCustomerDefaultAddress")
.get(CUSTOMER_DETAILS.setAddressAsDefaultBilling)
.get(CUSTOMER_DETAILS_SELECTORS.setAddressAsDefaultBilling)
.click()
.wait("@SetCustomerDefaultAddress");
getCustomer(user.id);
@ -187,13 +187,13 @@ describe("Tests for customer", () => {
createCustomer(email, randomName, address).then(({ user }) => {
cy.visit(customerDetailsUrl(user.id))
.get(CUSTOMER_DETAILS.manageAddressesButton)
.get(CUSTOMER_DETAILS_SELECTORS.manageAddressesButton)
.click()
.get(BUTTON_SELECTORS.showMoreButton)
.should("be.enabled")
.first()
.click()
.get(CUSTOMER_DETAILS.editAddressMenuitem)
.get(CUSTOMER_DETAILS_SELECTORS.editAddressMenuitem)
.click()
.addAliasToGraphRequest("UpdateCustomerAddress")
.fillUpAddressFormAndSubmit(secondAddress)
@ -239,7 +239,7 @@ describe("Tests for customer", () => {
createCustomer(email, randomName, address, true).then(({ user }) => {
cy.visit(customerDetailsUrl(user.id))
.get(CUSTOMER_DETAILS.activeCheckbox)
.get(CUSTOMER_DETAILS_SELECTORS.activeCheckbox)
.click()
.addAliasToGraphRequest("UpdateCustomer")
.get(BUTTON_SELECTORS.confirm)
@ -262,13 +262,13 @@ describe("Tests for customer", () => {
createCustomer(email, randomName, address, true).then(({ user }) => {
cy.visit(customerDetailsUrl(user.id))
.get(CUSTOMER_DETAILS.nameInput)
.get(CUSTOMER_DETAILS_SELECTORS.nameInput)
.clearAndType(updatedName)
.get(CUSTOMER_DETAILS.lastNameInput)
.get(CUSTOMER_DETAILS_SELECTORS.lastNameInput)
.clearAndType(updatedName)
.get(CUSTOMER_DETAILS.noteInput)
.get(CUSTOMER_DETAILS_SELECTORS.noteInput)
.clearAndType(updatedName)
.get(CUSTOMER_DETAILS.emailInput)
.get(CUSTOMER_DETAILS_SELECTORS.emailInput)
.clearAndType(`${updatedName}@example.com`)
.addAliasToGraphRequest("UpdateCustomer")
.get(BUTTON_SELECTORS.confirm)

View file

@ -3,8 +3,8 @@
import faker from "faker";
import { PERMISSION_GROUP_DETAILS } from "../../elements/permissionGroup/permissionGroupDetails";
import { PERMISSION_GROUP_LIST } from "../../elements/permissionGroup/permissionGroupsList";
import { PERMISSION_GROUP_DETAILS_SELECTORS } from "../../elements/permissionGroup/permissionGroupDetails";
import { PERMISSION_GROUP_LIST_SELECTORS } from "../../elements/permissionGroup/permissionGroupsList";
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
import {
@ -40,25 +40,25 @@ describe("Permissions groups", () => {
const permissionName = `${startsWith}${faker.datatype.number()}`;
cy.visit(urlList.permissionsGroups)
.get(PERMISSION_GROUP_LIST.createPermissionButton)
.get(PERMISSION_GROUP_LIST_SELECTORS.createPermissionButton)
.click()
.get(PERMISSION_GROUP_DETAILS.nameInput)
.get(PERMISSION_GROUP_DETAILS_SELECTORS.nameInput)
.type(permissionName)
.get(PERMISSION_GROUP_DETAILS.productsPermissionCheckbox)
.get(PERMISSION_GROUP_DETAILS_SELECTORS.productsPermissionCheckbox)
.check()
.get(
PERMISSION_GROUP_DETAILS.productsTypesAndAttributesPermissionCheckbox,
PERMISSION_GROUP_DETAILS_SELECTORS.productsTypesAndAttributesPermissionCheckbox,
)
.check()
.get(BUTTON_SELECTORS.confirm)
.click()
.get(PERMISSION_GROUP_DETAILS.assignMemberButton)
.get(PERMISSION_GROUP_DETAILS_SELECTORS.assignMemberButton)
.should("be.visible")
.get(BUTTON_SELECTORS.back)
.click()
.waitForProgressBarToNotExist();
cy.contains(
PERMISSION_GROUP_LIST.permissionGroupRow,
PERMISSION_GROUP_LIST_SELECTORS.permissionGroupRow,
permissionName,
).should("be.visible");
},
@ -82,13 +82,19 @@ describe("Permissions groups", () => {
permissionsArray: permissionManageProducts,
});
cy.visit(urlList.permissionsGroups);
cy.contains(PERMISSION_GROUP_LIST.permissionGroupRow, permissionName)
cy.contains(
PERMISSION_GROUP_LIST_SELECTORS.permissionGroupRow,
permissionName,
)
.should("be.visible")
.find(BUTTON_SELECTORS.deleteIcon)
.click()
.get(BUTTON_SELECTORS.submit)
.click();
cy.contains(PERMISSION_GROUP_LIST.permissionGroupRow, permissionName)
cy.contains(
PERMISSION_GROUP_LIST_SELECTORS.permissionGroupRow,
permissionName,
)
.should("not.exist")
.visit(staffMemberDetailsUrl(staffMember.id))
.get(SHARED_ELEMENTS.header)
@ -110,12 +116,12 @@ describe("Permissions groups", () => {
permissionsArray: permissionManageProducts,
}).then(({ group }) => {
cy.visit(permissionGroupDetails(group.id))
.get(PERMISSION_GROUP_DETAILS.assignMemberButton)
.get(PERMISSION_GROUP_DETAILS_SELECTORS.assignMemberButton)
.click()
.get(PERMISSION_GROUP_DETAILS.searchField)
.get(PERMISSION_GROUP_DETAILS_SELECTORS.searchField)
.type(TEST_ADMIN_USER.email);
cy.contains(
PERMISSION_GROUP_DETAILS.userRow,
PERMISSION_GROUP_DETAILS_SELECTORS.userRow,
`${TEST_ADMIN_USER.name} ${TEST_ADMIN_USER.lastName}`,
)
.should("have.length", 1)
@ -156,7 +162,7 @@ describe("Permissions groups", () => {
})
.then(({ group }) => {
cy.visit(permissionGroupDetails(group.id))
.get(PERMISSION_GROUP_DETAILS.removeUserButton)
.get(PERMISSION_GROUP_DETAILS_SELECTORS.removeUserButton)
.click()
.get(BUTTON_SELECTORS.submit)
.click()

View file

@ -3,8 +3,8 @@
import faker from "faker";
import { PLUGINS_DETAILS } from "../../../elements/plugins/pluginDetails";
import { PLUGINS_LIST } from "../../../elements/plugins/pluginsList";
import { PLUGINS_DETAILS_SELECTORS } from "../../../elements/plugins/pluginDetails";
import { PLUGINS_LIST_SELECTORS } from "../../../elements/plugins/pluginsList";
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import { urlList } from "../../../fixtures/urlList";
import {
@ -55,12 +55,12 @@ describe("As an admin I want to manage plugins", () => {
() => {
const customerEmail = `${randomName}@example.com`;
cy.contains(PLUGINS_LIST.pluginRow, "User emails")
cy.contains(PLUGINS_LIST_SELECTORS.pluginRow, "User emails")
.click()
.waitForProgressBarToNotBeVisible();
cy.contains(PLUGINS_DETAILS.channel, defaultChannel.name)
cy.contains(PLUGINS_DETAILS_SELECTORS.channel, defaultChannel.name)
.click()
.get(PLUGINS_DETAILS.accountConfirmationSubjectInput)
.get(PLUGINS_DETAILS_SELECTORS.accountConfirmationSubjectInput)
.clearAndType(randomName)
.get(BUTTON_SELECTORS.confirm)
.click()
@ -81,9 +81,9 @@ describe("As an admin I want to manage plugins", () => {
() => {
const adminName = `Admin${randomName}`;
cy.contains(PLUGINS_LIST.pluginRow, "Admin emails")
cy.contains(PLUGINS_LIST_SELECTORS.pluginRow, "Admin emails")
.click()
.get(PLUGINS_DETAILS.staffPasswordResetInput)
.get(PLUGINS_DETAILS_SELECTORS.staffPasswordResetInput)
.click()
.clear()
.clearAndType(adminName)

View file

@ -3,7 +3,7 @@
import faker from "faker";
import { PRODUCT_TYPE_DETAILS } from "../../../elements/productTypes/productTypeDetails";
import { PRODUCT_TYPE_DETAILS_SELECTORS } from "../../../elements/productTypes/productTypeDetails";
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import { productTypeDetailsUrl } from "../../../fixtures/urlList";
import { createAttribute } from "../../../support/api/requests/Attribute";
@ -40,7 +40,7 @@ describe("As an admin I want to manage attributes in product types", () => {
cy.visitAndWaitForProgressBarToDisappear(
productTypeDetailsUrl(productType.id),
)
.get(PRODUCT_TYPE_DETAILS.assignProductAttributeButton)
.get(PRODUCT_TYPE_DETAILS_SELECTORS.assignProductAttributeButton)
.click()
.addAliasToGraphRequest("AssignProductAttribute")
.assignElements(startsWith)
@ -65,10 +65,10 @@ describe("As an admin I want to manage attributes in product types", () => {
cy.visitAndWaitForProgressBarToDisappear(
productTypeDetailsUrl(productType.id),
)
.get(PRODUCT_TYPE_DETAILS.hasVariantsButton)
.get(PRODUCT_TYPE_DETAILS_SELECTORS.hasVariantsButton)
.should("be.enabled")
.click({ force: true })
.get(PRODUCT_TYPE_DETAILS.assignVariantAttributeButton)
.get(PRODUCT_TYPE_DETAILS_SELECTORS.assignVariantAttributeButton)
.click()
.addAliasToGraphRequest("AssignProductAttribute")
.assignElements(startsWith)
@ -100,7 +100,7 @@ describe("As an admin I want to manage attributes in product types", () => {
cy.visitAndWaitForProgressBarToDisappear(
productTypeDetailsUrl(productType.id),
)
.get(PRODUCT_TYPE_DETAILS.nameInput)
.get(PRODUCT_TYPE_DETAILS_SELECTORS.nameInput)
.should("be.enabled")
.get(BUTTON_SELECTORS.deleteIcon)
.should("be.enabled")
@ -133,7 +133,7 @@ describe("As an admin I want to manage attributes in product types", () => {
cy.visitAndWaitForProgressBarToDisappear(
productTypeDetailsUrl(productType.id),
)
.get(PRODUCT_TYPE_DETAILS.nameInput)
.get(PRODUCT_TYPE_DETAILS_SELECTORS.nameInput)
.should("be.enabled")
.get(BUTTON_SELECTORS.deleteIcon)
.should("be.enabled")
@ -166,7 +166,7 @@ describe("As an admin I want to manage attributes in product types", () => {
cy.visitAndWaitForProgressBarToDisappear(
productTypeDetailsUrl(productType.id),
)
.get(PRODUCT_TYPE_DETAILS.variantSelectionCheckbox)
.get(PRODUCT_TYPE_DETAILS_SELECTORS.variantSelectionCheckbox)
.click()
.addAliasToGraphRequest("ProductAttributeAssignmentUpdate")
.get(BUTTON_SELECTORS.confirm)

View file

@ -3,7 +3,7 @@
import faker from "faker";
import { CUSTOMER_DETAILS } from "../elements/customers/customer-details";
import { CUSTOMER_DETAILS_SELECTORS } from "../elements/customers/customer-details";
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
import { customerDetailsUrl } from "../fixtures/urlList";
import {
@ -76,7 +76,7 @@ describe("Tests for customer registration", () => {
cy.clearSessionData()
.loginUserViaRequest()
.visit(customerDetailsUrl(user.id))
.get(CUSTOMER_DETAILS.isActiveCheckbox)
.get(CUSTOMER_DETAILS_SELECTORS.isActiveCheckbox)
.click()
.get(BUTTON_SELECTORS.confirm)
.click()

View file

@ -2,98 +2,460 @@
/// <reference types="../support"/>
import {
APP_MENU_SELECTORS,
appCommonSelector,
LEFT_MENU_SELECTORS,
} from "../elements/account/left-menu/left-menu-selectors";
ADDRESS_SELECTORS,
APPS_LIST_SELECTORS,
CATEGORIES_LIST_SELECTORS,
CHANNELS_SELECTORS,
COLLECTION_SELECTORS,
CONFIGURATION_SELECTORS,
CUSTOMERS_LIST_SELECTORS,
DRAFT_ORDERS_LIST_SELECTORS,
LANGUAGES_LIST_SELECTORS,
MENU_SELECTORS,
ORDERS_SELECTORS,
PAGE_TYPES_LIST_SELECTORS,
PAGES_LIST_SELECTORS,
PERMISSION_GROUP_LIST_SELECTORS,
PLUGINS_LIST_SELECTORS,
PRODUCT_TYPES_LIST_SELECTORS,
SALES_SELECTORS,
SHIPPING_ZONES_LIST_SELECTORS,
STAFF_MEMBERS_LIST_SELECTORS,
VOUCHERS_SELECTORS,
} from "../elements/";
import { PERMISSIONS_OPTIONS } from "../fixtures/permissionsUsers";
import * as permissionsSteps from "../support/pages/permissionsPage";
// TODO: fix this test after release of new dashboard with sidebar
describe.skip("As a staff user I want to navigate through shop using different permissions", () => {
const permissionsOptions = PERMISSIONS_OPTIONS;
before(() => {
cy.loginUserViaRequest()
.visit("/")
.get(appCommonSelector)
.should("be.visible")
.get("body")
.then($body => {
// This will be deleted when Marketplace is released
// Consider this solution as temporary
let appPermissions;
if ($body.find(LEFT_MENU_SELECTORS.appSection).length) {
appPermissions = {
parent: {
parentMenuSelector: LEFT_MENU_SELECTORS.appSection,
parentSelectors: [APP_MENU_SELECTORS],
},
permissionSelectors: [APP_MENU_SELECTORS.app],
};
} else {
appPermissions = {
permissionSelectors: [LEFT_MENU_SELECTORS.app],
};
}
permissionsOptions.all.permissions.push(appPermissions);
permissionsOptions.app.permissions = [appPermissions];
});
});
Object.keys(permissionsOptions).forEach(key => {
if (key !== "all") {
it(
`should be able to navigate through shop as a staff member using ${key} permission. ${permissionsOptions[key].testCase}`,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease"] },
() => {
const permissionOption = permissionsOptions[key];
const permissions = permissionOption.permissions;
import { urlList } from "../fixtures/urlList";
import {
expectConfigurationAvailableSectionsNumber,
expectConfigurationSectionsToBeVisible,
} from "../support/pages/configurationPage";
import {
expectMainMenuAvailableSections,
expectMainMenuSectionsToBeVisible,
} from "../support/pages/mainMenuPage";
describe("As a staff user I want to navigate through shop using different permissions", () => {
beforeEach(() => {
cy.clearSessionData();
permissionsSteps.navigateToAllAvailablePageAndCheckIfDisplayed(
permissionOption,
);
permissionsSteps.getDisplayedSelectors().then(selectors => {
permissionsSteps.expectAllSelectorsPermitted(
permissions,
selectors,
);
});
if (!permissions) {
return;
}
permissions.forEach(permission => {
if (permission.parent) {
cy.get(permission.parent.parentMenuSelector).click();
permissionsSteps
.getDisplayedSelectors(permission.parent.parentSelectors)
.then(parentSelectors => {
permissionsSteps.expectAllSelectorsPermitted(
permissions,
parentSelectors,
it(
`should be able to navigate through shop as a staff member using DISCOUNTS permission. TC: SALEOR_3405a - sales list`,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.visitHomePageLoggedViaApi(PERMISSIONS_OPTIONS.discount.user);
cy.addAliasToGraphRequest("SaleList")
.clickOnElement(MENU_SELECTORS.MENU.discounts)
.waitForRequestAndCheckIfNoErrors("@SaleList");
cy.checkIfElementIsVisible(SALES_SELECTORS.createSaleButton);
},
);
it(
`should be able to navigate through shop as a staff member using DISCOUNTS permission. TC: SALEOR_3405b - voucher list`,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.addAliasToGraphRequest("VoucherList")
.loginUserViaRequest("auth", PERMISSIONS_OPTIONS.discount.user)
.visit(urlList.vouchers)
.waitForRequestAndCheckIfNoErrors("@VoucherList");
cy.checkIfElementIsVisible(VOUCHERS_SELECTORS.createVoucherButton);
},
);
it(
`should be able to navigate through shop as a staff member using ORDER permission. TC: SALEOR_3407a - order list `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.visitHomePageLoggedViaApi(PERMISSIONS_OPTIONS.order.user);
cy.addAliasToGraphRequest("OrderList")
.clickOnElement(MENU_SELECTORS.MENU.orders)
.waitForRequestAndCheckIfNoErrors("@OrderList")
.then(() => {
expectMainMenuAvailableSections(3);
expectMainMenuSectionsToBeVisible(
MENU_SELECTORS.ORDERS.orders,
MENU_SELECTORS.ORDERS.draftOrders,
);
cy.get(MENU_SELECTORS.ORDERS.orders)
.last()
.click()
.then(() => {
cy.checkIfElementIsVisible(ORDERS_SELECTORS.createOrderButton);
});
}
});
},
);
}
});
it(
`should be able to navigate through shop as a staff member using all permissions. ${permissionsOptions.all.testCase}`,
{ tags: ["@critical", "@allEnv", "@navigation", "@stable", "@oldRelease"] },
`should be able to navigate through shop as a staff member using ORDER permission. TC: SALEOR_3407b - draft list`,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
const permissionOption = permissionsOptions.all;
cy.clearSessionData();
permissionsSteps.navigateToAllAvailablePageAndCheckIfDisplayed(
permissionOption,
cy.addAliasToGraphRequest("OrderDraftList")
.loginUserViaRequest("auth", PERMISSIONS_OPTIONS.order.user)
.visit(urlList.draftOrders)
.waitForRequestAndCheckIfNoErrors("@OrderDraftList");
expectMainMenuAvailableSections(3);
cy.checkIfElementIsVisible(
DRAFT_ORDERS_LIST_SELECTORS.createDraftOrderButton,
);
},
);
it(
`should be able to navigate through shop as a staff member using APP permission. TC: SALEOR_3402 - app list `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.visitHomePageLoggedViaApi(PERMISSIONS_OPTIONS.app.user);
expectMainMenuAvailableSections(2);
cy.addAliasToGraphRequest("AppsList")
.clickOnElement(MENU_SELECTORS.MENU.app)
.waitForRequestAndCheckIfNoErrors("@AppsList")
.then(() => {
cy.checkIfElementIsVisible(
APPS_LIST_SELECTORS.createExternalAppButton,
);
});
},
);
it(
`should be able to navigate through shop as a staff member using CHANNEL permission. TC: SALEOR_3403 - channels list `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.visitHomePageLoggedViaApi(PERMISSIONS_OPTIONS.channel.user);
expectMainMenuAvailableSections(2);
cy.clickOnElement(MENU_SELECTORS.MENU.configuration).then(() => {
expectConfigurationAvailableSectionsNumber(3);
expectConfigurationSectionsToBeVisible(
CONFIGURATION_SELECTORS.taxes,
CONFIGURATION_SELECTORS.webhooks,
CONFIGURATION_SELECTORS.channels,
);
cy.addAliasToGraphRequest("Channels")
.get(CONFIGURATION_SELECTORS.channels)
.click()
.waitForRequestAndCheckIfNoErrors("@Channels");
cy.checkIfElementIsVisible(CHANNELS_SELECTORS.createChannelButton);
});
},
);
it(
`should be able to navigate through shop as a staff member using CHANNEL permission. TC: SALEOR_3403b - webhooks and events `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.addAliasToGraphRequest("AppsList")
.loginUserViaRequest("auth", PERMISSIONS_OPTIONS.channel.user)
.visit(urlList.webhooksAndEvents)
.waitForRequestAndCheckIfNoErrors("@AppsList");
expectMainMenuAvailableSections(2);
cy.checkIfElementIsVisible(APPS_LIST_SELECTORS.createLocalAppButton);
},
);
it(
`should be able to navigate through shop as a staff member using CUSTOMER permission. TC: SALEOR_3404 - customer list `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.visitHomePageLoggedViaApi(PERMISSIONS_OPTIONS.customer.user);
expectMainMenuAvailableSections(2);
cy.addAliasToGraphRequest("ListCustomers")
.clickOnElement(MENU_SELECTORS.MENU.customers)
.waitForRequestAndCheckIfNoErrors("@ListCustomers")
.then(() => {
cy.checkIfElementIsVisible(
CUSTOMERS_LIST_SELECTORS.createCustomerButton,
);
});
},
);
// //TODO fix when permissions bug is fixed
it.skip(
`should be able to navigate through shop as a staff member using GIFT CARD permission. TC: SALEOR_3406 - gift cards `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.loginUserViaRequest("auth", PERMISSIONS_OPTIONS.giftCard.user).visit(
urlList.homePage,
);
expectMainMenuAvailableSections(2);
cy.clickOnElement(MENU_SELECTORS.MENU.products).then(() => {
cy.get(MENU_SELECTORS.CATALOG.giftCards).should("be.visible");
expectMainMenuAvailableSections(3);
cy.addAliasToGraphRequest("GiftCardList")
.clickOnElement(MENU_SELECTORS.CATALOG.giftCards)
.waitForRequestAndCheckIfNoErrors("@GiftCardList");
});
},
);
it(
`should be able to navigate through shop as a staff member using PAGE permission. TC: SALEOR_3408 - page list`,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.visitHomePageLoggedViaApi(PERMISSIONS_OPTIONS.page.user);
expectMainMenuAvailableSections(3);
expectMainMenuSectionsToBeVisible(MENU_SELECTORS.MENU.pages);
cy.addAliasToGraphRequest("SearchPageTypes")
.clickOnElement(MENU_SELECTORS.MENU.pages)
.waitForRequestAndCheckIfNoErrors("@SearchPageTypes")
.then(() => {
cy.checkIfElementIsVisible(PAGES_LIST_SELECTORS.createPageButton);
cy.clickOnElement(MENU_SELECTORS.MENU.configuration).then(() => {
expectConfigurationAvailableSectionsNumber(3);
expectConfigurationSectionsToBeVisible(
CONFIGURATION_SELECTORS.taxes,
CONFIGURATION_SELECTORS.webhooks,
CONFIGURATION_SELECTORS.pageTypes,
);
});
});
},
);
it(
`should be able to navigate through shop as a staff member using PAGE - permission. TC: SALEOR_3408b - page types list `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.addAliasToGraphRequest("PageTypeList")
.loginUserViaRequest("auth", PERMISSIONS_OPTIONS.page.user)
.visit(urlList.pageTypes)
.waitForRequestAndCheckIfNoErrors("@PageTypeList");
expectMainMenuAvailableSections(3);
cy.checkIfElementIsVisible(
PAGE_TYPES_LIST_SELECTORS.createPageTypeButton,
);
},
);
it(
`should be able to navigate through shop as a staff member using PLUGIN permission. TC: SALEOR_3409 - plugins list `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.visitHomePageLoggedViaApi(PERMISSIONS_OPTIONS.plugin.user);
expectMainMenuAvailableSections(2);
cy.clickOnElement(MENU_SELECTORS.MENU.configuration).then(() => {
expectConfigurationAvailableSectionsNumber(3);
expectConfigurationSectionsToBeVisible(
CONFIGURATION_SELECTORS.taxes,
CONFIGURATION_SELECTORS.webhooks,
CONFIGURATION_SELECTORS.plugin,
);
cy.addAliasToGraphRequest("Plugins")
.clickOnElement(CONFIGURATION_SELECTORS.plugin)
.waitForRequestAndCheckIfNoErrors("@Plugins");
cy.checkIfElementIsVisible(PLUGINS_LIST_SELECTORS.pluginRow);
});
},
);
it(
`should be able to navigate through shop as a staff member using PRODUCT TYPE AND ATTRIBUTE permission. TC: SALEOR_3411 - product type list `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.visitHomePageLoggedViaApi(
PERMISSIONS_OPTIONS.productTypeAndAttribute.user,
);
expectMainMenuAvailableSections(2);
cy.clickOnElement(MENU_SELECTORS.MENU.configuration).then(() => {
expectConfigurationAvailableSectionsNumber(4);
expectConfigurationSectionsToBeVisible(
CONFIGURATION_SELECTORS.taxes,
CONFIGURATION_SELECTORS.productTypes,
CONFIGURATION_SELECTORS.attributes,
CONFIGURATION_SELECTORS.webhooks,
);
cy.addAliasToGraphRequest("ProductTypeList")
.clickOnElement(CONFIGURATION_SELECTORS.productTypes)
.waitForRequestAndCheckIfNoErrors("@ProductTypeList");
cy.checkIfElementIsVisible(
PRODUCT_TYPES_LIST_SELECTORS.addProductTypeButton,
);
});
},
);
// //TODO fix when permissions bug is fixed
it.skip(
`should be able to navigate through shop as a staff member using PRODUCT TYPE AND ATTRIBUTE permission. TC: SALEOR_3411b - attribute list `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.addAliasToGraphRequest("AttributeList")
.loginUserViaRequest(
"auth",
PERMISSIONS_OPTIONS.productTypeAndAttribute.user,
)
.visit(urlList.attributes)
.waitForRequestAndCheckIfNoErrors("@AttributeList");
// expectMainMenuAvailableSections(2);
cy.checkIfElementIsVisible(ATTRIBUTES_LIST.createAttributeButton);
},
);
it(
`should be able to navigate through shop as a staff member using PAGE TYPE AND ATTRIBUTE permission. TC: SALEOR_3412 - page type list`,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.visitHomePageLoggedViaApi(
PERMISSIONS_OPTIONS.pageTypeAndAttribute.user,
);
expectMainMenuAvailableSections(2);
cy.clickOnElement(MENU_SELECTORS.MENU.configuration).then(() => {
expectConfigurationAvailableSectionsNumber(4);
expectConfigurationSectionsToBeVisible(
CONFIGURATION_SELECTORS.taxes,
CONFIGURATION_SELECTORS.attributes,
CONFIGURATION_SELECTORS.webhooks,
CONFIGURATION_SELECTORS.pageTypes,
);
cy.addAliasToGraphRequest("PageTypeList")
.clickOnElement(CONFIGURATION_SELECTORS.pageTypes)
.waitForRequestAndCheckIfNoErrors("@PageTypeList");
cy.checkIfElementIsVisible(
PAGE_TYPES_LIST_SELECTORS.createPageTypeButton,
);
});
},
);
it(
`should be able to navigate through shop as a staff member using SETTINGS permission. TC: SALEOR_3413 - company settings `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.visitHomePageLoggedViaApi(PERMISSIONS_OPTIONS.settings.user);
expectMainMenuAvailableSections(2);
cy.clickOnElement(MENU_SELECTORS.MENU.configuration).then(() => {
expectConfigurationAvailableSectionsNumber(3);
expectConfigurationSectionsToBeVisible(
CONFIGURATION_SELECTORS.taxes,
CONFIGURATION_SELECTORS.settings,
CONFIGURATION_SELECTORS.webhooks,
);
cy.addAliasToGraphRequest("SiteSettings")
.clickOnElement(CONFIGURATION_SELECTORS.settings)
.waitForRequestAndCheckIfNoErrors("@SiteSettings");
cy.get(ADDRESS_SELECTORS.companyInfoSection)
.scrollIntoView()
.should("be.visible");
});
},
);
it(
`should be able to navigate through shop as a staff member using STAFF permission. TC: SALEOR_3414 - staff list `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.visitHomePageLoggedViaApi(PERMISSIONS_OPTIONS.staff.user);
expectMainMenuAvailableSections(2);
cy.clickOnElement(MENU_SELECTORS.MENU.configuration).then(() => {
expectConfigurationAvailableSectionsNumber(4);
expectConfigurationSectionsToBeVisible(
CONFIGURATION_SELECTORS.taxes,
CONFIGURATION_SELECTORS.permissionGroups,
CONFIGURATION_SELECTORS.staffMembers,
CONFIGURATION_SELECTORS.webhooks,
);
cy.addAliasToGraphRequest("StaffList")
.clickOnElement(CONFIGURATION_SELECTORS.staffMembers)
.waitForRequestAndCheckIfNoErrors("@StaffList");
cy.checkIfElementIsVisible(
STAFF_MEMBERS_LIST_SELECTORS.inviteStaffMemberButton,
);
});
},
);
it(
`should be able to navigate through shop as a staff member using STAFF permission. TC: SALEOR_3414b - permission group `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.addAliasToGraphRequest("PermissionGroupList")
.loginUserViaRequest("auth", PERMISSIONS_OPTIONS.staff.user)
.visit(urlList.permissionsGroups)
.waitForRequestAndCheckIfNoErrors("@PermissionGroupList");
expectMainMenuAvailableSections(2);
cy.checkIfElementIsVisible(
PERMISSION_GROUP_LIST_SELECTORS.createPermissionButton,
);
},
);
it(
`should be able to navigate through shop as a staff member using SHIPPING permission. TC: SALEOR_3415 - shipping zones `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.visitHomePageLoggedViaApi(PERMISSIONS_OPTIONS.shipping.user);
expectMainMenuAvailableSections(2);
cy.clickOnElement(MENU_SELECTORS.MENU.configuration).then(() => {
expectConfigurationAvailableSectionsNumber(3);
expectConfigurationSectionsToBeVisible(
CONFIGURATION_SELECTORS.taxes,
CONFIGURATION_SELECTORS.shipping,
CONFIGURATION_SELECTORS.webhooks,
);
cy.addAliasToGraphRequest("ShippingZones")
.clickOnElement(CONFIGURATION_SELECTORS.shipping)
.waitForRequestAndCheckIfNoErrors("@ShippingZones");
cy.checkIfElementIsVisible(
SHIPPING_ZONES_LIST_SELECTORS.addShippingZone,
);
});
},
);
it(
`should be able to navigate through shop as a staff member using TRANSLATION permission. TC: SALEOR_3416 - translations list `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.visitHomePageLoggedViaApi(PERMISSIONS_OPTIONS.translations.user);
expectMainMenuAvailableSections(2);
cy.clickOnElement(MENU_SELECTORS.MENU.translations).then(() => {
cy.checkIfElementIsVisible(
LANGUAGES_LIST_SELECTORS.translationListView,
);
});
},
);
it(
`should be able to navigate through shop as a staff member using PRODUCT permission. TC: SALEOR_3410a - products list `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.visitHomePageLoggedViaApi(PERMISSIONS_OPTIONS.product.user);
cy.addAliasToGraphRequest("ProductList")
.clickOnElement(MENU_SELECTORS.MENU.products)
.waitForRequestAndCheckIfNoErrors("@ProductList")
.then(() => {
cy.get(MENU_SELECTORS.CATALOG.products).last().should("be.visible");
cy.get(MENU_SELECTORS.CATALOG.categories).should("be.visible");
cy.get(MENU_SELECTORS.CATALOG.collections).should("be.visible");
expectMainMenuAvailableSections(5);
});
},
);
it(
`should be able to navigate through shop as a staff member using PRODUCT permission. TC: SALEOR_3410b - categories list `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.addAliasToGraphRequest("RootCategories")
.loginUserViaRequest("auth", PERMISSIONS_OPTIONS.product.user)
.visit(urlList.categories)
.waitForRequestAndCheckIfNoErrors("@RootCategories");
expectMainMenuAvailableSections(5);
cy.checkIfElementIsVisible(CATEGORIES_LIST_SELECTORS.addCategoryButton);
},
);
it(
`should be able to navigate through shop as a staff member using PRODUCT permission. TC: SALEOR_3410c - collections list `,
{ tags: ["@allEnv", "@navigation", "@stable", "@oldRelease", "@critical"] },
() => {
cy.addAliasToGraphRequest("CollectionList")
.loginUserViaRequest("auth", PERMISSIONS_OPTIONS.product.user)
.visit(urlList.collections)
.waitForRequestAndCheckIfNoErrors("@CollectionList");
expectMainMenuAvailableSections(5);
cy.checkIfElementIsVisible(COLLECTION_SELECTORS.createCollectionButton);
},
);
});

View file

@ -52,9 +52,7 @@ xdescribe("Channels in draft orders", () => {
channelName = channelInHeader;
},
);
cy.visit(urlList.orders)
.get(ORDERS_SELECTORS.createOrder)
.click();
cy.visit(urlList.orders).get(ORDERS_SELECTORS.createOrderButton).click();
cy.getTextFromElement(CHANNEL_FORM_SELECTORS.channelSelect).then(
selectedChannelName => {
expect(channelName).to.contains(selectedChannelName);
@ -76,7 +74,7 @@ xdescribe("Channels in draft orders", () => {
cy.visit(urlList.homePage);
selectChannelInHeader(otherChannel.name);
cy.visit(urlList.orders);
cy.get(ORDERS_SELECTORS.createOrder).click();
cy.get(ORDERS_SELECTORS.createOrderButton).click();
cy.getTextFromElement(CHANNEL_FORM_SELECTORS.channelSelect).then(
channelInSelect => {
expect(channelInSelect).to.be.eq(otherChannel.name);
@ -98,7 +96,7 @@ xdescribe("Channels in draft orders", () => {
cy.visit(urlList.homePage);
selectChannelInHeader(defaultChannel.name);
cy.visit(urlList.orders);
cy.get(ORDERS_SELECTORS.createOrder).click();
cy.get(ORDERS_SELECTORS.createOrderButton).click();
cy.getTextFromElement(CHANNEL_FORM_SELECTORS.channelSelect).then(
channelInSelect => {
expect(channelInSelect).to.be.eq(defaultChannel.name);

View file

@ -91,7 +91,7 @@ xdescribe("Draft orders", () => {
() => {
cy.visit(urlList.orders);
cy.expectSkeletonIsVisible();
cy.get(ORDERS_SELECTORS.createOrder).click();
cy.get(ORDERS_SELECTORS.createOrderButton).click();
selectChannelInPicker(defaultChannel.name);
finalizeDraftOrder(randomName, address).then(draftOrderNumber => {
cy.visit(urlList.orders);

View file

@ -127,7 +127,7 @@ describe("Orders", () => {
"should create order with selected channel. TC: SALEOR_2104",
{ tags: ["@orders", "@allEnv", "@stable", "@oldRelease"] },
() => {
cy.visit(urlList.orders).get(ORDERS_SELECTORS.createOrder).click();
cy.visit(urlList.orders).get(ORDERS_SELECTORS.createOrderButton).click();
selectChannelInPicker(defaultChannel.name);
finalizeDraftOrder(randomName, address);
},

View file

@ -3,8 +3,8 @@
import faker from "faker";
import { PAGE_TYPE_DETAILS } from "../../elements/pageTypes/pageTypeDetails";
import { PAGE_TYPES_LIST } from "../../elements/pageTypes/pageTypesList";
import { PAGE_TYPE_DETAILS_SELECTORS } from "../../elements/pageTypes/pageTypeDetails";
import { PAGE_TYPES_LIST_SELECTORS } from "../../elements/pageTypes/pageTypesList";
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
import { pageTypeDetailsUrl, urlList } from "../../fixtures/urlList";
@ -28,9 +28,9 @@ describe("Tests for page types", () => {
const randomName = startsWith + faker.datatype.number();
cy.visit(urlList.pageTypes)
.get(PAGE_TYPES_LIST.createPageTypeButton)
.get(PAGE_TYPES_LIST_SELECTORS.createPageTypeButton)
.click()
.get(PAGE_TYPE_DETAILS.nameInput)
.get(PAGE_TYPE_DETAILS_SELECTORS.nameInput)
.type(randomName)
.addAliasToGraphRequest("PageTypeCreate")
.get(BUTTON_SELECTORS.confirm)
@ -59,7 +59,7 @@ describe("Tests for page types", () => {
cy.visit(pageTypeDetailsUrl(pageType.id))
.get(SHARED_ELEMENTS.progressBar)
.should("be.not.visible")
.get(PAGE_TYPE_DETAILS.assignAttributesButton)
.get(PAGE_TYPE_DETAILS_SELECTORS.assignAttributesButton)
.click()
.assignElements(randomName)
.confirmationMessageShouldDisappear();

View file

@ -3,7 +3,7 @@
import faker from "faker";
import { PAGE_DETAILS } from "../../elements/pages/page-details";
import { PAGE_DETAILS_SELECTORS } from "../../elements/pages/page-details";
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { pageDetailsUrl } from "../../fixtures/urlList";
import { createAttribute } from "../../support/api/requests/Attribute";
@ -161,9 +161,9 @@ describe("Tests for pages", () => {
})
.then(({ page }) => {
cy.visit(pageDetailsUrl(page.id))
.get(PAGE_DETAILS.nameInput)
.get(PAGE_DETAILS_SELECTORS.nameInput)
.clearAndType(updatedName)
.get(PAGE_DETAILS.isNotPublishedCheckbox)
.get(PAGE_DETAILS_SELECTORS.isNotPublishedCheckbox)
.click()
.addAliasToGraphRequest("PageUpdate")
.get(BUTTON_SELECTORS.confirm)

View file

@ -7,9 +7,9 @@ import { LEFT_MENU_SELECTORS } from "../elements/account/left-menu/left-menu-sel
import { LOGIN_SELECTORS } from "../elements/account/login-selectors";
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../elements/shared/sharedElements";
import { INVITE_STAFF_MEMBER_FORM } from "../elements/staffMembers/inviteStaffMemberForm";
import { STAFF_MEMBER_DETAILS } from "../elements/staffMembers/staffMemberDetails";
import { STAFF_MEMBERS_LIST } from "../elements/staffMembers/staffMembersList";
import { INVITE_STAFF_MEMBER_FORM_SELECTORS } from "../elements/staffMembers/inviteStaffMemberForm";
import { STAFF_MEMBER_DETAILS_SELECTORS } from "../elements/staffMembers/staffMemberDetails";
import { STAFF_MEMBERS_LIST_SELECTORS } from "../elements/staffMembers/staffMembersList";
import { urlList, userDetailsUrl } from "../fixtures/urlList";
import { TEST_ADMIN_USER } from "../fixtures/users";
import { activatePlugin, updatePlugin } from "../support/api/requests/Plugins";
@ -70,7 +70,7 @@ describe("Staff members", () => {
cy.visit(urlList.staffMembers)
.expectSkeletonIsVisible()
.get(STAFF_MEMBERS_LIST.inviteStaffMemberButton)
.get(STAFF_MEMBERS_LIST_SELECTORS.inviteStaffMemberButton)
.click({ force: true });
fillUpUserDetailsAndAddFirstPermission(firstName, lastName, emailInvite);
getMailActivationLinkForUser(emailInvite).then(urlLink => {
@ -122,7 +122,7 @@ describe("Staff members", () => {
const serverStoredEmail = email.toLowerCase();
cy.visit(userDetailsUrl(user.id))
.get(STAFF_MEMBER_DETAILS.removePermissionButton)
.get(STAFF_MEMBER_DETAILS_SELECTORS.removePermissionButton)
.click()
.addAliasToGraphRequest("StaffMemberUpdate")
.get(BUTTON_SELECTORS.confirm)
@ -186,10 +186,10 @@ describe("Staff members", () => {
const emailInvite = TEST_ADMIN_USER.email;
cy.visit(urlList.staffMembers)
.expectSkeletonIsVisible()
.get(STAFF_MEMBERS_LIST.inviteStaffMemberButton)
.get(STAFF_MEMBERS_LIST_SELECTORS.inviteStaffMemberButton)
.click({ force: true });
fillUpOnlyUserDetails(firstName, lastName, emailInvite);
cy.get(INVITE_STAFF_MEMBER_FORM.emailValidationMessage).should(
cy.get(INVITE_STAFF_MEMBER_FORM_SELECTORS.emailValidationMessage).should(
"be.visible",
);
cy.get(BUTTON_SELECTORS.dialogBackButton).click();
@ -206,13 +206,15 @@ describe("Staff members", () => {
.get(SHARED_ELEMENTS.searchInput)
.type(`${email} {enter}`);
cy.waitForProgressBarToNotExist();
cy.get(STAFF_MEMBERS_LIST.staffAvatar).first().should("be.visible");
cy.get(STAFF_MEMBERS_LIST_SELECTORS.staffAvatar)
.first()
.should("be.visible");
cy.waitForProgressBarToNotExist()
.get(STAFF_MEMBERS_LIST.staffStatusText)
.get(STAFF_MEMBERS_LIST_SELECTORS.staffStatusText)
.first()
.should("be.visible")
.click();
cy.get(STAFF_MEMBER_DETAILS.staffEmail)
cy.get(STAFF_MEMBER_DETAILS_SELECTORS.staffEmail)
.click()
.clear()
.type(`${TEST_ADMIN_USER.email} {enter}`)
@ -250,9 +252,15 @@ describe("Staff members", () => {
cy.visit(urlList.staffMembers).get(LOGIN_SELECTORS.userMenu).click();
cy.get(LOGIN_SELECTORS.accountSettings).click();
cy.get(STAFF_MEMBER_DETAILS.staffFirstName).clear().type("สมชาย");
cy.get(STAFF_MEMBER_DETAILS.staffLastName).clear().type(newLastName);
cy.get(STAFF_MEMBER_DETAILS.staffEmail).clear().type(changedEmail);
cy.get(STAFF_MEMBER_DETAILS_SELECTORS.staffFirstName)
.clear()
.type("สมชาย");
cy.get(STAFF_MEMBER_DETAILS_SELECTORS.staffLastName)
.clear()
.type(newLastName);
cy.get(STAFF_MEMBER_DETAILS_SELECTORS.staffEmail)
.clear()
.type(changedEmail);
// Test blocked from this point by https://github.com/saleor/saleor-dashboard/issues/2847
cy.get(BUTTON_SELECTORS.confirm).confirmationMessageShouldAppear();
@ -292,13 +300,13 @@ describe("Staff members", () => {
cy.visit(urlList.staffMembers).get(LOGIN_SELECTORS.userMenu).click();
cy.get(LOGIN_SELECTORS.accountSettings).click();
cy.get(STAFF_MEMBER_DETAILS.changePasswordBtn).click();
cy.get(STAFF_MEMBER_DETAILS.changePasswordModal.oldPassword).type(
Cypress.env("USER_PASSWORD"),
);
cy.get(STAFF_MEMBER_DETAILS.changePasswordModal.newPassword).type(
newPass,
);
cy.get(STAFF_MEMBER_DETAILS_SELECTORS.changePasswordBtn).click();
cy.get(
STAFF_MEMBER_DETAILS_SELECTORS.changePasswordModal.oldPassword,
).type(Cypress.env("USER_PASSWORD"));
cy.get(
STAFF_MEMBER_DETAILS_SELECTORS.changePasswordModal.newPassword,
).type(newPass);
cy.get(BUTTON_SELECTORS.submit).click().confirmationMessageShouldAppear();
cy.clearSessionData().loginUserViaRequest("auth", {

View file

@ -0,0 +1,5 @@
import * as MENU_SELECTORS from "./left-menu/left-menu-selectors";
import * as LOGIN_SELECTORS from "./login-selectors";
import * as SET_PASSWORD_SELECTORS from "./login-selectors";
export { MENU_SELECTORS, LOGIN_SELECTORS, SET_PASSWORD_SELECTORS };

View file

@ -1,4 +1,4 @@
export const LEFT_MENU_SELECTORS = {
export const MENU = {
catalog: "[data-test-id='menu-item-label-catalogue']",
pages: "[data-test-id='menu-item-label-pages']",
configuration: "[data-test-id='menu-item-label-configure']",
@ -9,8 +9,12 @@ export const LEFT_MENU_SELECTORS = {
app: "[data-test-id='menu-item-label-apps']",
translations: "[data-test-id='menu-item-label-translations']",
customers: "[data-test-id='menu-item-label-customers']",
list: "[data-test-id='menu-list']",
listItem: "[data-test-id='menu-list-item']",
products: "[data-test-id='menu-item-label-products']",
menuItem: "[data-test-id*='menu-item-label-']",
};
export const DISCOUNTS_MENU_SELECTORS = {
export const DISCOUNTS = {
sales: "[data-test-id='menu-item-label-sales']",
vouchers: "[data-test-id='menu-item-label-vouchers']",
};
@ -22,9 +26,10 @@ export const CATALOG = {
products: "[data-test-id='menu-item-label-products']",
categories: "[data-test-id='menu-item-label-categories']",
collections: "[data-test-id='menu-item-label-collections']",
giftCards: "[data-test-id='menu-item-label-giftCards']",
};
export const APP_MENU_SELECTORS = {
export const APP = {
app: "[data-test-id='menu-item-label-apps']",
};

View file

@ -1,3 +1,4 @@
export const APPS_LIST = {
export const APPS_LIST_SELECTORS = {
createLocalAppButton: '[data-test-id="create-app"]',
createExternalAppButton: '[data-test-id="add-app-from-manifest"]',
};

View file

@ -0,0 +1,3 @@
import { APPS_LIST_SELECTORS } from "./appsList";
export { APPS_LIST_SELECTORS };

View file

@ -0,0 +1,4 @@
import { ATTRIBUTES_DETAILS } from "./attributes_details";
import { ATTRIBUTES_LIST } from "./attributes_list";
export { ATTRIBUTES_DETAILS, ATTRIBUTES_LIST };

View file

@ -1,5 +1,5 @@
export const CATEGORIES_LIST = {
addCategoryButton: '[data-test-id="create-category"]'
export const CATEGORIES_LIST_SELECTORS = {
addCategoryButton: '[data-test-id="create-category"]',
};
export const categoryRow = categoryId => `[data-test-id*="${categoryId}"]`;

View file

@ -1,4 +1,4 @@
export const CATEGORY_DETAILS = {
export const CATEGORY_DETAILS_SELECTORS = {
nameInput: '[name="name"]',
descriptionInput: '[data-test-id="rich-text-editor-description"]',
createSubcategoryButton: '[data-test-id="create-subcategory"]',

View file

@ -0,0 +1,4 @@
import { CATEGORIES_LIST_SELECTORS } from "./categories-list";
import { CATEGORY_DETAILS_SELECTORS } from "./category-details";
export { CATEGORIES_LIST_SELECTORS, CATEGORY_DETAILS_SELECTORS };

View file

@ -0,0 +1,11 @@
import {
CATEGORIES_LIST_SELECTORS,
CATEGORY_DETAILS_SELECTORS,
} from "./categories";
import { COLLECTION_SELECTORS } from "./collection-selectors";
export {
CATEGORIES_LIST_SELECTORS,
CATEGORY_DETAILS_SELECTORS,
COLLECTION_SELECTORS,
};

View file

@ -0,0 +1,3 @@
import { CHANNELS_SELECTORS } from "./channels-selectors";
export { CHANNELS_SELECTORS };

View file

@ -2,6 +2,7 @@ export const CONFIGURATION_SELECTORS = {
channels: "[data-test-id*='channels']",
shipping: '[data-test-id*="shipping methods"]',
taxes: '[data-test-id*="configuration-menu-taxes"]',
webhooks: '[data-test-id*="configuration-menu-webhooks"]',
settings: '[data-test-id*="configuration-menu-site-settings"]',
pageTypes: '[data-test-id*="configuration-menu-page-types"]',
navigation: '[data-test-id*="configuration-menu-navigation"]',
@ -10,5 +11,7 @@ export const CONFIGURATION_SELECTORS = {
attributes: '[data-test-id*="configuration-menu-attributes"]',
productTypes: '[data-test-id*="configuration-menu-product-types"]',
plugin: '[data-test-id*="configuration-plugins-pages"]',
warehouse: '[data-test-id*="configuration-menu-warehouses"]'
warehouse: '[data-test-id*="configuration-menu-warehouses"]',
configurationMenu: "[data-test-id='configuration-menu']",
configurationMenuItem: "[data-test-id='configuration-menu-item']",
};

View file

@ -1,4 +1,4 @@
export const CUSTOMER_DETAILS = {
export const CUSTOMER_DETAILS_SELECTORS = {
nameInput: '[name="firstName"]',
customerAddressNameInput: '[name="customerFirstName"]',
lastNameInput: '[name="lastName"]',

View file

@ -1,3 +1,3 @@
export const CUSTOMERS_LIST = {
createCustomerButton: '[data-test-id="create-customer"]'
export const CUSTOMERS_LIST_SELECTORS = {
createCustomerButton: '[data-test-id="create-customer"]',
};

View file

@ -0,0 +1,4 @@
import { CUSTOMER_DETAILS_SELECTORS } from "./customer-details";
import { CUSTOMERS_LIST_SELECTORS } from "./customers-list";
export { CUSTOMER_DETAILS_SELECTORS, CUSTOMERS_LIST_SELECTORS };

View file

@ -1,3 +1,3 @@
export const CUSTOMER_DETAILS = {
isActiveCheckbox: '[name="isActive"]'
export const CUSTOMER_DETAILS_SELECTORS = {
isActiveCheckbox: '[name="isActive"]',
};

View file

@ -0,0 +1,4 @@
import { SALES_SELECTORS } from "./sales";
import { VOUCHERS_SELECTORS } from "./vouchers";
export { SALES_SELECTORS, VOUCHERS_SELECTORS };

79
cypress/elements/index.js Normal file
View file

@ -0,0 +1,79 @@
import {
LOGIN_SELECTORS,
MENU_SELECTORS,
SET_PASSWORD_SELECTORS,
} from "./account/";
import { APPS_LIST_SELECTORS } from "./apps";
import { ATTRIBUTES_DETAILS, ATTRIBUTES_LIST } from "./attribute";
import {
CATEGORIES_LIST_SELECTORS,
CATEGORY_DETAILS_SELECTORS,
COLLECTION_SELECTORS,
} from "./catalog";
import { CHANNELS_SELECTORS } from "./channels";
import { CONFIGURATION_SELECTORS } from "./configuration/configuration-selectors";
import {
CUSTOMER_DETAILS_SELECTORS,
CUSTOMERS_LIST_SELECTORS,
} from "./customer/";
import { SALES_SELECTORS, VOUCHERS_SELECTORS } from "./discounts";
import { DRAFT_ORDERS_LIST_SELECTORS, ORDERS_SELECTORS } from "./orders";
import { PAGE_DETAILS_SELECTORS, PAGES_LIST_SELECTORS } from "./pages/";
import {
PAGE_TYPE_DETAILS_SELECTORS,
PAGE_TYPES_LIST_SELECTORS,
} from "./pageTypes";
import {
PERMISSION_GROUP_DETAILS_SELECTORS,
PERMISSION_GROUP_LIST_SELECTORS,
} from "./permissionGroup";
import { PLUGINS_DETAILS_SELECTORS, PLUGINS_LIST_SELECTORS } from "./plugins";
import {
PRODUCT_TYPE_DETAILS_SELECTORS,
PRODUCT_TYPES_LIST_SELECTORS,
} from "./productTypes";
import { ADDRESS_SELECTORS, SHARED_ELEMENTS } from "./shared";
import { SHIPPING_ZONES_LIST_SELECTORS } from "./shipping";
import {
INVITE_STAFF_MEMBER_FORM_SELECTORS,
STAFF_MEMBER_DETAILS_SELECTORS,
STAFF_MEMBERS_LIST_SELECTORS,
} from "./staffMembers";
import { LANGUAGES_LIST_SELECTORS } from "./translations";
export {
ADDRESS_SELECTORS,
APPS_LIST_SELECTORS,
ATTRIBUTES_DETAILS,
ATTRIBUTES_LIST,
CATEGORIES_LIST_SELECTORS,
CATEGORY_DETAILS_SELECTORS,
CHANNELS_SELECTORS,
COLLECTION_SELECTORS,
CONFIGURATION_SELECTORS,
CUSTOMER_DETAILS_SELECTORS,
CUSTOMERS_LIST_SELECTORS,
DRAFT_ORDERS_LIST_SELECTORS,
INVITE_STAFF_MEMBER_FORM_SELECTORS,
LANGUAGES_LIST_SELECTORS,
LOGIN_SELECTORS,
MENU_SELECTORS,
ORDERS_SELECTORS,
PAGE_DETAILS_SELECTORS,
PAGE_TYPE_DETAILS_SELECTORS,
PAGE_TYPES_LIST_SELECTORS,
PAGES_LIST_SELECTORS,
PERMISSION_GROUP_DETAILS_SELECTORS,
PERMISSION_GROUP_LIST_SELECTORS,
PLUGINS_DETAILS_SELECTORS,
PLUGINS_LIST_SELECTORS,
PRODUCT_TYPE_DETAILS_SELECTORS,
PRODUCT_TYPES_LIST_SELECTORS,
SALES_SELECTORS,
SET_PASSWORD_SELECTORS,
SHARED_ELEMENTS,
SHIPPING_ZONES_LIST_SELECTORS,
STAFF_MEMBER_DETAILS_SELECTORS,
STAFF_MEMBERS_LIST_SELECTORS,
VOUCHERS_SELECTORS,
};

View file

@ -1,3 +1,4 @@
export const DRAFT_ORDERS_LIST_SELECTORS = {
draftOrderRow: "[data-test-id='draft-order-table-row']"
draftOrderRow: "[data-test-id='draft-order-table-row']",
createDraftOrderButton: "[data-test-id='create-draft-order-button']",
};

View file

@ -0,0 +1,4 @@
import { DRAFT_ORDERS_LIST_SELECTORS } from "./draft-orders-list-selectors";
import { ORDERS_SELECTORS } from "./orders-selectors";
export { DRAFT_ORDERS_LIST_SELECTORS, ORDERS_SELECTORS };

View file

@ -1,6 +1,6 @@
export const ORDERS_SELECTORS = {
orders: "[data-test-id='menu-item-label'][data-test-id='orders']",
createOrder: "[data-test-id='create-order-button']",
createOrderButton: "[data-test-id='create-order-button']",
orderRow: "[data-test-id='order-table-row']",
salesChannel: "[data-test-id='order-sales-channel']",
cancelFulfillment: "[data-test-id='cancel-fulfillment-button']",

View file

@ -0,0 +1,4 @@
import { PAGE_TYPE_DETAILS_SELECTORS } from "./pageTypeDetails";
import { PAGE_TYPES_LIST_SELECTORS } from "./pageTypesList";
export { PAGE_TYPE_DETAILS_SELECTORS, PAGE_TYPES_LIST_SELECTORS };

View file

@ -1,4 +1,4 @@
export const PAGE_TYPE_DETAILS = {
export const PAGE_TYPE_DETAILS_SELECTORS = {
nameInput: '[name="name"]',
assignAttributesButton: '[data-test-id="assign-attributes"]'
assignAttributesButton: '[data-test-id="assign-attributes"]',
};

View file

@ -1,3 +1,3 @@
export const PAGE_TYPES_LIST = {
createPageTypeButton: '[data-test-id="create-page-type"]'
export const PAGE_TYPES_LIST_SELECTORS = {
createPageTypeButton: '[data-test-id="create-page-type"]',
};

View file

@ -0,0 +1,4 @@
import { PAGE_DETAILS_SELECTORS } from "./page-details";
import { PAGES_LIST_SELECTORS } from "./pages-list";
export { PAGE_DETAILS_SELECTORS, PAGES_LIST_SELECTORS };

View file

@ -1,4 +1,4 @@
export const PAGE_DETAILS = {
export const PAGE_DETAILS_SELECTORS = {
nameInput: '[name="title"]',
pageTypesAutocompleteSelect:
'[data-test-id="page-types-autocomplete-select"]',

View file

@ -1,4 +1,4 @@
export const PAGES_LIST = {
export const PAGES_LIST_SELECTORS = {
createPageButton: '[data-test-id="create-page"]',
dialogPageTypeInput: "[data-test-id='dialog-page-type']",
};

View file

@ -0,0 +1,4 @@
import { PERMISSION_GROUP_DETAILS_SELECTORS } from "./permissionGroupDetails";
import { PERMISSION_GROUP_LIST_SELECTORS } from "./permissionGroupsList";
export { PERMISSION_GROUP_DETAILS_SELECTORS, PERMISSION_GROUP_LIST_SELECTORS };

View file

@ -1,4 +1,4 @@
export const PERMISSION_GROUP_DETAILS = {
export const PERMISSION_GROUP_DETAILS_SELECTORS = {
nameInput: '[name="name"]',
productsPermissionCheckbox: '[name="MANAGE_PRODUCTS"]',
productsTypesAndAttributesPermissionCheckbox:

View file

@ -1,4 +1,4 @@
export const PERMISSION_GROUP_LIST = {
export const PERMISSION_GROUP_LIST_SELECTORS = {
createPermissionButton: '[data-test-id="create-permission-group"]',
permissionGroupRow: '[data-test-id*="id-"]'
permissionGroupRow: '[data-test-id*="id-"]',
};

View file

@ -0,0 +1,4 @@
import { PLUGINS_DETAILS_SELECTORS } from "./pluginDetails";
import { PLUGINS_LIST_SELECTORS } from "./pluginsList";
export { PLUGINS_DETAILS_SELECTORS, PLUGINS_LIST_SELECTORS };

View file

@ -1,5 +1,5 @@
export const PLUGINS_DETAILS = {
export const PLUGINS_DETAILS_SELECTORS = {
channel: '[data-test-id="channel"]',
accountConfirmationSubjectInput: '[name="account_confirmation_subject"]',
staffPasswordResetInput: '[name="staff_password_reset_subject"]'
staffPasswordResetInput: '[name="staff_password_reset_subject"]',
};

View file

@ -1,3 +1,3 @@
export const PLUGINS_LIST = {
pluginRow: '[data-test-id="plugin"]'
export const PLUGINS_LIST_SELECTORS = {
pluginRow: '[data-test-id="plugin"]',
};

View file

@ -0,0 +1,4 @@
import { PRODUCT_TYPE_DETAILS_SELECTORS } from "./productTypeDetails";
import { PRODUCT_TYPES_LIST_SELECTORS } from "./productTypesList";
export { PRODUCT_TYPE_DETAILS_SELECTORS, PRODUCT_TYPES_LIST_SELECTORS };

View file

@ -1,4 +1,4 @@
export const PRODUCT_TYPE_DETAILS = {
export const PRODUCT_TYPE_DETAILS_SELECTORS = {
nameInput: '[name="name"]',
isShippingRequired: '[name="isShippingRequired"]',
assignProductAttributeButton: '[data-test-id="assign-products-attributes"]',
@ -6,5 +6,5 @@ export const PRODUCT_TYPE_DETAILS = {
hasVariantsButton: '[name="hasVariants"]',
shippingWeightInput: '[name="weight"]',
giftCardKindCheckbox: '[data-test-id="product-type-kind-option-GIFT_CARD"]',
variantSelectionCheckbox: '[data-test-id = "variant-selection-checkbox"]'
variantSelectionCheckbox: '[data-test-id = "variant-selection-checkbox"]',
};

View file

@ -1,3 +1,3 @@
export const PRODUCT_TYPES_LIST = {
addProductTypeButton: '[data-test-id="add-product-type"]'
export const PRODUCT_TYPES_LIST_SELECTORS = {
addProductTypeButton: '[data-test-id="add-product-type"]',
};

View file

@ -10,4 +10,5 @@ export const ADDRESS_SELECTORS = {
country: '[data-test-id="address-edit-country-select-field"]',
countryArea: '[data-test-id="address-edit-country-area-field"]',
saveButton: '[data-test-id="order-address-edit-dialog-confirm-button"]',
companyInfoSection: '[data-test-id="company-info"]',
};

View file

@ -0,0 +1,4 @@
import { SHARED_ELEMENTS } from "./sharedElements";
import { ADDRESS_SELECTORS } from "./addressForm";
export { SHARED_ELEMENTS, ADDRESS_SELECTORS };

View file

@ -0,0 +1,3 @@
import { SHIPPING_ZONES_LIST_SELECTORS } from "./shipping-zones-list";
export { SHIPPING_ZONES_LIST_SELECTORS };

View file

@ -1,7 +1,7 @@
export const SHIPPING_ZONES_LIST = {
export const SHIPPING_ZONES_LIST_SELECTORS = {
addShippingZone: "[data-test-id='add-shipping-zone']",
unitSelect: "[id='mui-component-select-unit']",
saveUnit: '[data-test-id="save-unit"]'
saveUnit: '[data-test-id="save-unit"]',
};
export const SHIPPING_ZONE_CHECKBOX = shippingId =>

View file

@ -0,0 +1,9 @@
import { INVITE_STAFF_MEMBER_FORM_SELECTORS } from "./inviteStaffMemberForm";
import { STAFF_MEMBER_DETAILS_SELECTORS } from "./staffMemberDetails";
import { STAFF_MEMBERS_LIST_SELECTORS } from "./staffMembersList";
export {
INVITE_STAFF_MEMBER_FORM_SELECTORS,
STAFF_MEMBER_DETAILS_SELECTORS,
STAFF_MEMBERS_LIST_SELECTORS,
};

View file

@ -1,4 +1,4 @@
export const INVITE_STAFF_MEMBER_FORM = {
export const INVITE_STAFF_MEMBER_FORM_SELECTORS = {
firstNameInput: '[name="firstName"]',
lastNameInput: '[name="lastName"]',
emailInput: '[name="email"]',

View file

@ -1,4 +1,4 @@
export const STAFF_MEMBER_DETAILS = {
export const STAFF_MEMBER_DETAILS_SELECTORS = {
permissionsSelect: '[data-test-id="permission-groups"]',
isActiveCheckBox: '[name="isActive"]',
removePermissionButton: '[data-test-id="remove"]',

View file

@ -1,4 +1,4 @@
export const STAFF_MEMBERS_LIST = {
export const STAFF_MEMBERS_LIST_SELECTORS = {
inviteStaffMemberButton: '[data-test-id="invite-staff-member"]',
staffStatusText: '[data-test-id="staffStatusText"]',
staffAvatar: '[data-test-id="staffAvatar"]',

View file

@ -0,0 +1,3 @@
import { LANGUAGES_LIST_SELECTORS } from "./languages-list";
export { LANGUAGES_LIST_SELECTORS };

View file

@ -1,3 +1,4 @@
export const LANGUAGES_LIST = {
polishLanguageButton: '[data-test-id="PL"]'
export const LANGUAGES_LIST_SELECTORS = {
polishLanguageButton: '[data-test-id="PL"]',
translationListView: '[data-test-id="translation-list-view"]',
};

View file

@ -2,7 +2,7 @@ import * as menuSelectors from "../elements/account/left-menu/left-menu-selector
import { CONFIGURATION_SELECTORS } from "../elements/configuration/configuration-selectors";
const configurationAsParent = {
parentMenuSelector: menuSelectors.LEFT_MENU_SELECTORS.configuration,
parentMenuSelector: menuSelectors.MENU.configuration,
parentSelectors: CONFIGURATION_SELECTORS,
};
@ -12,21 +12,21 @@ export const PERMISSIONS = {
permissionSelectors: [CONFIGURATION_SELECTORS.channels],
},
customer: {
permissionSelectors: [menuSelectors.LEFT_MENU_SELECTORS.customers],
permissionSelectors: [menuSelectors.MENU.customers],
},
discounts: {
parent: {
parentMenuSelector: menuSelectors.LEFT_MENU_SELECTORS.discounts,
parentSelectors: [menuSelectors.DISCOUNTS_MENU_SELECTORS],
parentMenuSelector: menuSelectors.MENU.discounts,
parentSelectors: [menuSelectors.DISCOUNTS],
},
permissionSelectors: [
menuSelectors.DISCOUNTS_MENU_SELECTORS.sales,
menuSelectors.DISCOUNTS_MENU_SELECTORS.vouchers,
menuSelectors.DISCOUNTS.sales,
menuSelectors.DISCOUNTS.vouchers,
],
},
order: {
parent: {
parentMenuSelector: menuSelectors.LEFT_MENU_SELECTORS.orders,
parentMenuSelector: menuSelectors.MENU.orders,
parentSelectors: menuSelectors.ORDERS,
},
permissionSelectors: [
@ -38,7 +38,7 @@ export const PERMISSIONS = {
parent: configurationAsParent,
permissionSelectors: [
CONFIGURATION_SELECTORS.pageTypes,
menuSelectors.LEFT_MENU_SELECTORS.pages,
menuSelectors.MENU.pages,
],
},
plugin: {
@ -47,7 +47,7 @@ export const PERMISSIONS = {
},
product: {
parent: {
parentMenuSelector: menuSelectors.LEFT_MENU_SELECTORS.catalog,
parentMenuSelector: menuSelectors.MENU.catalog,
parentSelectors: menuSelectors.CATALOG,
},
permissionSelectors: [
@ -89,7 +89,7 @@ export const PERMISSIONS = {
],
},
translations: {
permissionSelectors: [menuSelectors.LEFT_MENU_SELECTORS.translations],
permissionSelectors: [menuSelectors.MENU.translations],
},
warehouse: {
parent: configurationAsParent,

View file

@ -1,12 +1,7 @@
import { PERMISSIONS } from "./permissions";
import { ONE_PERMISSION_USERS, TEST_ADMIN_USER } from "./users";
import { ONE_PERMISSION_USERS } from "./users";
export const PERMISSIONS_OPTIONS = {
all: {
user: TEST_ADMIN_USER,
permissions: Object.values(PERMISSIONS),
testCase: "TC: SALEOR_3401",
},
app: {
user: ONE_PERMISSION_USERS.app,
permissions: [],

View file

@ -30,12 +30,13 @@ export const urlList = {
vouchers: "discounts/vouchers/",
variant: "variant/",
warehouses: "warehouses/",
webhooksAndEvents: "custom-apps/",
};
export const addVariantUrl = productId =>
`${urlList.products}${productId}/${urlList.variants}add`;
export const appDetailsUrl = appId => `${urlList.apps}${appId}`;
export const appDetailsUrl = appId => `${urlList.webhooksAndEvents}${appId}`;
export const attributeDetailsUrl = attributeId =>
`${urlList.attributes}${attributeId}`;

View file

@ -11,6 +11,9 @@ Cypress.Commands.add("clearAndType", { prevSubject: true }, (subject, text) => {
}
});
});
Cypress.Commands.add("clickOnElement", selector => {
cy.get(selector).click();
});
Cypress.Commands.add("waitForRequestAndCheckIfNoErrors", alias => {
cy.wait(alias).then(resp => {
@ -35,3 +38,6 @@ Cypress.Commands.add("checkIfDataAreNotNull", data => {
});
}
});
Cypress.Commands.add("checkIfElementIsVisible", element => {
cy.get(element).should("be.visible");
});

View file

@ -1,6 +1,7 @@
import "../../api/requests/utils/index";
import { LOGIN_SELECTORS } from "../../../elements/account/login-selectors";
import { urlList } from "../../../fixtures/urlList";
import { TEST_ADMIN_USER } from "../../../fixtures/users";
Cypress.Commands.add("loginUser", () =>
@ -17,6 +18,13 @@ Cypress.Commands.add("loginInShop", () => {
cy.loginUserViaRequest("token");
});
Cypress.Commands.add("visitHomePageLoggedViaApi", user => {
cy.addAliasToGraphRequest("Home")
.loginUserViaRequest("auth", user)
.visit(urlList.homePage)
.waitForRequestAndCheckIfNoErrors("@Home");
});
Cypress.Commands.add(
"loginUserViaRequest",
(authorization = "auth", user = TEST_ADMIN_USER) => {

View file

@ -1,4 +1,4 @@
import { CATEGORY_DETAILS } from "../../../elements/catalog/categories/category-details";
import { CATEGORY_DETAILS_SELECTORS } from "../../../elements/catalog/categories/category-details";
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
@ -14,16 +14,16 @@ export function updateCategory({ name, description }) {
export function fillUpCategoryGeneralInfo({ name, description }) {
return cy
.get(CATEGORY_DETAILS.descriptionInput)
.get(CATEGORY_DETAILS_SELECTORS.descriptionInput)
.find(SHARED_ELEMENTS.contentEditable)
.should("be.visible")
.get(CATEGORY_DETAILS.descriptionInput)
.get(CATEGORY_DETAILS_SELECTORS.descriptionInput)
.click()
.get(CATEGORY_DETAILS.descriptionInput)
.get(CATEGORY_DETAILS_SELECTORS.descriptionInput)
.find(SHARED_ELEMENTS.contentEditable)
.get(CATEGORY_DETAILS.descriptionInput)
.get(CATEGORY_DETAILS_SELECTORS.descriptionInput)
.clearAndType(description)
.get(CATEGORY_DETAILS.nameInput)
.get(CATEGORY_DETAILS_SELECTORS.nameInput)
.clearAndType(name);
}

View file

@ -0,0 +1,12 @@
import { CONFIGURATION_SELECTORS } from "../../elements";
export function expectConfigurationAvailableSectionsNumber(sectionsNumber) {
cy.get(CONFIGURATION_SELECTORS.configurationMenu)
.find("[data-test-id*=subsection]")
.should("have.length", sectionsNumber);
}
export function expectConfigurationSectionsToBeVisible(...sections) {
sections.forEach(selector => {
cy.get(selector).scrollIntoView().should("be.visible");
});
}

View file

@ -0,0 +1,12 @@
import { MENU_SELECTORS } from "../../elements";
export function expectMainMenuAvailableSections(sectionsNumber) {
cy.get(MENU_SELECTORS.MENU.list)
.find(MENU_SELECTORS.MENU.menuItem)
.should("have.length", sectionsNumber);
}
export function expectMainMenuSectionsToBeVisible(...sections) {
sections.forEach(selector => {
cy.get(selector).should("be.visible");
});
}

View file

@ -1,5 +1,5 @@
import { PAGE_DETAILS } from "../../elements/pages/page-details";
import { PAGES_LIST } from "../../elements/pages/pages-list";
import { PAGE_DETAILS_SELECTORS } from "../../elements/pages/page-details";
import { PAGES_LIST_SELECTORS } from "../../elements/pages/pages-list";
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
import { urlList } from "../../fixtures/urlList";
@ -15,7 +15,10 @@ export const attributesTypes = {
export function fillUpPageTypeDialog({ pageTypeName }) {
const organization = {};
return cy
.fillAutocompleteSelect(PAGES_LIST.dialogPageTypeInput, pageTypeName)
.fillAutocompleteSelect(
PAGES_LIST_SELECTORS.dialogPageTypeInput,
pageTypeName,
)
.then(selected => {
organization.pageType = selected;
return organization;
@ -35,25 +38,30 @@ export function createPage({
}
export function addSelectAttributeValue(attributeValue) {
cy.fillAutocompleteSelect(PAGE_DETAILS.attributeValues, attributeValue);
cy.fillAutocompleteSelect(
PAGE_DETAILS_SELECTORS.attributeValues,
attributeValue,
);
}
export function addRichTextAttributeValue(attributeValue) {
cy.get(PAGE_DETAILS.attributeValues)
cy.get(PAGE_DETAILS_SELECTORS.attributeValues)
.find(SHARED_ELEMENTS.richTextEditor.empty)
.should("exist")
.get(PAGE_DETAILS.attributeValues)
.find(PAGE_DETAILS.richTextEditorAttributeValue)
.get(PAGE_DETAILS_SELECTORS.attributeValues)
.find(PAGE_DETAILS_SELECTORS.richTextEditorAttributeValue)
.type(attributeValue)
.wait(500);
}
export function addBooleanAttributeValue() {
cy.get(PAGE_DETAILS.booleanAttributeValueCheckbox).click();
cy.get(PAGE_DETAILS_SELECTORS.booleanAttributeValueCheckbox).click();
}
export function addNumericAttributeValue(attributeValue) {
cy.get(PAGE_DETAILS.numericAttributeValueInput).type(attributeValue);
cy.get(PAGE_DETAILS_SELECTORS.numericAttributeValueInput).type(
attributeValue,
);
}
function openCreatePageAndFillUpGeneralFields({
@ -61,19 +69,17 @@ function openCreatePageAndFillUpGeneralFields({
pageTypeName,
isPublished,
}) {
cy.visit(urlList.pages)
.get(PAGES_LIST.createPageButton)
.click();
cy.visit(urlList.pages).get(PAGES_LIST_SELECTORS.createPageButton).click();
fillUpPageTypeDialog({ pageTypeName });
cy.get(BUTTON_SELECTORS.submit)
.click()
.get(PAGE_DETAILS.nameInput)
.get(PAGE_DETAILS_SELECTORS.nameInput)
.type(pageName);
if (!isPublished) {
cy.get(PAGE_DETAILS.isNotPublishedCheckbox).click();
cy.get(PAGE_DETAILS_SELECTORS.isNotPublishedCheckbox).click();
}
cy.fillAutocompleteSelect(
PAGE_DETAILS.pageTypesAutocompleteSelect,
PAGE_DETAILS_SELECTORS.pageTypesAutocompleteSelect,
pageTypeName,
);
}

View file

@ -1,4 +1,4 @@
import { LEFT_MENU_SELECTORS } from "../../elements/account/left-menu/left-menu-selectors";
import { MENU_SELECTORS } from "../../elements/account/left-menu/left-menu-selectors";
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
import { urlList } from "../../fixtures/urlList";
@ -29,7 +29,7 @@ export function isElementDisplayed(element = SHARED_ELEMENTS.header) {
return cy.get("body").then(body => body.find(element).length > 0);
}
export function getDisplayedSelectors(selectors = LEFT_MENU_SELECTORS) {
export function getDisplayedSelectors(selectors = MENU_SELECTORS) {
const displayedSelectors = {};
cy.wrap(displayedSelectors).as("displayedSelectors");
@ -58,7 +58,7 @@ export function expectAllSelectorsPermitted(permissions, selectors) {
}
function isPermitted(permissions, selector) {
let permittedSelectors = [LEFT_MENU_SELECTORS.home];
let permittedSelectors = [MENU_SELECTORS.home];
permissions.forEach(permission => {
if (permission.parent) {

View file

@ -1,20 +1,20 @@
import { PRODUCT_TYPE_DETAILS } from "../../elements/productTypes/productTypeDetails";
import { PRODUCT_TYPES_LIST } from "../../elements/productTypes/productTypesList";
import { PRODUCT_TYPE_DETAILS_SELECTORS } from "../../elements/productTypes/productTypeDetails";
import { PRODUCT_TYPES_LIST_SELECTORS } from "../../elements/productTypes/productTypesList";
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
export function createProductType({ name, shippingWeight, giftCard = false }) {
cy.get(PRODUCT_TYPES_LIST.addProductTypeButton)
cy.get(PRODUCT_TYPES_LIST_SELECTORS.addProductTypeButton)
.click()
.waitForProgressBarToNotBeVisible()
.get(PRODUCT_TYPE_DETAILS.nameInput)
.get(PRODUCT_TYPE_DETAILS_SELECTORS.nameInput)
.type(name);
if (giftCard) {
cy.get(PRODUCT_TYPE_DETAILS.giftCardKindCheckbox).click();
cy.get(PRODUCT_TYPE_DETAILS_SELECTORS.giftCardKindCheckbox).click();
}
if (shippingWeight) {
cy.get(PRODUCT_TYPE_DETAILS.isShippingRequired)
cy.get(PRODUCT_TYPE_DETAILS_SELECTORS.isShippingRequired)
.click()
.get(PRODUCT_TYPE_DETAILS.shippingWeightInput)
.get(PRODUCT_TYPE_DETAILS_SELECTORS.shippingWeightInput)
.type(shippingWeight);
}
return cy

View file

@ -2,7 +2,7 @@ import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
import { SHIPPING_RATE_DETAILS } from "../../elements/shipping/shipping-rate-details";
import { SHIPPING_ZONE_DETAILS } from "../../elements/shipping/shipping-zone-details";
import { SHIPPING_ZONES_LIST } from "../../elements/shipping/shipping-zones-list";
import { SHIPPING_ZONES_LIST_SELECTORS } from "../../elements/shipping/shipping-zones-list";
export function createShippingZone(
shippingName,
@ -10,7 +10,7 @@ export function createShippingZone(
country,
channelName,
) {
cy.get(SHIPPING_ZONES_LIST.addShippingZone).click();
cy.get(SHIPPING_ZONES_LIST_SELECTORS.addShippingZone).click();
fillUpShippingZoneData({
shippingName,
warehouseName,
@ -65,9 +65,9 @@ export function fillUpShippingZoneData({
}
export function changeWeightUnit(weightUnit) {
cy.fillBaseSelect(SHIPPING_ZONES_LIST.unitSelect, weightUnit)
cy.fillBaseSelect(SHIPPING_ZONES_LIST_SELECTORS.unitSelect, weightUnit)
.addAliasToGraphRequest("UpdateDefaultWeightUnit")
.get(SHIPPING_ZONES_LIST.saveUnit)
.get(SHIPPING_ZONES_LIST_SELECTORS.saveUnit)
.click()
.confirmationMessageShouldAppear()
.waitForRequestAndCheckIfNoErrors("@UpdateDefaultWeightUnit")

View file

@ -1,7 +1,7 @@
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
import { ELEMENT_TRANSLATION } from "../../elements/translations/element-translation";
import { LANGUAGES_LIST } from "../../elements/translations/languages-list";
import { LANGUAGES_LIST_SELECTORS } from "../../elements/translations/languages-list";
import { urlList } from "../../fixtures/urlList";
export function updateTranslationToCategory({
@ -12,7 +12,10 @@ export function updateTranslationToCategory({
translatedSeoDescription,
}) {
cy.visit(urlList.translations);
enterCategoryTranslation(LANGUAGES_LIST.polishLanguageButton, categoryName);
enterCategoryTranslation(
LANGUAGES_LIST_SELECTORS.polishLanguageButton,
categoryName,
);
cy.get(ELEMENT_TRANSLATION.editNameButton)
.click()
.get(SHARED_ELEMENTS.skeleton)
@ -49,9 +52,7 @@ export function updateTranslationToCategory({
export function enterCategoryTranslation(language, categoryName) {
cy.addAliasToGraphRequest("CategoryTranslations");
cy.get(language)
.click()
.waitForProgressBarToNotExist();
cy.get(language).click().waitForProgressBarToNotExist();
getCategoryFromTable(categoryName);
}

View file

@ -1,7 +1,7 @@
import { SET_PASSWORD } from "../../elements/account/setPassword";
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { INVITE_STAFF_MEMBER_FORM } from "../../elements/staffMembers/inviteStaffMemberForm";
import { STAFF_MEMBER_DETAILS } from "../../elements/staffMembers/staffMemberDetails";
import { INVITE_STAFF_MEMBER_FORM_SELECTORS } from "../../elements/staffMembers/inviteStaffMemberForm";
import { STAFF_MEMBER_DETAILS_SELECTORS } from "../../elements/staffMembers/staffMemberDetails";
import { userDetailsUrl } from "../../fixtures/urlList";
export function fillUpSetPassword(password) {
@ -22,8 +22,8 @@ export function fillUpUserDetailsAndAddFirstPermission(
) {
fillUpOnlyUserDetails(firstName, lastName, email);
cy.confirmationMessageShouldDisappear()
.fillAutocompleteSelect(STAFF_MEMBER_DETAILS.permissionsSelect)
.get(STAFF_MEMBER_DETAILS.permissionsSelect)
.fillAutocompleteSelect(STAFF_MEMBER_DETAILS_SELECTORS.permissionsSelect)
.get(STAFF_MEMBER_DETAILS_SELECTORS.permissionsSelect)
.find("input")
.first()
.type("{esc}", { force: true })
@ -34,11 +34,11 @@ export function fillUpUserDetailsAndAddFirstPermission(
}
export function fillUpOnlyUserDetails(firstName, lastName, email) {
cy.get(INVITE_STAFF_MEMBER_FORM.firstNameInput)
cy.get(INVITE_STAFF_MEMBER_FORM_SELECTORS.firstNameInput)
.type(firstName)
.get(INVITE_STAFF_MEMBER_FORM.lastNameInput)
.get(INVITE_STAFF_MEMBER_FORM_SELECTORS.lastNameInput)
.type(lastName)
.get(INVITE_STAFF_MEMBER_FORM.emailInput)
.get(INVITE_STAFF_MEMBER_FORM_SELECTORS.emailInput)
.type(email)
.get(BUTTON_SELECTORS.submit)
.click();
@ -46,7 +46,7 @@ export function fillUpOnlyUserDetails(firstName, lastName, email) {
export function updateUserActiveFlag(userId) {
cy.visitAndWaitForProgressBarToDisappear(userDetailsUrl(userId))
.get(STAFF_MEMBER_DETAILS.isActiveCheckBox)
.get(STAFF_MEMBER_DETAILS_SELECTORS.isActiveCheckBox)
.click()
.addAliasToGraphRequest("StaffMemberUpdate")
.get(BUTTON_SELECTORS.confirm)

View file

@ -84,7 +84,7 @@ const CompanyAddressForm: React.FC<CompanyAddressFormProps> = props => {
const formErrors = getFormErrors(formFields, errors);
return (
<div className={classes.root}>
<div className={classes.root} data-test-id="company-info">
<TextField
disabled={disabled}
error={!!formErrors.companyName}

View file

@ -19,7 +19,10 @@ export const ItemGroup: React.FC<Props> = ({ menuItem }) => {
const isExpanded = isActive || hasSubmenuActive;
return (
<List.ItemGroup defaultExpanded={isExpanded}>
<List.ItemGroup
defaultExpanded={isExpanded}
data-test-id={`menu-list-item`}
>
<List.ItemGroup.Trigger
paddingX={5}
borderRadius={3}

View file

@ -9,7 +9,7 @@ export const Menu = () => {
return (
<Box padding={6} overflowY="auto" className="hide-scrollbar">
<List as="ol" display="grid" gap={3}>
<List as="ol" display="grid" gap={3} data-test-id="menu-list">
{menuStructure.map(menuItem => (
<MenuItem menuItem={menuItem} key={menuItem.id} />
))}

View file

@ -98,7 +98,7 @@ export const ConfigurationPage: React.FC<ConfigurationPageProps> = props => {
<TopNav title={intl.formatMessage(sectionNames.configuration)}>
{isSmUp && renderVersionInfo}
</TopNav>
<DetailPageLayout.Content>
<DetailPageLayout.Content data-test-id="configuration-menu">
<Box paddingX={9} __maxWidth={"1024px"} margin="auto">
{menus
.filter(menu =>

View file

@ -64,6 +64,7 @@ const OrderDraftListPage: React.FC<OrderDraftListPageProps> = ({
variant="primary"
disabled={disabled || limitsReached}
onClick={onAdd}
data-test-id="create-draft-order-button"
>
<FormattedMessage
id="LshEVn"

View file

@ -47,7 +47,7 @@ const TranslationsLanguageList: React.FC<
<Card>
<CardContent className={classes.cardContent}>
<ResponsiveTable>
<TableBody>
<TableBody data-test-id="translation-list-view">
{renderCollection(
languages,
language => (

View file

@ -29,6 +29,7 @@ const TranslationsProductList: React.FC<TranslationsEntityListProps> = ({
return (
<PaginatorContext.Provider value={paginationValues}>
<TranslationsEntitiesList
data-test-id="translation-list-view"
disabled={loading}
entities={mapEdgesToItems(data?.translations)?.map(
node =>