From 54a594924db0351c534731b44470251e95ec374a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Carl=C3=A9?= Date: Fri, 28 Mar 2025 16:26:06 +0100 Subject: [PATCH 1/3] fix: remove duplications in steps due to empty parameters --- src/components/gherkin/GherkinStep.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/gherkin/GherkinStep.tsx b/src/components/gherkin/GherkinStep.tsx index 894d76e3..6759829a 100644 --- a/src/components/gherkin/GherkinStep.tsx +++ b/src/components/gherkin/GherkinStep.tsx @@ -77,7 +77,7 @@ const DefaultRenderer: DefaultComponent = ({ stepTextElements.push() } const arg = argument.group.value - if (arg) { + if (arg !== undefined && arg !== null) { if (arg.length > 0) { stepTextElements.push( Date: Fri, 28 Mar 2025 17:15:06 +0100 Subject: [PATCH 2/3] test: check no more duplications in gherkin step due to empty parameters --- src/components/gherkin/GherkinStep.spec.tsx | 39 +++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/components/gherkin/GherkinStep.spec.tsx b/src/components/gherkin/GherkinStep.spec.tsx index 8764805d..9153dc15 100644 --- a/src/components/gherkin/GherkinStep.spec.tsx +++ b/src/components/gherkin/GherkinStep.spec.tsx @@ -48,4 +48,43 @@ describe('', () => { expect(container).to.contain.text('Given') expect(container).to.contain.text('the 48 pixies') }) + it('empty parameters are respected correctly', () => { + const step: messages.Step = { + keyword: 'Given', + text: 'the order is placed', + location: { column: 1, line: 1 }, + id: '123', + } + + class StubCucumberQuery extends CucumberQuery { + public getStepMatchArgumentsLists(): messages.StepMatchArgumentsList[] { + return [ + { + stepMatchArguments: [ + { + group: { + start: 9, + value: '', + children: [], + }, + }, + ], + }, + ] + } + } + + class StubGherkinQuery extends GherkinQuery { + getPickleStepIds(): string[] { + return ['dummy-id'] + } + } + + const { container } = render(, { + gherkinQuery: new StubGherkinQuery(), + cucumberQuery: new StubCucumberQuery(), + }) + + expect(container).to.not.contain.text('the orderthe order is placed') + }) }) From 06e8145fc193ad2c4a9aae6f2d133bcd0479af3e Mon Sep 17 00:00:00 2001 From: David Goss Date: Sat, 29 Mar 2025 09:25:06 +0000 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd11bf74..46557623 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 +- Remove duplications in steps due to empty parameters ([#373](https://github.com/cucumber/react-components/pull/373)) ## [22.4.0] - 2025-03-26 ### Added