Skip to content

Commit

Permalink
fix(e2e): disable broken/flaky tests and add support for MUI v5 butto…
Browse files Browse the repository at this point in the history
…ns in playwright tests (#2003)

* fix(rbac): add support for mui v5 buttons in e2e helper

Signed-off-by: Christoph Jerolimov <[email protected]>

* chore(ci): disable `droute` until outage is resolved

* fix(e2e): skip broken/flaky tests

Signed-off-by: Christoph Jerolimov <[email protected]>

---------

Signed-off-by: Christoph Jerolimov <[email protected]>
Co-authored-by: Zbyněk Drápela <[email protected]>
  • Loading branch information
christoph-jerolimov and zdrapela authored Nov 27, 2024
1 parent 1535178 commit d907bac
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 67 deletions.
3 changes: 2 additions & 1 deletion .ibm/pipelines/openshift-ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ run_tests() {
cp -a "/tmp/${LOGFILE}.html" "${ARTIFACT_DIR}/${project}"
cp -a /tmp/backstage-showcase/e2e-tests/playwright-report/* "${ARTIFACT_DIR}/${project}"

droute_send "${release_name}" "${project}"
# TODO Re-enable `droute` once outage is resolved
# droute_send "${release_name}" "${project}"

echo "${project} RESULT: ${RESULT}"
if [ "${RESULT}" -ne 0 ]; then
Expand Down
4 changes: 3 additions & 1 deletion e2e-tests/playwright/e2e/catalog-scaffoldedfromLink.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { APIHelper } from "../utils/APIHelper";
import { githubAPIEndpoints } from "../utils/APIEndpoints";

let page: Page;
test.describe.serial("Link Scaffolded Templates to Catalog Items", () => {

// TODO: replace skip with serial
test.describe.skip("Link Scaffolded Templates to Catalog Items", () => {
let uiHelper: UIhelper;
let common: Common;
let catalogImport: CatalogImport;
Expand Down
9 changes: 6 additions & 3 deletions e2e-tests/playwright/e2e/github-happy-path.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import {
import { templates } from "../support/testData/templates";

let page: Page;
test.describe.serial("GitHub Happy path", () => {

// TODO: replace skip with serial
test.describe.skip("GitHub Happy path", () => {
let common: Common;
let uiHelper: UIhelper;
let catalogImport: CatalogImport;
Expand All @@ -27,14 +29,15 @@ test.describe.serial("GitHub Happy path", () => {
backstageShowcase = new BackstageShowcase(page);
await common.loginAsGithubUser();
});

test.beforeEach(
async () => await new Common(page).checkAndClickOnGHloginPopup(),
);

test("Verify Profile is Github Account Name in the Settings page", async () => {
await uiHelper.openSidebar("Settings");
await expect(page).toHaveURL("/settings");
await uiHelper.verifyHeading(process.env.GH_USER_ID as string);
await uiHelper.verifyHeading(process.env.GH_USER_ID);
await uiHelper.verifyHeading(`User Entity: ${process.env.GH_USER_ID}`);
});

Expand Down Expand Up @@ -118,7 +121,7 @@ test.describe.serial("GitHub Happy path", () => {
await backstageShowcase.verifyPRRows(closedPRs, 0, 5);
});

//TODO https://issues.redhat.com/browse/RHIDP-3159 The last ~10 GitHub Pull Requests are missing from the list
// TODO https://issues.redhat.com/browse/RHIDP-3159 The last ~10 GitHub Pull Requests are missing from the list
test.skip("Click on the arrows to verify that the next/previous/first/last pages of PRs are loaded", async () => {
console.log("Fetching all PRs from GitHub");
const allPRs = await BackstageShowcase.getShowcasePRs("all", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { Common } from "../../../utils/Common";
import { UIhelper } from "../../../utils/UIhelper";
import { UIhelperPO } from "../../../support/pageObjects/global-obj";

test.describe('Check RBAC "analytics-provider-segment" plugin', () => {
// TODO: reenable tests
test.describe.skip('Check RBAC "analytics-provider-segment" plugin', () => {
let common: Common;
let uiHelper: UIhelper;

Expand Down
3 changes: 2 additions & 1 deletion e2e-tests/playwright/e2e/plugins/rbac/rbac-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { UIhelper } from "../../../utils/UIhelper";
import { RbacConstants } from "../../../data/rbac-constants";
import { RhdhAuthHack } from "../../../support/api/rhdh-auth-hack";

test.describe("Test RBAC plugin REST API", () => {
// TODO: reenable tests
test.describe.skip("Test RBAC plugin REST API", () => {
let common: Common;
let uiHelper: UIhelper;
let page: Page;
Expand Down
121 changes: 62 additions & 59 deletions e2e-tests/playwright/e2e/plugins/rbac/rbac.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,74 +11,77 @@ import { Common, setupBrowser } from "../../../utils/Common";
import { UIhelper } from "../../../utils/UIhelper";
import fs from "fs/promises";

test.describe
.serial("Test RBAC plugin: load permission policies and conditions from files", () => {
let common: Common;
let uiHelper: UIhelper;
let page: Page;
// TODO: reenable tests, replace skip with serial
test.describe.skip(
"Test RBAC plugin: load permission policies and conditions from files",
() => {
let common: Common;
let uiHelper: UIhelper;
let page: Page;

test.beforeAll(async ({ browser }, testInfo) => {
page = (await setupBrowser(browser, testInfo)).page;

uiHelper = new UIhelper(page);
common = new Common(page);
await common.loginAsGithubUser();
await uiHelper.openSidebarButton("Administration");
await uiHelper.openSidebar("RBAC");
await uiHelper.verifyHeading("RBAC");
});

test.beforeAll(async ({ browser }, testInfo) => {
page = (await setupBrowser(browser, testInfo)).page;
test.beforeEach(
async () => await new Common(page).checkAndClickOnGHloginPopup(),
);

uiHelper = new UIhelper(page);
common = new Common(page);
await common.loginAsGithubUser();
await uiHelper.openSidebarButton("Administration");
await uiHelper.openSidebar("RBAC");
await uiHelper.verifyHeading("RBAC");
});
test("Check if permission policies defined in files are loaded and effective", async () => {
const testRole: string = "role:default/test2-role";

test.beforeEach(
async () => await new Common(page).checkAndClickOnGHloginPopup(),
);
await uiHelper.verifyHeading(/All roles \(\d+\)/);
await uiHelper.verifyLink(testRole);
await uiHelper.clickLink(testRole);

test("Check if permission policies defined in files are loaded and effective", async () => {
const testRole: string = "role:default/test2-role";
await uiHelper.verifyHeading(testRole);
await uiHelper.clickTab("Overview");

await uiHelper.verifyHeading(/All roles \(\d+\)/);
await uiHelper.verifyLink(testRole);
await uiHelper.clickLink(testRole);
await uiHelper.verifyText("About");
await uiHelper.verifyText("csv permission policy file");

await uiHelper.verifyHeading(testRole);
await uiHelper.clickTab("Overview");
await uiHelper.verifyHeading("Users and groups (1 group");
await uiHelper.verifyHeading("Permission policies (2)");
const permissionPoliciesColumnsText =
Roles.getPermissionPoliciesListColumnsText();
await uiHelper.verifyColumnHeading(permissionPoliciesColumnsText);
const permissionPoliciesCellsIdentifier =
Roles.getPermissionPoliciesListCellsIdentifier();
await uiHelper.verifyCellsInTable(permissionPoliciesCellsIdentifier);

await uiHelper.verifyText("About");
await uiHelper.verifyText("csv permission policy file");
await expect(page.getByRole("article")).toContainText("catalog-entity");
await expect(page.getByRole("article")).toContainText("Read, Update");
await expect(page.getByRole("article")).toContainText("Delete");

await uiHelper.verifyHeading("Users and groups (1 group");
await uiHelper.verifyHeading("Permission policies (2)");
const permissionPoliciesColumnsText =
Roles.getPermissionPoliciesListColumnsText();
await uiHelper.verifyColumnHeading(permissionPoliciesColumnsText);
const permissionPoliciesCellsIdentifier =
Roles.getPermissionPoliciesListCellsIdentifier();
await uiHelper.verifyCellsInTable(permissionPoliciesCellsIdentifier);

await expect(page.getByRole("article")).toContainText("catalog-entity");
await expect(page.getByRole("article")).toContainText("Read, Update");
await expect(page.getByRole("article")).toContainText("Delete");

await page.getByTestId("update-members").getByLabel("Update").click();
await expect(page.locator("tbody")).toContainText("rhdh-qe-2-team");
await uiHelper.clickButton("Next");
await page.getByLabel("configure-access").first().click();
await expect(page.getByPlaceholder("string, string")).toHaveValue(
"group:janus-qe/rhdh-qe-2-team,$currentUser",
);
await page.getByTestId("cancel-conditions").click();
await page.getByLabel("configure-access").nth(1).click();
await expect(page.getByPlaceholder("string, string")).toHaveValue(
"$currentUser",
);
await page.getByTestId("cancel-conditions").click();
await uiHelper.clickButton("Next");
await uiHelper.clickButton("Cancel");
});
await page.getByTestId("update-members").getByLabel("Update").click();
await expect(page.locator("tbody")).toContainText("rhdh-qe-2-team");
await uiHelper.clickButton("Next");
await page.getByLabel("configure-access").first().click();
await expect(page.getByPlaceholder("string, string")).toHaveValue(
"group:janus-qe/rhdh-qe-2-team,$currentUser",
);
await page.getByTestId("cancel-conditions").click();
await page.getByLabel("configure-access").nth(1).click();
await expect(page.getByPlaceholder("string, string")).toHaveValue(
"$currentUser",
);
await page.getByTestId("cancel-conditions").click();
await uiHelper.clickButton("Next");
await uiHelper.clickButton("Cancel");
});

test.afterAll(async () => {
await page.close();
});
});
test.afterAll(async () => {
await page.close();
});
},
);

test.describe
.serial("Test RBAC plugin: Aliases used in conditional access policies", () => {
Expand Down
5 changes: 4 additions & 1 deletion e2e-tests/playwright/support/pageObjects/global-obj.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ export const waitsObjs = {
};

export const UIhelperPO = {
MuiButtonLabel: 'span[class^="MuiButton-label"]',
// MUI v4 buttons are spans with a class starting with MuiButton-label
// MUI v5 buttons are HTML buttons with a class containing MuiButton-root
MuiButtonLabel:
'span[class^="MuiButton-label"],button[class~="MuiButton-root"]',
MuiToggleButtonLabel: 'span[class^="MuiToggleButton-label"]',
MuiBoxLabel: 'div[class*="MuiBox-root"] label',
MuiTableHead: 'th[class*="MuiTableCell-root"]',
Expand Down

0 comments on commit d907bac

Please sign in to comment.