-
Notifications
You must be signed in to change notification settings - Fork 28
test: Add test to delete SBOM and Advisory #875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
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 |
|---|---|---|
|
|
@@ -37,7 +37,7 @@ mode: 'agent' | |
| - Automatically run test with: | ||
| ```bash | ||
| cd $PROJECT_ROOT/e2e | ||
| npx playwright test --project='bdd' --trace on -g "scenario name here" --headed | ||
| npx playwright test --project='bdd' --trace on -g "scenario name here" | ||
| ``` | ||
| - In case of test failures, the above command launched HTML server to host the test output Press `Ctrl+C` to stop the server | ||
|
Contributor
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. suggestion (typo): Tense, article usage, and punctuation could be improved in this sentence. Consider rephrasing to: "In case of test failures, the above command launches an HTML server to host the test output. Press |
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { expect as baseExpect } from "@playwright/test"; | ||
| import type { DeletionConfirmDialog } from "../pages/ConfirmDialog"; | ||
| import type { MatcherResult } from "./types"; | ||
|
|
||
| export interface DialogMatchers { | ||
| toHaveTitle(expectedTitle: string): Promise<MatcherResult>; | ||
| } | ||
|
|
||
| type DialogMatcherDefinitions = { | ||
| readonly [K in keyof DialogMatchers]: ( | ||
| receiver: DeletionConfirmDialog, | ||
| ...args: Parameters<DialogMatchers[K]> | ||
| ) => Promise<MatcherResult>; | ||
| }; | ||
|
|
||
| export const dialogAssertions = baseExpect.extend<DialogMatcherDefinitions>({ | ||
| toHaveTitle: async ( | ||
| dialog: DeletionConfirmDialog, | ||
| expectedTitle: string, | ||
| ): Promise<MatcherResult> => { | ||
| try { | ||
| const dialogTitle = dialog.getDeletionConfirmDialogHeading(); | ||
| await baseExpect(dialogTitle).toHaveText(expectedTitle); | ||
| return { | ||
| pass: true, | ||
| message: () => `Dialog has title "${expectedTitle}"`, | ||
| }; | ||
| } catch (error) { | ||
| return { | ||
| pass: false, | ||
| message: () => (error instanceof Error ? error.message : String(error)), | ||
| }; | ||
| } | ||
| }, | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| import { createBdd } from "playwright-bdd"; | ||
| import { expect } from "playwright/test"; | ||
| import { expect } from "../../assertions"; | ||
| import { ToolbarTable } from "../../helpers/ToolbarTable"; | ||
| import { SearchPage } from "../../helpers/SearchPage"; | ||
| import { AdvisoryListPage } from "../../pages/advisory-list/AdvisoryListPage"; | ||
| import { test } from "../../fixtures"; | ||
| import { DeletionConfirmDialog } from "../../pages/ConfirmDialog"; | ||
| import { DetailsPage } from "../../helpers/DetailsPage"; | ||
|
|
||
| export const { Given, When, Then } = createBdd(test); | ||
|
|
||
|
|
@@ -151,3 +154,58 @@ Then( | |
| ).toBeVisible(); | ||
| }, | ||
| ); | ||
|
|
||
| When( | ||
| "User Deletes {string} using the toggle option from Advisory List Page", | ||
| async ({ page }, advisoryID) => { | ||
| const listPage = await AdvisoryListPage.build(page); | ||
| const toolbar = await listPage.getToolbar(); | ||
| await toolbar.applyFilter({ "Filter text": advisoryID }); | ||
| const table = await listPage.getTable(); | ||
| const rowToDelete = 0; | ||
| await table.clickAction("Delete", rowToDelete); | ||
| }, | ||
| ); | ||
|
|
||
| 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 Advisory model window", | ||
| async ({ page }) => { | ||
| const dialog = await DeletionConfirmDialog.build(page, "Confirm dialog"); | ||
| await expect(dialog).toHaveTitle( | ||
| "Warning alert:Permanently delete Advisory?", | ||
| ); | ||
| await dialog.clickConfirm(); | ||
| }, | ||
| ); | ||
|
|
||
| Then( | ||
| "The {string} should not be present on Advisory list page as it is deleted", | ||
| async ({ page }, advisoryID: string) => { | ||
| const list = await AdvisoryListPage.build(page); | ||
| const toolbar = await list.getToolbar(); | ||
| const table = await list.getTable(); | ||
| await toolbar.applyFilter({ "Filter text": advisoryID }); | ||
| await expect(table).toHaveEmptyState(); | ||
| }, | ||
| ); | ||
|
|
||
| Then("Application Navigates to Advisory list page", async ({ page }) => { | ||
| await expect( | ||
| page.getByRole("heading", { level: 1, name: "Advisories" }), | ||
| ).toBeVisible(); | ||
|
Comment on lines
+201
to
+203
Collaborator
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. This can be replaced by: const navigation = await Navigation.build(page);
await navigation.goToSidebar("Advisories");
Contributor
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. This step verifies that the application automatically navigated to the “Advisories” screen by confirming that the header is visible |
||
| }); | ||
|
|
||
| Then("The Advisory deleted message is displayed", async ({ page }) => { | ||
| const alertHeading = page.getByRole("heading", { level: 4 }).filter({ | ||
| hasText: /The Advisory .+ was deleted/, | ||
| }); | ||
| await expect(alertHeading).toBeVisible({ timeout: 10000 }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { expect, type Locator, type Page } from "@playwright/test"; | ||
|
|
||
| export class DeletionConfirmDialog { | ||
| _deleteConfirmationDialog: Locator; | ||
|
|
||
| private constructor(_deleteConfirmationDialog: Locator) { | ||
| this._deleteConfirmationDialog = _deleteConfirmationDialog; | ||
| } | ||
|
|
||
| static async build(page: Page, dialogAriaLabel: string) { | ||
| const dialog = page.locator(`div[aria-label="${dialogAriaLabel}"]`); | ||
| await expect(dialog).toBeVisible(); | ||
| return new DeletionConfirmDialog(dialog); | ||
| } | ||
|
|
||
| getDeletionConfirmDialogHeading() { | ||
| return this._deleteConfirmationDialog.getByRole("heading", { level: 1 }); | ||
| } | ||
|
|
||
| async clickConfirm() { | ||
| const confirmBtn = this._deleteConfirmationDialog.getByRole("button", { | ||
| name: "confirm", | ||
| }); | ||
| await expect(confirmBtn).toBeVisible(); | ||
| await expect(confirmBtn).toBeEnabled(); | ||
| await confirmBtn.click(); | ||
| } | ||
| } |
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 (typo): Consider changing "run test" to "run tests" for grammatical correctness.
You could also phrase it as "Automatically run tests with:" to better match the plural and improve the sentence flow.