-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: refactor alert and snackbar utils
- Loading branch information
Showing
11 changed files
with
46 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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,29 @@ | ||
import { Page, expect } from '@playwright/test'; | ||
import { TEST_ATTRIBUTES, TEST_IDS } from '../src/client/testIDs'; | ||
import { Severity } from '../src/server/server'; | ||
|
||
// Assumes you already are on a use case page with the Reset button present | ||
export async function resetScenarios(page: Page) { | ||
await page.getByTestId(TEST_IDS.reset.resetButton).click(); | ||
await page.getByTestId(TEST_IDS.reset.resetSuccess).waitFor({ timeout: 10000 }); | ||
await page.getByTestId(TEST_IDS.common.closeSnackbar).first().click(); | ||
} | ||
|
||
type AssertAlertOrSnackbarArgs = { | ||
page: Page; | ||
severity: Severity; | ||
text: string; | ||
index?: number; | ||
}; | ||
|
||
export async function assertAlert({ page, severity, text, index = 0 }: AssertAlertOrSnackbarArgs) { | ||
const alert = await page.getByTestId(TEST_IDS.common.alert).nth(index); | ||
await expect(alert).toHaveAttribute(TEST_ATTRIBUTES.severity, severity); | ||
await expect(alert).toContainText(text); | ||
} | ||
|
||
export async function assertSnackbar({ page, severity, text, index = 0 }: AssertAlertOrSnackbarArgs) { | ||
const snackbar = await page.getByTestId(TEST_IDS.common.snackBar).nth(index); | ||
await expect(snackbar).toHaveAttribute(TEST_ATTRIBUTES.severity, severity); | ||
await expect(snackbar).toContainText(text); | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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