Skip to content

Commit 3177821

Browse files
committed
test: improve Storybook tests
1 parent 58abc3d commit 3177821

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

site/src/components/UserDropdown/UserDropdown.stories.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@ ExampleNoRoles.args = {
2424
return Promise.resolve()
2525
},
2626
}
27+
28+
export const Open = Template.bind({})
29+
Open.args = {
30+
isOpen: true,
31+
user: MockUser,
32+
onSignOut: () => {
33+
return Promise.resolve()
34+
},
35+
}

site/src/components/UserDropdown/UsersDropdown.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ export const Language = {
2222
signOutLabel: "Sign Out",
2323
}
2424
export interface UserDropdownProps {
25+
isOpen?: boolean // *DO NOT USE* Only used for testing via Storybook
2526
user: TypesGen.User
2627
onSignOut: () => void
2728
}
2829

29-
export const UserDropdown: React.FC<UserDropdownProps> = ({ user, onSignOut }: UserDropdownProps) => {
30+
export const UserDropdown: React.FC<UserDropdownProps> = ({ isOpen, user, onSignOut }: UserDropdownProps) => {
3031
const styles = useStyles()
3132
const [anchorEl, setAnchorEl] = useState<HTMLElement | undefined>()
3233

@@ -51,7 +52,7 @@ export const UserDropdown: React.FC<UserDropdownProps> = ({ user, onSignOut }: U
5152
<BorderedMenu
5253
anchorEl={anchorEl}
5354
getContentAnchorEl={null}
54-
open={!!anchorEl}
55+
open={!!anchorEl || !!isOpen}
5556
anchorOrigin={{
5657
vertical: "bottom",
5758
horizontal: "right",

site/src/components/UserProfileCard/UserProfileCard.stories.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import { MockUser } from "../../testHelpers/entities"
44
import { UserProfileCard, UserProfileCardProps } from "./UserProfileCard"
55

66
export default {
7-
title: "components/UserDropdown",
7+
title: "components/UserProfileCard",
88
component: UserProfileCard,
9-
argTypes: {
10-
onSignOut: { action: "Sign Out" },
11-
},
9+
argTypes: {},
1210
}
1311

1412
const Template: Story<UserProfileCardProps> = (args: UserProfileCardProps) => <UserProfileCard {...args} />

0 commit comments

Comments
 (0)