Skip to content

Commit

Permalink
refactor(citrus-simulator-ui): refactor error-banner test
Browse files Browse the repository at this point in the history
  • Loading branch information
muellerfluri committed Sep 17, 2024
1 parent 87c6c51 commit 4d1f8bb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions simulator-ui/tests/error-banner.spec.ts
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,
});
});
};

0 comments on commit 4d1f8bb

Please sign in to comment.