index.spec.ts
index.spec.ts - Overview
This file contains Playwright tests for the "Exceptions" page in a web application. It tests various scenarios, including route validation, breadcrumb verification, handling different API response statuses (404, 500, 200), and rendering data in an Ant Design table.
Detailed Documentation
noDataTableData(page: Page): Promise<void>
- Purpose: This function checks the "No Data" state of the Ant Design table on the Exceptions page. It verifies the visibility and content of the "No Data" text and the column headers.
- Parameters:
page
:Page
- The Playwright Page object representing the current page.
- Returns:
Promise<void>
- A promise that resolves when the checks are complete.
test.describe('Expections page', async () => { ... })
- Purpose: This is a Playwright test suite that groups together tests related to the Exceptions page.
- Parameters: None
- Returns: None
test.beforeEach(async ({ baseURL, browser }) => { ... })
- Purpose: This function is executed before each test case within the "Expections page" test suite. It sets up the test environment by creating a new page with authentication, navigating to the application page, and assigning the new page to the
page
variable. - Parameters:
baseURL
: The base URL of the application under test.browser
: The Playwright Browser object.
- Returns: None
test('Should have a valid route', async () => { ... })
- Purpose: Tests whether the Exceptions page has a valid route. It navigates to the
ROUTES.ALL_ERROR
route and asserts that the page URL matches the expected route and takes a snapshot. - Parameters: None
- Returns: None
test('Should have a valid Breadcrumbs', async () => { ... })
- Purpose: Tests whether the Exceptions page has valid breadcrumbs. It navigates to the
ROUTES.ALL_ERROR
route, locates the "Exceptions" breadcrumb, and asserts that it is visible, has the correct text, and has the correcthref
attribute and takes a snapshot. - Parameters: None
- Returns: None
test('Should render the page with 404 status', async () => { ... })
- Purpose: Tests how the Exceptions page renders when the API returns a 404 status code. It intercepts the
**/listErrors
route, fulfills it with a 404 status and an empty JSON array, navigates to the Exceptions page, and asserts that thenoDataTableData
function is called and takes a snapshot. - Parameters: None
- Returns: None
test('Should render the page with 500 status in antd notification with no data antd table', async () => { ... })
- Purpose: Tests how the Exceptions page renders when the API returns a 500 status code. It intercepts the
**/listErrors**
route, fulfills it with a 500 status and an empty JSON array, navigates to the Exceptions page, and asserts that an Ant Design notification with the text "Something went wrong" is displayed and thenoDataTableData
function is called and takes a snapshot. - Parameters: None
- Returns: None
test('Should render data in antd table', async () => { ... })
- Purpose: Tests whether the Exceptions page correctly renders data in the Ant Design table when the API returns a 200 status code with data. It intercepts the
**/listErrors**
and**/countErrors**
routes, fulfills them with 200 status codes and mock data, navigates to the Exceptions page, scrolls to the bottom, and asserts that the exception type from the mock data is visible in the table and that pagination is visible and takes a snapshot. - Parameters: None
- Returns: None
Code Examples
None
Include in Getting Started: NO