forked from citrusframework/citrus-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(citrus-simulator-ui): refactor error-banner test
- Loading branch information
muellerfluri
committed
Sep 17, 2024
1 parent
87c6c51
commit 4d1f8bb
Showing
1 changed file
with
13 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
import { expect, Page, test } from '@playwright/test'; | ||
import { goToAllNavigationTabsAndOptionallyValidateContent, mockErrorResponseForAllNavbarLinkedSites } from './helpers/helper-functions'; | ||
import { | ||
goToAllNavigationTabsAndOptionallyValidateContent, | ||
mockResponseForAllNavbarLinkedSites | ||
} from './helpers/helper-functions'; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto('http://localhost:9000/'); | ||
}); | ||
|
||
test('should show error banner if there is an error code in the backend response while loading any page', async ({ page }) => { | ||
await mockErrorResponseForAllNavbarLinkedSites(page); | ||
await mockResponseForAllNavbarLinkedSites(page, mock500ErrorResponseForApiURL); | ||
|
||
await goToAllNavigationTabsAndOptionallyValidateContent(page, verifyErrorBannerIsVisible); | ||
}); | ||
|
||
const verifyErrorBannerIsVisible = async (pageToPass: Page): Promise<void> => await expect(pageToPass.getByTestId('error')).toBeVisible(); | ||
|
||
const mock500ErrorResponseForApiURL = async (page: Page, apiLink: string): Promise<void> => { | ||
await page.route(apiLink, async route => { | ||
await route.fulfill({ | ||
status: 500, | ||
}); | ||
}); | ||
}; |