From 36846ea08de198ab33379549ab3d3e9fe5daf51a Mon Sep 17 00:00:00 2001 From: Oleksandr_Halichenko Date: Fri, 27 Oct 2023 18:27:03 +0300 Subject: [PATCH 1/4] added displaying of execution time for steps and scenarios --- CHANGELOG.MD | 5 +++-- src/components/Scenario.tsx | 9 ++++++++- src/components/Step.tsx | 12 ++++++++---- src/components/TimeLabel.tsx | 9 +++++++++ test-e2e/features/ExecutionTime.feature | 12 ++++++++++++ test-e2e/po/components/Scenario.ts | 2 ++ 6 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 src/components/TimeLabel.tsx create mode 100644 test-e2e/features/ExecutionTime.feature diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 9fea8d2..2f74a61 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,6 +1,7 @@ -# [Unreleased] +# 0.15.0 - migrated to react 18 and vite dev server - +- added displaying of execution time for steps and scenarios + # 0.14.4 - fixed [Feature that contains only undefined/skipped scenarios is displayed as passed](https://github.com/qavajs/html-formatter/issues/36) diff --git a/src/components/Scenario.tsx b/src/components/Scenario.tsx index b909f81..f0acbdb 100644 --- a/src/components/Scenario.tsx +++ b/src/components/Scenario.tsx @@ -1,9 +1,14 @@ -import { FlexRow, Text, Badge, FlexCell, Accordion } from "@epam/promo"; +import {FlexRow, Text, Badge, FlexCell, Accordion} from "@epam/promo"; import { Step } from "./Step"; import css from "../App.module.scss"; import clipboard from "../utils/clipboard"; +import {FlexSpacer} from "@epam/uui"; +import {TimeLabel} from "./TimeLabel"; const filterByStatus = (scenario: any, status: string) => scenario.steps.filter((step: any) => step.result.status === status); +const getScenarioDuration = (scenario: any) => { + return `${(scenario.steps.reduce((duration: number, step: any) => duration + (step?.result.duration ?? 0), 0) / 1_000_000).toFixed(2)}s` +} const scenarioTitle = (scenario: any) => function ScenarioTitle() { const passed = filterByStatus(scenario, "passed").length; const failed = filterByStatus(scenario, "failed").length; @@ -29,6 +34,8 @@ const scenarioTitle = (scenario: any) => function ScenarioTitle() { caption={tag.name} onClick={clipboard(tag.name)} />)} + + } diff --git a/src/components/Step.tsx b/src/components/Step.tsx index e51efd1..9ba39fb 100644 --- a/src/components/Step.tsx +++ b/src/components/Step.tsx @@ -1,4 +1,4 @@ -import { Text, IconContainer, IconButton, LinkButton } from '@epam/promo'; +import {Text, IconContainer, IconButton, LinkButton, FlexRow} from '@epam/promo'; import { ErrorModal } from './ErrorModal'; import { ReactComponent as PassedIcon } from '@epam/assets/icons/common/notification-done-24.svg'; import { ReactComponent as FailedIcon } from '@epam/assets/icons/common/navigation-close-24.svg'; @@ -17,6 +17,8 @@ import { AttachmentModal } from './AttachmentModal'; import { supportedMimeTypes } from '../utils/supportedMimeTypes'; import { openInNewTab } from '../utils/openInNewTab'; import { LogsModal } from './LogsModal'; +import {TimeLabel} from "./TimeLabel"; +import {FlexSpacer} from '@epam/uui'; const icon = (status: string) => { switch (status) { @@ -73,8 +75,8 @@ export const Step = ({step}: {step: any}) => { const logs = step.embeddings ? step.embeddings.filter((embedding: any) => embedding.mime_type === 'text/x.cucumber.log+plain') : []; - return
-
+ return
+ {icon(step.result.status)} {`${step.name ?? step.keyword}`} {step.result.status === 'failed' && step.result.error_message && { onClick={ handleAttachmentClick(embedding, svc) } />) } -
+ + +
{step.arguments && step.arguments.map((arg: any, index: number) => )}
diff --git a/src/components/TimeLabel.tsx b/src/components/TimeLabel.tsx new file mode 100644 index 0000000..b27365f --- /dev/null +++ b/src/components/TimeLabel.tsx @@ -0,0 +1,9 @@ +import {ReactComponent as ClockIcon} from "@epam/assets/icons/common/action-clock-18.svg"; +import {IconContainer, Text} from "@epam/promo"; + +export const TimeLabel = (props: { time: string }) => { + return <> + + {props.time} + +} diff --git a/test-e2e/features/ExecutionTime.feature b/test-e2e/features/ExecutionTime.feature new file mode 100644 index 0000000..513f264 --- /dev/null +++ b/test-e2e/features/ExecutionTime.feature @@ -0,0 +1,12 @@ +Feature: Execution Time + + Background: + Given I open '$reportPage' url + When I click 'Main > Features Table > #FEATURE1 in Rows > Name' + Then I expect text of 'Feature > Title' to equal 'Feature: Feature1' + + Scenario: verify that scenario have execution time + Then I expect text of 'Feature > #1 of Scenarios > Time' to match '^\d+\.\d{2}s$' + When I click 'Feature > #1 of Scenarios' + Then I expect text of 'Feature > #1 of Scenarios > #1 of Steps > Time' to match '^\d+\.\d{2}s$' + diff --git a/test-e2e/po/components/Scenario.ts b/test-e2e/po/components/Scenario.ts index a2f9dd3..b2f3623 100644 --- a/test-e2e/po/components/Scenario.ts +++ b/test-e2e/po/components/Scenario.ts @@ -2,9 +2,11 @@ import { $, $$, Component } from '@qavajs/po-playwright'; class Step extends Component { Attachments = $$('button'); + Time = $('.AwUU3x + .uui-icon + div'); } export default class Scenario extends Component { Title = $('.uui-accordion-toggle-container > div > div'); Steps = $$(new Step('.uui-accordion-body > div')); + Time = $('.AwUU3x + .uui-icon + div'); } From 72865f45008e478f26eebe2e2ce9bc63434ac10e Mon Sep 17 00:00:00 2001 From: Oleksandr_Halichenko Date: Fri, 27 Oct 2023 19:45:43 +0300 Subject: [PATCH 2/4] fixed e2e tests --- test-e2e/po/components/Scenario.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-e2e/po/components/Scenario.ts b/test-e2e/po/components/Scenario.ts index b2f3623..ac12e7a 100644 --- a/test-e2e/po/components/Scenario.ts +++ b/test-e2e/po/components/Scenario.ts @@ -6,7 +6,7 @@ class Step extends Component { } export default class Scenario extends Component { - Title = $('.uui-accordion-toggle-container > div > div'); + Title = $('.uui-accordion-toggle-container > div > div:first-child'); Steps = $$(new Step('.uui-accordion-body > div')); Time = $('.AwUU3x + .uui-icon + div'); } From 602dc63fbb438078e4ad6f6c8b5a9e6ffe701700 Mon Sep 17 00:00:00 2001 From: Oleksandr_Halichenko Date: Fri, 27 Oct 2023 20:02:38 +0300 Subject: [PATCH 3/4] fixed nano seconds conversion --- CHANGELOG.MD | 3 +++ package-lock.json | 4 ++-- package.json | 2 +- src/components/Scenario.tsx | 2 +- src/components/Step.tsx | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 2f74a61..a2fa622 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,3 +1,6 @@ +# 0.15.1 +- fixed nano seconds conversion + # 0.15.0 - migrated to react 18 and vite dev server - added displaying of execution time for steps and scenarios diff --git a/package-lock.json b/package-lock.json index 68f7e57..b0d7bcc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@qavajs/html-formatter", - "version": "0.15.0", + "version": "0.15.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@qavajs/html-formatter", - "version": "0.15.0", + "version": "0.15.1", "devDependencies": { "@cucumber/cucumber": "^10.0.1", "@epam/assets": "latest", diff --git a/package.json b/package.json index f67483b..87c9220 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@qavajs/html-formatter", - "version": "0.15.0", + "version": "0.15.1", "main": "formatter/formatter.js", "authors": [ "Alexandr Galichenko", diff --git a/src/components/Scenario.tsx b/src/components/Scenario.tsx index f0acbdb..eaee723 100644 --- a/src/components/Scenario.tsx +++ b/src/components/Scenario.tsx @@ -7,7 +7,7 @@ import {TimeLabel} from "./TimeLabel"; const filterByStatus = (scenario: any, status: string) => scenario.steps.filter((step: any) => step.result.status === status); const getScenarioDuration = (scenario: any) => { - return `${(scenario.steps.reduce((duration: number, step: any) => duration + (step?.result.duration ?? 0), 0) / 1_000_000).toFixed(2)}s` + return `${(scenario.steps.reduce((duration: number, step: any) => duration + (step?.result.duration ?? 0), 0) / 1_000_000_000).toFixed(2)}s` } const scenarioTitle = (scenario: any) => function ScenarioTitle() { const passed = filterByStatus(scenario, "passed").length; diff --git a/src/components/Step.tsx b/src/components/Step.tsx index 9ba39fb..568be98 100644 --- a/src/components/Step.tsx +++ b/src/components/Step.tsx @@ -99,7 +99,7 @@ export const Step = ({step}: {step: any}) => { />) } - +
{step.arguments && step.arguments.map((arg: any, index: number) => )} From 1fce1fa1e060e1281b2db689f6cc8c8129adf58f Mon Sep 17 00:00:00 2001 From: Oleksandr_Halichenko Date: Fri, 27 Oct 2023 20:18:06 +0300 Subject: [PATCH 4/4] fixed nano seconds conversion --- formatter/json_formatter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/formatter/json_formatter.js b/formatter/json_formatter.js index ece0c0c..f06b5f0 100644 --- a/formatter/json_formatter.js +++ b/formatter/json_formatter.js @@ -43,7 +43,7 @@ class JsonFormatter extends Formatter { const result= testCase.stepResults[step.id]; step.result = { status: result.status.toLowerCase(), - duration: result.duration.seconds * 1_000_000 + result.duration.nanos, + duration: result.duration.seconds * 1_000_000_000 + result.duration.nanos, error_message: result.message }; step.embeddings = testCase.stepAttachments[step.id]?.map(attachment => ({