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
4 changes: 2 additions & 2 deletions features/actions/publishReport.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path from 'node:path'
import { Action } from '../support/Actor.mjs'
import { PublishResult } from './types'

export const publishReport: (privateToken?: string) => Action<PublishResult> = (privateToken) => {
export const publishReport: (fixture: string, privateToken?: string) => Action<PublishResult> = (fixture, privateToken) => {
return async () => {
const headers = new Headers()
if (privateToken) {
Expand All @@ -18,7 +18,7 @@ export const publishReport: (privateToken?: string) => Action<PublishResult> = (

if (getResponse.ok && url) {
const putUrl = getResponse.headers.get('Location') as string
const envelopes = readFileSync(path.join(import.meta.dirname, '..', 'fixtures', 'messages-valid.ndjson'), { encoding: 'utf-8' })
const envelopes = readFileSync(path.join(import.meta.dirname, '..', 'fixtures', fixture), { encoding: 'utf-8' })
const putResponse = await fetch(putUrl, {
method: 'PUT',
body: envelopes,
Expand Down
12 changes: 12 additions & 0 deletions features/fixtures/messages-omissions.ndjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{"meta":{"ci":{"buildNumber":"154666429","git":{"remote":"https://github.com/cucumber-ltd/shouty.rb.git","revision":"99684bcacf01d95875834d87903dcb072306c9ad"},"name":"GitHub Actions","url":"https://github.com/cucumber-ltd/shouty.rb/actions/runs/154666429"},"cpu":{"name":"x64"},"implementation":{"name":"fake-cucumber","version":"18.0.0"},"os":{"name":"darwin","version":"23.6.0"},"protocolVersion":"27.0.0","runtime":{"name":"node.js","version":"22.7.0"}}}
{"source":{"data":"Feature: minimal\n \n Cucumber doesn't execute this markdown, but @cucumber/react renders it\n \n * This is\n * a bullet\n * list\n \n Scenario: cukes\n Given I have 42 cukes in my belly\n","mediaType":"text/x.cucumber.gherkin+plain","uri":"samples/minimal/minimal.feature"}}
{"gherkinDocument":{"comments":[],"feature":{"children":[{"scenario":{"description":"","id":"2","keyword":"Scenario","location":{"column":3,"line":9},"name":"cukes","steps":[{"id":"1","keyword":"Given ","keywordType":"Context","location":{"column":5,"line":10},"text":"I have 42 cukes in my belly"}],"tags":[]}}],"description":" Cucumber doesn't execute this markdown, but @cucumber/react renders it\n \n * This is\n * a bullet\n * list","keyword":"Feature","language":"en","location":{"column":1,"line":1},"name":"minimal","tags":[]},"uri":"samples/minimal/minimal.feature"}}
{"pickle":{"astNodeIds":["2"],"id":"4","language":"en","name":"cukes","steps":[{"astNodeIds":["1"],"id":"3","text":"I have 42 cukes in my belly","type":"Context"}],"tags":[],"uri":"samples/minimal/minimal.feature"}}
{"stepDefinition":{"id":"0","pattern":{"source":"I have {int} cukes in my belly","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"location":{"line":3},"uri":"samples/minimal/minimal.feature.ts"}}}
{"testRunStarted":{"id":"5","timestamp":{"seconds":0}}}
{"testCase":{"id":"7","pickleId":"4","testRunStartedId":"5","testSteps":[{"id":"6","pickleStepId":"3","stepDefinitionIds":["0"],"stepMatchArgumentsLists":[{"stepMatchArguments":[{"group":{"children":[],"start":7,"value":"42"},"parameterTypeName":"int"}]}]}]}}
{"testCaseStarted":{"attempt":0,"id":"8","testCaseId":"7","timestamp":{"nanos":1000000,"seconds":0}}}
{"testStepStarted":{"testCaseStartedId":"8","testStepId":"6","timestamp":{"nanos":2000000,"seconds":0}}}
{"testStepFinished":{"testCaseStartedId":"8","testStepId":"6","testStepResult":{"duration":{"nanos":1000000,"seconds":0},"status":"PASSED"},"timestamp":{"nanos":3000000,"seconds":0}}}
{"testCaseFinished":{"testCaseStartedId":"8","timestamp":{"nanos":4000000,"seconds":0},"willBeRetried":false}}
{"testRunFinished":{"success":true,"testRunStartedId":"5","timestamp":{"nanos":5000000,"seconds":0}}}
6 changes: 6 additions & 0 deletions features/publishing.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ Feature: Publishing
And Garrett shares their link with Hannah
When Hannah views the shared report
Then Hannah should see the test results

Scenario: Report still renders with fields omitted from messages
Given a Cucumber implementation that omits some fields
When Ira publishes a report
And Ira views the report they just published
Then Ira should see their test results
6 changes: 5 additions & 1 deletion features/steps/steps.mts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import { wasNotFound } from '../actions/wasNotFound.mjs'
import { navigateToSite } from '../actions/navigateToSite.mjs'
import { canSeeSample } from '../actions/canSeeSample.mjs'

Given('a Cucumber implementation that omits some fields', async (t) => {
t.world.messagesFixture = 'messages-omissions.ndjson'
})

Given('{actor} has a private token', async (t, actor: Actor) => {
actor.remember('privateToken', crypto.randomBytes(16).toString('hex'));
})
Expand All @@ -26,7 +30,7 @@ Given('a report previously published by {actor} has been deleted', async (t, act
})

When('{actor} publishes a report', async (t, actor: Actor) => {
const publishResult = await actor.attemptsTo(publishReport(actor.recall('privateToken')))
const publishResult = await actor.attemptsTo(publishReport(t.world.messagesFixture, actor.recall('privateToken')))
actor.remember('publishResult', publishResult)
t.world.publishResults.push(publishResult)
})
Expand Down
1 change: 1 addition & 0 deletions features/support/CustomWorld.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { PublishResult } from '../actions/types'
export class CustomWorld {
private readonly actorLookup = new ActorLookup()
private browser: Browser | undefined
public messagesFixture = 'messages-valid.ndjson'
public publishResults: Array<PublishResult> = []

public findOrCreateActor(actorName: string): Actor {
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useEnvelopes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useQuery } from '@tanstack/react-query'
import { Envelope } from '@cucumber/messages'
import { Envelope, parseEnvelope } from '@cucumber/messages'

export function useEnvelopes(id: string, getUrl: string) {
return useQuery({
Expand All @@ -10,7 +10,7 @@ export function useEnvelopes(id: string, getUrl: string) {
throw new Error('Failed to fetch envelopes', { cause: response })
}
const raw = await response.text()
return raw.trim().split('\n').map(s => JSON.parse(s) as Envelope)
return raw.trim().split('\n').map(s => parseEnvelope(s))
},
meta: {
envelopes: true
Expand Down