diff --git a/e2e/chip.spec.ts b/e2e/chip.spec.ts index 3c6e92c81..1c33e2c9c 100644 --- a/e2e/chip.spec.ts +++ b/e2e/chip.spec.ts @@ -20,13 +20,13 @@ test.describe("chip", () => { }); test("simple chip", async ({ page, monaco }) => { - await page.goto("chip"); + await page.goto("chip?monaco=false"); await page.getByRole("button", { name: "Accept" }).click(); await page.getByTestId("project-picker").selectOption("Project 1"); await page.getByTestId("chip-picker").selectOption("Not"); - await monaco.write(NOT); - await page.screenshot({ path: "not.png" }); + await monaco.toggleMonaco(); + await monaco.write(NOT, "hdl"); await expect(page.getByText("HDL code: No syntax errors")).toBeVisible(); await page.getByRole("button", { name: "Run ️⏩" }).click(); diff --git a/e2e/util/base.ts b/e2e/util/base.ts index 8cea522cb..0277706ff 100644 --- a/e2e/util/base.ts +++ b/e2e/util/base.ts @@ -2,22 +2,42 @@ import type { Locator, Page } from "@playwright/test"; import { test as base } from "@playwright/test"; export class MonacoPage { + private usingMonaco = true; public readonly monacoEditor: Locator; constructor(readonly page: Page) { this.monacoEditor = page.locator(".monaco-editor").nth(0); } - async clearEditor() { - await this.monacoEditor.click(); - await this.page.keyboard.press("ControlOrMeta+KeyA"); - await this.page.keyboard.press("Backspace"); - await this.page.keyboard.press("ControlOrMeta+KeyA"); - await this.page.keyboard.press("Backspace"); + async toggleMonaco() { + await this.page.getByText("settings", { exact: true }).click(); + await this.page.getByText("Use Monaco Editor").click(); + await this.page + .locator("header") + .filter({ hasText: /^Settings$/ }) + .getByRole("link") + .click(); + this.usingMonaco = !this.usingMonaco; } - async write(text: string) { - await this.clearEditor(); - await this.monacoEditor.click(); + async clearEditor(editor: string) { + if (this.usingMonaco) { + await this.monacoEditor.click(); + await this.page.keyboard.press("ControlOrMeta+KeyA"); + await this.page.keyboard.press("Backspace"); + await this.page.keyboard.press("ControlOrMeta+KeyA"); + await this.page.keyboard.press("Backspace"); + } else { + await this.page.getByTestId(`editor-${editor}`).clear(); + } + } + + async write(text: string, editor: string) { + await this.clearEditor(editor); + if (this.usingMonaco) { + await this.monacoEditor.click(); + } else { + await this.page.getByTestId(`editor-${editor}`); + } for (const line of text.split("\n")) { await this.page.keyboard.type(`${line}\n`); }