2021-09-27 10:04:21 +00:00
|
|
|
/// <reference types="cypress"/>
|
|
|
|
/// <reference types="../support"/>
|
|
|
|
|
|
|
|
import { PERMISSIONS_OPTIONS } from "../fixtures/permissionsUsers";
|
2021-07-23 09:46:44 +00:00
|
|
|
import filterTests from "../support/filterTests";
|
2021-09-27 10:04:21 +00:00
|
|
|
import * as permissionsSteps from "../support/pages/permissionsPage";
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-03-21 12:17:37 +00:00
|
|
|
describe("As a staff user I want to navigate through shop using different permissions", () => {
|
2021-07-23 09:46:44 +00:00
|
|
|
Object.keys(PERMISSIONS_OPTIONS).forEach(key => {
|
2022-03-21 12:17:37 +00:00
|
|
|
const tags =
|
|
|
|
key === "all" ? ["critical", "all", "refactored"] : ["all", "refactored"];
|
2021-09-27 10:04:21 +00:00
|
|
|
filterTests({ definedTags: tags }, () => {
|
2022-03-21 12:17:37 +00:00
|
|
|
it(`should be able to navigate through shop as a staff member using ${key} permission. ${PERMISSIONS_OPTIONS[key].testCase}`, () => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const permissionOption = PERMISSIONS_OPTIONS[key];
|
|
|
|
const permissions = permissionOption.permissions;
|
|
|
|
cy.clearSessionData();
|
|
|
|
permissionsSteps.navigateToAllAvailablePageAndCheckIfDisplayed(
|
|
|
|
permissionOption
|
|
|
|
);
|
|
|
|
if (key === "all") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
permissionsSteps
|
|
|
|
.getDisplayedSelectors()
|
|
|
|
.then(selectors => {
|
|
|
|
permissionsSteps.expectAllSelectorsPermitted(
|
|
|
|
permissions,
|
|
|
|
selectors
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
if (!permissions) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
permissions.forEach(permission => {
|
|
|
|
if (permission.parent) {
|
|
|
|
cy.get(permission.parent.parentMenuSelector)
|
|
|
|
.click()
|
|
|
|
.then(() => {
|
|
|
|
permissionsSteps.getDisplayedSelectors(
|
|
|
|
permission.parent.parentSelectors
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.then(parentSelectors => {
|
|
|
|
permissionsSteps.expectAllSelectorsPermitted(
|
|
|
|
permissions,
|
|
|
|
parentSelectors
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|