forked from guacsec/trustify-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsbom-explorer.step.ts
More file actions
226 lines (198 loc) · 7.27 KB
/
sbom-explorer.step.ts
File metadata and controls
226 lines (198 loc) · 7.27 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
import { createBdd } from "playwright-bdd";
import { DetailsPage } from "../../helpers/DetailsPage";
import { ToolbarTable } from "../../helpers/ToolbarTable";
import { DeletionConfirmDialog } from "../../pages/ConfirmDialog";
import { SbomListPage } from "../../pages/sbom-list/SbomListPage";
import { test } from "../../fixtures";
import { expect } from "../../assertions";
export const { Given, When, Then } = createBdd(test);
const PACKAGE_TABLE_NAME = "Package table";
const VULN_TABLE_NAME = "Vulnerability table";
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(
"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);
},
);
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='vulnerabilities-tab-section']//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='vulnerabilities-tab-section']//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='vulnerabilities-tab-section']//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(
"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);
},
);
When(
"User Adds Labels {string} to {string} SBOM from Explorer Page",
async ({ page }, labelList, _sbomName) => {
const detailsPage = new DetailsPage(page);
await detailsPage.editLabelsDetailsPage();
const labelsToAdd =
labelList === "RANDOM_LABELS" ? detailsPage.generateLabels() : labelList;
await detailsPage.addLabels(labelsToAdd);
// biome-ignore lint/suspicious/noExplicitAny: allowed
(page as any).testContext = {
// biome-ignore lint/suspicious/noExplicitAny: allowed
...(page as any).testContext,
generatedLabels: labelsToAdd,
};
},
);
Then(
"The Label list {string} added to the SBOM {string} on Explorer Page",
async ({ page }, labelList, sbomName) => {
const detailsPage = new DetailsPage(page);
await detailsPage.selectTab(`Info`);
const infoSection = page.locator("#info-tab-section");
// Use stored generated labels if placeholder was used
const labelsToVerify =
labelList === "RANDOM_LABELS"
? // biome-ignore lint/suspicious/noExplicitAny: allowed
(page as any).testContext?.generatedLabels || labelList
: labelList;
await detailsPage.verifyLabels(labelsToVerify, sbomName, infoSection);
},
);
When(
"User Clicks on Actions button and Selects Delete option from the drop down",
async ({ page }) => {
const details = new DetailsPage(page);
await details.clickOnPageAction("Delete");
},
);
When(
"User select Delete button from the Permanently delete SBOM model window",
async ({ page }) => {
const dialog = await DeletionConfirmDialog.build(page, "Confirm dialog");
await expect(dialog).toHaveTitle("Warning alert:Permanently delete SBOM?");
await dialog.clickConfirm();
},
);
When(
"User Deletes {string} using the toggle option from SBOM List Page",
async ({ page }, sbomName) => {
const listPage = await SbomListPage.build(page);
const toolbar = await listPage.getToolbar();
await toolbar.applyFilter({ "Filter text": sbomName });
const table = await listPage.getTable();
const rowToDelete = 0;
await table.clickAction("Delete", rowToDelete);
},
);
Then("Application Navigates to SBOM list page", async ({ page }) => {
await expect(
page.getByRole("heading", { level: 1, name: "SBOMs" }),
).toBeVisible();
});
Then(
"The {string} should not be present on SBOM list page as it is deleted",
async ({ page }, sbomName: string) => {
const list = await SbomListPage.build(page);
const toolbar = await list.getToolbar();
const table = await list.getTable();
await toolbar.applyFilter({ "Filter text": sbomName });
await expect(table).toHaveEmptyState();
},
);
Then("The SBOM deleted message is displayed", async ({ page }) => {
// PatternFly toast alerts render the title as a heading inside AlertGroup
const alertHeading = page.getByRole("heading", { level: 4 }).filter({
hasText: /The SBOM .+ was deleted/,
});
await expect(alertHeading).toBeVisible({ timeout: 10000 });
});