Skip to content

chore(site): fix reset password storybook flake #15380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions site/src/pages/UsersPage/UsersPage.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ const meta: Meta<typeof UsersPage> = {
component: UsersPage,
parameters,
decorators: [withGlobalSnackbar, withAuthProvider, withDashboardProvider],
args: {
defaultNewPassword: "edWbqYiaVpEiEWwI",
},
};

export default meta;
Expand Down
10 changes: 8 additions & 2 deletions site/src/pages/UsersPage/UsersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ import { ResetPasswordDialog } from "./ResetPasswordDialog";
import { useStatusFilterMenu } from "./UsersFilter";
import { UsersPageView } from "./UsersPageView";

const UsersPage: FC = () => {
type UserPageProps = {
// Used by Storybook to prevent generating a new password each time the story
// loads, avoiding Chromatic snapshot differences.
defaultNewPassword?: string;
};

const UsersPage: FC<UserPageProps> = ({ defaultNewPassword }) => {
const queryClient = useQueryClient();
const navigate = useNavigate();
const location = useLocation();
Expand Down Expand Up @@ -134,7 +140,7 @@ const UsersPage: FC = () => {
onResetUserPassword={(user) => {
setConfirmResetPassword({
user,
newPassword: generateRandomString(12),
newPassword: defaultNewPassword ?? generateRandomString(12),
});
}}
onUpdateUserRoles={async (userId, roles) => {
Expand Down
1 change: 0 additions & 1 deletion site/src/pages/UsersPage/UsersPageView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const meta: Meta<typeof UsersPageView> = {
isNonInitialPage: false,
users: [MockUser, MockUser2],
roles: MockAssignableSiteRoles,

canEditUsers: true,
filterProps: defaultFilterProps,
authMethods: MockAuthMethodsPasswordOnly,
Expand Down
Loading