Skip to content

Commit

Permalink
sort page duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
nilgaar committed Nov 12, 2024
1 parent 1562afa commit 9401a22
Showing 1 changed file with 46 additions and 46 deletions.
92 changes: 46 additions & 46 deletions e2e-tests/playwright/e2e/plugins/rbac/rbac-as-admin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,24 @@ base.describe.serial("Test RBAC plugin as an admin user", () => {

base(
"Create and edit a role from the roles list page",
async ({ uiHelper, testId, rolesHelper, page }) => {
async ({ uiHelper, testId, rolesHelper }) => {
await rolesHelper.createRole(testId.testRole);
await page.click(RoleListPO.editRole(testId.composedRole));
await myPage.click(RoleListPO.editRole(testId.composedRole));
await uiHelper.verifyHeading("Edit Role");
await uiHelper.clickButton("Next");
await page.fill(RoleFormPO.addUsersAndGroups, "Jonathon Page");
await page.click(RoleFormPO.selectMember("Jonathon Page"));
await myPage.fill(RoleFormPO.addUsersAndGroups, "Jonathon Page");
await myPage.click(RoleFormPO.selectMember("Jonathon Page"));
await uiHelper.verifyHeading("Users and groups (3 users, 1 group)");
await uiHelper.clickButton("Next");
await uiHelper.clickButton("Next");
await uiHelper.clickButton("Save");
await uiHelper.verifyText(
`Role ${testId.composedRole} updated successfully`,
);
await page.locator(HomePagePO.searchBar).waitFor({ state: "visible" });
await page.locator(HomePagePO.searchBar).fill(testId.testRole);
await myPage.locator(HomePagePO.searchBar).waitFor({ state: "visible" });
await myPage.locator(HomePagePO.searchBar).fill(testId.testRole);
await uiHelper.verifyHeading("All roles (1)");
const usersAndGroupsLocator = page
const usersAndGroupsLocator = myPage
.locator(UIhelperPO.MuiTableCell)
.filter({ hasText: "3 users, 1 group" });
await usersAndGroupsLocator.waitFor();
Expand All @@ -112,17 +112,17 @@ base.describe.serial("Test RBAC plugin as an admin user", () => {

base(
"Edit users and groups and update policies of a role from the overview page",
async ({ uiHelper, testId, rolesHelper, page }) => {
async ({ uiHelper, testId, rolesHelper }) => {
await rolesHelper.createRole(testId.testRole);
await uiHelper.clickLink(testId.composedRole);

await uiHelper.verifyHeading(testId.composedRole);
await uiHelper.clickTab("Overview");

await page.click(RoleOverviewPO.updateMembers);
await myPage.click(RoleOverviewPO.updateMembers);
await uiHelper.verifyHeading("Edit Role");
await page.locator(HomePagePO.searchBar).fill("Guest User");
await page.click('button[aria-label="Remove"]');
await myPage.locator(HomePagePO.searchBar).fill("Guest User");
await myPage.click('button[aria-label="Remove"]');
await uiHelper.verifyHeading("Users and groups (1 user, 1 group)");
await uiHelper.clickButton("Next");
await uiHelper.clickButton("Next");
Expand All @@ -132,12 +132,12 @@ base.describe.serial("Test RBAC plugin as an admin user", () => {
);
await uiHelper.verifyHeading("Users and groups (1 user, 1 group)");

await page.click(RoleOverviewPO.updatePolicies);
await myPage.click(RoleOverviewPO.updatePolicies);
await uiHelper.verifyHeading("Edit Role");
await page.click(RoleFormPO.addPermissionPolicy);
await page.click(RoleFormPO.selectPermissionPolicyPlugin(1));
await myPage.click(RoleFormPO.addPermissionPolicy);
await myPage.click(RoleFormPO.selectPermissionPolicyPlugin(1));
await uiHelper.optionSelector("scaffolder");
await page.click(RoleFormPO.selectPermissionPolicyPermission(1));
await myPage.click(RoleFormPO.selectPermissionPolicyPermission(1));
await uiHelper.optionSelector("scaffolder-template");
await uiHelper.clickButton("Next");
await uiHelper.clickButton("Save");
Expand All @@ -152,45 +152,45 @@ base.describe.serial("Test RBAC plugin as an admin user", () => {

base(
"Create a role with a permission policy per resource type and verify that the only authorized users can access specific resources.",
async ({ uiHelper, rolesHelper, testId, page }) => {
async ({ uiHelper, rolesHelper, testId }) => {
await rolesHelper.createRoleWithPermissionPolicy(testId.testRole);

await page.locator(HomePagePO.searchBar).waitFor({ state: "visible" });
await page.locator(HomePagePO.searchBar).fill(testId.testRole);
await myPage.locator(HomePagePO.searchBar).waitFor({ state: "visible" });
await myPage.locator(HomePagePO.searchBar).fill(testId.testRole);
await uiHelper.verifyHeading("All roles (1)");
await rolesHelper.deleteRole(testId.composedRole);
},
);

base(
"Admin cannot create a role if there are no rules defined for the selected resource type.",
async ({ uiHelper, testId, page }) => {
async ({ uiHelper, testId }) => {
await uiHelper.clickButton("Create");
await uiHelper.verifyHeading("Create role");

await page.fill(RoleFormPO.roleName, testId.testRole);
await myPage.fill(RoleFormPO.roleName, testId.testRole);
await uiHelper.clickButton("Next");
await page.fill(RoleFormPO.addUsersAndGroups, "guest user");
await page.click(RoleFormPO.selectMember("Guest User"));
await myPage.fill(RoleFormPO.addUsersAndGroups, "guest user");
await myPage.click(RoleFormPO.selectMember("Guest User"));
await uiHelper.clickButton("Next");

await page.click(RoleFormPO.selectPermissionPolicyPlugin(0));
await myPage.click(RoleFormPO.selectPermissionPolicyPlugin(0));
await uiHelper.optionSelector("catalog");

await page.click(RoleFormPO.selectPermissionPolicyPermission(0));
await myPage.click(RoleFormPO.selectPermissionPolicyPermission(0));
await uiHelper.optionSelector("catalog.entity.create");

await expect(page.getByLabel("configure-access")).not.toBeVisible();
await expect(myPage.getByLabel("configure-access")).not.toBeVisible();
await uiHelper.clickButton("Cancel");
},
);

base(
"As an RHDH admin, I want to be able to restrict access by using the Not condition to part of the plugin, so that some information is protected from unauthorized access.",
async ({ uiHelper, testId, rolesHelper, page }) => {
async ({ uiHelper, testId, rolesHelper, myPage }) => {
await rolesHelper.createRoleWithNotPermissionPolicy(testId.testRole);
await page.locator(HomePagePO.searchBar).waitFor({ state: "visible" });
await page.locator(HomePagePO.searchBar).fill(testId.testRole);
await myPage.locator(HomePagePO.searchBar).waitFor({ state: "visible" });
await myPage.locator(HomePagePO.searchBar).fill(testId.testRole);
await uiHelper.verifyHeading("All roles (1)");

await rolesHelper.deleteRole(testId.composedRole);
Expand All @@ -199,24 +199,24 @@ base.describe.serial("Test RBAC plugin as an admin user", () => {

base(
"As an RHDH admin, I want to be able to edit the access rule, so I can keep it up to date and be able to add more plugins in the future.",
async ({ uiHelper, rolesHelper, testId, page }) => {
async ({ uiHelper, rolesHelper, testId }) => {
await rolesHelper.createRoleWithNotPermissionPolicy(testId.testRole);
await page.locator(HomePagePO.searchBar).waitFor({ state: "visible" });
await page.locator(HomePagePO.searchBar).fill(testId.testRole);
await myPage.locator(HomePagePO.searchBar).waitFor({ state: "visible" });
await myPage.locator(HomePagePO.searchBar).fill(testId.testRole);
await uiHelper.verifyHeading("All roles (1)");

await page.click(RoleListPO.editRole(testId.composedRole));
await myPage.click(RoleListPO.editRole(testId.composedRole));
await uiHelper.verifyHeading("Edit Role");
await uiHelper.clickButton("Next");
await uiHelper.clickButton("Next");

await page.getByLabel("configure-access").click();
await page.getByRole("button", { name: "Condition" }).click();
await page.getByTestId("rules-sidebar").getByLabel("Open").click();
await page.getByText("HAS_SPEC").click();
await page.getByLabel("key *").click();
await page.getByLabel("key *").fill("lifecycle");
await page.getByTestId("save-conditions").click();
await myPage.getByLabel("configure-access").click();
await myPage.getByRole("button", { name: "Condition" }).click();
await myPage.getByTestId("rules-sidebar").getByLabel("Open").click();
await myPage.getByText("HAS_SPEC").click();
await myPage.getByLabel("key *").click();
await myPage.getByLabel("key *").fill("lifecycle");
await myPage.getByTestId("save-conditions").click();

await uiHelper.clickButton("Next");
await uiHelper.clickButton("Save");
Expand All @@ -228,20 +228,20 @@ base.describe.serial("Test RBAC plugin as an admin user", () => {

base.fixme(
"As an RHDH admin, I want to be able to remove an access rule from an existing permission policy.",
async ({ uiHelper, rolesHelper, testId, page }) => {
async ({ uiHelper, rolesHelper, testId }) => {
await rolesHelper.createRoleWithPermissionPolicy(testId.testRole);
await page.locator(HomePagePO.searchBar).waitFor({ state: "visible" });
await page.locator(HomePagePO.searchBar).fill(testId.testRole);
await myPage.locator(HomePagePO.searchBar).waitFor({ state: "visible" });
await myPage.locator(HomePagePO.searchBar).fill(testId.testRole);
await uiHelper.verifyHeading("All roles (1)");

await page.click(RoleListPO.editRole(testId.composedRole));
await myPage.click(RoleListPO.editRole(testId.composedRole));
await uiHelper.verifyHeading("Edit Role");
await uiHelper.clickButton("Next");
await uiHelper.clickButton("Next");

await page.getByLabel("configure-access").click();
await page.getByRole("button", { name: "Remove" }).nth(2).click();
await page.getByTestId("save-conditions").click();
await myPage.getByLabel("configure-access").click();
await myPage.getByRole("button", { name: "Remove" }).nth(2).click();
await myPage.getByTestId("save-conditions").click();
await uiHelper.verifyText("Configure access (2 rules)");

await uiHelper.clickButton("Next");
Expand Down

0 comments on commit 9401a22

Please sign in to comment.