Skip to content

Commit d73ab8d

Browse files
committed
fix: fix some node playwright tests
1 parent 26a882b commit d73ab8d

3 files changed

Lines changed: 21 additions & 11 deletions

File tree

packages/context-editor/playwright.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export default defineConfig({
3737
use: {
3838
/* Base URL to use in actions like `await page.goto('/')`. */
3939
baseURL,
40-
4140
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
4241
trace: "on-first-retry",
4342
},

packages/context-editor/playwright/attribute-panel.spec.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ test.describe("attribute panel", () => {
2525
await test.step("fill out panel while keeping it open", async () => {
2626
const id = "test id";
2727
const className = "test class";
28-
await page.getByRole("textbox", { name: "id" }).fill(id);
29-
await page.getByRole("textbox", { name: "class" }).fill(className);
28+
await page.getByTestId("advanced-options-trigger").click();
29+
await page.getByTestId("id-input").fill(id);
30+
await page.getByTestId("class-input").fill(className);
3031
});
3132

3233
await test.step("can close the panel by clicking the button again", async () => {
@@ -60,9 +61,11 @@ test.describe("attribute panel", () => {
6061
await clickNode(page, "paragraph");
6162
await page.getByTestId("attribute-panel").waitFor();
6263
await expect(page.getByTestId("attribute-panel")).not.toContainText("strong");
64+
65+
await page.getByTestId("advanced-options-trigger").click();
6366
const id = "paragraph-id";
64-
await page.getByRole("textbox", { name: "id" }).fill(id);
65-
await expect(page.getByRole("textbox", { name: "id" })).toHaveValue(id);
67+
await page.getByTestId("id-input").fill(id);
68+
await expect(page.getByTestId("id-input")).toHaveValue(id);
6669
});
6770

6871
await test.step("click on other text", async () => {
@@ -72,7 +75,8 @@ test.describe("attribute panel", () => {
7275
.getByText(text)
7376
.click({ position: { x: 20, y: 0 } });
7477
await expect(page.getByTestId("attribute-panel")).toContainText("strong");
75-
await expect(page.getByRole("textbox", { name: "id" })).toHaveValue("");
78+
await page.getByTestId("advanced-options-trigger").click();
79+
await expect(page.getByTestId("id-input")).toHaveValue("");
7680
});
7781
});
7882

@@ -91,15 +95,17 @@ test.describe("attribute panel", () => {
9195
await page.getByTestId("attribute-panel").waitFor();
9296
const id = "id1";
9397
const className = "class1";
94-
await page.getByRole("textbox", { name: "id" }).fill(id);
95-
await page.getByRole("textbox", { name: "class" }).fill(className);
98+
await page.getByTestId("advanced-options-trigger").click();
99+
await page.getByTestId("id-input").fill(id);
100+
await page.getByTestId("class-input").fill(className);
96101
});
97102

98103
await test.step("open panel on second paragraph", async () => {
99104
await clickNode(page, "paragraph", 1);
100105
// Make sure the second paragraph does not have the same attrs as the first
101-
await expect(page.getByRole("textbox", { name: "id" })).toHaveValue("");
102-
await expect(page.getByRole("textbox", { name: "class" })).toHaveValue("");
106+
await page.getByTestId("advanced-options-trigger").click();
107+
await expect(page.getByTestId("id-input")).toHaveValue("");
108+
await expect(page.getByTestId("class-input")).toHaveValue("");
103109
});
104110
});
105111
});

packages/context-editor/src/components/menus/MenuFields.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ export const MenuInputField = ({
2727
<FormLabel>{label}</FormLabel>
2828
<div className="col-span-3 flex items-center gap-4">
2929
<FormControl>
30-
<Input {...field} placeholder="None" />
30+
<Input
31+
{...field}
32+
placeholder="None"
33+
data-testid={`${name}-input`}
34+
/>
3135
</FormControl>
3236
{right ? right(field.value) : null}
3337
</div>
@@ -60,6 +64,7 @@ export const MenuSwitchField = (props: MenuSwitchFieldProps) => {
6064
<FormLabel>{label}</FormLabel>
6165
<FormControl>
6266
<Switch
67+
data-testid={`${props.name}-switch`}
6368
checked={props.value ?? field.value}
6469
onCheckedChange={props.onChange ?? field.onChange}
6570
className="data-[state=checked]:bg-emerald-400"

0 commit comments

Comments
 (0)