Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Commit cd80755

Browse files
add sbom info tab tests
Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
1 parent ecf3f23 commit cd80755

File tree

6 files changed

+174
-30
lines changed

6 files changed

+174
-30
lines changed
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
import { expect, Page } from "@playwright/test";
1+
import { expect, Locator, Page } from "@playwright/test";
22

3-
export class DetailsPage {
3+
export class DetailsPageLayout {
44
private _page: Page;
5+
_detailsPage: Locator;
56

6-
constructor(page: Page) {
7+
private constructor(page: Page) {
78
this._page = page;
89
}
910

11+
static async build(page: Page) {
12+
await expect(page.locator("nav[aria-label='Breadcrumb']")).toBeVisible();
13+
return new DetailsPageLayout(page);
14+
}
15+
1016
async selectTab(tabName: string) {
1117
const tab = this._page.locator("button[role='tab']", { hasText: tabName });
1218
await expect(tab).toBeVisible();

tests/ui/pages/LabelsModal.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { Locator, Page } from "playwright-core";
2+
import { expect } from "playwright/test";
3+
4+
/**
5+
* Used to navigate to different pages
6+
*/
7+
export class LabelsModal {
8+
private _page: Page;
9+
private _dialog: Locator;
10+
11+
private constructor(page: Page, dialog: Locator) {
12+
this._page = page;
13+
this._dialog = dialog;
14+
}
15+
16+
static async build(page: Page) {
17+
const dialog = page.getByRole("dialog");
18+
expect(dialog).toBeVisible();
19+
return new LabelsModal(page, dialog);
20+
}
21+
22+
async clickSave() {
23+
await this._dialog.locator("button[aria-label='submit']").click();
24+
await expect(this._dialog).not.toBeVisible();
25+
}
26+
27+
async addLabels(labels: string[]) {
28+
const inputText = this._dialog.getByPlaceholder("Add label");
29+
30+
for (const label of labels) {
31+
await inputText.click();
32+
await inputText.fill(label);
33+
await inputText.press("Enter");
34+
}
35+
}
36+
37+
async removeLabels(labels: string[]) {
38+
for (const label of labels) {
39+
await this._dialog
40+
.locator(".pf-v6-c-label-group__list-item", {
41+
hasText: label,
42+
})
43+
.locator("button")
44+
.click();
45+
}
46+
}
47+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { expect, Page } from "@playwright/test";
2+
import { SBOMListPage } from "../Constants";
3+
import { DetailsPageLayout } from "../DetailsPageLayout";
4+
import { Navigation } from "../Navigation";
5+
import { Table } from "../Table";
6+
import { Toolbar } from "../Toolbar";
7+
8+
export class SbomDetailsPage {
9+
private _page: Page;
10+
_layout: DetailsPageLayout;
11+
12+
private constructor(page: Page, layout: DetailsPageLayout) {
13+
this._page = page;
14+
this._layout = layout;
15+
}
16+
17+
static async build(page: Page, sbomName: string) {
18+
const navigation = await Navigation.build(page);
19+
await navigation.goToSidebar("SBOMs");
20+
21+
const toolbar = await Toolbar.build(page, SBOMListPage.toolbarAriaLabel);
22+
const table = await Table.build(page, SBOMListPage.tableAriaLabel);
23+
24+
await toolbar.applyTextFilter(SBOMListPage.filters.filterText, sbomName);
25+
await table.waitUntilDataIsLoaded();
26+
await table.verifyColumnContainsText("Name", sbomName);
27+
28+
await page.getByRole("link", { name: "quarkus-bom", exact: true }).click();
29+
30+
const layout = await DetailsPageLayout.build(page);
31+
await expect(page.getByRole("heading", { name: sbomName })).toBeVisible();
32+
33+
return new SbomDetailsPage(page, layout);
34+
}
35+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// @ts-check
2+
3+
import { expect, test } from "@playwright/test";
4+
5+
import { login } from "../../helpers/Auth";
6+
import { SbomDetailsPage } from "./SbomDetailsPage";
7+
8+
test.describe("Action validations", { tag: "@tier1" }, () => {
9+
test.beforeEach(async ({ page }) => {
10+
await login(page);
11+
});
12+
13+
test("Actions - Download SBOM", async ({ page }) => {
14+
const detailsPage = await SbomDetailsPage.build(page, "quarkus-bom");
15+
16+
const downloadPromise = page.waitForEvent("download");
17+
await detailsPage._layout.clickOnPageAction("Download SBOM");
18+
const download = await downloadPromise;
19+
const filename = download.suggestedFilename();
20+
expect(filename).toEqual("quarkus-bom.json");
21+
});
22+
23+
test("Actions - Download License Report", async ({ page }) => {
24+
const detailsPage = await SbomDetailsPage.build(page, "quarkus-bom");
25+
26+
const downloadPromise = page.waitForEvent("download");
27+
await detailsPage._layout.clickOnPageAction("Download License Report");
28+
const download = await downloadPromise;
29+
const filename = download.suggestedFilename();
30+
expect(filename).toContain("quarkus-bom");
31+
});
32+
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// @ts-check
2+
3+
import { expect, test } from "@playwright/test";
4+
5+
import { login } from "../../../helpers/Auth";
6+
import { SbomDetailsPage } from "../SbomDetailsPage";
7+
import { LabelsModal } from "../../LabelsModal";
8+
9+
test.describe("Info Tab validations", { tag: "@tier1" }, () => {
10+
test.beforeEach(async ({ page }) => {
11+
await login(page);
12+
});
13+
14+
test("Labels", async ({ page }) => {
15+
await SbomDetailsPage.build(page, "quarkus-bom");
16+
const labels = ["color=red", "production"];
17+
18+
// Open Edit Labels Modal
19+
await page.getByRole("button", { name: "Edit" }).click();
20+
21+
let labelsModal = await LabelsModal.build(page);
22+
await labelsModal.addLabels(labels);
23+
await labelsModal.clickSave();
24+
25+
for (const label of labels) {
26+
await expect(
27+
page.locator(".pf-v6-c-label-group__list-item", { hasText: label })
28+
).toHaveCount(1);
29+
}
30+
31+
// Clean labels added previously
32+
await page.getByRole("button", { name: "Edit" }).click();
33+
34+
labelsModal = await LabelsModal.build(page);
35+
await labelsModal.removeLabels(labels);
36+
await labelsModal.clickSave();
37+
38+
for (const label of labels) {
39+
await expect(
40+
page.locator(".pf-v6-c-label-group__list-item", { hasText: label })
41+
).toHaveCount(0);
42+
}
43+
});
44+
});

tests/ui/pages/sbom-list/actions.spec.ts

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { login } from "../../helpers/Auth";
66
import { SBOMListPage } from "../Constants";
77
import { Navigation } from "../Navigation";
88
import { Table } from "../Table";
9+
import { LabelsModal } from "../LabelsModal";
910

1011
test.describe("Action validations", { tag: "@tier1" }, () => {
1112
test.beforeEach(async ({ page }) => {
@@ -49,25 +50,11 @@ test.describe("Action validations", { tag: "@tier1" }, () => {
4950
const table = await Table.build(page, SBOMListPage.tableAriaLabel);
5051
await table.clickAction("Edit labels", 0);
5152

52-
// Verify Modal is open
53-
const dialog = page.getByRole("dialog");
54-
expect(dialog).toBeVisible();
55-
56-
const saveLabels = async () => {
57-
await dialog.locator("button[aria-label='submit']").click();
58-
await expect(dialog).not.toBeVisible();
59-
};
53+
let labelsModal = await LabelsModal.build(page);
6054

6155
// Add labels
62-
const inputText = dialog.getByPlaceholder("Add label");
63-
64-
for (const label of labels) {
65-
await inputText.click();
66-
await inputText.fill(label);
67-
await inputText.press("Enter");
68-
}
69-
70-
await saveLabels();
56+
await labelsModal.addLabels(labels);
57+
await labelsModal.clickSave();
7158

7259
// Verify labels were added
7360
await table.waitUntilDataIsLoaded();
@@ -83,18 +70,11 @@ test.describe("Action validations", { tag: "@tier1" }, () => {
8370
// Clean labels added previously
8471
await table.clickAction("Edit labels", 0);
8572

86-
for (const label of labels) {
87-
await dialog
88-
.locator(".pf-v6-c-label-group__list-item", {
89-
hasText: label,
90-
})
91-
.locator("button")
92-
.click();
93-
}
73+
labelsModal = await LabelsModal.build(page);
74+
await labelsModal.removeLabels(labels);
75+
await labelsModal.clickSave();
9476

95-
await saveLabels();
9677
await table.waitUntilDataIsLoaded();
97-
9878
for (const label of labels) {
9979
await expect(
10080
table._table

0 commit comments

Comments
 (0)