Skip to content

Commit 0b4777d

Browse files
committed
Test without monaco
1 parent cb7d7ab commit 0b4777d

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

e2e/chip.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ test.describe("chip", () => {
2020
});
2121

2222
test("simple chip", async ({ page, monaco }) => {
23-
await page.goto("chip");
23+
await page.goto("chip?monaco=false");
2424
await page.getByRole("button", { name: "Accept" }).click();
2525
await page.getByTestId("project-picker").selectOption("Project 1");
2626
await page.getByTestId("chip-picker").selectOption("Not");
2727

28-
await monaco.write(NOT);
29-
await page.screenshot({ path: "not.png" });
28+
await monaco.toggleMonaco();
29+
await monaco.write(NOT, "hdl");
3030
await expect(page.getByText("HDL code: No syntax errors")).toBeVisible();
3131

3232
await page.getByRole("button", { name: "Run ️⏩" }).click();

e2e/util/base.ts

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,42 @@ import type { Locator, Page } from "@playwright/test";
22
import { test as base } from "@playwright/test";
33

44
export class MonacoPage {
5+
private usingMonaco = true;
56
public readonly monacoEditor: Locator;
67
constructor(readonly page: Page) {
78
this.monacoEditor = page.locator(".monaco-editor").nth(0);
89
}
910

10-
async clearEditor() {
11-
await this.monacoEditor.click();
12-
await this.page.keyboard.press("ControlOrMeta+KeyA");
13-
await this.page.keyboard.press("Backspace");
14-
await this.page.keyboard.press("ControlOrMeta+KeyA");
15-
await this.page.keyboard.press("Backspace");
11+
async toggleMonaco() {
12+
await this.page.getByText("settings", { exact: true }).click();
13+
await this.page.getByText("Use Monaco Editor").click();
14+
await this.page
15+
.locator("header")
16+
.filter({ hasText: /^Settings$/ })
17+
.getByRole("link")
18+
.click();
19+
this.usingMonaco = !this.usingMonaco;
1620
}
1721

18-
async write(text: string) {
19-
await this.clearEditor();
20-
await this.monacoEditor.click();
22+
async clearEditor(editor: string) {
23+
if (this.usingMonaco) {
24+
await this.monacoEditor.click();
25+
await this.page.keyboard.press("ControlOrMeta+KeyA");
26+
await this.page.keyboard.press("Backspace");
27+
await this.page.keyboard.press("ControlOrMeta+KeyA");
28+
await this.page.keyboard.press("Backspace");
29+
} else {
30+
await this.page.getByTestId(`editor-${editor}`).clear();
31+
}
32+
}
33+
34+
async write(text: string, editor: string) {
35+
await this.clearEditor(editor);
36+
if (this.usingMonaco) {
37+
await this.monacoEditor.click();
38+
} else {
39+
await this.page.getByTestId(`editor-${editor}`);
40+
}
2141
for (const line of text.split("\n")) {
2242
await this.page.keyboard.type(`${line}\n`);
2343
}

0 commit comments

Comments
 (0)