-
Notifications
You must be signed in to change notification settings - Fork 10
Tests for SBOM Vulnerabilities Summary Panel #40
Changes from all commits
045ff0f
001d943
947ed5b
a754488
477b489
0839ace
036dee2
d07ec92
ba681c7
2147f41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,8 @@ Feature: SBOM Explorer - View SBOM details | |
| Given User is authenticated | ||
|
|
||
| Scenario Outline: View SBOM Overview | ||
| Given User visits SBOM details Page of "<sbomName>" | ||
| Given An ingested "<sbomType>" SBOM "<sbomName>" is available | ||
| When User visits SBOM details Page of "<sbomName>" | ||
| Then The page title is "<sbomName>" | ||
| And Tab "Info" is visible | ||
| And Tab "Packages" is visible | ||
|
|
@@ -15,7 +16,8 @@ Feature: SBOM Explorer - View SBOM details | |
| | quarkus-bom | | ||
|
|
||
| Scenario Outline: View SBOM Info (Metadata) | ||
| Given User visits SBOM details Page of "<sbomName>" | ||
| Given An ingested "<sbomType>" SBOM "<sbomName>" is available | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, |
||
| When User visits SBOM details Page of "<sbomName>" | ||
| Then Tab "Info" is selected | ||
| Then "SBOM's name" is visible | ||
| And "SBOM's namespace" is visible | ||
|
|
@@ -26,18 +28,20 @@ Feature: SBOM Explorer - View SBOM details | |
| Examples: | ||
| | sbomName | | ||
| | quarkus-bom | | ||
|
|
||
| Scenario Outline: Downloading SBOM file | ||
| Given User visits SBOM details Page of "<sbomName>" | ||
| Given An ingested "<sbomType>" SBOM "<sbomName>" is available | ||
| When User visits SBOM details Page of "<sbomName>" | ||
| Then "Download SBOM" action is invoked and downloaded filename is "<expectedSbomFilename>" | ||
| Then "Download License Report" action is invoked and downloaded filename is "<expectedLicenseFilename>" | ||
|
|
||
| Examples: | ||
| | sbomName | expectedSbomFilename | expectedLicenseFilename | | ||
| | quarkus-bom | quarkus-bom.json | quarkus-bom_licenses.tar.gz | | ||
|
|
||
| Scenario Outline: View list of SBOM Packages | ||
| Given User visits SBOM details Page of "<sbomName>" | ||
| Given An ingested "<sbomType>" SBOM "<sbomName>" is available | ||
| When User visits SBOM details Page of "<sbomName>" | ||
| When User selects the Tab "Packages" | ||
| # confirms its visible for all tabs | ||
| Then The page title is "<sbomName>" | ||
|
|
@@ -55,5 +59,42 @@ Feature: SBOM Explorer - View SBOM details | |
| Then The Package table total results is greather than 1 | ||
|
|
||
| Examples: | ||
| | sbomName | packageName | | ||
| | quarkus-bom | jdom | | ||
| | sbomType | sbomName | packageName | | ||
| | SPDX | quarkus-bom | jdom | | ||
|
|
||
| Scenario Outline: View <sbomType> SBOM Vulnerabilities | ||
| Given An ingested "<sbomType>" SBOM "<sbomName>" containing Vulnerabilities | ||
| When User visits SBOM details Page of "<sbomName>" | ||
| When User selects the Tab "Vulnerabilities" | ||
| When User Clicks on Vulnerabilities Tab Action | ||
| Then Vulnerability Popup menu appears with message | ||
| Then Vulnerability Risk Profile circle should be visible | ||
| Then Vulnerability Risk Profile shows summary of vulnerabilities | ||
|
mrrajan marked this conversation as resolved.
|
||
| Then SBOM Name "<sbomName>" should be visible inside the tab | ||
| Then SBOM Version should be visible inside the tab | ||
| Then SBOM Creation date should be visible inside the tab | ||
| # Then List of related Vulnerabilities should be sorted by "CVSS" in descending order | ||
|
|
||
| Examples: | ||
| | sbomType | sbomName | | ||
| | SPDX | quarkus-bom | | ||
|
|
||
| @slow | ||
| Scenario Outline: Pagination of <sbomType> SBOM Vulnerabilities | ||
| Given An ingested "<sbomType>" SBOM "<sbomName>" containing Vulnerabilities | ||
| When User visits SBOM details Page of "<sbomName>" | ||
| When User selects the Tab "Vulnerabilities" | ||
| Then Pagination of Vulnerabilities list works | ||
| Examples: | ||
| | sbomType | sbomName | | ||
| | SPDX | quarkus-bom | | ||
|
|
||
| @slow | ||
| Scenario Outline: View paginated list of <sbomType> SBOM Packages | ||
| Given An ingested "<sbomType>" SBOM "<sbomName>" is available | ||
| When User visits SBOM details Page of "<sbomName>" | ||
| When User selects the Tab "Packages" | ||
| Then Pagination of Packages list works | ||
| Examples: | ||
| | sbomType | sbomName | | ||
| | SPDX | quarkus-bom | | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,21 +2,24 @@ import { createBdd } from "playwright-bdd"; | |
| import { expect } from "playwright/test"; | ||
| import { DetailsPage } from "../../helpers/DetailsPage"; | ||
| import { ToolbarTable } from "../../helpers/ToolbarTable"; | ||
| import { SearchPage } from "../../helpers/SearchPage"; | ||
|
|
||
| export const { Given, When, Then } = createBdd(); | ||
|
|
||
| const PACKAGE_TABLE_NAME = "Package table"; | ||
| const VULN_TABLE_NAME = "Vulnerability table"; | ||
|
|
||
| Given( | ||
| "An ingested {string} SBOM {string} is available", | ||
| async ({ page }, _sbomType, sbomName) => { | ||
| const searchPage = new SearchPage(page); | ||
| await searchPage.dedicatedSearch("SBOMs", sbomName); | ||
| } | ||
| ); | ||
|
|
||
| When( | ||
| "User visits SBOM details Page of {string}", | ||
| async ({ page }, sbomName) => { | ||
| await page.goto("/"); | ||
| await page.getByRole("link", { name: "SBOMs" }).click(); | ||
|
|
||
| await page.getByPlaceholder("Search").click(); | ||
| await page.getByPlaceholder("Search").fill(sbomName); | ||
| await page.getByPlaceholder("Search").press("Enter"); | ||
|
|
||
| await page.getByRole("link", { name: sbomName, exact: true }).click(); | ||
| } | ||
| ); | ||
|
|
@@ -31,7 +34,7 @@ Then( | |
| const downloadPromise = page.waitForEvent("download"); | ||
|
|
||
| const detailsPage = new DetailsPage(page); | ||
| detailsPage.clickOnPageAction(actionName); | ||
| await detailsPage.clickOnPageAction(actionName); | ||
|
|
||
| const download = await downloadPromise; | ||
|
|
||
|
|
@@ -44,7 +47,7 @@ Then( | |
| "The Package table is sorted by {string}", | ||
| async ({ page }, columnName) => { | ||
| const toolbarTable = new ToolbarTable(page, PACKAGE_TABLE_NAME); | ||
| toolbarTable.verifyTableIsSortedBy(columnName); | ||
| await toolbarTable.verifyTableIsSortedBy(columnName); | ||
| } | ||
| ); | ||
|
|
||
|
|
@@ -78,3 +81,89 @@ Then( | |
| await toolbarTable.verifyColumnContainsText(columnName, expectedValue); | ||
| } | ||
| ); | ||
|
|
||
| Given( | ||
| "An ingested {string} SBOM {string} containing Vulnerabilities", | ||
| async ({ page }, _sbomType, sbomName) => { | ||
| const searchPage = new SearchPage(page); | ||
| await searchPage.dedicatedSearch("SBOMs", sbomName); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the // Here we define that when we instantiate a Search Object we want to move the page to the SBOMs page.
const searchPage = new SearchPage(page, "SBOMs");
await searchPage.search("sbom_name");
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Functionality wise, this wont make much difference. But, it makes sense for code maintenance and readability. I will try including this change as part of next PR. |
||
| const element = await page.locator( | ||
| `xpath=(//tr[contains(.,'${sbomName}')]/td[@data-label='Vulnerabilities']/div)[1]` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see many
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In most of the conditions - I agree, we should consider aria-label or clean object selectors. But dynamic xpath's would be super helpful with reusable functions. For example, the pagination or per page selector validation dynamic xpath will be more useful. Let's consider where we can have dynamic xpath and static locators. |
||
| ); | ||
| await expect(element, "SBOM have no vulnerabilities").toHaveText( | ||
| /^(?!0$).+/ | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| When("User Clicks on Vulnerabilities Tab Action", async ({ page }) => { | ||
| await page.getByLabel("Tab action").click(); | ||
| }); | ||
|
|
||
| Then("Vulnerability Popup menu appears with message", async ({ page }) => { | ||
| await page.getByText("Any found vulnerabilities").isVisible(); | ||
| await page.getByLabel("Close").click(); | ||
| }); | ||
|
|
||
| Then( | ||
| "Vulnerability Risk Profile circle should be visible", | ||
| async ({ page }) => { | ||
| await page.locator(`xpath=//div[contains(@class, 'chart')]`).isVisible(); | ||
| } | ||
| ); | ||
|
|
||
| Then( | ||
| "Vulnerability Risk Profile shows summary of vulnerabilities", | ||
| async ({ page }) => { | ||
| const detailsPage = new DetailsPage(page); | ||
| await detailsPage.verifyVulnerabilityPanelcount(); | ||
| } | ||
| ); | ||
|
|
||
| Then( | ||
| "SBOM Name {string} should be visible inside the tab", | ||
| async ({ page }, sbomName) => { | ||
| const panelSbomName = await page.locator( | ||
| `xpath=//section[@id='refVulnerabilitiesSection']//dt[contains(.,'Name')]/following-sibling::dd` | ||
|
mrrajan marked this conversation as resolved.
|
||
| ); | ||
| await panelSbomName.isVisible(); | ||
| await expect(await panelSbomName.textContent()).toEqual(sbomName); | ||
| } | ||
| ); | ||
|
|
||
| Then("SBOM Version should be visible inside the tab", async ({ page }) => { | ||
| const panelSBOMVersion = await page.locator( | ||
| `xpath=//section[@id='refVulnerabilitiesSection']//dt[contains(.,'Version')]/following-sibling::dd` | ||
|
mrrajan marked this conversation as resolved.
|
||
| ); | ||
| await panelSBOMVersion.isVisible(); | ||
| }); | ||
|
|
||
| Then( | ||
| "SBOM Creation date should be visible inside the tab", | ||
| async ({ page }) => { | ||
| const panelSBOMVersion = await page.locator( | ||
| `xpath=//section[@id='refVulnerabilitiesSection']//dt[contains(.,'Creation date')]/following-sibling::dd` | ||
|
mrrajan marked this conversation as resolved.
|
||
| ); | ||
| await panelSBOMVersion.isVisible(); | ||
| } | ||
| ); | ||
|
|
||
| Then( | ||
| "List of related Vulnerabilities should be sorted by {string} in descending order", | ||
| async ({ page }, columnName) => { | ||
| const toolbarTable = new ToolbarTable(page, VULN_TABLE_NAME); | ||
| await toolbarTable.verifyTableIsSortedBy(columnName, false); | ||
| } | ||
| ); | ||
|
|
||
| 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("Pagination of Packages list works", async ({ page }) => { | ||
| const toolbarTable = new ToolbarTable(page, PACKAGE_TABLE_NAME); | ||
| const vulnTableTopPagination = `xpath=//div[@id="package-table-pagination-top"]`; | ||
| await toolbarTable.verifyPagination(vulnTableTopPagination); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
The
<sbomType>is not used neither declared in theExamplessection of the Scenario definition. I wonder if we should remove it.