Skip to content

Commit 93fc4ab

Browse files
authored
test: script for AIBOM and CBOM label validation (#913)
Signed-off-by: mrrajan <86094767+mrrajan@users.noreply.github.com.>
1 parent 0bef992 commit 93fc4ab

File tree

8 files changed

+112
-8
lines changed

8 files changed

+112
-8
lines changed
769 Bytes
Binary file not shown.
4.37 KB
Binary file not shown.

e2e/tests/ui/assertions/TableMatchers.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface TableMatchers<
1313
toHaveColumnWithValue(
1414
columnName: TColumns[number],
1515
value: string | RegExp,
16-
rowIndex?: number,
16+
rowIndex?: number | "all",
1717
): Promise<MatcherResult>;
1818
toHaveNumberOfRows(expectedRows: {
1919
equal?: number;
@@ -64,7 +64,7 @@ export const tableAssertions = baseExpect.extend<TableMatcherDefinitions>({
6464
table: Table<TColumns, TActions>,
6565
columnName: TColumns[number],
6666
value: string | RegExp,
67-
rowIndex?: number,
67+
rowIndex?: number | "all",
6868
) => {
6969
try {
7070
if (rowIndex === undefined) {
@@ -75,6 +75,19 @@ export const tableAssertions = baseExpect.extend<TableMatcherDefinitions>({
7575
})
7676
.first(),
7777
).toBeVisible();
78+
} else if (rowIndex === "all") {
79+
const rows = table._table.locator(
80+
`td[data-label="${table._columns[0]}"]`,
81+
);
82+
await baseExpect.poll(() => rows.count()).toBeGreaterThan(0);
83+
84+
// Verify all rows in the specified column contain the expected value
85+
const column = await table.getColumn(columnName);
86+
const allRows = await column.all();
87+
88+
for (const row of allRows) {
89+
await baseExpect(row).toContainText(value);
90+
}
7891
} else {
7992
await baseExpect(
8093
table._table.locator(`td[data-label="${columnName}"]`).nth(rowIndex),
@@ -83,7 +96,15 @@ export const tableAssertions = baseExpect.extend<TableMatcherDefinitions>({
8396

8497
return {
8598
pass: true,
86-
message: () => `Table contains ${value} in column ${columnName}`,
99+
message: () => {
100+
if (rowIndex === undefined) {
101+
return `Column "${columnName}" contains value "${value}"`;
102+
} else if (rowIndex === "all") {
103+
return `All rows in column "${columnName}" contain value "${value}"`;
104+
} else {
105+
return `Row ${rowIndex} contains "${value}" in column "${columnName}"`;
106+
}
107+
},
87108
};
88109
} catch (error) {
89110
return {

e2e/tests/ui/features/@sbom-explorer/sbom-explorer.feature

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Feature: SBOM Explorer - View SBOM details
129129
Given An ingested SBOM "<sbomName>" is available
130130
When User visits SBOM details Page of "<sbomName>"
131131
When User Adds Labels "<Labels>" to "<sbomName>" SBOM from Explorer Page
132-
Then The Label list "<Labels>" added to the SBOM "<sbomName>" on Explorer Page
132+
Then The Label list "<Labels>" is visible on the Explorer Page for SBOM "<sbomName>"
133133

134134
Examples:
135135
| sbomName | Labels |
@@ -190,3 +190,21 @@ Feature: SBOM Explorer - View SBOM details
190190
Examples:
191191
| sbomName | vulnerabilityID | packageName |
192192
| quarkus-bom | CVE-2023-0044 | quarkus-vertx-http |
193+
194+
Scenario Outline: Verify Labels of CBOM on SBOM Explorer Page
195+
Given An ingested SBOM "<sbomName>" is available
196+
When User visits SBOM details Page of "<sbomName>"
197+
Then The Label list "<Labels>" is visible on the Explorer Page for SBOM "<sbomName>"
198+
199+
Examples:
200+
| sbomName | Labels |
201+
| liboqs | kind=cbom |
202+
203+
Scenario Outline: Verify Labels of AIBOM on SBOM Explorer Page
204+
Given An ingested SBOM "<sbomName>" is available
205+
When User visits SBOM details Page of "<sbomName>"
206+
Then The Label list "<Labels>" is visible on the Explorer Page for SBOM "<sbomName>"
207+
208+
Examples:
209+
| sbomName | Labels |
210+
| claude-4-opus | kind=aibom |

e2e/tests/ui/features/@sbom-explorer/sbom-explorer.step.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ When(
177177
);
178178

179179
Then(
180-
"The Label list {string} added to the SBOM {string} on Explorer Page",
180+
"The Label list {string} is visible on the Explorer Page for SBOM {string}",
181181
async ({ page }, labelList: string, sbomName: string) => {
182182
const detailsPage = new DetailsPage(page);
183183
await detailsPage.selectTab("Info");

e2e/tests/ui/features/@sbom-search/sbom-search.feature

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,42 @@ Feature: SBOM Search Page
1313
Scenario Outline: Add Labels to SBOM from SBOM List Page
1414
Given An ingested SBOM "<sbomName>" is available
1515
When User Adds Labels "<Labels>" to "<sbomName>" SBOM from List Page
16-
Then The Label list "<Labels>" added to the SBOM "<sbomName>" on List Page
16+
Then The Label list "<Labels>" is visible on the List Page for SBOM "<sbomName>"
1717

1818
Examples:
1919
| sbomName | Labels |
2020
| quarkus-bom | RANDOM_LABELS |
21+
22+
Scenario Outline: Verify Labels of CBOM on SBOM List Page
23+
Given An ingested SBOM "<sbomName>" is available
24+
Then The Label list "<Labels>" is visible on the List Page for SBOM "<sbomName>"
25+
26+
Examples:
27+
| sbomName | Labels |
28+
| liboqs | kind=cbom |
29+
30+
Scenario Outline: Verify Labels of AIBOM on SBOM List Page
31+
Given An ingested SBOM "<sbomName>" is available
32+
Then The Label list "<Labels>" is visible on the List Page for SBOM "<sbomName>"
33+
34+
Examples:
35+
| sbomName | Labels |
36+
| claude-4-opus | kind=aibom |
37+
38+
Scenario Outline: Filter AIBOM on SBOM List Page
39+
Given An ingested SBOM "<sbomName>" is available
40+
When User applies "Label" filter with "kind=aibom" on the SBOM List Page
41+
Then The SBOM List Page shows only SBOMs with label "kind=aibom"
42+
43+
Examples:
44+
| sbomName |
45+
| claude-4-opus |
46+
47+
Scenario Outline: Filter CBOM on SBOM List Page
48+
Given An ingested SBOM "<sbomName>" is available
49+
When User applies "Label" filter with "kind=cbom" on the SBOM List Page
50+
Then The SBOM List Page shows only SBOMs with label "kind=cbom"
51+
52+
Examples:
53+
| sbomName |
54+
| liboqs |

e2e/tests/ui/features/@sbom-search/sbom-search.step.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Given(
3030
When(
3131
"User Adds Labels {string} to {string} SBOM from List Page",
3232
async ({ page }, labelList, sbomName) => {
33-
const listPage = await SbomListPage.build(page);
33+
const listPage = await SbomListPage.fromCurrentPage(page);
3434
const toolbar = await listPage.getToolbar();
3535
const table = await listPage.getTable();
3636

@@ -61,7 +61,7 @@ When(
6161
);
6262

6363
Then(
64-
"The Label list {string} added to the SBOM {string} on List Page",
64+
"The Label list {string} is visible on the List Page for SBOM {string}",
6565
async ({ page }, labelList, sbomName) => {
6666
const detailsPage = new DetailsPage(page);
6767

@@ -74,3 +74,31 @@ Then(
7474
await detailsPage.verifyLabels(labelsToVerify, sbomName);
7575
},
7676
);
77+
78+
When(
79+
"User applies {string} filter with {string} on the SBOM List Page",
80+
async ({ page }, filterName: string, filterValue: string) => {
81+
const listPage = await SbomListPage.build(page);
82+
const toolbar = await listPage.getToolbar();
83+
const table = await listPage.getTable();
84+
if (filterName === "Label") {
85+
await toolbar.applyFilter({ Label: [filterValue] });
86+
} else if (filterName === "Filter text") {
87+
await toolbar.applyFilter({ "Filter text": filterValue });
88+
} else if (filterName === "License") {
89+
await toolbar.applyFilter({ License: [filterValue] });
90+
}
91+
await table.waitUntilDataIsLoaded();
92+
},
93+
);
94+
95+
Then(
96+
"The SBOM List Page shows only SBOMs with label {string}",
97+
async ({ page }, labelValue: string) => {
98+
const listPage = await SbomListPage.fromCurrentPage(page);
99+
const table = await listPage.getTable();
100+
const toolbar = await listPage.getToolbar();
101+
await expect(toolbar).toHaveLabels({ Label: [labelValue] });
102+
await expect(table).toHaveColumnWithValue("Labels", labelValue, "all");
103+
},
104+
);

e2e/tests/ui/pages/sbom-list/SbomListPage.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ export class SbomListPage {
1414
static async build(page: Page) {
1515
const navigation = await Navigation.build(page);
1616
await navigation.goToSidebar("All SBOMs");
17+
return new SbomListPage(page);
18+
}
1719

20+
static async fromCurrentPage(page: Page) {
1821
return new SbomListPage(page);
1922
}
2023

0 commit comments

Comments
 (0)