Skip to content

Commit 5cbb61b

Browse files
authored
chore(e2e): unskip RBAC as admin on K8s (#3509)
1 parent 2262350 commit 5cbb61b

File tree

6 files changed

+53
-41
lines changed

6 files changed

+53
-41
lines changed

e2e-tests/playwright/e2e/plugins/bulk-import.spec.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ spec:
194194
});
195195

196196
test("Merge the PR on GitHub and Confirm the Status Updates to 'Added'", async () => {
197+
// TODO: https://issues.redhat.com/browse/RHDHBUGS-2116
198+
test.fixme();
197199
await uiHelper.openSidebar("Bulk import");
198200
// Merge PR is generated for the repository without the catalog.yaml file.
199201
await APIHelper.mergeGitHubPR(
@@ -283,7 +285,7 @@ spec:
283285

284286
test.describe
285287
.serial("Bulk Import - Verify existing repo are displayed in bulk import Added repositories", () => {
286-
// test.skip(() => process.env.JOB_NAME.includes("osd-gcp")); // skipping due to RHIDP-5704 on OSD Env
288+
test.skip(() => process.env.JOB_NAME.includes("osd-gcp")); // skipping due to RHIDP-5704 on OSD Env
287289
// TODO: https://issues.redhat.com/browse/RHDHBUGS-2116
288290
test.fixme();
289291
let page: Page;
@@ -312,8 +314,6 @@ test.describe
312314
});
313315

314316
test("Verify existing repo from app-config is displayed in bulk import Added repositories", async () => {
315-
// TODO: https://issues.redhat.com/browse/RHDHBUGS-2116
316-
test.fixme();
317317
await uiHelper.openSidebar("Bulk import");
318318
await common.waitForLoad();
319319
await bulkimport.filterAddedRepo(existingRepoFromAppConfig);
@@ -324,8 +324,6 @@ test.describe
324324

325325
test('Verify repo from "import an existing git repository" are displayed in bulk import Added repositories', async () => {
326326
// Import an existing Git repository
327-
// TODO: https://issues.redhat.com/browse/RHDHBUGS-2116
328-
test.fixme();
329327
await uiHelper.openSidebar("Catalog");
330328
await uiHelper.clickButton("Self-service");
331329
await uiHelper.clickButton("Import an existing Git repository");
@@ -347,9 +345,7 @@ test.describe
347345

348346
test.describe
349347
.serial("Bulk Import - Ensure users without bulk import permissions cannot access the bulk import plugin", () => {
350-
//test.skip(() => process.env.JOB_NAME.includes("osd-gcp")); // skipping due to RHIDP-5704 on OSD Env
351-
// TODO: https://issues.redhat.com/browse/RHDHBUGS-2116
352-
test.fixme();
348+
test.skip(() => process.env.JOB_NAME.includes("osd-gcp")); // skipping due to RHIDP-5704 on OSD Env
353349
let page: Page;
354350
let uiHelper: UIhelper;
355351
let common: Common;

e2e-tests/playwright/e2e/plugins/rbac/rbac.spec.ts

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Response, Roles } from "../../../support/pages/rbac";
33
import { UI_HELPER_ELEMENTS } from "../../../support/page-objects/global-obj";
44
import {
55
SEARCH_OBJECTS_COMPONENTS,
6-
ROLE_OVERVIEW_COMPONENTS,
6+
ROLE_OVERVIEW_COMPONENTS_TEST_ID,
77
ROLES_PAGE_COMPONENTS,
88
} from "../../../support/page-objects/page-obj";
99
import { Common, setupBrowser } from "../../../utils/common";
@@ -213,8 +213,6 @@ test.describe.serial("Test RBAC", () => {
213213
});
214214

215215
test.describe("Test RBAC plugin as an admin user", () => {
216-
// TODO: fix https://issues.redhat.com/browse/RHIDP-6625 and remove the skip
217-
test.skip(() => process.env.IS_OPENSHIFT.includes("false"));
218216
test.beforeEach(async ({ page }, testInfo) => {
219217
testInfo.setTimeout(testInfo.timeout + 30_000); // Additional time due to repeated timeout failure in OSD env.
220218
const common = new Common(page);
@@ -236,28 +234,33 @@ test.describe.serial("Test RBAC", () => {
236234
await uiHelper.verifyCellsInTable(allCellsIdentifier);
237235
});
238236

239-
test("Should download the user list", async ({ page }) => {
240-
await page.locator('a:has-text("Download User List")').click();
241-
const fileContent = await downloadAndReadFile(
242-
page,
243-
'a:has-text("Download User List")',
244-
);
237+
test("Should export CSV of the user list", async ({ page }) => {
238+
const exportCsvLink = page.getByRole("link", { name: "Export CSV" });
239+
await exportCsvLink.click();
240+
const fileContent = await downloadAndReadFile(page, exportCsvLink);
241+
await test.info().attach("user-list-file", {
242+
body: fileContent,
243+
contentType: "text/plain",
244+
});
245245
const lines = fileContent.trim().split("\n");
246246

247247
const header = "userEntityRef,displayName,email,lastAuthTime";
248-
// eslint-disable-next-line playwright/no-conditional-in-test
249-
if (lines[0] !== header) {
250-
throw new Error("Header does not match");
251-
}
248+
expect(lines[0], "Header needs to match the expected header").toBe(
249+
header,
250+
);
252251

253-
// Check that each subsequent line starts with "user:default"
254-
const allUsersValid = lines
252+
// Check that each subsequent line starts with "user:default" or "user:development"
253+
const invalidLines = lines
255254
.slice(1)
256-
.every((line) => line.startsWith("user:default"));
257-
// eslint-disable-next-line playwright/no-conditional-in-test
258-
if (!allUsersValid) {
259-
throw new Error("Not all users info are valid");
260-
}
255+
.filter(
256+
(line) =>
257+
!line.startsWith("user:default") &&
258+
!line.startsWith("user:development"),
259+
);
260+
261+
await test.step(`Validate user lines: ${invalidLines.length} invalid out of ${lines.length} total`, async () => {
262+
expect(invalidLines, "All users should be valid").toHaveLength(0);
263+
});
261264
});
262265

263266
test("View details of a role", async ({ page }) => {
@@ -277,7 +280,7 @@ test.describe.serial("Test RBAC", () => {
277280
Roles.getUsersAndGroupsListCellsIdentifier();
278281
await uiHelper.verifyCellsInTable(usersAndGroupsCellsIdentifier);
279282

280-
await uiHelper.verifyHeading("Permission policies (5)");
283+
await uiHelper.verifyHeading("5 permissions");
281284
const permissionPoliciesColumnsText =
282285
Roles.getPermissionPoliciesListColumnsText();
283286
await uiHelper.verifyColumnHeading(permissionPoliciesColumnsText);
@@ -381,7 +384,9 @@ test.describe.serial("Test RBAC", () => {
381384
await uiHelper.verifyHeading("role:default/test-role1");
382385
await uiHelper.clickTab("Overview");
383386

384-
await page.click(ROLE_OVERVIEW_COMPONENTS.updateMembers);
387+
await page
388+
.getByTestId(ROLE_OVERVIEW_COMPONENTS_TEST_ID.updateMembers)
389+
.click();
385390
await uiHelper.verifyHeading("Edit Role");
386391
await uiHelper.fillTextInputByLabel(
387392
"Select users and groups",
@@ -409,7 +414,9 @@ test.describe.serial("Test RBAC", () => {
409414
);
410415
await uiHelper.verifyHeading(rbacPo.regexpShortUsersAndGroups(1, 1));
411416

412-
await page.click(ROLE_OVERVIEW_COMPONENTS.updatePolicies);
417+
await page
418+
.getByTestId(ROLE_OVERVIEW_COMPONENTS_TEST_ID.updatePolicies)
419+
.click();
413420
await uiHelper.verifyHeading("Edit Role");
414421
await rbacPo.selectPluginsCombobox.click();
415422
await rbacPo.selectOption("scaffolder");
@@ -421,21 +428,26 @@ test.describe.serial("Test RBAC", () => {
421428
await uiHelper.verifyText(
422429
"Role role:default/test-role1 updated successfully",
423430
);
424-
await uiHelper.verifyHeading("Permission Policies (2)");
431+
await uiHelper.verifyHeading("2 permissions");
425432

426433
await rbacPo.deleteRole("role:default/test-role1");
427434
});
428435

429436
test("Create a role with a permission policy per resource type and verify that the only authorized users can access specific resources.", async ({
430437
page,
431438
}) => {
439+
// TODO: https://issues.redhat.com/browse/RHDHBUGS-2127
440+
test.fixme(true, "Cannot delete role because of missing permissions");
441+
432442
const uiHelper = new UIhelper(page);
433443
const rbacPo = new RbacPo(page);
434444
await rbacPo.createConditionalRole(
435445
"test-role1",
436-
["Guest User", "rhdh-qe"],
446+
["Guest User", "rhdh-qe rhdh-qe"],
437447
["Backstage"],
438448
"anyOf",
449+
"catalog",
450+
"user:default/rhdh-qe",
439451
);
440452

441453
await page

e2e-tests/playwright/support/page-objects/page-obj.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const DELETE_ROLE_COMPONENTS = {
4242
roleName: 'input[name="delete-role"]',
4343
};
4444

45-
export const ROLE_OVERVIEW_COMPONENTS = {
46-
updatePolicies: 'span[data-testid="update-policies"]',
47-
updateMembers: 'span[data-testid="update-members"]',
45+
export const ROLE_OVERVIEW_COMPONENTS_TEST_ID = {
46+
updatePolicies: "update-policies",
47+
updateMembers: "update-members",
4848
};

e2e-tests/playwright/support/page-objects/rbac-po.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,9 @@ export class RbacPo extends PageObject {
295295
groups: string[],
296296
permissionPolicyType: PermissionPolicyType,
297297
pluginId: "catalog" | "kubernetes" | "scaffolder" = "catalog",
298+
owner?: string,
298299
) {
299-
await this.createRoleUsers(name, users, groups);
300+
await this.createRoleUsers(name, users, groups, owner);
300301

301302
// select permissions
302303
await this.selectPluginsCombobox.click();

e2e-tests/playwright/support/pages/topology.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ export class Topology {
4646
.click();
4747

4848
if (allowed) {
49+
const downloadLogsButton = this.page.getByRole("button", {
50+
name: "download logs",
51+
});
4952
const fileContent = await downloadAndReadFile(
5053
this.page,
51-
'role=button[name="download logs"]',
54+
downloadLogsButton,
5255
);
5356
expect(fileContent).not.toBeUndefined();
5457
expect(fileContent).not.toBe("");

e2e-tests/playwright/utils/helper.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { type Page } from "@playwright/test";
1+
import { type Page, type Locator } from "@playwright/test";
22
import fs from "fs";
33

44
export async function downloadAndReadFile(
55
page: Page,
6-
locator: string,
6+
locator: Locator,
77
): Promise<string | undefined> {
88
const [download] = await Promise.all([
99
page.waitForEvent("download"),
10-
page.locator(locator).click(),
10+
locator.click(),
1111
]);
1212

1313
const filePath = await download.path();

0 commit comments

Comments
 (0)