diff --git a/simulator-ui/tests/entities.spec.ts b/simulator-ui/tests/entities.spec.ts index 104a1445..0200f8fb 100644 --- a/simulator-ui/tests/entities.spec.ts +++ b/simulator-ui/tests/entities.spec.ts @@ -126,8 +126,7 @@ const entityPageContentMap: EntityPageContentObject[] = [ }, ]; - -entityPageContentMap.forEach(( contentObject: EntityPageContentObject ) => { +entityPageContentMap.forEach((contentObject: EntityPageContentObject) => { test(`${contentObject.testName}`, async ({ page }) => { //'first test' await mockBackendResponse(page, contentObject.apiUrl, contentObject.contentJson); diff --git a/simulator-ui/tests/error-banner.spec.ts b/simulator-ui/tests/error-banner.spec.ts index a6b2b109..9dd1e05d 100644 --- a/simulator-ui/tests/error-banner.spec.ts +++ b/simulator-ui/tests/error-banner.spec.ts @@ -1,16 +1,11 @@ import { expect, Page, test } from '@playwright/test'; -import { - goToAllPagesAndCheckURLPlusContent, - mockBackendResponse, - mockErrorResponseOfAllApiUrls -} from './helpers/helper-functions'; +import { goToAllPagesAndCheckURLPlusContent, mockBackendResponse, mockErrorResponseOfAllApiUrls } 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 }) => { - const thingsToCheckOnAllPages = async (pageToPass: Page): Promise => { await expect(pageToPass.getByTestId('error')).toBeVisible(); }; diff --git a/simulator-ui/tests/helpers/helper-functions.ts b/simulator-ui/tests/helpers/helper-functions.ts index 5bbb9e97..17fc8ce4 100644 --- a/simulator-ui/tests/helpers/helper-functions.ts +++ b/simulator-ui/tests/helpers/helper-functions.ts @@ -2,13 +2,13 @@ import { expect, Page } from '@playwright/test'; import { navbarElementLinkPair } from './helper-interfaces'; export const elementLinkPairNoDropdown: navbarElementLinkPair[] = [ - { testName: 'navigationScenariosLink', link: /.*scenario*/, apiLink: '**/api/scenarios*'}, + { testName: 'navigationScenariosLink', link: /.*scenario*/, apiLink: '**/api/scenarios*' }, { testName: 'navigationScenarioExecutionsLink', link: /.*scenario-result*/, apiLink: '**/api/scenario-executions*' }, ]; export const elementLinkPairEntityDroptdown: navbarElementLinkPair[] = [ - { testName: 'navigationEntitiesMessageLink', link: /.*\/message*/ , apiLink: '**/api/messages*'}, - { testName: 'navigationEntitiesMessageHeaderLink', link: /.*\/message-header*/, apiLink: '**/api/message-headers*'}, - { testName: 'navigationEntitiesScenarioExecutionLink', link: /.*\/scenario-execution*/, apiLink: '**/api/scenario-executions*'}, + { testName: 'navigationEntitiesMessageLink', link: /.*\/message*/, apiLink: '**/api/messages*' }, + { testName: 'navigationEntitiesMessageHeaderLink', link: /.*\/message-header*/, apiLink: '**/api/message-headers*' }, + { testName: 'navigationEntitiesScenarioExecutionLink', link: /.*\/scenario-execution*/, apiLink: '**/api/scenario-executions*' }, { testName: 'navigationEntitiesScenarioActionLink', link: /.*\/scenario-action*/, apiLink: '**/api/scenario-actions*' }, { testName: 'navigationEntitiesScenarioParameterLink', link: /.*\/scenario-parameter*/, apiLink: '**/api/scenario-parameters*' }, { testName: 'navigationEntitiesTestResultLink', link: /.*\/test-result*/, apiLink: '**/api/test-results*' }, @@ -31,11 +31,14 @@ export const clickOnLinkAndCheckIfTabOpensWithCorrectURL = async ( await expect(newTab).toHaveURL(expectedURL); }; -export const mockBackendResponse = async (page: Page, apiURL: string, responseJson: object, headers?: {[key: string]: string; }): Promise => { +export const mockBackendResponse = async ( + page: Page, + apiURL: string, + responseJson: object, + headers?: { [key: string]: string }, +): Promise => { await page.route(apiURL, async route => { - headers - ? await route.fulfill({ json: responseJson , headers: headers }) - : await route.fulfill({ json: responseJson }) + headers ? await route.fulfill({ json: responseJson, headers: headers }) : await route.fulfill({ json: responseJson }); }); }; diff --git a/simulator-ui/tests/home.spec.ts b/simulator-ui/tests/home.spec.ts index 544baf28..8bd5b02c 100644 --- a/simulator-ui/tests/home.spec.ts +++ b/simulator-ui/tests/home.spec.ts @@ -87,7 +87,9 @@ test('should have updated total, successful, failed tabs after refresh button cl await checkIfSummaryTabsAreDisplayingRightNumbers(page, nbOfTotalTests, nbOfSuccessfulTests, nbOfFailedTests); }); -test('(test if frontend trusts backend blindly) should have updated total, successful, failed tabs after refresh button clicked negative test with false total', async ({ page }) => { +test('(test if frontend trusts backend blindly) should have updated total, successful, failed tabs after refresh button clicked negative test with false total', async ({ + page, +}) => { await checkIfSummaryTabsAreDisplayingRightNumbers(page, nbOfTotalTests, nbOfSuccessfulTests, nbOfFailedTests); nbOfFailedTests -= 10; // so the total will be wrong! const newCorrectTotal: number = nbOfTotalTests - 10; @@ -109,9 +111,8 @@ test('should have same total, successful, failed tabs after cancel deletion via let deleteRequestWasMade = false; page.on('request', request => { - if (request.method() == 'DELETE') - deleteRequestWasMade = true - }) + if (request.method() == 'DELETE') deleteRequestWasMade = true; + }); for (const button of closeButtons) { await page.getByTestId('resetButton').click(); await expect(page.getByTestId('testResultDeleteDialogHeading')).toBeVisible(); diff --git a/simulator-ui/tests/scenario.spec.ts b/simulator-ui/tests/scenario.spec.ts index 118fe4af..d5e11414 100644 --- a/simulator-ui/tests/scenario.spec.ts +++ b/simulator-ui/tests/scenario.spec.ts @@ -14,11 +14,11 @@ const scenarioJson = [ { name: 'HiStarter', type: 'STARTER' }, ]; -const addititonalPageJson=[ +const addititonalPageJson = [ { name: 'One', type: 'STARTER' }, { name: 'Two', type: 'STARTER' }, { name: 'Three', type: 'STARTER' }, -] +]; const orderedJson = [ { name: 'Fail', type: 'MESSAGE_TRIGGERED' }, @@ -43,13 +43,13 @@ const parameterJson = [ const availableScenarios: number = addititonalPageJson.length + scenarioJson.length; test.beforeEach(async ({ page }) => { - await mockBackendResponse(page, '**/api/scenarios**page=0**', scenarioJson, {'x-total-count': availableScenarios.toString()}) + await mockBackendResponse(page, '**/api/scenarios**page=0**', scenarioJson, { 'x-total-count': availableScenarios.toString() }); await page.goto('http://localhost:9000/scenario'); await page.getByTestId('itemsPerPageSelect').selectOption('10'); }); test('should display all scenario information of a starter scenario', async ({ page }) => { - await mockBackendResponse(page, '**/api/scenarios**', [{ name: 'Test', type: 'STARTER' }], {'x-total-count': '1'}); + await mockBackendResponse(page, '**/api/scenarios**', [{ name: 'Test', type: 'STARTER' }], { 'x-total-count': '1' }); await page.goto('http://localhost:9000/scenario'); @@ -61,7 +61,7 @@ test('should display all scenario information of a starter scenario', async ({ p }); test('should display all scenario information of a non-starter scenario', async ({ page }) => { - await mockBackendResponse(page, '**/api/scenarios**', [{ name: 'Test', type: 'MESSAGE_TRIGGERED' }], {'x-total-count': '1'}); + await mockBackendResponse(page, '**/api/scenarios**', [{ name: 'Test', type: 'MESSAGE_TRIGGERED' }], { 'x-total-count': '1' }); await page.goto('http://localhost:9000/scenario'); @@ -71,13 +71,11 @@ test('should display all scenario information of a non-starter scenario', async await expect(page.getByTestId('scenarioExecutionButton')).toBeVisible(); }); -test('should have the first 10 of 13 elements displayed in the table and display right nb of visible elements', async ({ - page, -}) => { +test('should have the first 10 of 13 elements displayed in the table and display right nb of visible elements', async ({ page }) => { await checkIfAllJsonContentIsVisible(page, 10, availableScenarios, scenarioJson); }); -test('should have the last 3 of 13 elements displayed in the table after clicking on 2. page', async ({page,}) => { +test('should have the last 3 of 13 elements displayed in the table after clicking on 2. page', async ({ page }) => { await mockBackendResponse(page, '**/api/scenarios**page=1**', addititonalPageJson); await page.getByRole('link', { name: '2' }).click(); await checkIfAllJsonContentIsVisible(page, 10, availableScenarios, addititonalPageJson); @@ -92,7 +90,7 @@ test('see if frontend trusts backend to send only as much data as requested', as await page.getByTestId('itemsPerPageSelect').selectOption(selectedPageSize.toString()); - await checkIfAllJsonContentIsVisible(page, selectedPageSize, availableScenarios, scenarioJson) + await checkIfAllJsonContentIsVisible(page, selectedPageSize, availableScenarios, scenarioJson); await expect(page.getByTestId('itemsPerPageSelect')).toHaveValue(selectedPageSize.toString()); scenarioJson.pop(); }); @@ -109,11 +107,11 @@ test('should have updated displayed scenarios after refresh button was clicked a for (const option of selectOptionsForNumberOfScenariosToDisplay) { await page.getByTestId('itemsPerPageSelect').selectOption(option.toString()); scenarioJson.pop(); - await mockBackendResponse(page, '**/api/scenarios**', scenarioJson, {'x-total-count': scenarioJson.length.toString()}); + await mockBackendResponse(page, '**/api/scenarios**', scenarioJson, { 'x-total-count': scenarioJson.length.toString() }); await page.getByTestId('refreshListButton').click(); await checkIfAllJsonContentIsVisible(page, option, scenarioJson.length, scenarioJson); - scenarioJson.push({ name: 'HiStarter', type: 'STARTER' },); + scenarioJson.push({ name: 'HiStarter', type: 'STARTER' }); } }); @@ -176,7 +174,7 @@ test('should go to detail view of a scenario (not type starter) and then go back }); test('should go to detail view of a scenario type STARTER check for content and go back', async ({ page }) => { - await mockBackendResponse(page, '**/api/scenarios/ByeStarter/parameters', parameterJson) + await mockBackendResponse(page, '**/api/scenarios/ByeStarter/parameters', parameterJson); const allVisibleDetailElements = [ 'scenarioDetailsHeading', 'scenarioDetailsName', @@ -219,7 +217,7 @@ const applyFilterAAndCheckCorrectness = async (page: Page): Promise => { const pageSize: number = 20; await page.getByTestId('itemsPerPageSelect').selectOption(pageSize.toString()); await checkIfAllJsonContentIsVisible(page, pageSize, availableScenarios, scenarioJson); - await mockBackendResponse(page, '**/api/scenarios?**nameContains=a&sort=id,asc', orderedJson, {'x-total-count': '5'}); + await mockBackendResponse(page, '**/api/scenarios?**nameContains=a&sort=id,asc', orderedJson, { 'x-total-count': '5' }); await page.getByTestId('scenarioFilterByNameInput').fill('a');