This repository was archived by the owner on Sep 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Automate Advisories Vulnerability tab #67
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d774922
add license explorer feature file
807aa2e
Merge remote-tracking branch 'upstream/main'
98e05b1
Merge remote-tracking branch 'upstream/main'
1ec128a
Automate Advisories Vulnerability tab
e7a8955
update feature file
62549ae
prettier and change advisory name
a09221a
change advisory id
b06e1d1
add pagination
151fc4c
change COLUMN_LABELS list to be handled as part of BDD statement
c76cc68
Merge branch 'main' into tests
a-oren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
tests/ui/features/@advisory-explorer/advisory-explorer.feature
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| Feature: Advisory Explorer | ||
| Background: Authentication | ||
| Given User is authenticated | ||
|
|
||
| # Advisory Vulnerabilities | ||
| Scenario: Display vulnerabilities tied to a single advisory | ||
| Given User visits Advisory details Page of "<advisoryName>" | ||
| Then User navigates to the Vulnerabilites tab on the Advisory Overview page | ||
| Then Pagination of Vulnerabilities list works | ||
| Then A list of all active vulnerabilites tied to the advisory should display | ||
| And The ID, Title, Discovery, Release, Score and CWE information should be visible for each vulnerability | ||
| And The vulnerabilities should be sorted by ID by default | ||
| And User visits Vulnerability details Page of "<vulnerabilityID>" by clicking it | ||
|
|
||
| Examples: | ||
| | advisoryName | vulnerabilityID | | ||
| | CVE-2023-3223 | CVE-2023-3223 | | ||
|
|
92 changes: 92 additions & 0 deletions
92
tests/ui/features/@advisory-explorer/advisory-explorer.step.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import { createBdd } from "playwright-bdd"; | ||
| import { expect } from "playwright/test"; | ||
| import { ToolbarTable } from "../../helpers/ToolbarTable"; | ||
| import { SearchPage } from "../../helpers/SearchPage"; | ||
|
|
||
| export const { Given, When, Then } = createBdd(); | ||
|
|
||
| const VULN_TABLE_NAME = "vulnerability table"; | ||
| const COLUMN_LABELS = ["ID", "Title", "Discovery", "Release", "Score", "CWE"]; | ||
|
|
||
| Given( | ||
| "User visits Advisory details Page of {string}", | ||
| async ({ page }, advisoryName) => { | ||
| const searchPage = new SearchPage(page, "Advisories"); | ||
| await searchPage.dedicatedSearch(advisoryName); | ||
| await page.getByRole("link", { name: advisoryName }).click(); | ||
| } | ||
| ); | ||
|
|
||
| Then( | ||
| "User navigates to the Vulnerabilites tab on the Advisory Overview page", | ||
| async ({ page }) => { | ||
| await page.getByRole("tab", { name: "Vulnerabilities" }).click(); | ||
| } | ||
| ); | ||
|
|
||
| Then("Pagination of Vulnerabilities list works", async ({ page }) => { | ||
| const toolbarTable = new ToolbarTable(page, VULN_TABLE_NAME); | ||
| const vulnTableTopPagination = `xpath=//div[@id="vulnerability-table-pagination-top"]`; | ||
| await toolbarTable.verifyPagination(vulnTableTopPagination); | ||
| }); | ||
|
|
||
| Then( | ||
| "A list of all active vulnerabilites tied to the advisory should display", | ||
| async ({ page }) => { | ||
| const totalItemsLocator = page | ||
| .locator( | ||
| "#vulnerability-table-pagination-top .pf-v6-c-pagination__page-menu" | ||
| ) | ||
| .first(); | ||
|
|
||
| await expect(totalItemsLocator).toBeVisible(); | ||
|
|
||
| const totalText = await totalItemsLocator.textContent(); | ||
| const match = totalText?.match(/of\s+(\d+)/); | ||
| expect(match, "unable to parse pagination total").not.toBeNull(); | ||
|
|
||
| const total = Number(match![1]); | ||
| expect(total).toBeGreaterThan(0); | ||
| } | ||
| ); | ||
|
|
||
| Then( | ||
| "The ID, Title, Discovery, Release, Score and CWE information should be visible for each vulnerability", | ||
| async ({ page }) => { | ||
| for (const label of COLUMN_LABELS) { | ||
| const header = page.getByRole("columnheader", { name: label }); | ||
| if (await header.count()) { | ||
| await expect(header).toBeVisible(); | ||
| } else { | ||
| await expect(page.getByRole("button", { name: label })).toBeVisible(); | ||
| } | ||
| } | ||
| } | ||
| ); | ||
|
|
||
| Then( | ||
| "The vulnerabilities should be sorted by ID by default", | ||
| async ({ page }) => { | ||
| const toolbarTable = new ToolbarTable(page, VULN_TABLE_NAME); | ||
| await toolbarTable.verifyTableIsSortedBy("ID"); | ||
| } | ||
| ); | ||
|
|
||
| Then( | ||
| "User visits Vulnerability details Page of {string} by clicking it", | ||
| async ({ page }, vulnerabilityID) => { | ||
| const link = page.getByRole("link", { name: vulnerabilityID }); | ||
|
|
||
| await Promise.all([ | ||
| page.waitForURL(new RegExp(`/vulnerabilities/${vulnerabilityID}$`)), | ||
| link.click(), | ||
| ]); | ||
|
|
||
| await expect( | ||
| page.getByRole("heading", { | ||
| level: 1, | ||
| name: new RegExp(`^${vulnerabilityID}\\s*$`), | ||
| }) | ||
| ).toBeVisible(); | ||
| } | ||
| ); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Instead of creating column name list, the column headers can be parsed from the BDD statement like https://github.com/trustification/trustify-tests/blob/main/tests/ui/features/%40sbom-explorer/sbom-explorer.step.ts#L184