From 8e652d7c5536c71b4dd77ddc56d53cb8e9425a78 Mon Sep 17 00:00:00 2001 From: muellerfluri Date: Tue, 17 Sep 2024 12:24:28 +0200 Subject: [PATCH] fix(citrus-simulator-ui): run prettier write --- simulator-ui/tests/entities.spec.ts | 78 ++++++++-------- simulator-ui/tests/error-banner.spec.ts | 11 +-- .../tests/helpers/helper-functions.ts | 34 +++---- simulator-ui/tests/home.spec.ts | 42 ++++----- simulator-ui/tests/navbar.spec.ts | 17 ++-- simulator-ui/tests/no-data.spec.ts | 8 +- simulator-ui/tests/scenario-results.spec.ts | 40 ++++----- simulator-ui/tests/scenario.spec.ts | 88 +++++++++---------- 8 files changed, 155 insertions(+), 163 deletions(-) diff --git a/simulator-ui/tests/entities.spec.ts b/simulator-ui/tests/entities.spec.ts index bc521573..3ea55599 100644 --- a/simulator-ui/tests/entities.spec.ts +++ b/simulator-ui/tests/entities.spec.ts @@ -1,13 +1,7 @@ -import {expect, Page, test} from '@playwright/test'; -import {EntityPageContentObject} from './helpers/helper-interfaces'; -import { - messageHeaderJson, - messageJson, - scenarioActionJson, - scenarioExecutionJson, - testResultJson, -} from './helpers/entity-jsons'; -import {mockBackendResponse} from './helpers/helper-functions'; +import { expect, Page, test } from '@playwright/test'; +import { EntityPageContentObject } from './helpers/helper-interfaces'; +import { messageHeaderJson, messageJson, scenarioActionJson, scenarioExecutionJson, testResultJson } from './helpers/entity-jsons'; +import { mockBackendResponse } from './helpers/helper-functions'; const exampleDate = '23 Aug 2024 08:25:31'; const entityPageContentMap: EntityPageContentObject[] = [ @@ -25,12 +19,12 @@ const entityPageContentMap: EntityPageContentObject[] = [ 'th :text("Last Modified Date")', ], testIdsAndExpectedValues: [ - {testId: 'messageEntityMessageId', expectedValue: '1'}, - {testId: 'messageEntityMessageDirection', expectedValue: 'INBOUND'}, - {testId: 'messageEntityMessagePayload', expectedValue: 'Should trigger default scenario'}, - {testId: 'messageEntityMessageCitrusMessage', expectedValue: '5605967b-bfd6-42bb-ba3b-a2404d20783a'}, - {testId: 'messageEntityMessageCreatedDate', expectedValue: exampleDate}, - {testId: 'messageEntityMessageLastModified', expectedValue: exampleDate}, + { testId: 'messageEntityMessageId', expectedValue: '1' }, + { testId: 'messageEntityMessageDirection', expectedValue: 'INBOUND' }, + { testId: 'messageEntityMessagePayload', expectedValue: 'Should trigger default scenario' }, + { testId: 'messageEntityMessageCitrusMessage', expectedValue: '5605967b-bfd6-42bb-ba3b-a2404d20783a' }, + { testId: 'messageEntityMessageCreatedDate', expectedValue: exampleDate }, + { testId: 'messageEntityMessageLastModified', expectedValue: exampleDate }, ], testIdToBeVisible: ['filterOtherEntityButton'], }, @@ -41,9 +35,9 @@ const entityPageContentMap: EntityPageContentObject[] = [ contentJson: messageHeaderJson, locators: ['th :text("Name")', 'th :text("Value")'], testIdsAndExpectedValues: [ - {testId: 'messageHeaderEntityId', expectedValue: '13'}, - {testId: 'messageHeaderEntityName', expectedValue: 'Content-Type'}, - {testId: 'messageHeaderEntityValue', expectedValue: 'application/xml;charset=UTF-8'}, + { testId: 'messageHeaderEntityId', expectedValue: '13' }, + { testId: 'messageHeaderEntityName', expectedValue: 'Content-Type' }, + { testId: 'messageHeaderEntityValue', expectedValue: 'application/xml;charset=UTF-8' }, ], testIdToBeVisible: [], }, @@ -54,12 +48,12 @@ const entityPageContentMap: EntityPageContentObject[] = [ contentJson: scenarioExecutionJson, locators: ['th :text("Name")', 'th :text("Start Date")', 'th :text("End Date")', 'th :text("Status")', 'th :text("Error Message")'], testIdsAndExpectedValues: [ - {testId: 'scenarioExecutionEntityScenarioExecutionLink', expectedValue: '1'}, - {testId: 'scenarioExecutionEntityScenarioName', expectedValue: 'Default'}, - {testId: 'scenarioExecutionEntityStartDate', expectedValue: exampleDate}, - {testId: 'scenarioExecutionEntityEndDate', expectedValue: exampleDate}, - {testId: 'scenarioExecutionEntityStatus', expectedValue: 'FAILURE'}, - {testId: 'scenarioExecutionEntityTestResult', expectedValue: 'New Error'}, + { testId: 'scenarioExecutionEntityScenarioExecutionLink', expectedValue: '1' }, + { testId: 'scenarioExecutionEntityScenarioName', expectedValue: 'Default' }, + { testId: 'scenarioExecutionEntityStartDate', expectedValue: exampleDate }, + { testId: 'scenarioExecutionEntityEndDate', expectedValue: exampleDate }, + { testId: 'scenarioExecutionEntityStatus', expectedValue: 'FAILURE' }, + { testId: 'scenarioExecutionEntityTestResult', expectedValue: 'New Error' }, ], testIdToBeVisible: [], }, @@ -70,10 +64,10 @@ const entityPageContentMap: EntityPageContentObject[] = [ contentJson: scenarioActionJson, locators: ['th :text("Name")', 'th :text("Start Date")', 'th :text("End Date")', 'th :text("Scenario Execution")'], testIdsAndExpectedValues: [ - {testId: 'scenarioActionEntitiesId', expectedValue: '1'}, - {testId: 'scenarioActionEntitiesName', expectedValue: 'http:receive-request'}, - {testId: 'scenarioActionEntitiesStartDate', expectedValue: exampleDate}, - {testId: 'scenarioActionEntitiesEndDate', expectedValue: exampleDate}, + { testId: 'scenarioActionEntitiesId', expectedValue: '1' }, + { testId: 'scenarioActionEntitiesName', expectedValue: 'http:receive-request' }, + { testId: 'scenarioActionEntitiesStartDate', expectedValue: exampleDate }, + { testId: 'scenarioActionEntitiesEndDate', expectedValue: exampleDate }, ], testIdToBeVisible: [], }, @@ -90,22 +84,22 @@ const entityPageContentMap: EntityPageContentObject[] = [ 'th :text("Stack Trace")', ], testIdsAndExpectedValues: [ - {testId: 'testResultEntitiesId', expectedValue: '1'}, - {testId: 'testResultEntitiesStatus', expectedValue: 'FAILURE'}, - {testId: 'testResultEntitiesTestName', expectedValue: 'Scenario(Default)'}, - {testId: 'testResultEntitiesClassName', expectedValue: 'DefaultTestCase'}, - {testId: 'testResultEntitiesErrorMessage', expectedValue: 'New Error'}, - {testId: 'testResultEntitiesStackTrace', expectedValue: 'New Stacktrace'}, - {testId: 'testResultEntitiesFailureType', expectedValue: ''}, - {testId: 'testResultEntitiesCreatedDate', expectedValue: exampleDate}, - {testId: 'testResultEntitiesLastModifiedDate', expectedValue: exampleDate}, + { testId: 'testResultEntitiesId', expectedValue: '1' }, + { testId: 'testResultEntitiesStatus', expectedValue: 'FAILURE' }, + { testId: 'testResultEntitiesTestName', expectedValue: 'Scenario(Default)' }, + { testId: 'testResultEntitiesClassName', expectedValue: 'DefaultTestCase' }, + { testId: 'testResultEntitiesErrorMessage', expectedValue: 'New Error' }, + { testId: 'testResultEntitiesStackTrace', expectedValue: 'New Stacktrace' }, + { testId: 'testResultEntitiesFailureType', expectedValue: '' }, + { testId: 'testResultEntitiesCreatedDate', expectedValue: exampleDate }, + { testId: 'testResultEntitiesLastModifiedDate', expectedValue: exampleDate }, ], testIdToBeVisible: [], }, ]; entityPageContentMap.forEach((contentObject: EntityPageContentObject) => { - test(`${contentObject.testName}`, async ({page}) => { + test(`${contentObject.testName}`, async ({ page }) => { await mockBackendResponse(page, contentObject.apiUrl, contentObject.contentJson); await page.goto(contentObject.entityUrl); @@ -117,7 +111,7 @@ entityPageContentMap.forEach((contentObject: EntityPageContentObject) => { }); test.describe('message entity table', () => { - test('should show message headers when clicking button', async ({page}) => { + test('should show message headers when clicking button', async ({ page }) => { const contentObject = entityPageContentMap[0]; await mockBackendResponse(page, contentObject.apiUrl, contentObject.contentJson); @@ -130,7 +124,7 @@ test.describe('message entity table', () => { }); test.describe('test results entity table', () => { - test('should show test parameters when clicking on button', async ({page}) => { + test('should show test parameters when clicking on button', async ({ page }) => { const contentObject = entityPageContentMap[4]; await mockBackendResponse(page, contentObject.apiUrl, contentObject.contentJson); @@ -142,7 +136,7 @@ test.describe('test results entity table', () => { }); }); -test('should display table of test parameters', async ({page}) => { +test('should display table of test parameters', async ({ page }) => { const contentObject = entityPageContentMap[5]; 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 068467b3..06674d13 100644 --- a/simulator-ui/tests/error-banner.spec.ts +++ b/simulator-ui/tests/error-banner.spec.ts @@ -1,14 +1,11 @@ -import {expect, Page, test} from '@playwright/test'; -import { - goToAllNavigationTabsAndOptionallyValidateContent, - mockErrorResponseForAllNavbarLinkedSites -} from './helpers/helper-functions'; +import { expect, Page, test } from '@playwright/test'; +import { goToAllNavigationTabsAndOptionallyValidateContent, mockErrorResponseForAllNavbarLinkedSites } from './helpers/helper-functions'; -test.beforeEach(async ({page}) => { +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}) => { +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 goToAllNavigationTabsAndOptionallyValidateContent(page, verifyErrorBannerIsVisible); diff --git a/simulator-ui/tests/helpers/helper-functions.ts b/simulator-ui/tests/helpers/helper-functions.ts index 8ad6ac67..034a504a 100644 --- a/simulator-ui/tests/helpers/helper-functions.ts +++ b/simulator-ui/tests/helpers/helper-functions.ts @@ -22,9 +22,9 @@ export const entityChildLinks: NavbarElementLinkPair[] = [ // a list of every navbar element, which leads directly to another page export const navbarElementLinkPairs: NavbarElementLinkPair[] = [ -{ testName: 'navigationScenariosLink', link: /.*scenario*/, apiLink: '**/api/scenarios*' }, -{ testName: 'navigationScenarioExecutionsLink', link: /.*scenario-result*/, apiLink: '**/api/scenario-executions*' }, -{ testName: 'navigationEntitiesLink', childElements: entityChildLinks }, + { testName: 'navigationScenariosLink', link: /.*scenario*/, apiLink: '**/api/scenarios*' }, + { testName: 'navigationScenarioExecutionsLink', link: /.*scenario-result*/, apiLink: '**/api/scenario-executions*' }, + { testName: 'navigationEntitiesLink', childElements: entityChildLinks }, ]; export const clickOnLinkAndCheckIfTabOpensWithCorrectURL = async ( @@ -60,48 +60,52 @@ export const mockBackendResponse = async ( export const mockErrorResponseForAllNavbarLinkedSites = async (page: Page): Promise => { for (const element of navbarElementLinkPairs) { - if(element.childElements){ - for(const child of element.childElements){ - if(child.apiLink){ + if (element.childElements) { + for (const child of element.childElements) { + if (child.apiLink) { await mock500ErrorResponseForApiURL(page, child.apiLink); } } } - if(element.apiLink){ + if (element.apiLink) { await mock500ErrorResponseForApiURL(page, element.apiLink); } } }; -const mock500ErrorResponseForApiURL = async (page: Page, apiLink: string) : Promise => { +const mock500ErrorResponseForApiURL = async (page: Page, apiLink: string): Promise => { await page.route(apiLink, async route => { await route.fulfill({ status: 500, }); }); -} +}; export const goToAllNavigationTabsAndOptionallyValidateContent = async ( page: Page, validatePageContent?: (page: Page) => Promise, ): Promise => { for (const element of navbarElementLinkPairs) { - if(element.childElements){ - for(const child of element.childElements){ + if (element.childElements) { + for (const child of element.childElements) { await page.getByTestId(element.testName).click(); await clickOnNavbarElementAndOptionallyValidateContent(page, child, validatePageContent); } } - await clickOnNavbarElementAndOptionallyValidateContent(page, element, validatePageContent); + await clickOnNavbarElementAndOptionallyValidateContent(page, element, validatePageContent); } }; -const clickOnNavbarElementAndOptionallyValidateContent = async (page: Page, navbarElement: NavbarElementLinkPair, validatePageContent?: (page: Page) => Promise) : Promise => { +const clickOnNavbarElementAndOptionallyValidateContent = async ( + page: Page, + navbarElement: NavbarElementLinkPair, + validatePageContent?: (page: Page) => Promise, +): Promise => { await page.getByTestId(navbarElement.testName).click(); - if(navbarElement.link){ + if (navbarElement.link) { await expect(page).toHaveURL(navbarElement.link); } if (validatePageContent) { await validatePageContent(page); } -} +}; diff --git a/simulator-ui/tests/home.spec.ts b/simulator-ui/tests/home.spec.ts index a308378d..8e54c5b9 100644 --- a/simulator-ui/tests/home.spec.ts +++ b/simulator-ui/tests/home.spec.ts @@ -1,30 +1,30 @@ -import {expect, Page, test} from '@playwright/test'; +import { expect, Page, test } from '@playwright/test'; -import {clickOnLinkAndCheckIfTabOpensWithCorrectURL, mockBackendResponse} from './helpers/helper-functions'; +import { clickOnLinkAndCheckIfTabOpensWithCorrectURL, mockBackendResponse } from './helpers/helper-functions'; let nbOfSuccessfulTests = 90; let nbOfFailedTests = 10; let nbOfTotalTests = nbOfSuccessfulTests + nbOfFailedTests; const scenarioSummariesLinkFilterTriples = [ - {testName: 'totalSimulationsButton', link: /.*\/scenario-result*/, filterText: ''}, - {testName: 'successfulSimulationsButton', link: /.*\/scenario-result*/, filterText: 'SUCCESS'}, - {testName: 'failedSimulationsButton', link: /.*\/scenario-result*/, filterText: 'FAILURE'}, + { testName: 'totalSimulationsButton', link: /.*\/scenario-result*/, filterText: '' }, + { testName: 'successfulSimulationsButton', link: /.*\/scenario-result*/, filterText: 'SUCCESS' }, + { testName: 'failedSimulationsButton', link: /.*\/scenario-result*/, filterText: 'FAILURE' }, ]; -test.beforeEach(async ({page}) => { +test.beforeEach(async ({ page }) => { await mockBackendResponse(page, '**/api/test-results/count-by-status', { successful: nbOfSuccessfulTests, failed: nbOfFailedTests, total: nbOfTotalTests, }); await mockBackendResponse(page, '**/api/manage/info', { - config: {'reset-results-enabled': 'true',} + config: { 'reset-results-enabled': 'true' }, }); await page.goto('http://localhost:9000/'); }); -test('should have title, disclaimer, refresh button, reset button, feedback option, summary-tabs and footer', async ({page}) => { +test('should have title, disclaimer, refresh button, reset button, feedback option, summary-tabs and footer', async ({ page }) => { const visibleElements: string[] = [ 'disclaimer', 'refreshListButton', @@ -42,11 +42,11 @@ test('should have title, disclaimer, refresh button, reset button, feedback opti } }); -test('check if summary-tab displays right percentage with round numbers', async ({page}) => { +test('check if summary-tab displays right percentage with round numbers', async ({ page }) => { await checkIfSummaryTabsAreDisplayingRightNumbers(page, nbOfTotalTests, nbOfSuccessfulTests, nbOfFailedTests); }); -test('total, successful, failed tabs should display percentage in simulations count rounded to two decimal numbers', async ({page}) => { +test('total, successful, failed tabs should display percentage in simulations count rounded to two decimal numbers', async ({ page }) => { const successfulTestsBig = 746039; const failedTestsBig = 490; const totalTestsBig = successfulTestsBig + failedTestsBig; @@ -61,12 +61,12 @@ test('total, successful, failed tabs should display percentage in simulations co await checkIfSummaryTabsAreDisplayingRightNumbers(page, totalTestsBig, successfulTestsBig, failedTestsBig); }); -test('should move to right page with feedback resp suggestion link', async ({page}) => { +test('should move to right page with feedback resp suggestion link', async ({ page }) => { await clickOnLinkAndCheckIfTabOpensWithCorrectURL(page, 'feedbackLinkStarGithub', /.*\/github\.com\/citrusframework\/citrus-simulator/); await clickOnLinkAndCheckIfTabOpensWithCorrectURL(page, 'feedbackAndSuggestionLink', /.*\/github\.com.*issue/); }); -test('should move to scenario-results page with right search field params after click on detail buttons', async ({page}) => { +test('should move to scenario-results page with right search field params after click on detail buttons', async ({ page }) => { for (const element of scenarioSummariesLinkFilterTriples) { await page.goto('http://localhost:9000/'); await page.getByTestId(element.testName).click(); @@ -75,7 +75,7 @@ test('should move to scenario-results page with right search field params after } }); -test('should have updated total, successful, failed tabs after refresh button clicked positive test', async ({page}) => { +test('should have updated total, successful, failed tabs after refresh button clicked positive test', async ({ page }) => { await checkIfSummaryTabsAreDisplayingRightNumbers(page, nbOfTotalTests, nbOfSuccessfulTests, nbOfFailedTests); nbOfFailedTests -= 10; @@ -91,8 +91,8 @@ test('should have updated total, successful, failed tabs after refresh button cl }); 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, - }) => { + page, +}) => { await checkIfSummaryTabsAreDisplayingRightNumbers(page, nbOfTotalTests, nbOfSuccessfulTests, nbOfFailedTests); nbOfFailedTests -= 10; // so the total will be wrong! const newCorrectTotal: number = nbOfTotalTests - 10; @@ -108,7 +108,7 @@ test('(test if frontend trusts backend blindly) should have updated total, succe expect(nbOfTotalTests === newCorrectTotal).toBeFalsy(); }); -test('should have same total, successful, failed tabs after cancel deletion via close-Button and cancel-Button', async ({page}) => { +test('should have same total, successful, failed tabs after cancel deletion via close-Button and cancel-Button', async ({ page }) => { await checkIfSummaryTabsAreDisplayingRightNumbers(page, nbOfTotalTests, nbOfSuccessfulTests, nbOfFailedTests); const closeButtons = ['testResultDeleteDialogCloseButton', 'testResultDeleteDialogCancelButton']; let deleteRequestWasMade = false; @@ -129,7 +129,7 @@ test('should have same total, successful, failed tabs after cancel deletion via } }); -test('should have reset total, successful, failed tabs after confirmed deletion with (200, OK) response', async ({page}) => { +test('should have reset total, successful, failed tabs after confirmed deletion with (200, OK) response', async ({ page }) => { await checkIfSummaryTabsAreDisplayingRightNumbers(page, nbOfTotalTests, nbOfSuccessfulTests, nbOfFailedTests); await page.getByTestId('resetButton').click(); await expect(page.getByTestId('testResultDeleteDialogHeading')).toBeVisible(); @@ -182,10 +182,10 @@ const checkIfSummaryTabsAreDisplayingRightNumbers = async ( for (const percentageDisplay of summarySelectorToAbsoluteValueMapping) { await expect(page.getByTestId(percentageDisplay.testSelector)).toHaveText( percentageDisplay.value + - ` (${((percentageDisplay.value / totalTests) * 100).toLocaleString(undefined, { - maximumFractionDigits: 2, - minimumFractionDigits: 0, - })} %)`, + ` (${((percentageDisplay.value / totalTests) * 100).toLocaleString(undefined, { + maximumFractionDigits: 2, + minimumFractionDigits: 0, + })} %)`, ); } }; diff --git a/simulator-ui/tests/navbar.spec.ts b/simulator-ui/tests/navbar.spec.ts index aa25f051..c7178d77 100644 --- a/simulator-ui/tests/navbar.spec.ts +++ b/simulator-ui/tests/navbar.spec.ts @@ -1,30 +1,27 @@ -import {expect, test} from '@playwright/test'; -import { - clickOnLinkAndCheckIfTabOpensWithCorrectURL, - goToAllNavigationTabsAndOptionallyValidateContent -} from './helpers/helper-functions'; +import { expect, test } from '@playwright/test'; +import { clickOnLinkAndCheckIfTabOpensWithCorrectURL, goToAllNavigationTabsAndOptionallyValidateContent } from './helpers/helper-functions'; -test.beforeEach(async ({page}) => { +test.beforeEach(async ({ page }) => { await page.goto('http://localhost:9000/'); }); -test('should move to all pages as intended', async ({page}) => { +test('should move to all pages as intended', async ({ page }) => { await goToAllNavigationTabsAndOptionallyValidateContent(page); }); -test('should move to scenario-result and then move back home ', async ({page}) => { +test('should move to scenario-result and then move back home ', async ({ page }) => { await page.getByTestId('navigationScenarioExecutionsLink').click(); await expect(page).toHaveURL(/.*scenario-result*/); await page.getByTestId('navigationHomeLink').click(); await expect(page).toHaveURL(/.*\//); }); -test('should move to the documentation in a new Tab', async ({page}) => { +test('should move to the documentation in a new Tab', async ({ page }) => { await page.getByTestId('entity').click(); await clickOnLinkAndCheckIfTabOpensWithCorrectURL(page, 'documentation', /.*\/\/citrusframework.org\/citrus-simulator/); }); -test('should move to the swaggerUI documentation', async ({page}) => { +test('should move to the swaggerUI documentation', async ({ page }) => { await page.getByTestId('entity').click(); await page.getByTestId('swaggerUI').click(); await expect(page).toHaveURL(/.*swagger-ui\/index.html/); diff --git a/simulator-ui/tests/no-data.spec.ts b/simulator-ui/tests/no-data.spec.ts index 726c8a5f..1a3affa0 100644 --- a/simulator-ui/tests/no-data.spec.ts +++ b/simulator-ui/tests/no-data.spec.ts @@ -1,11 +1,11 @@ -import {expect, Page, test} from '@playwright/test'; -import {goToAllNavigationTabsAndOptionallyValidateContent} from './helpers/helper-functions'; +import { expect, Page, test } from '@playwright/test'; +import { goToAllNavigationTabsAndOptionallyValidateContent } from './helpers/helper-functions'; -test.beforeEach(async ({page}) => { +test.beforeEach(async ({ page }) => { await page.goto('http://localhost:9000/'); }); -test('should show no-data-banner if there is an empty backend response on all pages', async ({page}) => { +test('should show no-data-banner if there is an empty backend response on all pages', async ({ page }) => { await goToAllNavigationTabsAndOptionallyValidateContent(page, verifyNoDataFoundBannerIsVisible); }); diff --git a/simulator-ui/tests/scenario-results.spec.ts b/simulator-ui/tests/scenario-results.spec.ts index c0368b63..aa92d528 100644 --- a/simulator-ui/tests/scenario-results.spec.ts +++ b/simulator-ui/tests/scenario-results.spec.ts @@ -1,5 +1,5 @@ -import {expect, Locator, test} from '@playwright/test'; -import {mockBackendResponse} from './helpers/helper-functions'; +import { expect, Locator, test } from '@playwright/test'; +import { mockBackendResponse } from './helpers/helper-functions'; import { messageHeaderJson, messageJson, @@ -9,7 +9,7 @@ import { twoScenarioExecutions, } from './helpers/scenario-results-jsons'; -test('should display input form', async ({page}) => { +test('should display input form', async ({ page }) => { await page.goto('http://localhost:9000/scenario-result/'); await expect(page.getByTestId('itemsPerPageSelect')).toBeVisible(); @@ -21,7 +21,7 @@ test('should display input form', async ({page}) => { await expect(page.getByTestId('scenarioExecutionHeaderFilterInput')).toBeVisible(); }); -test('should filter with input form', async ({page}) => { +test('should filter with input form', async ({ page }) => { await page.goto('http://localhost:9000/scenario-result/'); await mockBackendResponse(page, '**/api/scenario-executions?page=0&size=10&sort=executionId,asc', twoScenarioExecutions); await mockBackendResponse( @@ -46,7 +46,7 @@ const fillDatePickerField = async (dateField: Locator, date: string, time: strin await dateField.pressSequentially(time); }; -test('should display table headers for scenario executions', async ({page}) => { +test('should display table headers for scenario executions', async ({ page }) => { await mockBackendResponse(page, '**/api/scenario-executions*', scenarioExecutionJsonWithoutDetails); await page.goto('http://localhost:9000/scenario-result/'); @@ -59,7 +59,7 @@ test('should display table headers for scenario executions', async ({page}) => { await expect(page.locator('th :text("Error Message")')).toHaveCount(1); }); -test('should display table row for scenario executions', async ({page}) => { +test('should display table row for scenario executions', async ({ page }) => { await mockBackendResponse(page, '**/api/scenario-executions*', scenarioExecutionJsonWithoutDetails); await page.goto('http://localhost:9000/scenario-result/'); @@ -79,14 +79,14 @@ test('should display table row for scenario executions', async ({page}) => { await expect(page.locator('tr :text("Parameters")')).toHaveCount(1); }); -test('should display help dialog after clicking button', async ({page}) => { +test('should display help dialog after clicking button', async ({ page }) => { await page.goto('http://localhost:9000/scenario-result/'); await page.getByTestId('scenarioExecutionOpenHelpButton').click(); await expect(page.getByTestId('helpDialog')).toBeVisible(); }); -test('should display filter message header popup after clicking button', async ({page}) => { +test('should display filter message header popup after clicking button', async ({ page }) => { await page.goto('http://localhost:9000/scenario-result/'); await page.getByTestId('scenarioExecutionOpenFilterButton').click(); @@ -99,7 +99,7 @@ test('should display filter message header popup after clicking button', async ( await expect(page.getByTestId('applyHeaderFilterButton')).toBeVisible(); }); -test('should filter message headers with header name and header value', async ({page}) => { +test('should filter message headers with header name and header value', async ({ page }) => { await page.goto('http://localhost:9000/scenario-result/'); await page.getByTestId('scenarioExecutionOpenFilterButton').click(); @@ -113,7 +113,7 @@ test('should filter message headers with header name and header value', async ({ await expect(page.getByTestId('scenarioExecutionHeaderFilterInput')).toHaveValue('HeaderName1=HeaderValue1; HeaderName2~HeaderValue2'); }); -test('should delete second message header filter', async ({page}) => { +test('should delete second message header filter', async ({ page }) => { await page.goto('http://localhost:9000/scenario-result/'); await page.getByTestId('scenarioExecutionOpenFilterButton').click(); @@ -126,7 +126,7 @@ test('should delete second message header filter', async ({page}) => { await expect(page.locator('#header-1-value')).toHaveCount(0); }); -test('should clear all filters with button', async ({page}) => { +test('should clear all filters with button', async ({ page }) => { await page.goto('http://localhost:9000/scenario-result/'); await page.getByTestId('scenarioExecutionFilterInput').fill('Test Scenario'); @@ -152,7 +152,7 @@ test('should clear all filters with button', async ({page}) => { await expect(page.getByTestId('scenarioExecutionHeaderFilterInput')).toBeEmpty(); }); -test('should clear all filters with icon', async ({page}) => { +test('should clear all filters with icon', async ({ page }) => { await page.goto('http://localhost:9000/scenario-result/'); await page.getByTestId('scenarioExecutionFilterInput').fill('Test Scenario'); @@ -178,13 +178,13 @@ test('should clear all filters with icon', async ({page}) => { await expect(page.getByTestId('scenarioExecutionHeaderFilterInput')).toBeEmpty(); }); -test('should display detail view of scenario execution', async ({page}) => { +test('should display detail view of scenario execution', async ({ page }) => { await mockBackendResponse(page, '**/api/scenario-executions*', scenarioExecutionJsonWithoutDetails); await mockBackendResponse(page, '**/api/scenario-executions/752603', scenarioExecutionJsonWithDetails); await page.goto('http://localhost:9000/scenario-result/'); - await page.getByRole('link', {name: '752603'}).click(); + await page.getByRole('link', { name: '752603' }).click(); await expect(page).toHaveURL('http://localhost:9000/scenario-execution/752603/view'); await expect(page.getByTestId('scenarioExecutionId')).toHaveText('752603'); await expect(page.getByTestId('scenarioExecutionStartDate')).toHaveText('27 Jun 2024 10:59:03'); @@ -200,13 +200,13 @@ test('should display detail view of scenario execution', async ({page}) => { ); }); -test('should display detail view of message', async ({page}) => { +test('should display detail view of message', async ({ page }) => { await mockBackendResponse(page, '**/api/scenario-executions?page=0&size=10&sort=executionId,asc', scenarioExecutionJsonWithoutDetails); await mockBackendResponse(page, '**/api/scenario-executions/752603', scenarioExecutionJsonWithDetails); await mockBackendResponse(page, '**/api/messages/20', messageJson); await page.goto('http://localhost:9000/scenario-result/'); - await page.getByRole('link', {name: '752603'}).click(); + await page.getByRole('link', { name: '752603' }).click(); await expect(page).toHaveURL('http://localhost:9000/scenario-execution/752603/view'); await page.getByTestId('scenarioMessagesEntityMessageLink').click(); @@ -231,14 +231,14 @@ test('should display detail view of message', async ({page}) => { await expect(page.locator('tr :text("22 Aug 2024 08:38:56")').nth(3)).toHaveCount(1); }); -test('should display detail view of message header', async ({page}) => { +test('should display detail view of message header', async ({ page }) => { await mockBackendResponse(page, '**/api/scenario-executions?page=0&size=10&sort=executionId,asc', scenarioExecutionJsonWithoutDetails); await mockBackendResponse(page, '**/api/scenario-executions/752603', scenarioExecutionJsonWithDetails); await mockBackendResponse(page, '**/api/messages/20', messageJson); await mockBackendResponse(page, '**/api/message-headers/214', messageHeaderJson); await page.goto('http://localhost:9000/scenario-result/'); - await page.getByRole('link', {name: '752603'}).click(); + await page.getByRole('link', { name: '752603' }).click(); await expect(page).toHaveURL('http://localhost:9000/scenario-execution/752603/view'); await page.getByTestId('scenarioMessagesEntityMessageLink').click(); await expect(page).toHaveURL('http://localhost:9000/message/20/view'); @@ -251,14 +251,14 @@ test('should display detail view of message header', async ({page}) => { await expect(page.getByTestId('messageHeaderDetailsLastModified')).toHaveText('22 Aug 2024 08:38:56'); }); -test('should display detail view of scenario action', async ({page}) => { +test('should display detail view of scenario action', async ({ page }) => { await mockBackendResponse(page, '**/api/scenario-executions*', scenarioExecutionJsonWithoutDetails); await mockBackendResponse(page, '**/api/scenario-executions/752603', scenarioExecutionJsonWithDetails); await mockBackendResponse(page, '**/api/scenario-actions/29', scenarioActionJson); await page.goto('http://localhost:9000/scenario-result/'); - await page.getByRole('link', {name: '752603'}).click(); + await page.getByRole('link', { name: '752603' }).click(); await expect(page).toHaveURL('http://localhost:9000/scenario-execution/752603/view'); await page.getByTestId('scenarioActionsEntityScenarioActionLink').nth(0).click(); await expect(page).toHaveURL('http://localhost:9000/scenario-action/29/view'); diff --git a/simulator-ui/tests/scenario.spec.ts b/simulator-ui/tests/scenario.spec.ts index 77a2adac..441bdf8f 100644 --- a/simulator-ui/tests/scenario.spec.ts +++ b/simulator-ui/tests/scenario.spec.ts @@ -1,31 +1,31 @@ -import {expect, Page, test} from '@playwright/test'; -import {mockBackendResponse} from './helpers/helper-functions'; +import { expect, Page, test } from '@playwright/test'; +import { mockBackendResponse } from './helpers/helper-functions'; const scenarioJson = [ - {name: 'Default', type: 'MESSAGE_TRIGGERED'}, - {name: 'Fail', type: 'MESSAGE_TRIGGERED'}, - {name: 'GoodBye', type: 'MESSAGE_TRIGGERED'}, - {name: 'GoodNight', type: 'MESSAeGE_TRIGGERED'}, - {name: 'Hello', type: 'MESSAGE_TRIGGERED'}, - {name: 'Howdy', type: 'MESSAGE_TRIGGERED'}, - {name: 'Parm', type: 'MESSAGE_TRIGGERED'}, - {name: 'Throw', type: 'MESSAGE_TRIGGERED'}, - {name: 'ByeStarter', type: 'STARTER'}, - {name: 'HiStarter', type: 'STARTER'}, + { name: 'Default', type: 'MESSAGE_TRIGGERED' }, + { name: 'Fail', type: 'MESSAGE_TRIGGERED' }, + { name: 'GoodBye', type: 'MESSAGE_TRIGGERED' }, + { name: 'GoodNight', type: 'MESSAeGE_TRIGGERED' }, + { name: 'Hello', type: 'MESSAGE_TRIGGERED' }, + { name: 'Howdy', type: 'MESSAGE_TRIGGERED' }, + { name: 'Parm', type: 'MESSAGE_TRIGGERED' }, + { name: 'Throw', type: 'MESSAGE_TRIGGERED' }, + { name: 'ByeStarter', type: 'STARTER' }, + { name: 'HiStarter', type: 'STARTER' }, ]; const addititonalPageJson = [ - {name: 'One', type: 'STARTER'}, - {name: 'Two', type: 'STARTER'}, - {name: 'Three', type: 'STARTER'}, + { name: 'One', type: 'STARTER' }, + { name: 'Two', type: 'STARTER' }, + { name: 'Three', type: 'STARTER' }, ]; const orderedJson = [ - {name: 'Fail', type: 'MESSAGE_TRIGGERED'}, - {name: 'Parm', type: 'MESSAGE_TRIGGERED'}, - {name: 'Default', type: 'MESSAGE_TRIGGERED'}, - {name: 'HiStarter', type: 'STARTER'}, - {name: 'ByeStarter', type: 'STARTER'}, + { name: 'Fail', type: 'MESSAGE_TRIGGERED' }, + { name: 'Parm', type: 'MESSAGE_TRIGGERED' }, + { name: 'Default', type: 'MESSAGE_TRIGGERED' }, + { name: 'HiStarter', type: 'STARTER' }, + { name: 'ByeStarter', type: 'STARTER' }, ]; const parameterJson = [ @@ -42,14 +42,14 @@ 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()}); +test.beforeEach(async ({ page }) => { + 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'}); +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 page.goto('http://localhost:9000/scenario'); @@ -60,7 +60,7 @@ test('should display all scenario information of a starter scenario', async ({pa await expect(page.getByTestId('scenarioExecutionButton')).toBeVisible(); }); -test('should display all scenario information of a non-starter scenario', async ({page}) => { +test('should display all scenario information of a non-starter scenario', async ({ page }) => { await mockBackendResponse( page, '**/api/scenarios**', @@ -70,7 +70,7 @@ test('should display all scenario information of a non-starter scenario', async type: 'MESSAGE_TRIGGERED', }, ], - {'x-total-count': '1'}, + { 'x-total-count': '1' }, ); await page.goto('http://localhost:9000/scenario'); @@ -81,21 +81,21 @@ 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 page.getByRole('link', { name: '2' }).click(); await checkIfAllJsonContentIsVisible(page, 10, availableScenarios, addititonalPageJson); }); -test('see if frontend trusts backend to send only as much data as requested', async ({page}) => { +test('see if frontend trusts backend to send only as much data as requested', async ({ page }) => { const selectedPageSize = 10; await expect(page.getByTestId('itemsPerPageSelect')).toHaveValue('10'); - scenarioJson.push({name: 'One', type: 'STARTER'}); + scenarioJson.push({ name: 'One', type: 'STARTER' }); await page.goto('http://localhost:9000/scenario'); await page.getByTestId('itemsPerPageSelect').selectOption(selectedPageSize.toString()); @@ -105,31 +105,31 @@ test('see if frontend trusts backend to send only as much data as requested', as scenarioJson.pop(); }); -test('text filter input should apply and clear filter button should reset it', async ({page}) => { +test('text filter input should apply and clear filter button should reset it', async ({ page }) => { await applyFilterAAndCheckCorrectness(page); await page.getByTestId('clearFilterButton').click(); await expect(page.getByTestId('scenarioFilterByNameInput')).toHaveValue(''); }); -test('should have updated displayed scenarios after refresh button was clicked and a new scenario received', async ({page}) => { +test('should have updated displayed scenarios after refresh button was clicked and a new scenario received', async ({ page }) => { const selectOptionsForNumberOfScenariosToDisplay: number[] = [10, 20, 50, 100]; 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' }); } }); -test('should move to the scenario-execution page with right filter entered if clicked on the execution button', async ({page}) => { +test('should move to the scenario-execution page with right filter entered if clicked on the execution button', async ({ page }) => { const scenarioName = 'Test'; const urlRegex = new RegExp(`.*scenario-result\\?.*filter%5BscenarioName\\.equals%5D=${scenarioName}`); - await mockBackendResponse(page, '**/api/scenarios**', [{name: scenarioName, type: 'STARTER'}]); + await mockBackendResponse(page, '**/api/scenarios**', [{ name: scenarioName, type: 'STARTER' }]); await page.goto('http://localhost:9000/scenario'); await page.getByTestId('scenarioExecutionButton').click(); @@ -137,11 +137,11 @@ test('should move to the scenario-execution page with right filter entered if cl await expect(page.getByTestId('scenarioExecutionFilterInput')).toHaveValue(scenarioName); }); -test('should launch the scenario-execution and popup should be visible if clicked on the launch button', async ({page}) => { +test('should launch the scenario-execution and popup should be visible if clicked on the launch button', async ({ page }) => { const scenarioId = [7]; const scenarioName = 'Test'; const urlRegex = new RegExp(`.*scenario-result\\?.*filter%5BexecutionId\\.in%5D=${scenarioId[0].toString()}`); - await mockBackendResponse(page, '**/api/scenarios**', [{name: scenarioName, type: 'STARTER'}]); + await mockBackendResponse(page, '**/api/scenarios**', [{ name: scenarioName, type: 'STARTER' }]); await page.goto('http://localhost:9000/scenario'); await mockBackendResponse(page, `**/api/scenarios/${scenarioName}/launch**`, scenarioId); @@ -154,9 +154,9 @@ test('should launch the scenario-execution and popup should be visible if clicke await expect(page.getByText('executionId.in: ' + scenarioId[0])).toBeVisible(); }); -test('should show error message if launch failed after click on the launch button', async ({page}) => { +test('should show error message if launch failed after click on the launch button', async ({ page }) => { const scenarioName = 'Test'; - await mockBackendResponse(page, '**/api/scenarios**', [{name: scenarioName, type: 'STARTER'}]); + await mockBackendResponse(page, '**/api/scenarios**', [{ name: scenarioName, type: 'STARTER' }]); await page.goto('http://localhost:9000/scenario'); await page.getByTestId('scenarioLaunchButton').click(); @@ -165,7 +165,7 @@ test('should show error message if launch failed after click on the launch butto await expect(page).toHaveURL(/.*localhost:9000\/scenario/); }); -test('should go to detail view of a scenario type MESSAGE_TRIGGERED check for content and and then go back', async ({page}) => { +test('should go to detail view of a scenario type MESSAGE_TRIGGERED check for content and and then go back', async ({ page }) => { const allVisibleDetailElements = [ 'scenarioDetailsHeading', 'scenarioDetailsName', @@ -183,7 +183,7 @@ test('should go to detail view of a scenario type MESSAGE_TRIGGERED check for co await expect(page).toHaveURL(/.*scenario/); }); -test('should go to detail view of a scenario type STARTER check for content and go back', async ({page}) => { +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); const allVisibleDetailElements = [ 'scenarioDetailsHeading', @@ -227,7 +227,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');