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

Commit 1e92bc3

Browse files
make sbom packge tab reusable
1 parent 5fa7690 commit 1e92bc3

File tree

14 files changed

+76
-102
lines changed

14 files changed

+76
-102
lines changed

tests/ui/helpers/ToolbarTable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect, Page } from "@playwright/test";
22
export class ToolbarTable {
3-
private _page: Page;
3+
private readonly _page: Page;
44
private _tableName: string;
55

66
constructor(page: Page, tableName: string) {

tests/ui/pages/Constants.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
export const DetailsPage_SBOM = {
2-
packagesTab: {
3-
toolbarAriaLabel: "Package toolbar",
4-
tableAriaLabel: "Package table",
5-
paginationIdTop: "package-table-pagination-top",
6-
paginationIdBottom: "package-table-pagination-bottom",
7-
filters: {
8-
filterText: "Filter text",
9-
license: "License",
10-
},
11-
},
12-
};
13-
141
export const isSorted = (arr: string[], asc: boolean) => {
152
let sorted = [...arr].sort((a, b) => a.localeCompare(b));
163
if (!asc) {

tests/ui/pages/DetailsPageLayout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, Page } from "@playwright/test";
22

33
export class DetailsPageLayout {
4-
private _page: Page;
4+
private readonly _page: Page;
55

66
private constructor(page: Page) {
77
this._page = page;

tests/ui/pages/LabelsModal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Locator, Page } from "playwright-core";
22
import { expect } from "playwright/test";
33

44
export class LabelsModal {
5-
private _page: Page;
5+
private readonly _page: Page;
66
private _dialog: Locator;
77

88
private constructor(page: Page, dialog: Locator) {

tests/ui/pages/Navigation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Page } from "playwright-core";
44
* Used to navigate to different pages
55
*/
66
export class Navigation {
7-
private _page: Page;
7+
private readonly _page: Page;
88

99
private constructor(page: Page) {
1010
this._page = page;

tests/ui/pages/Pagination.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, Locator, Page } from "@playwright/test";
22
import { Table } from "./Table";
33

44
export class Pagination {
5-
private _page: Page;
5+
private readonly _page: Page;
66
_pagination: Locator;
77

88
private constructor(page: Page, pagination: Locator) {

tests/ui/pages/Table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, Locator, Page } from "@playwright/test";
22

33
export class Table {
4-
private _page: Page;
4+
private readonly _page: Page;
55
_table: Locator;
66

77
private constructor(page: Page, table: Locator) {

tests/ui/pages/Toolbar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, Locator, Page } from "@playwright/test";
22

33
export class Toolbar {
4-
private _page: Page;
4+
private readonly _page: Page;
55
_toolbar: Locator;
66

77
private constructor(page: Page, toolbar: Locator) {

tests/ui/pages/sbom-details/SbomDetailsPage.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { expect, Page } from "@playwright/test";
2-
import { ListPage_SBOM } from "../Constants";
32
import { DetailsPageLayout } from "../DetailsPageLayout";
43
import { Navigation } from "../Navigation";
5-
import { Table } from "../Table";
6-
import { Toolbar } from "../Toolbar";
4+
import { SbomListPage } from "../sbom-list/SbomListPage";
75

86
export class SbomDetailsPage {
9-
private _page: Page;
7+
private readonly _page: Page;
108
_layout: DetailsPageLayout;
119

1210
private constructor(page: Page, layout: DetailsPageLayout) {
@@ -18,10 +16,11 @@ export class SbomDetailsPage {
1816
const navigation = await Navigation.build(page);
1917
await navigation.goToSidebar("SBOMs");
2018

21-
const toolbar = await Toolbar.build(page, ListPage_SBOM.toolbarAriaLabel);
22-
const table = await Table.build(page, ListPage_SBOM.tableAriaLabel);
19+
const listPage = await SbomListPage.build(page);
20+
const toolbar = await listPage.getToolbar();
21+
const table = await listPage.getTable();
2322

24-
await toolbar.applyTextFilter(ListPage_SBOM.filters.filterText, sbomName);
23+
await toolbar.applyTextFilter("Filter text", sbomName);
2524
await table.waitUntilDataIsLoaded();
2625
await table.verifyColumnContainsText("Name", sbomName);
2726

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Page } from "@playwright/test";
2+
import { SbomDetailsPage } from "../SbomDetailsPage";
3+
import { Toolbar } from "../../Toolbar";
4+
import { Table } from "../../Table";
5+
import { Pagination } from "../../Pagination";
6+
7+
export class PackageTab {
8+
private readonly _page: Page;
9+
_detailsPage: SbomDetailsPage;
10+
11+
private constructor(page: Page, layout: SbomDetailsPage) {
12+
this._page = page;
13+
this._detailsPage = layout;
14+
}
15+
16+
static async build(page: Page, sbomName: string) {
17+
const detailsPage = await SbomDetailsPage.build(page, sbomName);
18+
await detailsPage._layout.selectTab("Packages");
19+
20+
return new PackageTab(page, detailsPage);
21+
}
22+
23+
async getToolbar() {
24+
return await Toolbar.build(this._page, "Package toolbar");
25+
}
26+
27+
async getTable() {
28+
return await Table.build(this._page, "Package table");
29+
}
30+
31+
async getPagination(top: boolean = true) {
32+
return await Pagination.build(
33+
this._page,
34+
`package-table-pagination-${top ? "top" : "bottom"}`
35+
);
36+
}
37+
}

0 commit comments

Comments
 (0)