Skip to content

Commit 68845ab

Browse files
authored
Apply URI based sorting for the displayed gherkin documents (#394)
1 parent b09198e commit 68845ab

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
9+
### Changed
10+
- Applied URI-based sorting for the displayed Gherkin documents ([#394](https://github.com/cucumber/react-components/pull/394))
911

1012
## [23.1.1] - 2025-06-24
1113
### Added

samples/random-order-run.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Generated file. Do not edit.
2+
import { Envelope } from '@cucumber/messages'
3+
4+
export default [
5+
{"testRunStarted":{"timestamp":{"seconds":1754497930,"nanos":556199500},"id":"XHNtvQ2esweysHgVBrq-Xg"}},
6+
{"meta":{"protocolVersion":"28.0.0","implementation":{"name":"Reqnroll","version":"3.0.0-local"},"runtime":{"name":"dotNet","version":"8.0.19"},"os":{"name":"Windows","version":"Microsoft Windows 10.0.26100"},"cpu":{"name":"x64"},"ci":{"name":"UNKNOWN","url":"","buildNumber":"UNKNOWN","git":{"remote":"","revision":"UNKNOWN","branch":"UNKNOWN","tag":"UNKNOWN"}}}},
7+
{"stepDefinition":{"id":"KKmmEJsAnxGFhjE6e2vf5A","pattern":{"source":"I do something","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"javaMethod":{"className":"ReqnrollFormatters.Standard.ReqnrollFormatters.Standard.StepDefinitions.ProjectStepDefinitions","methodName":"WhenIDoSomething","methodParameterTypes":[]}}}},
8+
{"source":{"uri":"Features/f.feature","data":"Feature: Feature F\r\n\r\nScenario: F\r\n\tWhen I do something\r\n","mediaType":"text/x.cucumber.gherkin+plain"}},
9+
{"gherkinDocument":{"uri":"Features/f.feature","feature":{"location":{"line":1,"column":1},"tags":[],"language":"en-US","keyword":"Feature","name":"Feature F","description":"","children":[{"scenario":{"location":{"line":3,"column":1},"tags":[],"keyword":"Scenario","name":"F","description":"","steps":[{"location":{"line":4,"column":2},"keyword":"When ","keywordType":"Action","text":"I do something","id":"ad7d1f59226b4d5a84ea6a727677f439"}],"examples":[],"id":"39903d0d70984d5ea6f6533d7b833c5e"}}]},"comments":[]}},
10+
{"pickle":{"id":"0d52d191d891b15c84c5d0a8013d8264","uri":"Features/f.feature","name":"F","language":"en-US","steps":[{"astNodeIds":["ad7d1f59226b4d5a84ea6a727677f439"],"id":"a66df8edb6d6a952b7b8748652df33f1","type":"Action","text":"I do something"}],"tags":[],"astNodeIds":["39903d0d70984d5ea6f6533d7b833c5e"]}},
11+
{"source":{"uri":"Features/d/e.feature","data":"Feature: Feature E\r\n\r\nScenario: E\r\n\tWhen I do something\r\n","mediaType":"text/x.cucumber.gherkin+plain"}},
12+
{"gherkinDocument":{"uri":"Features/d/e.feature","feature":{"location":{"line":1,"column":1},"tags":[],"language":"en-US","keyword":"Feature","name":"Feature E","description":"","children":[{"scenario":{"location":{"line":3,"column":1},"tags":[],"keyword":"Scenario","name":"E","description":"","steps":[{"location":{"line":4,"column":2},"keyword":"When ","keywordType":"Action","text":"I do something","id":"763896b65a7d3057aa7003a46180f1d2"}],"examples":[],"id":"7bd4d784df4cfe5a85f6f5d3964dacef"}}]},"comments":[]}},
13+
{"pickle":{"id":"09d9cff7cf97e15e920ddd0ff6cff865","uri":"Features/d/e.feature","name":"E","language":"en-US","steps":[{"astNodeIds":["763896b65a7d3057aa7003a46180f1d2"],"id":"b7d3f5ed69dacf5abc28d6c42a971f54","type":"Action","text":"I do something"}],"tags":[],"astNodeIds":["7bd4d784df4cfe5a85f6f5d3964dacef"]}},
14+
{"source":{"uri":"Features/c.feature","data":"Feature: Feature C\r\n\r\nScenario: C\r\n\tWhen I do something\r\n","mediaType":"text/x.cucumber.gherkin+plain"}},
15+
{"gherkinDocument":{"uri":"Features/c.feature","feature":{"location":{"line":1,"column":1},"tags":[],"language":"en-US","keyword":"Feature","name":"Feature C","description":"","children":[{"scenario":{"location":{"line":3,"column":1},"tags":[],"keyword":"Scenario","name":"C","description":"","steps":[{"location":{"line":4,"column":2},"keyword":"When ","keywordType":"Action","text":"I do something","id":"7f2baa4ba213025a8c954dd3fa1a46ef"}],"examples":[],"id":"6e1f57c19380d554810719bd44bed9c4"}}]},"comments":[]}},
16+
{"pickle":{"id":"5200930aabd8405a8fc8783c73665e7d","uri":"Features/c.feature","name":"C","language":"en-US","steps":[{"astNodeIds":["7f2baa4ba213025a8c954dd3fa1a46ef"],"id":"1ef20cd820aae754958dec063b4f3594","type":"Action","text":"I do something"}],"tags":[],"astNodeIds":["6e1f57c19380d554810719bd44bed9c4"]}},
17+
{"source":{"uri":"Features/B.feature","data":"Feature: Feature B\r\n\r\nScenario: B\r\n\tWhen I do something\r\n","mediaType":"text/x.cucumber.gherkin+plain"}},
18+
{"gherkinDocument":{"uri":"Features/B.feature","feature":{"location":{"line":1,"column":1},"tags":[],"language":"en-US","keyword":"Feature","name":"Feature B","description":"","children":[{"scenario":{"location":{"line":3,"column":1},"tags":[],"keyword":"Scenario","name":"B","description":"","steps":[{"location":{"line":4,"column":2},"keyword":"When ","keywordType":"Action","text":"I do something","id":"5013a9fbb23b3d54b8a428ebfd2beda2"}],"examples":[],"id":"5affe70a5f57955eb28432d153809f7c"}}]},"comments":[]}},
19+
{"pickle":{"id":"6b344fa619ab8d59bf9623a917c25809","uri":"Features/B.feature","name":"B","language":"en-US","steps":[{"astNodeIds":["5013a9fbb23b3d54b8a428ebfd2beda2"],"id":"6197cd2fd441c855a3cc39bd92b10b7e","type":"Action","text":"I do something"}],"tags":[],"astNodeIds":["5affe70a5f57955eb28432d153809f7c"]}},
20+
{"source":{"uri":"Features/a.feature","data":"Feature: Feature A\r\n\r\nScenario: A\r\n\tWhen I do something\r\n","mediaType":"text/x.cucumber.gherkin+plain"}},
21+
{"gherkinDocument":{"uri":"Features/a.feature","feature":{"location":{"line":1,"column":1},"tags":[],"language":"en-US","keyword":"Feature","name":"Feature A","description":"","children":[{"scenario":{"location":{"line":3,"column":1},"tags":[],"keyword":"Scenario","name":"A","description":"","steps":[{"location":{"line":4,"column":2},"keyword":"When ","keywordType":"Action","text":"I do something","id":"296b1a107c42c05d9037c3528441275a"}],"examples":[],"id":"e02fc8947b050459b8cbbdf6c77d1094"}}]},"comments":[]}},
22+
{"pickle":{"id":"aafc4d1e871e4451bfa434ea62129d4d","uri":"Features/a.feature","name":"A","language":"en-US","steps":[{"astNodeIds":["296b1a107c42c05d9037c3528441275a"],"id":"4ff368d746ebd559952ac0bb310c826e","type":"Action","text":"I do something"}],"tags":[],"astNodeIds":["e02fc8947b050459b8cbbdf6c77d1094"]}},
23+
{"testCase":{"id":"OzXpR1OItgyrp49QtQo1zA","pickleId":"6b344fa619ab8d59bf9623a917c25809","testSteps":[{"id":"ZiGwC8opNyDoZ5krq9jUfg","pickleStepId":"6197cd2fd441c855a3cc39bd92b10b7e","stepDefinitionIds":["KKmmEJsAnxGFhjE6e2vf5A"],"stepMatchArgumentsLists":[{"stepMatchArguments":[]}]}],"testRunStartedId":"XHNtvQ2esweysHgVBrq-Xg"}},
24+
{"testCase":{"id":"DHIfSJmPTJgMwVEFRtW32A","pickleId":"0d52d191d891b15c84c5d0a8013d8264","testSteps":[{"id":"3otV4fogW9HK1kOC_AwndQ","pickleStepId":"a66df8edb6d6a952b7b8748652df33f1","stepDefinitionIds":["KKmmEJsAnxGFhjE6e2vf5A"],"stepMatchArgumentsLists":[{"stepMatchArguments":[]}]}],"testRunStartedId":"XHNtvQ2esweysHgVBrq-Xg"}},
25+
{"testCase":{"id":"uoGdbqTcP5xB4SjJvP9X5Q","pickleId":"aafc4d1e871e4451bfa434ea62129d4d","testSteps":[{"id":"tgcP6vp6S6RH80MBxzEuHA","pickleStepId":"4ff368d746ebd559952ac0bb310c826e","stepDefinitionIds":["KKmmEJsAnxGFhjE6e2vf5A"],"stepMatchArgumentsLists":[{"stepMatchArguments":[]}]}],"testRunStartedId":"XHNtvQ2esweysHgVBrq-Xg"}},
26+
{"testCase":{"id":"HZpm33Wg_A7y2BKf5Mg4uQ","pickleId":"09d9cff7cf97e15e920ddd0ff6cff865","testSteps":[{"id":"5HZCzi5HKtiqDAqqx3r6Wg","pickleStepId":"b7d3f5ed69dacf5abc28d6c42a971f54","stepDefinitionIds":["KKmmEJsAnxGFhjE6e2vf5A"],"stepMatchArgumentsLists":[{"stepMatchArguments":[]}]}],"testRunStartedId":"XHNtvQ2esweysHgVBrq-Xg"}},
27+
{"testCase":{"id":"4KR_yErm0JUG4_HjCKcc3Q","pickleId":"5200930aabd8405a8fc8783c73665e7d","testSteps":[{"id":"Rm_43_InDucSj7Kouov2HQ","pickleStepId":"1ef20cd820aae754958dec063b4f3594","stepDefinitionIds":["KKmmEJsAnxGFhjE6e2vf5A"],"stepMatchArgumentsLists":[{"stepMatchArguments":[]}]}],"testRunStartedId":"XHNtvQ2esweysHgVBrq-Xg"}},
28+
{"testCaseStarted":{"attempt":0,"id":"5Vv2pGjgh757z5fhYNEZ4A","testCaseId":"uoGdbqTcP5xB4SjJvP9X5Q","timestamp":{"seconds":1754497930,"nanos":587544800}}},
29+
{"testStepStarted":{"testCaseStartedId":"5Vv2pGjgh757z5fhYNEZ4A","testStepId":"tgcP6vp6S6RH80MBxzEuHA","timestamp":{"seconds":1754497930,"nanos":600425000}}},
30+
{"testStepFinished":{"testCaseStartedId":"5Vv2pGjgh757z5fhYNEZ4A","testStepId":"tgcP6vp6S6RH80MBxzEuHA","testStepResult":{"duration":{"seconds":0,"nanos":8659000},"message":"","status":"PASSED"},"timestamp":{"seconds":1754497930,"nanos":609084000}}},
31+
{"testCaseFinished":{"testCaseStartedId":"5Vv2pGjgh757z5fhYNEZ4A","timestamp":{"seconds":1754497930,"nanos":615191200},"willBeRetried":false}},
32+
{"testCaseStarted":{"attempt":0,"id":"u14lVvOXie29T2poDou-rw","testCaseId":"OzXpR1OItgyrp49QtQo1zA","timestamp":{"seconds":1754497930,"nanos":638320400}}},
33+
{"testStepStarted":{"testCaseStartedId":"u14lVvOXie29T2poDou-rw","testStepId":"ZiGwC8opNyDoZ5krq9jUfg","timestamp":{"seconds":1754497930,"nanos":638697500}}},
34+
{"testStepFinished":{"testCaseStartedId":"u14lVvOXie29T2poDou-rw","testStepId":"ZiGwC8opNyDoZ5krq9jUfg","testStepResult":{"duration":{"seconds":0,"nanos":417200},"message":"","status":"PASSED"},"timestamp":{"seconds":1754497930,"nanos":639114700}}},
35+
{"testCaseFinished":{"testCaseStartedId":"u14lVvOXie29T2poDou-rw","timestamp":{"seconds":1754497930,"nanos":639845800},"willBeRetried":false}},
36+
{"testCaseStarted":{"attempt":0,"id":"XtYMaO8YpGFeKi7mOBaeCQ","testCaseId":"4KR_yErm0JUG4_HjCKcc3Q","timestamp":{"seconds":1754497930,"nanos":643194300}}},
37+
{"testStepStarted":{"testCaseStartedId":"XtYMaO8YpGFeKi7mOBaeCQ","testStepId":"Rm_43_InDucSj7Kouov2HQ","timestamp":{"seconds":1754497930,"nanos":643314000}}},
38+
{"testStepFinished":{"testCaseStartedId":"XtYMaO8YpGFeKi7mOBaeCQ","testStepId":"Rm_43_InDucSj7Kouov2HQ","testStepResult":{"duration":{"seconds":0,"nanos":66000},"message":"","status":"PASSED"},"timestamp":{"seconds":1754497930,"nanos":643380000}}},
39+
{"testCaseFinished":{"testCaseStartedId":"XtYMaO8YpGFeKi7mOBaeCQ","timestamp":{"seconds":1754497930,"nanos":643917200},"willBeRetried":false}},
40+
{"testCaseStarted":{"attempt":0,"id":"4v-PJFAAXaGNJuk38njtHg","testCaseId":"DHIfSJmPTJgMwVEFRtW32A","timestamp":{"seconds":1754497930,"nanos":646891000}}},
41+
{"testStepStarted":{"testCaseStartedId":"4v-PJFAAXaGNJuk38njtHg","testStepId":"3otV4fogW9HK1kOC_AwndQ","timestamp":{"seconds":1754497930,"nanos":647000500}}},
42+
{"testStepFinished":{"testCaseStartedId":"4v-PJFAAXaGNJuk38njtHg","testStepId":"3otV4fogW9HK1kOC_AwndQ","testStepResult":{"duration":{"seconds":0,"nanos":65900},"message":"","status":"PASSED"},"timestamp":{"seconds":1754497930,"nanos":647066400}}},
43+
{"testCaseFinished":{"testCaseStartedId":"4v-PJFAAXaGNJuk38njtHg","timestamp":{"seconds":1754497930,"nanos":647549100},"willBeRetried":false}},
44+
{"testCaseStarted":{"attempt":0,"id":"py4RxIpb0fVEmdEDi2K-Jw","testCaseId":"HZpm33Wg_A7y2BKf5Mg4uQ","timestamp":{"seconds":1754497930,"nanos":650466200}}},
45+
{"testStepStarted":{"testCaseStartedId":"py4RxIpb0fVEmdEDi2K-Jw","testStepId":"5HZCzi5HKtiqDAqqx3r6Wg","timestamp":{"seconds":1754497930,"nanos":650563400}}},
46+
{"testStepFinished":{"testCaseStartedId":"py4RxIpb0fVEmdEDi2K-Jw","testStepId":"5HZCzi5HKtiqDAqqx3r6Wg","testStepResult":{"duration":{"seconds":0,"nanos":53700},"message":"","status":"PASSED"},"timestamp":{"seconds":1754497930,"nanos":650617100}}},
47+
{"testCaseFinished":{"testCaseStartedId":"py4RxIpb0fVEmdEDi2K-Jw","timestamp":{"seconds":1754497930,"nanos":651094500},"willBeRetried":false}},
48+
{"testRunFinished":{"success":true,"timestamp":{"seconds":1754497930,"nanos":662900000},"testRunStartedId":"XHNtvQ2esweysHgVBrq-Xg"}},
49+
] as ReadonlyArray<Envelope>

src/components/app/FilteredDocuments.spec.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import React from 'react'
66

77
import attachments from '../../../acceptance/attachments/attachments.feature.js'
88
import examplesTables from '../../../acceptance/examples-tables/examples-tables.feature.js'
9+
import randomOrderRun from '../../../samples/random-order-run.js'
910
import targetedRun from '../../../samples/targeted-run.js'
1011
import { EnvelopesProvider } from './EnvelopesProvider.js'
1112
import { FilteredDocuments } from './FilteredDocuments.js'
@@ -38,6 +39,28 @@ describe('FilteredDocuments', () => {
3839
).not.to.exist
3940
})
4041
})
42+
43+
it('displays features in alphabetical order by URI', async () => {
44+
const { getAllByRole } = render(
45+
<EnvelopesProvider envelopes={randomOrderRun}>
46+
<FilteredDocuments />
47+
</EnvelopesProvider>
48+
)
49+
50+
await waitFor(() => {
51+
const headings = getAllByRole('heading', { level: 3 })
52+
const featureNames = headings.map((heading: HTMLElement) => heading.textContent)
53+
54+
// Verify the features are displayed in alphabetical order by URI
55+
expect(featureNames).to.deep.equal([
56+
'Features/a.feature',
57+
'Features/B.feature',
58+
'Features/c.feature',
59+
'Features/d/e.feature',
60+
'Features/f.feature',
61+
])
62+
})
63+
})
4164
})
4265

4366
describe('searching', () => {

src/hooks/useFilteredDocuments.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export function useFilteredDocuments(): GherkinDocument[] | undefined {
3131
)
3232
)
3333
.filter((document) => document !== null) as GherkinDocument[]
34+
filtered.sort((a, b) => (a.uri || '').localeCompare(b.uri || ''))
3435
setResults(filtered)
3536
}
3637
)

0 commit comments

Comments
 (0)