diff --git a/simulator-ui/tests/error-banner.spec.ts b/simulator-ui/tests/error-banner.spec.ts index 06674d13..90abdb62 100644 --- a/simulator-ui/tests/error-banner.spec.ts +++ b/simulator-ui/tests/error-banner.spec.ts @@ -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 => await expect(pageToPass.getByTestId('error')).toBeVisible(); + +const mock500ErrorResponseForApiURL = async (page: Page, apiLink: string): Promise => { + await page.route(apiLink, async route => { + await route.fulfill({ + status: 500, + }); + }); +};