Skip to content

Commit 4c52214

Browse files
authored
Recast wrappers as providers (#385)
1 parent f6316c8 commit 4c52214

19 files changed

+77
-85
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2020
- Redesigned report header block ([#381](https://github.com/cucumber/react-components/pull/381))
2121
- BREAKING CHANGE: Remove props from `<StatusesSummary/>`, `<ExecutionSummary/>` and `<SearchBar/>` components, use contexts for state ([#374](https://github.com/cucumber/react-components/pull/374))
2222
- BREAKING CHANGE: Components and hooks are now exported at the top level, not within `components` and `hooks` objects ([#383](https://github.com/cucumber/react-components/pull/383))
23+
- BREAKING CHANGE: `<EnvelopesWrapper/>` and `<QueriesWrapper/>` renamed to `<EnvelopesProvider/>` and `<QueriesProvider/>` for clarity ([#385](https://github.com/cucumber/react-components/pull/385))
2324

2425
### Removed
2526
- BREAKING CHANGE: Remove `EnvelopesQuery` and its React context ([#374](https://github.com/cucumber/react-components/pull/374))
2627
- BREAKING CHANGE: Remove defunct `<CucumberReact/>` component ([#382](https://github.com/cucumber/react-components/pull/382))
2728
- BREAKING CHANGE: Remove `SearchQueryContext`, `<SearchWrapper/>` and related defunct symbols ([#384](https://github.com/cucumber/react-components/pull/384))
29+
- BREAKING CHANGE: Remove `GherkinQueryContext` and `CucumberQueryContext` from entry point ([#385](https://github.com/cucumber/react-components/pull/385))
2830

2931
## [22.4.1] - 2025-03-30
3032
### Fixed

src/acceptance.spec.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { pipeline, Writable } from 'stream'
1717
import { promisify } from 'util'
1818

1919
import { CucumberQueryStream, render } from '../test-utils/index.js'
20-
import { GherkinDocumentList, QueriesWrapper } from './index.js'
20+
import { GherkinDocumentList, QueriesProvider } from './index.js'
2121

2222
describe('acceptance tests', function () {
2323
this.timeout('30s')
@@ -41,9 +41,9 @@ describe('acceptance tests', function () {
4141
await runCucumber(supportCode, gherkinStream, gherkinQuery, cucumberQueryStream)
4242

4343
const { container } = render(
44-
<QueriesWrapper gherkinQuery={gherkinQuery} cucumberQuery={cucumberQuery}>
44+
<QueriesProvider gherkinQuery={gherkinQuery} cucumberQuery={cucumberQuery}>
4545
<GherkinDocumentList gherkinDocuments={gherkinQuery.getGherkinDocuments()} />
46-
</QueriesWrapper>
46+
</QueriesProvider>
4747
)
4848

4949
expect(container.textContent).to.not.eq(null)
@@ -86,9 +86,9 @@ describe('acceptance tests', function () {
8686
)
8787

8888
const { container } = render(
89-
<QueriesWrapper gherkinQuery={gherkinQuery} cucumberQuery={cucumberQuery}>
89+
<QueriesProvider gherkinQuery={gherkinQuery} cucumberQuery={cucumberQuery}>
9090
<GherkinDocumentList gherkinDocuments={gherkinQuery.getGherkinDocuments()} />
91-
</QueriesWrapper>
91+
</QueriesProvider>
9292
)
9393

9494
expect(container.textContent).not.to.eq(null)
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import { Query as GherkinQuery } from '@cucumber/gherkin-utils'
2-
import * as messages from '@cucumber/messages'
2+
import { Envelope } from '@cucumber/messages'
33
import { Query as CucumberQuery } from '@cucumber/query'
4-
import React, { FunctionComponent, PropsWithChildren, useMemo } from 'react'
4+
import React, { FC, PropsWithChildren, useMemo } from 'react'
55

6-
import { QueriesWrapper } from './QueriesWrapper.js'
6+
import { QueriesProvider } from './QueriesProvider.js'
77

8-
interface IProps {
9-
envelopes: readonly messages.Envelope[]
8+
interface Props {
9+
envelopes: readonly Envelope[]
1010
}
1111

12-
export const EnvelopesWrapper: FunctionComponent<PropsWithChildren<IProps>> = ({
13-
envelopes,
14-
children,
15-
}) => {
12+
export const EnvelopesProvider: FC<PropsWithChildren<Props>> = ({ envelopes, children }) => {
1613
const { gherkinQuery, cucumberQuery } = useMemo(() => {
1714
const gherkinQuery = new GherkinQuery()
1815
const cucumberQuery = new CucumberQuery()
@@ -23,8 +20,8 @@ export const EnvelopesWrapper: FunctionComponent<PropsWithChildren<IProps>> = ({
2320
return { gherkinQuery, cucumberQuery }
2421
}, [envelopes])
2522
return (
26-
<QueriesWrapper gherkinQuery={gherkinQuery} cucumberQuery={cucumberQuery}>
23+
<QueriesProvider gherkinQuery={gherkinQuery} cucumberQuery={cucumberQuery}>
2724
{children}
28-
</QueriesWrapper>
25+
</QueriesProvider>
2926
)
3027
}

src/components/app/ExecutionSummary.spec.tsx

+11-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import React from 'react'
66
import sinon from 'sinon'
77

88
import examplesTablesFeature from '../../../acceptance/examples-tables/examples-tables.feature.js'
9-
import { EnvelopesWrapper } from './EnvelopesWrapper.js'
9+
import { EnvelopesProvider } from './EnvelopesProvider.js'
1010
import { ExecutionSummary } from './ExecutionSummary.js'
1111

1212
const meta: Meta = {
@@ -47,9 +47,9 @@ describe('<ExecutionSummary/>', () => {
4747
describe('meta', () => {
4848
it('should include a phrase for the setup details', () => {
4949
render(
50-
<EnvelopesWrapper envelopes={envelopes}>
50+
<EnvelopesProvider envelopes={envelopes}>
5151
<ExecutionSummary />
52-
</EnvelopesWrapper>
52+
</EnvelopesProvider>
5353
)
5454

5555
expect(screen.getByTestId('setup.phrase')).to.contain.text(
@@ -59,9 +59,9 @@ describe('<ExecutionSummary/>', () => {
5959

6060
it('should copy the setup details on request', async () => {
6161
render(
62-
<EnvelopesWrapper envelopes={envelopes}>
62+
<EnvelopesProvider envelopes={envelopes}>
6363
<ExecutionSummary />
64-
</EnvelopesWrapper>
64+
</EnvelopesProvider>
6565
)
6666

6767
await userEvent.click(screen.getByRole('button', { name: 'Copy' }))
@@ -74,19 +74,19 @@ Platform: [email protected]`)
7474

7575
it('should include the pass rate', () => {
7676
render(
77-
<EnvelopesWrapper envelopes={envelopes}>
77+
<EnvelopesProvider envelopes={envelopes}>
7878
<ExecutionSummary />
79-
</EnvelopesWrapper>
79+
</EnvelopesProvider>
8080
)
8181

8282
expect(screen.getByText('55.5% passed')).to.be.visible
8383
})
8484

8585
it('should include the job link', () => {
8686
render(
87-
<EnvelopesWrapper envelopes={envelopes}>
87+
<EnvelopesProvider envelopes={envelopes}>
8888
<ExecutionSummary />
89-
</EnvelopesWrapper>
89+
</EnvelopesProvider>
9090
)
9191

9292
expect(screen.getByRole('link', { name: 'GitHub Actions' }))
@@ -96,9 +96,9 @@ Platform: [email protected]`)
9696

9797
it('should include the commit link', () => {
9898
render(
99-
<EnvelopesWrapper envelopes={envelopes}>
99+
<EnvelopesProvider envelopes={envelopes}>
100100
<ExecutionSummary />
101-
</EnvelopesWrapper>
101+
</EnvelopesProvider>
102102
)
103103

104104
expect(screen.getByRole('link', { name: 'b53d820' }))

src/components/app/ExecutionSummary.stories.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Story } from '@ladle/react'
44
import React from 'react'
55

66
import examplesTablesFeature from '../../../acceptance/examples-tables/examples-tables.feature.js'
7-
import { EnvelopesWrapper } from './EnvelopesWrapper.js'
7+
import { EnvelopesProvider } from './EnvelopesProvider.js'
88
import { ExecutionSummary } from './ExecutionSummary.js'
99

1010
const metaMinimal: messages.Meta = {
@@ -49,9 +49,9 @@ type TemplateArgs = {
4949

5050
const Template: Story<TemplateArgs> = ({ envelopes }) => {
5151
return (
52-
<EnvelopesWrapper envelopes={envelopes}>
52+
<EnvelopesProvider envelopes={envelopes}>
5353
<ExecutionSummary />
54-
</EnvelopesWrapper>
54+
</EnvelopesProvider>
5555
)
5656
}
5757

src/components/app/FilteredResults.spec.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ import attachments from '../../../acceptance/attachments/attachments.feature.js'
88
import examplesTables from '../../../acceptance/examples-tables/examples-tables.feature.js'
99
import minimal from '../../../acceptance/minimal/minimal.feature.js'
1010
import targetedRun from '../../../samples/targeted-run.js'
11-
import { EnvelopesWrapper } from './EnvelopesWrapper.js'
11+
import { EnvelopesProvider } from './EnvelopesProvider.js'
1212
import { FilteredResults } from './FilteredResults.js'
1313
import { InMemorySearchProvider } from './InMemorySearchProvider.js'
1414

1515
describe('FilteredResults', () => {
1616
const TestableFilteredResults: FC<{ envelopes: Envelope[] }> = ({ envelopes }) => {
1717
return (
18-
<EnvelopesWrapper envelopes={envelopes}>
18+
<EnvelopesProvider envelopes={envelopes}>
1919
<InMemorySearchProvider>
2020
<FilteredResults />
2121
</InMemorySearchProvider>
22-
</EnvelopesWrapper>
22+
</EnvelopesProvider>
2323
)
2424
}
2525

src/components/app/FilteredResults.stories.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React from 'react'
44

55
import testData from '../../../acceptance/examples-tables/examples-tables.feature.js'
66
import targetedRun from '../../../samples/targeted-run.js'
7-
import { EnvelopesWrapper } from './EnvelopesWrapper.js'
7+
import { EnvelopesProvider } from './EnvelopesProvider.js'
88
import { FilteredResults } from './FilteredResults.js'
99
import { InMemorySearchProvider } from './InMemorySearchProvider.js'
1010

@@ -18,11 +18,11 @@ type TemplateArgs = {
1818

1919
const Template: Story<TemplateArgs> = ({ envelopes }) => {
2020
return (
21-
<EnvelopesWrapper envelopes={envelopes}>
21+
<EnvelopesProvider envelopes={envelopes}>
2222
<InMemorySearchProvider>
2323
<FilteredResults />
2424
</InMemorySearchProvider>
25-
</EnvelopesWrapper>
25+
</EnvelopesProvider>
2626
)
2727
}
2828

src/components/app/HealthChart.stories.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Story } from '@ladle/react'
33
import React from 'react'
44

55
import examplesTablesFeature from '../../../acceptance/examples-tables/examples-tables.feature.js'
6-
import { EnvelopesWrapper } from './EnvelopesWrapper.js'
6+
import { EnvelopesProvider } from './EnvelopesProvider.js'
77
import { HealthChart } from './HealthChart.js'
88

99
export default {
@@ -16,9 +16,9 @@ type TemplateArgs = {
1616

1717
const Template: Story<TemplateArgs> = ({ envelopes }) => {
1818
return (
19-
<EnvelopesWrapper envelopes={envelopes}>
19+
<EnvelopesProvider envelopes={envelopes}>
2020
<HealthChart />
21-
</EnvelopesWrapper>
21+
</EnvelopesProvider>
2222
)
2323
}
2424

src/components/app/QueriesWrapper.tsx renamed to src/components/app/QueriesProvider.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { Query as GherkinQuery } from '@cucumber/gherkin-utils'
22
import { Query as CucumberQuery } from '@cucumber/query'
3-
import React, { FunctionComponent, PropsWithChildren } from 'react'
3+
import React, { FC, PropsWithChildren } from 'react'
44

55
import CucumberQueryContext from '../../CucumberQueryContext.js'
66
import GherkinQueryContext from '../../GherkinQueryContext.js'
77

8-
interface IProps {
8+
interface Props {
99
cucumberQuery: CucumberQuery
1010
gherkinQuery: GherkinQuery
1111
}
1212

13-
export const QueriesWrapper: FunctionComponent<PropsWithChildren<IProps>> = (props) => (
13+
export const QueriesProvider: FC<PropsWithChildren<Props>> = (props) => (
1414
<CucumberQueryContext.Provider value={props.cucumberQuery}>
1515
<GherkinQueryContext.Provider value={props.gherkinQuery}>
1616
{props.children}

src/components/app/SearchBar.spec.tsx

+13-13
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import examplesTablesFeature from '../../../acceptance/examples-tables/examples-
99
import minimalFeature from '../../../acceptance/minimal/minimal.feature.js'
1010
import { SearchState } from '../../SearchContext.js'
1111
import { ControlledSearchProvider } from './ControlledSearchProvider.js'
12-
import { EnvelopesWrapper } from './EnvelopesWrapper.js'
12+
import { EnvelopesProvider } from './EnvelopesProvider.js'
1313
import { SearchBar } from './SearchBar.js'
1414

1515
const TestableSearchBar: FC<{
@@ -100,29 +100,29 @@ describe('SearchBar', () => {
100100
describe('filtering by status', () => {
101101
it('should not show status filters when no statuses', () => {
102102
const { queryByRole } = render(
103-
<EnvelopesWrapper envelopes={[]}>
103+
<EnvelopesProvider envelopes={[]}>
104104
<TestableSearchBar />
105-
</EnvelopesWrapper>
105+
</EnvelopesProvider>
106106
)
107107

108108
expect(queryByRole('checkbox')).not.to.exist
109109
})
110110

111111
it('should not show status filters when just one status', () => {
112112
const { queryByRole } = render(
113-
<EnvelopesWrapper envelopes={minimalFeature}>
113+
<EnvelopesProvider envelopes={minimalFeature}>
114114
<TestableSearchBar />
115-
</EnvelopesWrapper>
115+
</EnvelopesProvider>
116116
)
117117

118118
expect(queryByRole('checkbox')).not.to.exist
119119
})
120120

121121
it('should show named status filters, all checked by default, when multiple statuses', () => {
122122
const { getAllByRole, getByRole } = render(
123-
<EnvelopesWrapper envelopes={examplesTablesFeature}>
123+
<EnvelopesProvider envelopes={examplesTablesFeature}>
124124
<TestableSearchBar />
125-
</EnvelopesWrapper>
125+
</EnvelopesProvider>
126126
)
127127

128128
expect(getAllByRole('checkbox')).to.have.length(3)
@@ -137,9 +137,9 @@ describe('SearchBar', () => {
137137
it('updates the search context with a hidden status when unchecked', async () => {
138138
const onChange = sinon.fake()
139139
const { getByRole } = render(
140-
<EnvelopesWrapper envelopes={examplesTablesFeature}>
140+
<EnvelopesProvider envelopes={examplesTablesFeature}>
141141
<TestableSearchBar onChange={onChange} />
142-
</EnvelopesWrapper>
142+
</EnvelopesProvider>
143143
)
144144

145145
await userEvent.click(getByRole('checkbox', { name: 'undefined 2' }))
@@ -152,11 +152,11 @@ describe('SearchBar', () => {
152152

153153
it('should show hidden statuses as unchecked', () => {
154154
const { getByRole } = render(
155-
<EnvelopesWrapper envelopes={examplesTablesFeature}>
155+
<EnvelopesProvider envelopes={examplesTablesFeature}>
156156
<TestableSearchBar
157157
defaultValue={{ query: '', hideStatuses: [TestStepResultStatus.UNDEFINED] }}
158158
/>
159-
</EnvelopesWrapper>
159+
</EnvelopesProvider>
160160
)
161161

162162
expect(getByRole('checkbox', { name: 'passed 5' })).to.be.checked
@@ -167,15 +167,15 @@ describe('SearchBar', () => {
167167
it('updates the search context when a status is rechecked', async () => {
168168
const onChange = sinon.fake()
169169
const { getByRole } = render(
170-
<EnvelopesWrapper envelopes={examplesTablesFeature}>
170+
<EnvelopesProvider envelopes={examplesTablesFeature}>
171171
<TestableSearchBar
172172
defaultValue={{
173173
query: '',
174174
hideStatuses: [TestStepResultStatus.FAILED, TestStepResultStatus.UNDEFINED],
175175
}}
176176
onChange={onChange}
177177
/>
178-
</EnvelopesWrapper>
178+
</EnvelopesProvider>
179179
)
180180

181181
await userEvent.click(getByRole('checkbox', { name: 'failed 2' }))

src/components/app/StatusesSummary.spec.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import { expect } from 'chai'
33
import React from 'react'
44

55
import examplesTablesFeature from '../../../acceptance/examples-tables/examples-tables.feature.js'
6-
import { EnvelopesWrapper } from './EnvelopesWrapper.js'
6+
import { EnvelopesProvider } from './EnvelopesProvider.js'
77
import { StatusesSummary } from './StatusesSummary.js'
88

99
describe('StatusesSummary', () => {
1010
it('should render correctly', () => {
1111
const { getAllByRole } = render(
12-
<EnvelopesWrapper envelopes={examplesTablesFeature}>
12+
<EnvelopesProvider envelopes={examplesTablesFeature}>
1313
<StatusesSummary />
14-
</EnvelopesWrapper>
14+
</EnvelopesProvider>
1515
)
1616

1717
expect(getAllByRole('listitem').map((li) => li.textContent)).to.deep.eq([

src/components/app/StatusesSummary.stories.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Story } from '@ladle/react'
33
import React from 'react'
44

55
import examplesTablesFeature from '../../../acceptance/examples-tables/examples-tables.feature.js'
6-
import { EnvelopesWrapper } from './EnvelopesWrapper.js'
6+
import { EnvelopesProvider } from './EnvelopesProvider.js'
77
import { StatusesSummary } from './StatusesSummary.js'
88

99
export default {
@@ -16,9 +16,9 @@ type TemplateArgs = {
1616

1717
const Template: Story<TemplateArgs> = ({ envelopes }) => {
1818
return (
19-
<EnvelopesWrapper envelopes={envelopes}>
19+
<EnvelopesProvider envelopes={envelopes}>
2020
<StatusesSummary />
21-
</EnvelopesWrapper>
21+
</EnvelopesProvider>
2222
)
2323
}
2424

0 commit comments

Comments
 (0)