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

Commit 1ec128a

Browse files
author
Adva Oren
committed
Automate Advisories Vulnerability tab
1 parent 98e05b1 commit 1ec128a

File tree

3 files changed

+119
-7
lines changed

3 files changed

+119
-7
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { createBdd } from "playwright-bdd";
2+
import { expect } from "playwright/test";
3+
import { ToolbarTable } from "../../helpers/ToolbarTable";
4+
import { SearchPage } from "../../helpers/SearchPage";
5+
6+
export const { Given, When, Then } = createBdd();
7+
8+
const VULN_TABLE_NAME = "vulnerability table";
9+
const COLUMN_LABELS = ["ID", "Title", "Discovery", "Release", "Score", "CWE"];
10+
11+
12+
13+
Given(
14+
"User visits Advisory details Page of {string}",
15+
async ({ page }, advisoryName) => {
16+
const searchPage = new SearchPage(page, "Advisories");
17+
await searchPage.dedicatedSearch(advisoryName);
18+
await page.getByRole("link", { name: advisoryName, exact: true }).click();
19+
}
20+
);
21+
22+
Then(
23+
"User navigates to the Vulnerabilites tab on the Advisory Overview page",
24+
async ({ page }) => {
25+
await page.getByRole("tab", { name: "Vulnerabilities" }).click();
26+
}
27+
);
28+
29+
Then("Pagination of Vulnerabilities list works", async ({ page }) => {
30+
const toolbarTable = new ToolbarTable(page, VULN_TABLE_NAME);
31+
const vulnTableTopPagination = `xpath=//div[@id="vulnerability-table-pagination-top"]`;
32+
await toolbarTable.verifyPagination(vulnTableTopPagination);
33+
});
34+
35+
Then(
36+
"A list of all active vulnerabilites tied to the advisory should display",
37+
async ({ page }) => {
38+
const totalItemsLocator = page
39+
.locator(
40+
"#vulnerability-table-pagination-top .pf-v6-c-pagination__page-menu"
41+
)
42+
.first();
43+
44+
await expect(totalItemsLocator).toBeVisible();
45+
46+
const totalText = await totalItemsLocator.textContent();
47+
const match = totalText?.match(/of\s+(\d+)/);
48+
expect(match, "unable to parse pagination total").not.toBeNull();
49+
50+
const total = Number(match![1]);
51+
expect(total).toBeGreaterThan(0);
52+
}
53+
);
54+
55+
Then(
56+
"The ID, Title, Discovery, Release, Score and CWE information should be visible for each vulnerability",
57+
async ({ page }) => {
58+
for (const label of COLUMN_LABELS) {
59+
const header = page.getByRole("columnheader", { name: label });
60+
if (await header.count()) {
61+
await expect(header).toBeVisible();
62+
} else {
63+
await expect(page.getByRole("button", { name: label })).toBeVisible();
64+
}
65+
}
66+
}
67+
);
68+
69+
Then(
70+
"The vulnerabilities should be sorted by ID by default",
71+
async ({ page }) => {
72+
const toolbarTable = new ToolbarTable(page, VULN_TABLE_NAME);
73+
await toolbarTable.verifyTableIsSortedBy("ID");
74+
}
75+
);
76+
77+
Then(
78+
"User visits Vulnerability details Page of {string} by clicking it",
79+
async ({ page }, vulnerabilityID) => {
80+
const link = page.getByRole("link", { name: vulnerabilityID });
81+
82+
await Promise.all([
83+
page.waitForURL(new RegExp(`/vulnerabilities/${vulnerabilityID}$`)),
84+
link.click(),
85+
]);
86+
87+
await expect(
88+
page.getByRole("heading", {
89+
level: 1,
90+
name: new RegExp(`^${vulnerabilityID}\\s*$`),
91+
})
92+
).toBeVisible();
93+
}
94+
);
95+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Feature: Advisory Explorer
2+
Background: Authentication
3+
Given User is authenticated
4+
5+
# Advisory Vulnerabilities
6+
Scenario: Display vulnerabilities tied to a single advisory
7+
Given User visits Advisory details Page of "<advisoryName>"
8+
Then User navigates to the Vulnerabilites tab on the Advisory Overview page
9+
Then A list of all active vulnerabilites tied to the advisory should display
10+
And The ID, Title, Discovery, Release, Score and CWE information should be visible for each vulnerability
11+
And The vulnerabilities should be sorted by ID by default
12+
And User visits Vulnerability details Page of "<vulnerabilityID>" by clicking it
13+
14+
Examples:
15+
| advisoryName | vulnerabilityID |
16+
| GHSA-526j-mv3p-f4vv | CVE-2025-54379 |
17+

tests/ui/features/advisory-explorer.feature

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ Scenario: Display notes about a single advisory
6464
Scenario: Display vulnerabilities tied to a single advisory
6565
Given User is on the Home page
6666
When User navigates to the Advisory Explorer page
67-
And User navigates to the Vulnerabilites tab on the Advisory Overview page
67+
Then User visits Advisory details Page of "<advisoryName>"
68+
Then User navigates to the Vulnerabilites tab on the Advisory Overview page
6869
Then A list of all active vulnerabilites tied to the advisory should display
6970
And The ID, Title, Discovery, Release, Score and CWE information should be visible for each vulnerability
7071
And The vulnerabilities should be sorted by ID by default
71-
And Each vulnerability should be expandable
72+
And User visits Vulnerability details Page of "<vulnerabilityID>" by clicking it
7273

73-
Scenario: Display detailed information about a single vulnerability tied to a single advisory
74+
Scenario: Pagination of Vulnerabilities
7475
Given User is on the Home page
7576
When User navigates to the Advisory Explorer page
7677
And User navigates to the Vulnerabilites tab on the Advisory Overview page
77-
And User expands the row of a selected vulnerability
78-
Then A list of all affected products, separated by status, should display
79-
And Each product should display a link to a remediation
80-
And All notes on a vulnerability should be displayed underneath the list of products
78+
Then Pagination of Vulnerabilities list works
79+
80+

0 commit comments

Comments
 (0)