Skip to content

Commit fab18b0

Browse files
committed
fix: fix UsersPage storybook tests
1 parent 3000fea commit fab18b0

File tree

1 file changed

+16
-34
lines changed

1 file changed

+16
-34
lines changed

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

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,8 @@ export const SuspendUserSuccess: Story = {
9999
count: 60,
100100
});
101101

102-
await user.click(within(userRow).getByLabelText("More options"));
103-
const suspendButton = await within(userRow).findByText("Suspend", {
104-
exact: false,
105-
});
102+
await user.click(within(userRow).getByLabelText("Open menu"));
103+
const suspendButton = await within(document.body).findByText("Suspend…");
106104
await user.click(suspendButton);
107105

108106
const dialog = await within(document.body).findByRole("dialog");
@@ -120,10 +118,8 @@ export const SuspendUserError: Story = {
120118
}
121119
spyOn(API, "suspendUser").mockRejectedValue(undefined);
122120

123-
await user.click(within(userRow).getByLabelText("More options"));
124-
const suspendButton = await within(userRow).findByText("Suspend", {
125-
exact: false,
126-
});
121+
await user.click(within(userRow).getByLabelText("Open menu"));
122+
const suspendButton = await within(document.body).findByText("Suspend…");
127123
await user.click(suspendButton);
128124

129125
const dialog = await within(document.body).findByRole("dialog");
@@ -149,10 +145,8 @@ export const DeleteUserSuccess: Story = {
149145
count: 59,
150146
});
151147

152-
await user.click(within(userRow).getByLabelText("More options"));
153-
const deleteButton = await within(userRow).findByText("Delete", {
154-
exact: false,
155-
});
148+
await user.click(within(userRow).getByLabelText("Open menu"));
149+
const deleteButton = await within(document.body).findByText("Delete…");
156150
await user.click(deleteButton);
157151

158152
const dialog = await within(document.body).findByRole("dialog");
@@ -172,10 +166,8 @@ export const DeleteUserError: Story = {
172166
}
173167
spyOn(API, "deleteUser").mockRejectedValue({});
174168

175-
await user.click(within(userRow).getByLabelText("More options"));
176-
const deleteButton = await within(userRow).findByText("Delete", {
177-
exact: false,
178-
});
169+
await user.click(within(userRow).getByLabelText("Open menu"));
170+
const deleteButton = await within(document.body).findByText("Delete…");
179171
await user.click(deleteButton);
180172

181173
const dialog = await within(document.body).findByRole("dialog");
@@ -220,10 +212,8 @@ export const ActivateUserSuccess: Story = {
220212
count: 60,
221213
});
222214

223-
await user.click(within(userRow).getByLabelText("More options"));
224-
const activateButton = await within(userRow).findByText("Activate", {
225-
exact: false,
226-
});
215+
await user.click(within(userRow).getByLabelText("Open menu"));
216+
const activateButton = await within(document.body).findByText("Activate…");
227217
await user.click(activateButton);
228218

229219
const dialog = await within(document.body).findByRole("dialog");
@@ -242,10 +232,8 @@ export const ActivateUserError: Story = {
242232
}
243233
spyOn(API, "activateUser").mockRejectedValue({});
244234

245-
await user.click(within(userRow).getByLabelText("More options"));
246-
const activateButton = await within(userRow).findByText("Activate", {
247-
exact: false,
248-
});
235+
await user.click(within(userRow).getByLabelText("Open menu"));
236+
const activateButton = await within(document.body).findByText("Activate…");
249237
await user.click(activateButton);
250238

251239
const dialog = await within(document.body).findByRole("dialog");
@@ -279,11 +267,8 @@ export const ResetUserPasswordSuccess: Story = {
279267
}
280268
spyOn(API, "updateUserPassword").mockResolvedValue();
281269

282-
await user.click(within(userRow).getByLabelText("More options"));
283-
const resetPasswordButton = await within(userRow).findByText(
284-
"Reset password",
285-
{ exact: false },
286-
);
270+
await user.click(within(userRow).getByLabelText("Open menu"));
271+
const resetPasswordButton = await within(document.body).findByText("Reset password…");
287272
await user.click(resetPasswordButton);
288273

289274
const dialog = await within(document.body).findByRole("dialog");
@@ -306,11 +291,8 @@ export const ResetUserPasswordError: Story = {
306291
}
307292
spyOn(API, "updateUserPassword").mockRejectedValue({});
308293

309-
await user.click(within(userRow).getByLabelText("More options"));
310-
const resetPasswordButton = await within(userRow).findByText(
311-
"Reset password",
312-
{ exact: false },
313-
);
294+
await user.click(within(userRow).getByLabelText("Open menu"));
295+
const resetPasswordButton = await within(document.body).findByText("Reset password…");
314296
await user.click(resetPasswordButton);
315297

316298
const dialog = await within(document.body).findByRole("dialog");

0 commit comments

Comments
 (0)