Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaf4d0b1

Browse files
authored
chore: add stories forPopover (#12387)
1 parent722ff50 commitaf4d0b1

File tree

4 files changed

+74
-11
lines changed

4 files changed

+74
-11
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
importButtonfrom"@mui/material/Button";
2+
importtype{Meta,StoryObj}from"@storybook/react";
3+
import{expect,screen,userEvent,within,waitFor}from"@storybook/test";
4+
import{Popover,PopoverTrigger,PopoverContent}from"./Popover";
5+
6+
constmeta:Meta<typeofPopover>={
7+
title:"components/Popover",
8+
component:Popover,
9+
};
10+
11+
exportdefaultmeta;
12+
typeStory=StoryObj<typeofPopover>;
13+
14+
constcontent=`
15+
According to all known laws of aviation, there is no way a bee should be able to fly.
16+
Its wings are too small to get its fat little body off the ground. The bee, of course,
17+
flies anyway because bees don't care what humans think is impossible.
18+
`;
19+
20+
exportconstExample:Story={
21+
args:{
22+
children:(
23+
<>
24+
<PopoverTrigger>
25+
<Button>Click here!</Button>
26+
</PopoverTrigger>
27+
<PopoverContent>{content}</PopoverContent>
28+
</>
29+
),
30+
},
31+
play:async({ canvasElement, step})=>{
32+
constcanvas=within(canvasElement);
33+
34+
awaitstep("click to open",async()=>{
35+
awaituserEvent.click(canvas.getByRole("button"));
36+
awaitwaitFor(()=>
37+
expect(
38+
screen.getByText(/accordingtoallknownlaws/i),
39+
).toBeInTheDocument(),
40+
);
41+
});
42+
},
43+
};
44+
45+
exportconstHorizontal:Story={
46+
args:{
47+
children:(
48+
<>
49+
<PopoverTrigger>
50+
<Button>Click here!</Button>
51+
</PopoverTrigger>
52+
<PopoverContenthorizontal="right">{content}</PopoverContent>
53+
</>
54+
),
55+
},
56+
play:Example.play,
57+
};

‎site/src/modules/dashboard/Navbar/NavbarView.test.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { MockPrimaryWorkspaceProxy, MockUser } from "testHelpers/entities";
33
import{renderWithAuth}from"testHelpers/renderHelpers";
44
import{LanguageasnavLanguage,NavbarView}from"./NavbarView";
55
import{ProxyContextValue}from"contexts/ProxyContext";
6-
import{action}from"@storybook/addon-actions";
76

87
constproxyContextValue:ProxyContextValue={
98
proxy:{
@@ -14,15 +13,13 @@ const proxyContextValue: ProxyContextValue = {
1413
isLoading:false,
1514
isFetched:true,
1615
setProxy:jest.fn(),
17-
clearProxy:action("clearProxy"),
16+
clearProxy:jest.fn(),
1817
refetchProxyLatencies:jest.fn(),
1918
proxyLatencies:{},
2019
};
2120

2221
describe("NavbarView",()=>{
23-
constnoop=()=>{
24-
return;
25-
};
22+
constnoop=jest.fn();
2623

2724
it("workspaces nav link has the correct href",async()=>{
2825
renderWithAuth(

‎site/src/modules/dashboard/Navbar/UserDropdown/UserDropdown.stories.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
importtype{Meta,StoryObj}from"@storybook/react";
2+
import{expect,screen,userEvent,within,waitFor}from"@storybook/test";
13
import{MockBuildInfo,MockUser}from"testHelpers/entities";
24
import{UserDropdown}from"./UserDropdown";
3-
importtype{Meta,StoryObj}from"@storybook/react";
45

56
constmeta:Meta<typeofUserDropdown>={
67
title:"modules/dashboard/UserDropdown",
78
component:UserDropdown,
89
args:{
910
user:MockUser,
10-
isDefaultOpen:true,
1111
buildInfo:MockBuildInfo,
1212
supportLinks:[
1313
{icon:"docs",name:"Documentation",target:""},
@@ -21,6 +21,17 @@ const meta: Meta<typeof UserDropdown> = {
2121
exportdefaultmeta;
2222
typeStory=StoryObj<typeofUserDropdown>;
2323

24-
constExample:Story={};
24+
constExample:Story={
25+
play:async({ canvasElement, step})=>{
26+
constcanvas=within(canvasElement);
27+
28+
awaitstep("click to open",async()=>{
29+
awaituserEvent.click(canvas.getByRole("button"));
30+
awaitwaitFor(()=>
31+
expect(screen.getByText(/v99\.999\.9999/i)).toBeInTheDocument(),
32+
);
33+
});
34+
},
35+
};
2536

2637
export{ExampleasUserDropdown};

‎site/src/modules/dashboard/Navbar/UserDropdown/UserDropdown.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export interface UserDropdownProps {
1717
buildInfo?:TypesGen.BuildInfoResponse;
1818
supportLinks?:TypesGen.LinkConfig[];
1919
onSignOut:()=>void;
20-
isDefaultOpen?:boolean;
2120
children?:ReactNode;
2221
}
2322

@@ -26,12 +25,11 @@ export const UserDropdown: FC<UserDropdownProps> = ({
2625
user,
2726
supportLinks,
2827
onSignOut,
29-
isDefaultOpen,
3028
})=>{
3129
consttheme=useTheme();
3230

3331
return(
34-
<PopoverisDefaultOpen={isDefaultOpen}>
32+
<Popover>
3533
{(popover)=>(
3634
<>
3735
<PopoverTrigger>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp