Skip to content

Commit 259e8a3

Browse files
committed
test: expect elements rendered by Popover
1 parent 85611c3 commit 259e8a3

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

site/src/components/Filter/SelectFilter.stories.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Meta, StoryObj } from "@storybook/react-vite";
33
import { Avatar } from "components/Avatar/Avatar";
44
import { useState } from "react";
55
import { action } from "storybook/actions";
6-
import { expect, userEvent, within } from "storybook/test";
6+
import { expect, screen, userEvent, within } from "storybook/test";
77
import {
88
SelectFilter,
99
type SelectFilterOption,
@@ -88,7 +88,7 @@ export const SelectingOption: Story = {
8888
const canvas = within(canvasElement);
8989
const button = canvas.getByRole("button");
9090
await userEvent.click(button);
91-
const option = canvas.getByText("Option 25");
91+
const option = screen.getByText("Option 25");
9292
await userEvent.click(option);
9393
await expect(button).toHaveTextContent("Option 25");
9494
},
@@ -102,7 +102,7 @@ export const UnselectingOption: Story = {
102102
const canvas = within(canvasElement);
103103
const button = canvas.getByRole("button");
104104
await userEvent.click(button);
105-
const menu = canvasElement.querySelector<HTMLElement>("[role=menu]")!;
105+
const menu = screen.getByRole("menu");
106106
const option = within(menu).getByText("Option 26");
107107
await userEvent.click(option);
108108
await expect(button).toHaveTextContent("All options");
@@ -140,7 +140,7 @@ export const SearchingOption: Story = {
140140
const canvas = within(canvasElement);
141141
const button = canvas.getByRole("button");
142142
await userEvent.click(button);
143-
const search = canvas.getByLabelText("Search options");
143+
const search = screen.getByLabelText("Search options");
144144
await userEvent.type(search, "option-2");
145145
},
146146
};

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { MockWorkspace } from "testHelpers/entities";
22
import type { Meta, StoryObj } from "@storybook/react-vite";
3-
import { expect, userEvent, waitFor, within } from "storybook/test";
3+
import { expect, screen, userEvent, waitFor } from "storybook/test";
44
import { DebugButton } from "./DebugButton";
55

66
const meta: Meta<typeof DebugButton> = {
@@ -41,9 +41,7 @@ export const WithOpenBuildParameters: Story = {
4141
},
4242
],
4343
},
44-
play: async ({ canvasElement, step }) => {
45-
const screen = within(canvasElement);
46-
44+
play: async ({ step }) => {
4745
await step("open popover", async () => {
4846
await userEvent.click(screen.getByTestId("build-parameters-button"));
4947
await waitFor(() =>

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
MockWorkspace,
55
} from "testHelpers/entities";
66
import type { Meta, StoryObj } from "@storybook/react-vite";
7-
import { expect, userEvent, waitFor, within } from "storybook/test";
7+
import { expect, screen, userEvent, waitFor } from "storybook/test";
88
import { RetryButton } from "./RetryButton";
99

1010
const meta: Meta<typeof RetryButton> = {
@@ -45,9 +45,7 @@ export const WithOpenBuildParameters: Story = {
4545
},
4646
],
4747
},
48-
play: async ({ canvasElement, step }) => {
49-
const screen = within(canvasElement);
50-
48+
play: async ({ step }) => {
5149
await step("open popover", async () => {
5250
await userEvent.click(screen.getByTestId("build-parameters-button"));
5351
await waitFor(() =>
@@ -73,13 +71,15 @@ export const WithOpenEphemeralBuildParameters: Story = {
7371
},
7472
],
7573
},
76-
play: async ({ canvasElement, step }) => {
77-
const screen = within(canvasElement);
78-
74+
play: async ({ step }) => {
7975
await step("open popover", async () => {
8076
await userEvent.click(screen.getByTestId("build-parameters-button"));
8177
await waitFor(() =>
82-
expect(screen.getByText("Build Options")).toBeInTheDocument(),
78+
expect(
79+
screen.getByText(
80+
"These parameters only apply for a single workspace start.",
81+
),
82+
).toBeInTheDocument(),
8383
);
8484
});
8585
},
@@ -105,13 +105,15 @@ export const WithOpenEphemeralBuildParametersNotClassic: Story = {
105105
},
106106
],
107107
},
108-
play: async ({ canvasElement, step }) => {
109-
const screen = within(canvasElement);
110-
108+
play: async ({ step }) => {
111109
await step("open popover", async () => {
112110
await userEvent.click(screen.getByTestId("build-parameters-button"));
113111
await waitFor(() =>
114-
expect(screen.getByText("Build Options")).toBeInTheDocument(),
112+
expect(
113+
screen.getByText(
114+
"This workspace has ephemeral parameters which may use a temporary value on workspace start. Configure the following parameters in workspace settings.",
115+
),
116+
).toBeInTheDocument(),
115117
);
116118
});
117119
},

0 commit comments

Comments
 (0)