Skip to content

Commit 5dc876e

Browse files
misc: Update nested groups design (#31739)
* refactor: Update nested groups design * Update styles * Enhance command method styling for child elements in the reporter. Updated the CommandDetails component to conditionally apply a class for child commands and added corresponding SCSS styles to display a prefix for child command methods. * Fix formatting in SCSS for child command styles by adjusting indentation for better readability. * add chanagelog entry * Enhance command expander styling by adding a parent class for better layout control and adjusting margin for command number column. * Update padding for error message styles in SCSS to improve layout consistency. * Refactor SCSS styles and introduce mixins for gutter alignment and command info padding. Update error component styles for improved layout and consistency. Adjust padding and margins for better alignment across command and error sections. * Refactor command styles by removing redundant class names and consolidating group indentation styles into a mixin. Update SCSS files to utilize the new mixin for consistent width handling across command and error components. * Enhance SCSS mixins by adding align-self property for improved layout consistency in command info and group indentation styles. * Remove redundant align-self property from SCSS mixin for command info and add logging and expectation in Cypress test for improved clarity in UI state tests. * Use snapshotReporter instead * Refactor snapshotReporter to dynamically set width based on reporter panel size, improving snapshot accuracy and visibility of UI elements. * Update snapshotReporter to include sidebar width in percy snapshots, enhancing UI element visibility and accuracy. --------- Co-authored-by: Jennifer Shehane <shehane.jennifer@gmail.com> Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
1 parent acb9427 commit 5dc876e

File tree

10 files changed

+184
-85
lines changed

10 files changed

+184
-85
lines changed

cli/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
_Released 6/3/2025 (PENDING)_
55

6+
**Misc:**
7+
8+
- The design of commands that display as grouped (such as `.within()` and `cy.session()`) has been updated to provide better clarity when collapsing groups. Addressed in [#31739](https://github.com/cypress-io/cypress/pull/31739).
9+
610
**Dependency Updates:**
711

812
- Updated `@sinonjs/fake-timers` from `10.3.0` to `11.3.1`. Addressed in [#31746](https://github.com/cypress-io/cypress/pull/31746).
Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
// Takes percy snapshot with navigation/AUT/reporter hidden
22
export const snapshotReporter = () => {
3-
cy.percySnapshot({
4-
width: 450,
5-
elementOverrides: {
6-
'.cy-tooltip': true,
7-
'[data-cy=sidebar]': ($el) => {
8-
$el.attr('style', 'display: none !important')
9-
},
10-
'[data-cy=aut-panel]': ($el) => {
11-
$el.attr('style', 'display: none !important')
12-
},
13-
'[data-cy=reporter-panel]': ($el) => {
14-
$el.attr('style', 'width: 450px !important')
15-
},
16-
'[data-cy=reporter-running-icon]': ($el) => {
17-
// remove 'fa-spin' class so that the icon is not animated
18-
$el.attr('class', '')
19-
},
20-
'.command-progress': ($el) => {
21-
// don't display command progress bar in snapshot
22-
$el.attr('style', 'display: none !important')
3+
let sidebarWidth = 0
4+
5+
cy.get('[data-cy=sidebar]')
6+
.invoke('width')
7+
.then((w) => {
8+
if (w) {
9+
sidebarWidth = w
10+
}
11+
}).then(() => {
12+
cy.get('[data-cy=reporter-panel]')
13+
})
14+
.invoke('width')
15+
.then((w) => {
16+
cy.percySnapshot({
17+
width: w + sidebarWidth,
18+
elementOverrides: {
19+
'.cy-tooltip': true,
20+
'[data-cy=sidebar]': ($el) => {
21+
$el.attr('style', 'display: none !important')
22+
},
23+
'[data-cy=aut-panel]': ($el) => {
24+
$el.attr('style', 'display: none !important')
25+
},
26+
'[data-cy=reporter-running-icon]': ($el) => {
27+
// remove 'fa-spin' class so that the icon is not animated
28+
$el.attr('class', '')
29+
},
30+
'.command-progress': ($el) => {
31+
// don't display command progress bar in snapshot
32+
$el.attr('style', 'display: none !important')
33+
},
2334
},
24-
},
35+
})
2536
})
2637
}

packages/app/cypress/e2e/runner/ui-states.cy.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { snapshotReporter } from './support/snapshot-reporter'
12
import { loadSpec } from './support/spec-loader'
23

34
describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 600000 }, () => {
@@ -12,7 +13,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
1213
})
1314

1415
cy.contains('test hooks').should('be.visible')
15-
cy.percySnapshot()
16+
snapshotReporter()
1617
})
1718

1819
it('nested tests', () => {
@@ -22,7 +23,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
2223
})
2324

2425
cy.contains('Nested Tests').should('be.visible')
25-
cy.percySnapshot()
26+
snapshotReporter()
2627
})
2728

2829
describe('commands', () => {
@@ -33,7 +34,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
3334
})
3435

3536
cy.contains('part 1 - basic commands').should('be.visible').click()
36-
cy.percySnapshot()
37+
snapshotReporter()
3738
})
3839

3940
it('part 2 - traversal and navigation', () => {
@@ -45,7 +46,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
4546
cy.contains('part 2 - traversal and navigation').should('be.visible')
4647
.click()
4748

48-
cy.percySnapshot()
49+
snapshotReporter()
4950
})
5051

5152
it('part 3 - element manipulation', () => {
@@ -57,7 +58,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
5758
cy.contains('part 3 - element manipulation').should('be.visible')
5859
.click()
5960

60-
cy.percySnapshot()
61+
snapshotReporter()
6162
})
6263

6364
it('part 4 - advanced interactions', () => {
@@ -69,7 +70,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
6970
cy.contains('part 4 - advanced interactions').should('be.visible')
7071
.click()
7172

72-
cy.percySnapshot()
73+
snapshotReporter()
7374
})
7475

7576
it('commands that do not appear in command log', () => {
@@ -79,7 +80,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
7980
})
8081

8182
cy.contains('commands that do not appear in command log').should('be.visible').click()
82-
cy.percySnapshot()
83+
snapshotReporter()
8384
})
8485

8586
it('form interaction command options', () => {
@@ -89,7 +90,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
8990
})
9091

9192
cy.contains('form interaction command options').should('be.visible').click()
92-
cy.percySnapshot()
93+
snapshotReporter()
9394
})
9495

9596
it('DOM traversal command options', () => {
@@ -99,7 +100,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
99100
})
100101

101102
cy.contains('DOM traversal command options').should('be.visible').click()
102-
cy.percySnapshot()
103+
snapshotReporter()
103104
})
104105

105106
it('element state and navigation command options', () => {
@@ -109,7 +110,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
109110
})
110111

111112
cy.contains('element state and navigation command options').should('be.visible').click()
112-
cy.percySnapshot()
113+
snapshotReporter()
113114
})
114115

115116
it('element traversal and file operations command options', () => {
@@ -119,7 +120,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
119120
})
120121

121122
cy.contains('element traversal and file operations command options').should('be.visible').click()
122-
cy.percySnapshot()
123+
snapshotReporter()
123124
})
124125

125126
it('scrolling and form interaction command options', () => {
@@ -129,7 +130,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
129130
})
130131

131132
cy.contains('scrolling and form interaction command options').should('be.visible').click()
132-
cy.percySnapshot()
133+
snapshotReporter()
133134
})
134135

135136
it('user interaction and window command options', () => {
@@ -139,7 +140,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
139140
})
140141

141142
cy.contains('user interaction and window command options').should('be.visible').click()
142-
cy.percySnapshot()
143+
snapshotReporter()
143144
})
144145

145146
it('verify element visibility state', () => {
@@ -149,7 +150,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
149150
})
150151

151152
cy.contains('verify element visibility state').should('be.visible').click()
152-
cy.percySnapshot()
153+
snapshotReporter()
153154
})
154155
})
155156

@@ -160,7 +161,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
160161
})
161162

162163
cy.contains('Request Statuses').should('be.visible')
163-
cy.percySnapshot()
164+
snapshotReporter()
164165
})
165166

166167
it('page events', () => {
@@ -170,7 +171,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
170171
})
171172

172173
cy.contains('events - page events').should('be.visible')
173-
cy.percySnapshot()
174+
snapshotReporter()
174175
})
175176

176177
describe('errors', () => {
@@ -181,7 +182,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
181182
})
182183

183184
cy.contains('simple error with docs link').should('be.visible')
184-
cy.percySnapshot()
185+
snapshotReporter()
185186
})
186187

187188
it('long error', () => {
@@ -192,7 +193,7 @@ describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 60
192193

193194
cy.contains('simple error with docs link').click()
194195
cy.contains('long error').should('be.visible')
195-
cy.percySnapshot()
196+
snapshotReporter()
196197
})
197198
})
198199
})

packages/reporter/src/commands/command.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ const NavColumns: React.FC<NavColumnsProps> = observer(({ model, isPinned, toggl
124124
{(!model._isPending() && isPinned) && <PinIcon className='command-pin' />}
125125
{(!model._isPending() && !isPinned) && model.number}
126126
</div>
127-
{model.hasChildren && (
127+
{model.hasChildren && !model.group && (
128128
<div className='command-expander-column' onClick={() => model.toggleOpen()}>
129129
<ChevronIcon className={cs('command-expander', { 'command-expander-is-open': model.hasChildren && !!model.isOpen })} />
130130
</div>
@@ -326,7 +326,7 @@ interface CommandProps {
326326

327327
const CommandDetails: React.FC<CommandDetailsProps> = observer(({ model, groupId, aliasesWithDuplicates }) => (
328328
<span className={cs('command-info')}>
329-
<span className='command-method'>
329+
<span className={cs('command-method', { 'command-method-child': !model.hasChildren })}>
330330
<span>
331331
{model.event && model.type !== 'system' ? `(${displayName(model)})` : displayName(model)}
332332
</span>
@@ -432,7 +432,10 @@ const Command: React.FC<CommandProps> = observer(({ model, aliasesWithDuplicates
432432
groupLevel = model.groupLevel < 6 ? model.groupLevel : 5
433433

434434
for (let i = 1; i < groupLevel; i++) {
435-
groupPlaceholder.push(<span key={`${groupId}-${i}`} className='command-group-block' />)
435+
groupPlaceholder.push(<span key={`${groupId}-${i}`} className='command-group-block' onClick={(e) => {
436+
e.stopPropagation()
437+
model.toggleOpen()
438+
}} />)
436439
}
437440
}
438441

@@ -520,14 +523,26 @@ const Command: React.FC<CommandProps> = observer(({ model, aliasesWithDuplicates
520523
message='Printed output to your console'
521524
onClick={_toggleColumnPin}
522525
shouldShowMessage={_shouldShowClickMessage}
523-
wrapperClassName={cs('command-pin-target', { 'command-group': !!groupId })}
526+
wrapperClassName={cs('command-pin-target', { 'command-group': !!groupId, 'command-group-no-children': !model.hasChildren && model.group })}
524527
>
525528
<div
526-
className='command-wrapper-text'
529+
className={cs('command-wrapper-text', {
530+
'command-wrapper-text-group': model.hasChildren && groupId,
531+
'command-wrapper-text-group-parent': model.hasChildren && !groupId,
532+
})}
527533
onMouseEnter={() => _snapshot(true)}
528534
onMouseLeave={() => _snapshot(false)}
529535
>
530536
{groupPlaceholder}
537+
538+
{model.hasChildren && groupId && (
539+
<div className={cs('command-expander-column-group', { 'nested-group-expander': model.groupLevel })} onClick={(e) => {
540+
e.stopPropagation()
541+
model.toggleOpen()
542+
}}>
543+
<ChevronIcon className={cs('command-expander', { 'command-expander-is-open': model.hasChildren && !!model.isOpen })} />
544+
</div>
545+
)}
531546
<CommandDetails model={model} groupId={groupId} aliasesWithDuplicates={aliasesWithDuplicates} />
532547
<CommandControls model={model} commandName={commandName} events={events} />
533548
</div>

0 commit comments

Comments
 (0)