saleor-dashboard/cypress/e2e/navigation.js
Patryk Andrzejewski 3789f5bb52
New macaw ui (#3069)
Co-authored-by: Krzysztof Żuraw <9116238+krzysztofzuraw@users.noreply.github.com>
Co-authored-by: Michał Droń <dron.official@yahoo.com>
Co-authored-by: Paweł Chyła <chyla1988@gmail.com>
2023-02-20 16:21:28 +01:00

99 lines
3.2 KiB
JavaScript

/// <reference types="cypress"/>
/// <reference types="../support"/>
import {
APP_MENU_SELECTORS,
appCommonSelector,
LEFT_MENU_SELECTORS,
} from "../elements/account/left-menu/left-menu-selectors";
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;
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 all permissions. ${permissionsOptions.all.testCase}`,
{ tags: ["@critical", "@allEnv", "@navigation", "@stable", "@oldRelease"] },
() => {
const permissionOption = permissionsOptions.all;
cy.clearSessionData();
permissionsSteps.navigateToAllAvailablePageAndCheckIfDisplayed(
permissionOption,
);
},
);
});