Skip to content

Commit 18c2386

Browse files
chore(site): fix reset password storybook flake (#15380)
Fix coder/internal#69
1 parent 335e4ab commit 18c2386

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

site/src/pages/UsersPage/UsersPage.stories.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ const meta: Meta<typeof UsersPage> = {
7272
component: UsersPage,
7373
parameters,
7474
decorators: [withGlobalSnackbar, withAuthProvider, withDashboardProvider],
75+
args: {
76+
defaultNewPassword: "edWbqYiaVpEiEWwI",
77+
},
7578
};
7679

7780
export default meta;

site/src/pages/UsersPage/UsersPage.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ import { ResetPasswordDialog } from "./ResetPasswordDialog";
3535
import { useStatusFilterMenu } from "./UsersFilter";
3636
import { UsersPageView } from "./UsersPageView";
3737

38-
const UsersPage: FC = () => {
38+
type UserPageProps = {
39+
// Used by Storybook to prevent generating a new password each time the story
40+
// loads, avoiding Chromatic snapshot differences.
41+
defaultNewPassword?: string;
42+
};
43+
44+
const UsersPage: FC<UserPageProps> = ({ defaultNewPassword }) => {
3945
const queryClient = useQueryClient();
4046
const navigate = useNavigate();
4147
const location = useLocation();
@@ -134,7 +140,7 @@ const UsersPage: FC = () => {
134140
onResetUserPassword={(user) => {
135141
setConfirmResetPassword({
136142
user,
137-
newPassword: generateRandomString(12),
143+
newPassword: defaultNewPassword ?? generateRandomString(12),
138144
});
139145
}}
140146
onUpdateUserRoles={async (userId, roles) => {

site/src/pages/UsersPage/UsersPageView.stories.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ const meta: Meta<typeof UsersPageView> = {
3434
isNonInitialPage: false,
3535
users: [MockUser, MockUser2],
3636
roles: MockAssignableSiteRoles,
37-
3837
canEditUsers: true,
3938
filterProps: defaultFilterProps,
4039
authMethods: MockAuthMethodsPasswordOnly,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy