From d5e5d92b9ddfa554250bc31b0d6568648e5ab840 Mon Sep 17 00:00:00 2001 From: David Goss Date: Tue, 25 Nov 2025 10:11:00 +0000 Subject: [PATCH 1/6] failing test --- .../results/TestStepOutcome.spec.tsx | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/components/results/TestStepOutcome.spec.tsx diff --git a/src/components/results/TestStepOutcome.spec.tsx b/src/components/results/TestStepOutcome.spec.tsx new file mode 100644 index 00000000..946cc96a --- /dev/null +++ b/src/components/results/TestStepOutcome.spec.tsx @@ -0,0 +1,30 @@ +import { Query as CucumberQuery } from '@cucumber/query' +import { expect } from 'chai' +import React from 'react' + +import minimalSample from '../../../acceptance/minimal/minimal.js' +import { render } from '../../../test-utils/index.js' +import { EnvelopesProvider } from '../app/index.js' +import { TestStepOutcome } from './TestStepOutcome.js' + +describe('TestStepOutcome', () => { + it('should still work when we cant resolve the original step', () => { + // omit gherkinDocument messages so we have PickleStep but not Step + const envelopes = minimalSample.filter((envelope) => !envelope.gherkinDocument) + + const cucumberQuery = new CucumberQuery() + envelopes.forEach((envelope) => cucumberQuery.update(envelope)) + + const [testCaseStarted] = cucumberQuery.findAllTestCaseStarted() + const [[testStepFinished, testStep]] = + cucumberQuery.findTestStepFinishedAndTestStepBy(testCaseStarted) + + const { getByText } = render( + + + + ) + + expect(getByText('I have 42 cukes in my belly')).to.be.visible + }) +}) From 69d7994014ac5e0d2f72f256d56d86a3cb4d5a75 Mon Sep 17 00:00:00 2001 From: David Goss Date: Tue, 25 Nov 2025 10:38:33 +0000 Subject: [PATCH 2/6] handle missing step --- src/components/results/TestStepOutcome.spec.tsx | 2 +- src/components/results/TestStepOutcome.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/results/TestStepOutcome.spec.tsx b/src/components/results/TestStepOutcome.spec.tsx index 946cc96a..2573f959 100644 --- a/src/components/results/TestStepOutcome.spec.tsx +++ b/src/components/results/TestStepOutcome.spec.tsx @@ -25,6 +25,6 @@ describe('TestStepOutcome', () => { ) - expect(getByText('I have 42 cukes in my belly')).to.be.visible + expect(getByText('cukes in my belly')).to.be.visible }) }) diff --git a/src/components/results/TestStepOutcome.tsx b/src/components/results/TestStepOutcome.tsx index b8b2c60e..980b103e 100644 --- a/src/components/results/TestStepOutcome.tsx +++ b/src/components/results/TestStepOutcome.tsx @@ -48,10 +48,10 @@ const HookStepTitle: FC<{ testStep: TestStep }> = ({ testStep }) => { const PickleStepTitle: FC<{ testStep: TestStep }> = ({ testStep }) => { const { cucumberQuery } = useQueries() const pickleStep = cucumberQuery.findPickleStepBy(testStep) as PickleStep - const step = cucumberQuery.findStepBy(pickleStep) as Step + const step = cucumberQuery.findStepBy(pickleStep) return ( <> - {step.keyword.trim()} + {step?.keyword?.trim()} {composePickleStepTitle(pickleStep.text, testStep.stepMatchArgumentsLists).map( (fragment, index) => { if (fragment.parameterTypeName) { From f9522ee917567274b245013625ccecb6e8c47a22 Mon Sep 17 00:00:00 2001 From: David Goss Date: Tue, 25 Nov 2025 10:57:25 +0000 Subject: [PATCH 3/6] make test setup better --- .../results/TestStepOutcome.spec.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/results/TestStepOutcome.spec.tsx b/src/components/results/TestStepOutcome.spec.tsx index 2573f959..28a568bf 100644 --- a/src/components/results/TestStepOutcome.spec.tsx +++ b/src/components/results/TestStepOutcome.spec.tsx @@ -1,3 +1,4 @@ +import { GherkinDocument } from '@cucumber/messages' import { Query as CucumberQuery } from '@cucumber/query' import { expect } from 'chai' import React from 'react' @@ -9,8 +10,21 @@ import { TestStepOutcome } from './TestStepOutcome.js' describe('TestStepOutcome', () => { it('should still work when we cant resolve the original step', () => { - // omit gherkinDocument messages so we have PickleStep but not Step - const envelopes = minimalSample.filter((envelope) => !envelope.gherkinDocument) + // omit children from gherkinDocument.feature so that Step is unresolved + const envelopes = minimalSample.map((envelope) => { + if (envelope.gherkinDocument) { + return { + gherkinDocument: { + ...envelope.gherkinDocument, + feature: { + ...envelope.gherkinDocument.feature, + children: [] + } + } as GherkinDocument + } + } + return envelope + }) const cucumberQuery = new CucumberQuery() envelopes.forEach((envelope) => cucumberQuery.update(envelope)) From 8840f7dd23f1b216e03cfcc263b670568c53f92c Mon Sep 17 00:00:00 2001 From: David Goss Date: Tue, 25 Nov 2025 13:22:55 +0000 Subject: [PATCH 4/6] update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8f239c5..0d34479f 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] +### Fixed +- Handle missing step gracefully ([#419](https://github.com/cucumber/react-components/pull/419)) ## [24.1.1] - 2025-11-24 ### Changed From ba3af33b847c9dff47b4ea03d429d62b67f47c0a Mon Sep 17 00:00:00 2001 From: David Goss Date: Tue, 25 Nov 2025 13:23:36 +0000 Subject: [PATCH 5/6] clean up import --- src/components/results/TestStepOutcome.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/results/TestStepOutcome.tsx b/src/components/results/TestStepOutcome.tsx index 980b103e..9290cfeb 100644 --- a/src/components/results/TestStepOutcome.tsx +++ b/src/components/results/TestStepOutcome.tsx @@ -1,4 +1,4 @@ -import { PickleStep, Step, TestStep, TestStepFinished } from '@cucumber/messages' +import { PickleStep, TestStep, TestStepFinished } from '@cucumber/messages' import React, { FC } from 'react' import { useQueries } from '../../hooks/index.js' From c543f663ee175f41da37663eb9c01dad258bf607 Mon Sep 17 00:00:00 2001 From: David Goss Date: Tue, 25 Nov 2025 13:24:20 +0000 Subject: [PATCH 6/6] formatting --- src/components/results/TestStepOutcome.spec.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/results/TestStepOutcome.spec.tsx b/src/components/results/TestStepOutcome.spec.tsx index 28a568bf..32f7b6af 100644 --- a/src/components/results/TestStepOutcome.spec.tsx +++ b/src/components/results/TestStepOutcome.spec.tsx @@ -18,9 +18,9 @@ describe('TestStepOutcome', () => { ...envelope.gherkinDocument, feature: { ...envelope.gherkinDocument.feature, - children: [] - } - } as GherkinDocument + children: [], + }, + } as GherkinDocument, } } return envelope