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

Commit 503a2f7

Browse files
mrrajanRajan Ravi
andauthored
Tests for SBOM Vulnerabilities Summary Panel (#40)
Added test for SBOM Explorer Vulnerabilities tab to verify the vulnerabilities count - Validation for individual severity count - Comparison for PieChart total value to individual severity counts [test-results.zip](https://github.com/user-attachments/files/19446544/test-results.zip) --------- Signed-off-by: Rajan Ravi <rravi@rravi-thinkpadp1gen4i.bengluru.csb> Co-authored-by: Rajan Ravi <rravi@rravi-thinkpadp1gen4i.bengluru.csb>
1 parent e1d585c commit 503a2f7

File tree

7 files changed

+473
-33
lines changed

7 files changed

+473
-33
lines changed

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

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Feature: SBOM Explorer - View SBOM details
33
Given User is authenticated
44

55
Scenario Outline: View SBOM Overview
6-
Given User visits SBOM details Page of "<sbomName>"
6+
Given An ingested "<sbomType>" SBOM "<sbomName>" is available
7+
When User visits SBOM details Page of "<sbomName>"
78
Then The page title is "<sbomName>"
89
And Tab "Info" is visible
910
And Tab "Packages" is visible
@@ -15,7 +16,8 @@ Feature: SBOM Explorer - View SBOM details
1516
| quarkus-bom |
1617

1718
Scenario Outline: View SBOM Info (Metadata)
18-
Given User visits SBOM details Page of "<sbomName>"
19+
Given An ingested "<sbomType>" SBOM "<sbomName>" is available
20+
When User visits SBOM details Page of "<sbomName>"
1921
Then Tab "Info" is selected
2022
Then "SBOM's name" is visible
2123
And "SBOM's namespace" is visible
@@ -26,18 +28,20 @@ Feature: SBOM Explorer - View SBOM details
2628
Examples:
2729
| sbomName |
2830
| quarkus-bom |
29-
31+
3032
Scenario Outline: Downloading SBOM file
31-
Given User visits SBOM details Page of "<sbomName>"
33+
Given An ingested "<sbomType>" SBOM "<sbomName>" is available
34+
When User visits SBOM details Page of "<sbomName>"
3235
Then "Download SBOM" action is invoked and downloaded filename is "<expectedSbomFilename>"
3336
Then "Download License Report" action is invoked and downloaded filename is "<expectedLicenseFilename>"
3437

3538
Examples:
3639
| sbomName | expectedSbomFilename | expectedLicenseFilename |
3740
| quarkus-bom | quarkus-bom.json | quarkus-bom_licenses.tar.gz |
38-
41+
3942
Scenario Outline: View list of SBOM Packages
40-
Given User visits SBOM details Page of "<sbomName>"
43+
Given An ingested "<sbomType>" SBOM "<sbomName>" is available
44+
When User visits SBOM details Page of "<sbomName>"
4145
When User selects the Tab "Packages"
4246
# confirms its visible for all tabs
4347
Then The page title is "<sbomName>"
@@ -55,5 +59,42 @@ Feature: SBOM Explorer - View SBOM details
5559
Then The Package table total results is greather than 1
5660

5761
Examples:
58-
| sbomName | packageName |
59-
| quarkus-bom | jdom |
62+
| sbomType | sbomName | packageName |
63+
| SPDX | quarkus-bom | jdom |
64+
65+
Scenario Outline: View <sbomType> SBOM Vulnerabilities
66+
Given An ingested "<sbomType>" SBOM "<sbomName>" containing Vulnerabilities
67+
When User visits SBOM details Page of "<sbomName>"
68+
When User selects the Tab "Vulnerabilities"
69+
When User Clicks on Vulnerabilities Tab Action
70+
Then Vulnerability Popup menu appears with message
71+
Then Vulnerability Risk Profile circle should be visible
72+
Then Vulnerability Risk Profile shows summary of vulnerabilities
73+
Then SBOM Name "<sbomName>" should be visible inside the tab
74+
Then SBOM Version should be visible inside the tab
75+
Then SBOM Creation date should be visible inside the tab
76+
# Then List of related Vulnerabilities should be sorted by "CVSS" in descending order
77+
78+
Examples:
79+
| sbomType | sbomName |
80+
| SPDX | quarkus-bom |
81+
82+
@slow
83+
Scenario Outline: Pagination of <sbomType> SBOM Vulnerabilities
84+
Given An ingested "<sbomType>" SBOM "<sbomName>" containing Vulnerabilities
85+
When User visits SBOM details Page of "<sbomName>"
86+
When User selects the Tab "Vulnerabilities"
87+
Then Pagination of Vulnerabilities list works
88+
Examples:
89+
| sbomType | sbomName |
90+
| SPDX | quarkus-bom |
91+
92+
@slow
93+
Scenario Outline: View paginated list of <sbomType> SBOM Packages
94+
Given An ingested "<sbomType>" SBOM "<sbomName>" is available
95+
When User visits SBOM details Page of "<sbomName>"
96+
When User selects the Tab "Packages"
97+
Then Pagination of Packages list works
98+
Examples:
99+
| sbomType | sbomName |
100+
| SPDX | quarkus-bom |

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

Lines changed: 98 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@ import { createBdd } from "playwright-bdd";
22
import { expect } from "playwright/test";
33
import { DetailsPage } from "../../helpers/DetailsPage";
44
import { ToolbarTable } from "../../helpers/ToolbarTable";
5+
import { SearchPage } from "../../helpers/SearchPage";
56

67
export const { Given, When, Then } = createBdd();
78

89
const PACKAGE_TABLE_NAME = "Package table";
10+
const VULN_TABLE_NAME = "Vulnerability table";
911

1012
Given(
13+
"An ingested {string} SBOM {string} is available",
14+
async ({ page }, _sbomType, sbomName) => {
15+
const searchPage = new SearchPage(page);
16+
await searchPage.dedicatedSearch("SBOMs", sbomName);
17+
}
18+
);
19+
20+
When(
1121
"User visits SBOM details Page of {string}",
1222
async ({ page }, sbomName) => {
13-
await page.goto("/");
14-
await page.getByRole("link", { name: "SBOMs" }).click();
15-
16-
await page.getByPlaceholder("Search").click();
17-
await page.getByPlaceholder("Search").fill(sbomName);
18-
await page.getByPlaceholder("Search").press("Enter");
19-
2023
await page.getByRole("link", { name: sbomName, exact: true }).click();
2124
}
2225
);
@@ -31,7 +34,7 @@ Then(
3134
const downloadPromise = page.waitForEvent("download");
3235

3336
const detailsPage = new DetailsPage(page);
34-
detailsPage.clickOnPageAction(actionName);
37+
await detailsPage.clickOnPageAction(actionName);
3538

3639
const download = await downloadPromise;
3740

@@ -44,7 +47,7 @@ Then(
4447
"The Package table is sorted by {string}",
4548
async ({ page }, columnName) => {
4649
const toolbarTable = new ToolbarTable(page, PACKAGE_TABLE_NAME);
47-
toolbarTable.verifyTableIsSortedBy(columnName);
50+
await toolbarTable.verifyTableIsSortedBy(columnName);
4851
}
4952
);
5053

@@ -78,3 +81,89 @@ Then(
7881
await toolbarTable.verifyColumnContainsText(columnName, expectedValue);
7982
}
8083
);
84+
85+
Given(
86+
"An ingested {string} SBOM {string} containing Vulnerabilities",
87+
async ({ page }, _sbomType, sbomName) => {
88+
const searchPage = new SearchPage(page);
89+
await searchPage.dedicatedSearch("SBOMs", sbomName);
90+
const element = await page.locator(
91+
`xpath=(//tr[contains(.,'${sbomName}')]/td[@data-label='Vulnerabilities']/div)[1]`
92+
);
93+
await expect(element, "SBOM have no vulnerabilities").toHaveText(
94+
/^(?!0$).+/
95+
);
96+
}
97+
);
98+
99+
When("User Clicks on Vulnerabilities Tab Action", async ({ page }) => {
100+
await page.getByLabel("Tab action").click();
101+
});
102+
103+
Then("Vulnerability Popup menu appears with message", async ({ page }) => {
104+
await page.getByText("Any found vulnerabilities").isVisible();
105+
await page.getByLabel("Close").click();
106+
});
107+
108+
Then(
109+
"Vulnerability Risk Profile circle should be visible",
110+
async ({ page }) => {
111+
await page.locator(`xpath=//div[contains(@class, 'chart')]`).isVisible();
112+
}
113+
);
114+
115+
Then(
116+
"Vulnerability Risk Profile shows summary of vulnerabilities",
117+
async ({ page }) => {
118+
const detailsPage = new DetailsPage(page);
119+
await detailsPage.verifyVulnerabilityPanelcount();
120+
}
121+
);
122+
123+
Then(
124+
"SBOM Name {string} should be visible inside the tab",
125+
async ({ page }, sbomName) => {
126+
const panelSbomName = await page.locator(
127+
`xpath=//section[@id='refVulnerabilitiesSection']//dt[contains(.,'Name')]/following-sibling::dd`
128+
);
129+
await panelSbomName.isVisible();
130+
await expect(await panelSbomName.textContent()).toEqual(sbomName);
131+
}
132+
);
133+
134+
Then("SBOM Version should be visible inside the tab", async ({ page }) => {
135+
const panelSBOMVersion = await page.locator(
136+
`xpath=//section[@id='refVulnerabilitiesSection']//dt[contains(.,'Version')]/following-sibling::dd`
137+
);
138+
await panelSBOMVersion.isVisible();
139+
});
140+
141+
Then(
142+
"SBOM Creation date should be visible inside the tab",
143+
async ({ page }) => {
144+
const panelSBOMVersion = await page.locator(
145+
`xpath=//section[@id='refVulnerabilitiesSection']//dt[contains(.,'Creation date')]/following-sibling::dd`
146+
);
147+
await panelSBOMVersion.isVisible();
148+
}
149+
);
150+
151+
Then(
152+
"List of related Vulnerabilities should be sorted by {string} in descending order",
153+
async ({ page }, columnName) => {
154+
const toolbarTable = new ToolbarTable(page, VULN_TABLE_NAME);
155+
await toolbarTable.verifyTableIsSortedBy(columnName, false);
156+
}
157+
);
158+
159+
Then("Pagination of Vulnerabilities list works", async ({ page }) => {
160+
const toolbarTable = new ToolbarTable(page, VULN_TABLE_NAME);
161+
const vulnTableTopPagination = `xpath=//div[@id="vulnerability-table-pagination-top"]`;
162+
await toolbarTable.verifyPagination(vulnTableTopPagination);
163+
});
164+
165+
Then("Pagination of Packages list works", async ({ page }) => {
166+
const toolbarTable = new ToolbarTable(page, PACKAGE_TABLE_NAME);
167+
const vulnTableTopPagination = `xpath=//div[@id="package-table-pagination-top"]`;
168+
await toolbarTable.verifyPagination(vulnTableTopPagination);
169+
});

tests/ui/features/@vulnerability-explorer/vulnerability-explorer.step.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createBdd } from "playwright-bdd";
22
import { ToolbarTable } from "../../helpers/ToolbarTable";
3+
import { SearchPage } from "../../helpers/SearchPage";
34

45
export const { Given, When, Then } = createBdd();
56

@@ -9,13 +10,8 @@ const ADVISORY_TABLE_NAME = "Advisory table";
910
Given(
1011
"User visits Vulnerability details Page of {string}",
1112
async ({ page }, vulnerabilityID) => {
12-
await page.goto("/");
13-
await page.getByRole("link", { name: "Vulnerabilities" }).click();
14-
15-
await page.getByPlaceholder("Search").click();
16-
await page.getByPlaceholder("Search").fill(vulnerabilityID);
17-
await page.getByPlaceholder("Search").press("Enter");
18-
13+
const searchPage = new SearchPage(page);
14+
await searchPage.dedicatedSearch("Vulnerabilities", vulnerabilityID);
1915
await page.getByRole("link", { name: vulnerabilityID }).click();
2016
}
2117
);
@@ -24,7 +20,7 @@ Given(
2420

2521
Then("The SBOMs table is sorted by {string}", async ({ page }, columnName) => {
2622
const toolbarTable = new ToolbarTable(page, SBOM_TABLE_NAME);
27-
toolbarTable.verifyTableIsSortedBy(columnName);
23+
await toolbarTable.verifyTableIsSortedBy(columnName);
2824
});
2925

3026
Then(
@@ -63,7 +59,7 @@ Then(
6359
"The Advisory table is sorted by {string}",
6460
async ({ page }, columnName) => {
6561
const toolbarTable = new ToolbarTable(page, ADVISORY_TABLE_NAME);
66-
toolbarTable.verifyTableIsSortedBy(columnName);
62+
await toolbarTable.verifyTableIsSortedBy(columnName);
6763
}
6864
);
6965

tests/ui/features/sbom-explorer.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ Feature: SBOM Explorer - View SBOM details
174174
| SPDX |
175175

176176
Scenario Outline: View <sbomType> SBOM Vulnerabilities
177-
Given there is ingested <sbomType> SBOM which is affected by Vulnerabilities
178-
When user visits SBOM details page
179-
And user selects Vulnerabilities tab
177+
Given An ingested <sbomType> SBOM containing Vulnerabilities
178+
When User visits SBOM details page
179+
And Selects Vulnerabilities tab
180180
Then Vulnerability Risk Profile circle should be visible
181181
And Vulnerability Risk Profile shows summary of vulnerabilities
182182
And SBOM Name should be visible inside the tab
183183
And SBOM Version should be visible inside the tab
184184
And SBOM Creation date should be visible inside the tab
185-
And list of related Vulnerabilities should be sorted by CVSS in descending order
185+
And List of related Vulnerabilities should be sorted by CVSS in descending order
186186

187187
Examples:
188188
| sbomType |

0 commit comments

Comments
 (0)