Skip to content

Commit a7dcbce

Browse files
committed
fix: fix tests
1 parent 9153ef7 commit a7dcbce

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

site/src/pages/OrganizationSettingsPage/OrganizationMembersPage.test.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
MockEntitlementsWithMultiOrg,
77
MockOrganization,
88
MockOrganizationAuditorRole,
9+
MockOrganizationMember,
10+
MockOrganizationMember2,
911
MockOrganizationPermissions,
1012
MockUser,
1113
} from "testHelpers/entities";
@@ -46,20 +48,19 @@ const renderPage = async () => {
4648

4749
const removeMember = async () => {
4850
const user = userEvent.setup();
49-
// Click on the "Open menu" button to display the "Remove" option
50-
const menuButtons = await screen.findAllByRole("button", { name: "Open menu" });
51-
// get MockUser2
52-
const selectedMenuButton = menuButtons[0];
53-
54-
await user.click(selectedMenuButton);
55-
56-
// Wait for the dropdown menu to be visible and find the remove button
57-
const menuItems = await screen.findAllByRole("menuitem");
58-
const removeButton = menuItems.find(item => item.textContent === "Remove");
59-
if (!removeButton) {
60-
throw new Error("Remove button not found");
51+
52+
const users = await screen.findAllByText(/.*@coder.com/);
53+
const userRow = users[1].closest("tr");
54+
if (!userRow) {
55+
throw new Error("Error on get the first user row");
6156
}
62-
await user.click(removeButton);
57+
const menuButton = await within(userRow).findByRole("button", {
58+
name: "Open menu",
59+
});
60+
await user.click(menuButton);
61+
62+
const removeOption = await screen.findByRole("menuitem", { name: "Remove" });
63+
await user.click(removeOption);
6364

6465
const dialog = await within(document.body).findByRole("dialog");
6566
await user.click(within(dialog).getByRole("button", { name: "Remove" }));

site/src/pages/WorkspacePage/WorkspaceActions/WorkspaceActions.stories.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ export const OpenDownloadLogs: Story = {
202202
},
203203
play: async ({ canvasElement }) => {
204204
const canvas = within(canvasElement);
205-
await userEvent.click(canvas.getByRole("button", { name: "Workspace actions" }));
205+
await userEvent.click(
206+
canvas.getByRole("button", { name: "Workspace actions" }),
207+
);
206208
const screen = within(document.body);
207209
await userEvent.click(screen.getByText("Download logs…"));
208210
await expect(screen.getByTestId("dialog")).toBeInTheDocument();
@@ -215,7 +217,9 @@ export const CanDeleteDormantWorkspace: Story = {
215217
},
216218
play: async ({ canvasElement }) => {
217219
const canvas = within(canvasElement);
218-
await userEvent.click(canvas.getByRole("button", { name: "Workspace actions" }));
220+
await userEvent.click(
221+
canvas.getByRole("button", { name: "Workspace actions" }),
222+
);
219223
const screen = within(document.body);
220224
const deleteButton = screen.getByText("Delete…");
221225
await expect(deleteButton).toBeEnabled();

0 commit comments

Comments
 (0)