forked from trustification/trustify-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsbom-explorer.step.ts
More file actions
189 lines (161 loc) · 6.15 KB
/
sbom-explorer.step.ts
File metadata and controls
189 lines (161 loc) · 6.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
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 SBOM {string} is available", async ({ page }, sbomName) => {
const searchPage = new SearchPage(page, "SBOMs");
await searchPage.dedicatedSearch(sbomName);
});
When(
"User visits SBOM details Page of {string}",
async ({ page }, sbomName) => {
await page.getByRole("link", { name: sbomName, exact: true }).click();
}
);
Then("{string} is visible", async ({ page }, fieldName) => {
await expect(page.locator(`[aria-label="${fieldName}"]`)).toBeVisible();
});
Then(
"{string} action is invoked and downloaded filename is {string}",
async ({ page }, actionName, expectedFilename) => {
const downloadPromise = page.waitForEvent("download");
const detailsPage = new DetailsPage(page);
await detailsPage.clickOnPageAction(actionName);
const download = await downloadPromise;
const filename = download.suggestedFilename();
expect(filename).toEqual(expectedFilename);
}
);
Then(
"The Package table is sorted by {string}",
async ({ page }, columnName) => {
const toolbarTable = new ToolbarTable(page, PACKAGE_TABLE_NAME);
await toolbarTable.verifyTableIsSortedBy(columnName);
}
);
Then("Search by FilterText {string}", async ({ page }, filterText) => {
const toolbarTable = new ToolbarTable(page, PACKAGE_TABLE_NAME);
await toolbarTable.filterByText(filterText);
});
Then(
"The Package table total results is {int}",
async ({ page }, totalResults) => {
const toolbarTable = new ToolbarTable(page, PACKAGE_TABLE_NAME);
await toolbarTable.verifyPaginationHasTotalResults(totalResults);
}
);
Then(
"The Package table total results is greather than {int}",
async ({ page }, totalResults) => {
const toolbarTable = new ToolbarTable(page, PACKAGE_TABLE_NAME);
await toolbarTable.verifyPaginationHasTotalResultsGreatherThan(
totalResults
);
}
);
Then(
"The {string} column of the Package table table contains {string}",
async ({ page }, columnName, expectedValue) => {
const toolbarTable = new ToolbarTable(page, PACKAGE_TABLE_NAME);
await toolbarTable.verifyColumnContainsText(columnName, expectedValue);
}
);
Given(
"An ingested SBOM {string} containing Vulnerabilities",
async ({ page }, sbomName) => {
const searchPage = new SearchPage(page, "SBOMs");
await searchPage.dedicatedSearch(sbomName);
const element = await page.locator(
`xpath=(//tr[contains(.,'${sbomName}')]/td[@data-label='Vulnerabilities']/div)[1]`
);
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`
);
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`
);
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`
);
await panelSBOMVersion.isVisible();
}
);
Then(
"List of related Vulnerabilities should be sorted by {string} in ascending order",
async ({ page }, columnName) => {
const toolbarTable = new ToolbarTable(page, VULN_TABLE_NAME);
await toolbarTable.verifyTableIsSortedBy(columnName, true);
}
);
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);
});
Then(
"List of Vulnerabilities has column {string}",
async ({ page }, columnHeader) => {
const toolbarTable = new ToolbarTable(page, VULN_TABLE_NAME);
await toolbarTable.verifyTableHeaderContains(columnHeader);
}
);
Then(
"Table column {string} is not sortable",
async ({ page }, columnHeader) => {
const toolbarTable = new ToolbarTable(page, VULN_TABLE_NAME);
await toolbarTable.verifyColumnIsNotSortable(columnHeader);
}
);
Then("Sorting of {string} Columns Works", async ({ page }, columnHeaders) => {
const headers = columnHeaders.split(`,`).map((column) => column.trim());
const toolbarTable = new ToolbarTable(page, VULN_TABLE_NAME);
const vulnTableTopPagination = `xpath=//div[@id="vulnerability-table-pagination-top"]`;
await toolbarTable.verifySorting(vulnTableTopPagination, headers);
});