Skip to content

Commit 6f1e8de

Browse files
authored
fix(fuselage): SidebarItemV2 visual regressions (#1742)
1 parent 5bbd461 commit 6f1e8de

File tree

11 files changed

+2731
-73
lines changed

11 files changed

+2731
-73
lines changed

.changeset/few-bikes-refuse.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rocket.chat/fuselage': patch
3+
---
4+
5+
fix(fuselage): SidebarItemV2 visual regressions
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { composeStories } from '@storybook/react-webpack5';
2+
import { axe } from 'jest-axe';
3+
4+
import { render } from '../../testing';
5+
6+
import * as stories from './SidebarItem.stories';
7+
8+
const testCases = Object.values(composeStories(stories)).map((Story) => [
9+
Story.storyName || 'Story',
10+
Story,
11+
]);
12+
13+
test.each(testCases)(
14+
`renders %s without crashing`,
15+
async (_storyname, Story) => {
16+
const tree = render(<Story />);
17+
expect(tree.baseElement).toMatchSnapshot();
18+
},
19+
);
20+
21+
test.each(testCases)(
22+
'%s should have no a11y violations',
23+
async (_storyname, Story) => {
24+
const { container } = render(<Story />);
25+
26+
const results = await axe(container);
27+
expect(results).toHaveNoViolations();
28+
},
29+
);

packages/fuselage/src/components/Sidebar/Item.stories.tsx renamed to packages/fuselage/src/components/Sidebar/SidebarItem.stories.tsx

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ export default {
3030
},
3131
} satisfies Meta<typeof SidebarItem>;
3232

33+
const sidebarItemActions = (
34+
<SidebarItemActions>
35+
<SidebarItemAction aria-label='accept' secondary success icon='phone' />
36+
<SidebarItemAction
37+
aria-label='cancel'
38+
secondary
39+
danger
40+
icon='circle-cross'
41+
/>
42+
<SidebarItemAction aria-label='delete' secondary info icon='trash' />
43+
<SidebarItemAction aria-label='accept' secondary icon='phone' />
44+
</SidebarItemActions>
45+
);
46+
3347
export const Default: StoryFn<typeof SidebarItem> = () => (
3448
<>
3549
<SidebarItem>
@@ -50,14 +64,7 @@ export const Default: StoryFn<typeof SidebarItem> = () => (
5064
</SidebarItemTitle>
5165
</SidebarItemWrapper>
5266
</SidebarItemContent>
53-
<SidebarItemContainer>
54-
<SidebarItemActions>
55-
<SidebarItemAction secondary success icon='phone' />
56-
<SidebarItemAction secondary danger icon='circle-cross' />
57-
<SidebarItemAction secondary info icon='trash' />
58-
<SidebarItemAction secondary icon='phone' />
59-
</SidebarItemActions>
60-
</SidebarItemContainer>
67+
<SidebarItemContainer>{sidebarItemActions}</SidebarItemContainer>
6168
</SidebarItem>
6269

6370
<SidebarItem highlighted is='a'>
@@ -75,14 +82,7 @@ export const Default: StoryFn<typeof SidebarItem> = () => (
7582
<SidebarItemTitle>highlighted</SidebarItemTitle>
7683
</SidebarItemWrapper>
7784
</SidebarItemContent>
78-
<SidebarItemContainer>
79-
<SidebarItemActions>
80-
<SidebarItemAction secondary success icon='phone' />
81-
<SidebarItemAction secondary danger icon='circle-cross' />
82-
<SidebarItemAction secondary info icon='trash' />
83-
<SidebarItemAction secondary icon='phone' />
84-
</SidebarItemActions>
85-
</SidebarItemContainer>
85+
<SidebarItemContainer />
8686
</SidebarItem>
8787
<SidebarItem selected is='a'>
8888
<SidebarItemAvatar>
@@ -102,14 +102,7 @@ export const Default: StoryFn<typeof SidebarItem> = () => (
102102
</SidebarItemTitle>
103103
</SidebarItemWrapper>
104104
</SidebarItemContent>
105-
<SidebarItemContainer>
106-
<SidebarItemActions>
107-
<SidebarItemAction secondary success icon='phone' />
108-
<SidebarItemAction secondary danger icon='circle-cross' />
109-
<SidebarItemAction secondary info icon='trash' />
110-
<SidebarItemAction secondary icon='phone' />
111-
</SidebarItemActions>
112-
</SidebarItemContainer>
105+
<SidebarItemContainer>{sidebarItemActions}</SidebarItemContainer>
113106
</SidebarItem>
114107
<SidebarItem is='a'>
115108
<SidebarItemAvatar>
@@ -140,12 +133,7 @@ export const Default: StoryFn<typeof SidebarItem> = () => (
140133
</SidebarItemContent>
141134
</SidebarItemContent>
142135
<SidebarItemContainer>
143-
<SidebarItemActions>
144-
<SidebarItemAction secondary success icon='phone' />
145-
<SidebarItemAction secondary danger icon='circle-cross' />
146-
<SidebarItemAction secondary info icon='trash' />
147-
<SidebarItemAction secondary icon='phone' />
148-
</SidebarItemActions>
136+
<SidebarItemContainer>{sidebarItemActions}</SidebarItemContainer>
149137
</SidebarItemContainer>
150138
</SidebarItem>
151139
</>

0 commit comments

Comments
 (0)