Skip to content

Commit 4937cf1

Browse files
authored
omit documents with no test cases from results (#321)
1 parent 245b5dd commit 4937cf1

File tree

6 files changed

+36
-51
lines changed

6 files changed

+36
-51
lines changed

samples/targeted-run.ts

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.

src/components/app/FilteredResults.spec.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import React, { VoidFunctionComponent } from 'react'
66
import attachments from '../../../acceptance/attachments/attachments.feature'
77
import examplesTables from '../../../acceptance/examples-tables/examples-tables.feature'
88
import minimal from '../../../acceptance/minimal/minimal.feature'
9+
import targetedRun from '../../../samples/targeted-run'
910
import SearchQueryContext, { useSearchQueryCtx } from '../../SearchQueryContext'
1011
import { EnvelopesWrapper } from './EnvelopesWrapper'
1112
import { FilteredResults } from './FilteredResults'
@@ -23,6 +24,30 @@ describe('FilteredResults', () => {
2324
)
2425
}
2526

27+
describe('with a targeted run', () => {
28+
it('doesnt include features where no scenarios became test cases', () => {
29+
const { getByRole, queryByRole } = render(
30+
<TestableFilteredResults envelopes={targetedRun as Envelope[]} />
31+
)
32+
33+
expect(
34+
getByRole('heading', {
35+
name: 'features/adding.feature',
36+
})
37+
).toBeVisible()
38+
expect(
39+
queryByRole('heading', {
40+
name: 'features/editing.feature',
41+
})
42+
).not.toBeInTheDocument()
43+
expect(
44+
queryByRole('heading', {
45+
name: 'features/empty.feature',
46+
})
47+
).not.toBeInTheDocument()
48+
})
49+
})
50+
2651
describe('searching', () => {
2752
it('shows a message for a search term that yields no results', async () => {
2853
const { getByRole, getByText } = render(

src/components/app/FilteredResults.stories.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Story } from '@ladle/react'
33
import React from 'react'
44

55
import testData from '../../../acceptance/examples-tables/examples-tables.feature'
6+
import targetedRun from '../../../samples/targeted-run'
67
import { CucumberReact } from '../CucumberReact'
78
import { EnvelopesWrapper } from './EnvelopesWrapper'
89
import { FilteredResults } from './FilteredResults'
@@ -32,3 +33,8 @@ export const Default = Template.bind({})
3233
Default.args = {
3334
envelopes: testData,
3435
}
36+
37+
export const TargetedRun = Template.bind({})
38+
TargetedRun.args = {
39+
envelopes: targetedRun,
40+
}

src/components/app/FilteredResults.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import styles from './FilteredResults.module.scss'
1010
import { GherkinDocumentList } from './GherkinDocumentList'
1111
import { NoMatchResult } from './NoMatchResult'
1212
import { SearchBar } from './SearchBar'
13-
import statuses from './statuses'
1413
import { StatusesSummary } from './StatusesSummary'
1514

1615
interface IProps {
@@ -30,7 +29,7 @@ export const FilteredResults: React.FunctionComponent<IProps> = ({ className })
3029
search.add(gherkinDocument)
3130
}
3231

33-
const onlyShowStatuses = statuses.filter((s) => !hideStatuses.includes(s))
32+
const onlyShowStatuses = statusesWithScenarios.filter((s) => !hideStatuses.includes(s))
3433

3534
const matches = query ? search.search(query) : allDocuments
3635
const filtered = matches

src/countScenariosByStatuses.spec.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { Query as GherkinQuery } from '@cucumber/gherkin-utils'
33
import * as messages from '@cucumber/messages'
44
import { Envelope, SourceReference, TestStepResultStatus } from '@cucumber/messages'
55
import { Query as CucumberQuery } from '@cucumber/query'
6-
import fs from 'fs'
7-
import path from 'path'
86

7+
import targetedRun from '../samples/targeted-run'
98
import { runFeature } from '../test-utils'
109
import countScenariosByStatuses from './countScenariosByStatuses'
1110
import { EnvelopesQuery } from './EnvelopesQueryContext'
@@ -103,15 +102,9 @@ Feature: statuses
103102
})
104103

105104
it('only includes pickles that were slated for execution as test cases', () => {
106-
const raw = fs.readFileSync(
107-
path.join(__dirname, '../test-utils/messages/filtered-pickles.ndjson'),
108-
{
109-
encoding: 'utf-8',
110-
}
111-
)
112-
const envelopes: Envelope[] = JSON.parse('[' + raw.trim().split('\n').join(',') + ']')
113105
const gherkinQuery = new GherkinQuery()
114106
const cucumberQuery = new CucumberQuery()
107+
const envelopes = targetedRun as Envelope[]
115108
envelopes.forEach((envelope) => {
116109
gherkinQuery.update(envelope)
117110
cucumberQuery.update(envelope)

0 commit comments

Comments
 (0)