Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions samples/targeted-run.ts

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions src/components/app/FilteredResults.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import React, { VoidFunctionComponent } from 'react'
import attachments from '../../../acceptance/attachments/attachments.feature'
import examplesTables from '../../../acceptance/examples-tables/examples-tables.feature'
import minimal from '../../../acceptance/minimal/minimal.feature'
import targetedRun from '../../../samples/targeted-run'
import SearchQueryContext, { useSearchQueryCtx } from '../../SearchQueryContext'
import { EnvelopesWrapper } from './EnvelopesWrapper'
import { FilteredResults } from './FilteredResults'
Expand All @@ -23,6 +24,30 @@ describe('FilteredResults', () => {
)
}

describe('with a targeted run', () => {
it('doesnt include features where no scenarios became test cases', () => {
const { getByRole, queryByRole } = render(
<TestableFilteredResults envelopes={targetedRun as Envelope[]} />
)

expect(
getByRole('heading', {
name: 'features/adding.feature',
})
).toBeVisible()
expect(
queryByRole('heading', {
name: 'features/editing.feature',
})
).not.toBeInTheDocument()
expect(
queryByRole('heading', {
name: 'features/empty.feature',
})
).not.toBeInTheDocument()
})
})

describe('searching', () => {
it('shows a message for a search term that yields no results', async () => {
const { getByRole, getByText } = render(
Expand Down
6 changes: 6 additions & 0 deletions src/components/app/FilteredResults.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Story } from '@ladle/react'
import React from 'react'

import testData from '../../../acceptance/examples-tables/examples-tables.feature'
import targetedRun from '../../../samples/targeted-run'
import { CucumberReact } from '../CucumberReact'
import { EnvelopesWrapper } from './EnvelopesWrapper'
import { FilteredResults } from './FilteredResults'
Expand Down Expand Up @@ -32,3 +33,8 @@ export const Default = Template.bind({})
Default.args = {
envelopes: testData,
}

export const TargetedRun = Template.bind({})
TargetedRun.args = {
envelopes: targetedRun,
}
3 changes: 1 addition & 2 deletions src/components/app/FilteredResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import styles from './FilteredResults.module.scss'
import { GherkinDocumentList } from './GherkinDocumentList'
import { NoMatchResult } from './NoMatchResult'
import { SearchBar } from './SearchBar'
import statuses from './statuses'
import { StatusesSummary } from './StatusesSummary'

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

const onlyShowStatuses = statuses.filter((s) => !hideStatuses.includes(s))
const onlyShowStatuses = statusesWithScenarios.filter((s) => !hideStatuses.includes(s))

const matches = query ? search.search(query) : allDocuments
const filtered = matches
Expand Down
11 changes: 2 additions & 9 deletions src/countScenariosByStatuses.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { Query as GherkinQuery } from '@cucumber/gherkin-utils'
import * as messages from '@cucumber/messages'
import { Envelope, SourceReference, TestStepResultStatus } from '@cucumber/messages'
import { Query as CucumberQuery } from '@cucumber/query'
import fs from 'fs'
import path from 'path'

import targetedRun from '../samples/targeted-run'
import { runFeature } from '../test-utils'
import countScenariosByStatuses from './countScenariosByStatuses'
import { EnvelopesQuery } from './EnvelopesQueryContext'
Expand Down Expand Up @@ -103,15 +102,9 @@ Feature: statuses
})

it('only includes pickles that were slated for execution as test cases', () => {
const raw = fs.readFileSync(
path.join(__dirname, '../test-utils/messages/filtered-pickles.ndjson'),
{
encoding: 'utf-8',
}
)
const envelopes: Envelope[] = JSON.parse('[' + raw.trim().split('\n').join(',') + ']')
const gherkinQuery = new GherkinQuery()
const cucumberQuery = new CucumberQuery()
const envelopes = targetedRun as Envelope[]
envelopes.forEach((envelope) => {
gherkinQuery.update(envelope)
cucumberQuery.update(envelope)
Expand Down
Loading