From 2cb38630dad9b9fe49b70ba288ba5afc0ebcd4b1 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 4 Sep 2025 14:58:36 +0100 Subject: [PATCH 1/6] Add in new ability to store passed/total as a bracketed total --- src/components/app/ExecutionSummary.tsx | 5 +++++ src/formatPassedQuantity.spec.ts | 22 ++++++++++++++++++++++ src/formatPassedQuantity.ts | 3 +++ 3 files changed, 30 insertions(+) create mode 100644 src/formatPassedQuantity.spec.ts create mode 100644 src/formatPassedQuantity.ts diff --git a/src/components/app/ExecutionSummary.tsx b/src/components/app/ExecutionSummary.tsx index 624d3fc9..27ceee90 100644 --- a/src/components/app/ExecutionSummary.tsx +++ b/src/components/app/ExecutionSummary.tsx @@ -6,6 +6,7 @@ import React, { FC } from 'react' import { formatExecutionDistance } from '../../formatExecutionDistance.js' import { formatExecutionDuration } from '../../formatExecutionDuration.js' import { formatStatusRate } from '../../formatStatusRate.js' +import { formatPassedQuantity } from '../../formatPassedQuantity.js' import { useQueries } from '../../hooks/index.js' import { useResultStatistics } from '../../hooks/useResultStatistics.js' import { CICommitLink } from './CICommitLink.js' @@ -63,6 +64,10 @@ export const ExecutionSummary: FC = () => { scenarioCountByStatus[TestStepResultStatus.PASSED], totalScenarioCount )} + {formatPassedQuantity( + scenarioCountByStatus[TestStepResultStatus.PASSED], + totalScenarioCount + )} {' passed'} diff --git a/src/formatPassedQuantity.spec.ts b/src/formatPassedQuantity.spec.ts new file mode 100644 index 00000000..c42e091f --- /dev/null +++ b/src/formatPassedQuantity.spec.ts @@ -0,0 +1,22 @@ +import { expect } from 'chai' + +import { formatPassedQuantity } from './formatPassedQuantity.js' + +describe('formatPassedQuantity', () => { + const examples: [passed: number, total: number, proportion: string][] = [ + [13, 45, '(13 / 45)'], + [5, 45, '(5 / 45)'], + [45, 45, '(45 / 45)'], + [0, 45, '(0 / 45)'], + [0, 0, '(0 / 0)'], + [999, 1000, '(999 / 1000)'], + [99999, 100000, '(99999 / 100000)'], + [9999999, 10000000, '(9999999 / 10000000)'], + ] + + for (const [passed, total, proportion] of examples) { + it(`should render correctly for ${proportion}`, () => { + expect(formatPassedQuantity(passed, total)).to.eq(proportion) + }) + } +}) diff --git a/src/formatPassedQuantity.ts b/src/formatPassedQuantity.ts new file mode 100644 index 00000000..cb93e3f0 --- /dev/null +++ b/src/formatPassedQuantity.ts @@ -0,0 +1,3 @@ +export function formatPassedQuantity(passed: number, total: number) { + return `(${passed} / ${total})` +} From 86d725693507f3a4d23e60b39e626738bb84fc0e Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 4 Sep 2025 15:01:39 +0100 Subject: [PATCH 2/6] Add comma suffix; --- src/components/app/ExecutionSummary.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/app/ExecutionSummary.tsx b/src/components/app/ExecutionSummary.tsx index 27ceee90..7d3f4249 100644 --- a/src/components/app/ExecutionSummary.tsx +++ b/src/components/app/ExecutionSummary.tsx @@ -68,7 +68,7 @@ export const ExecutionSummary: FC = () => { scenarioCountByStatus[TestStepResultStatus.PASSED], totalScenarioCount )} - {' passed'} + {', passed'} From 81be4322bbd32a11babd82028a0294d81f4350ec Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 4 Sep 2025 15:10:54 +0100 Subject: [PATCH 3/6] Fix up the specs --- src/components/app/ExecutionSummary.spec.tsx | 2 +- src/components/app/ExecutionSummary.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/app/ExecutionSummary.spec.tsx b/src/components/app/ExecutionSummary.spec.tsx index 77f6fa98..0d0c3332 100644 --- a/src/components/app/ExecutionSummary.spec.tsx +++ b/src/components/app/ExecutionSummary.spec.tsx @@ -79,7 +79,7 @@ Platform: linux@5.11.0-1022-azure`) ) - expect(screen.getByText('55.5% passed')).to.be.visible + expect(screen.getByText('55.5% (5 / 9), passed')).to.be.visible }) it('should include the job link', () => { diff --git a/src/components/app/ExecutionSummary.tsx b/src/components/app/ExecutionSummary.tsx index 7d3f4249..63ae255c 100644 --- a/src/components/app/ExecutionSummary.tsx +++ b/src/components/app/ExecutionSummary.tsx @@ -64,6 +64,7 @@ export const ExecutionSummary: FC = () => { scenarioCountByStatus[TestStepResultStatus.PASSED], totalScenarioCount )} + {' '} {formatPassedQuantity( scenarioCountByStatus[TestStepResultStatus.PASSED], totalScenarioCount From 8547f79dc95758c1e3dc8bf9a5ee74f5efea6e7a Mon Sep 17 00:00:00 2001 From: David Goss Date: Thu, 4 Sep 2025 18:10:49 +0100 Subject: [PATCH 4/6] lose the comma --- src/components/app/ExecutionSummary.spec.tsx | 2 +- src/components/app/ExecutionSummary.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/app/ExecutionSummary.spec.tsx b/src/components/app/ExecutionSummary.spec.tsx index 0d0c3332..a0dbf952 100644 --- a/src/components/app/ExecutionSummary.spec.tsx +++ b/src/components/app/ExecutionSummary.spec.tsx @@ -79,7 +79,7 @@ Platform: linux@5.11.0-1022-azure`) ) - expect(screen.getByText('55.5% (5 / 9), passed')).to.be.visible + expect(screen.getByText('55.5% (5 / 9) passed')).to.be.visible }) it('should include the job link', () => { diff --git a/src/components/app/ExecutionSummary.tsx b/src/components/app/ExecutionSummary.tsx index 63ae255c..86959c54 100644 --- a/src/components/app/ExecutionSummary.tsx +++ b/src/components/app/ExecutionSummary.tsx @@ -69,7 +69,7 @@ export const ExecutionSummary: FC = () => { scenarioCountByStatus[TestStepResultStatus.PASSED], totalScenarioCount )} - {', passed'} + {' passed'} From ee65fd3f74169296cc106e1dcfcca1113f439fe3 Mon Sep 17 00:00:00 2001 From: David Goss Date: Thu, 4 Sep 2025 18:12:10 +0100 Subject: [PATCH 5/6] lint --- src/components/app/ExecutionSummary.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/app/ExecutionSummary.tsx b/src/components/app/ExecutionSummary.tsx index 86959c54..ac1e960b 100644 --- a/src/components/app/ExecutionSummary.tsx +++ b/src/components/app/ExecutionSummary.tsx @@ -5,8 +5,8 @@ import React, { FC } from 'react' import { formatExecutionDistance } from '../../formatExecutionDistance.js' import { formatExecutionDuration } from '../../formatExecutionDuration.js' -import { formatStatusRate } from '../../formatStatusRate.js' import { formatPassedQuantity } from '../../formatPassedQuantity.js' +import { formatStatusRate } from '../../formatStatusRate.js' import { useQueries } from '../../hooks/index.js' import { useResultStatistics } from '../../hooks/useResultStatistics.js' import { CICommitLink } from './CICommitLink.js' @@ -63,8 +63,7 @@ export const ExecutionSummary: FC = () => { {formatStatusRate( scenarioCountByStatus[TestStepResultStatus.PASSED], totalScenarioCount - )} - {' '} + )}{' '} {formatPassedQuantity( scenarioCountByStatus[TestStepResultStatus.PASSED], totalScenarioCount From 60c059c7f53dd65e898a9000bc769c5d9c54fdad Mon Sep 17 00:00:00 2001 From: David Goss Date: Thu, 4 Sep 2025 18:13:16 +0100 Subject: [PATCH 6/6] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 629a8af8..aadf43c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Added +- Include pass rate in execution summary ([#397](https://github.com/cucumber/react-components/pull/397)) ## [23.2.0] - 2025-08-07 ### Changed