From 845ababe9781e3caf69ea652a8ba84c505bb987d Mon Sep 17 00:00:00 2001 From: konojunya Date: Tue, 24 Mar 2026 11:47:27 +0900 Subject: [PATCH] test: expand E2E tests and add push/PR trigger to CI Add 15 new test cases per plugin (60 total, 92 overall): - Insert mode variants: a, A, I, O - Delete variants: x, D - Change: cc - Undo: u - Visual mode: v, V, visual delete - Replace: r - Join lines: J - Search: / - Line motions: $, 0 Also add push (main) and pull_request triggers to E2E CI workflow. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/e2e.yml | 3 + e2e/tests/codemirror.test.ts | 159 ++++++++++++++++++++++++++++ e2e/tests/monaco.test.ts | 159 ++++++++++++++++++++++++++++ e2e/tests/shiki-editor.test.ts | 159 ++++++++++++++++++++++++++++ e2e/tests/textarea.test.ts | 182 +++++++++++++++++++++++++++++++++ 5 files changed, 662 insertions(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 4840ffe..6f1e005 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -1,6 +1,9 @@ name: E2E Tests on: + push: + branches: [main] + pull_request: workflow_dispatch: jobs: diff --git a/e2e/tests/codemirror.test.ts b/e2e/tests/codemirror.test.ts index 9c7f1d1..c8e15fa 100644 --- a/e2e/tests/codemirror.test.ts +++ b/e2e/tests/codemirror.test.ts @@ -76,4 +76,163 @@ test.describe("codemirror", () => { await page.keyboard.press(":"); await expect(page.getByTestId("mode")).toHaveText("command-line"); }); + + test("a appends after cursor", async ({ page }) => { + await page.keyboard.press("a"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("Z"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^HZ/); + }); + + test("A appends at end of line", async ({ page }) => { + await page.keyboard.press("A"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("END"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + const firstLine = content!.split("\n")[0]; + expect(firstLine).toMatch(/END$/); + }); + + test("I inserts at beginning of line", async ({ page }) => { + await page.keyboard.press("l"); + await page.keyboard.press("l"); + await page.keyboard.press("I"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("START"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^START/); + }); + + test("O opens new line above", async ({ page }) => { + await page.keyboard.press("j"); + await page.keyboard.press("O"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("above"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + const lines = content!.split("\n"); + expect(lines[1]).toBe("above"); + }); + + test("x deletes character at cursor", async ({ page }) => { + await page.keyboard.press("x"); + + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^ello, vimee!/); + }); + + test("D deletes to end of line", async ({ page }) => { + await page.keyboard.press("l"); + await page.keyboard.press("D"); + + const content = await page.getByTestId("content").textContent(); + const firstLine = content!.split("\n")[0]; + expect(firstLine).toBe("H"); + }); + + test("cc changes entire line", async ({ page }) => { + await page.keyboard.press("c"); + await page.keyboard.press("c"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("replaced"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + const firstLine = content!.split("\n")[0]; + expect(firstLine).toBe("replaced"); + }); + + test("u undoes last change", async ({ page }) => { + const before = await page.getByTestId("content").textContent(); + + await page.keyboard.press("d"); + await page.keyboard.press("d"); + + const afterDelete = await page.getByTestId("content").textContent(); + expect(afterDelete).not.toBe(before); + + await page.keyboard.press("u"); + + const afterUndo = await page.getByTestId("content").textContent(); + expect(afterUndo).toBe(before); + }); + + test("v enters visual mode", async ({ page }) => { + await page.keyboard.press("v"); + await expect(page.getByTestId("mode")).toHaveText("visual"); + }); + + test("V enters visual-line mode", async ({ page }) => { + await page.keyboard.press("V"); + await expect(page.getByTestId("mode")).toHaveText("visual-line"); + }); + + test("visual mode delete removes selected text", async ({ page }) => { + await page.keyboard.press("v"); + await page.keyboard.press("l"); + await page.keyboard.press("l"); + await page.keyboard.press("l"); + await page.keyboard.press("l"); + await page.keyboard.press("d"); + + await expect(page.getByTestId("mode")).toHaveText("normal"); + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^, vimee!/); + }); + + test("r replaces character under cursor", async ({ page }) => { + await page.keyboard.press("r"); + await page.keyboard.press("Z"); + + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^Zello/); + await expect(page.getByTestId("mode")).toHaveText("normal"); + }); + + test("J joins current line with next", async ({ page }) => { + const before = await page.getByTestId("content").textContent(); + const linesBefore = before!.split("\n").length; + + await page.keyboard.press("J"); + + const after = await page.getByTestId("content").textContent(); + const linesAfter = after!.split("\n").length; + expect(linesAfter).toBe(linesBefore - 1); + expect(after).toMatch(/vimee! This is/); + }); + + test("search with / finds text", async ({ page }) => { + await page.keyboard.press("/"); + await expect(page.getByTestId("mode")).toHaveText("command-line"); + await page.keyboard.type("line 2"); + await page.keyboard.press("Enter"); + await expect(page.getByTestId("mode")).toHaveText("normal"); + }); + + test("$ moves to end of line, 0 moves to start", async ({ page }) => { + await page.keyboard.press("$"); + await page.keyboard.press("a"); + await page.keyboard.type("!"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + const firstLine = content!.split("\n")[0]; + expect(firstLine).toMatch(/!$/); + + await page.keyboard.press("0"); + await page.keyboard.press("i"); + await page.keyboard.type(">"); + await page.keyboard.press("Escape"); + + const content2 = await page.getByTestId("content").textContent(); + expect(content2).toMatch(/^>/); + }); }); diff --git a/e2e/tests/monaco.test.ts b/e2e/tests/monaco.test.ts index 99683d2..e41a1e1 100644 --- a/e2e/tests/monaco.test.ts +++ b/e2e/tests/monaco.test.ts @@ -77,4 +77,163 @@ test.describe("monaco", () => { await page.keyboard.press(":"); await expect(page.getByTestId("mode")).toHaveText("command-line"); }); + + test("a appends after cursor", async ({ page }) => { + await page.keyboard.press("a"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("Z"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^HZ/); + }); + + test("A appends at end of line", async ({ page }) => { + await page.keyboard.press("A"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("END"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + const firstLine = content!.split("\n")[0]; + expect(firstLine).toMatch(/END$/); + }); + + test("I inserts at beginning of line", async ({ page }) => { + await page.keyboard.press("l"); + await page.keyboard.press("l"); + await page.keyboard.press("I"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("START"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^START/); + }); + + test("O opens new line above", async ({ page }) => { + await page.keyboard.press("j"); + await page.keyboard.press("O"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("above"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + const lines = content!.split("\n"); + expect(lines[1]).toBe("above"); + }); + + test("x deletes character at cursor", async ({ page }) => { + await page.keyboard.press("x"); + + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^ello, vimee!/); + }); + + test("D deletes to end of line", async ({ page }) => { + await page.keyboard.press("l"); + await page.keyboard.press("D"); + + const content = await page.getByTestId("content").textContent(); + const firstLine = content!.split("\n")[0]; + expect(firstLine).toBe("H"); + }); + + test("cc changes entire line", async ({ page }) => { + await page.keyboard.press("c"); + await page.keyboard.press("c"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("replaced"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + const firstLine = content!.split("\n")[0]; + expect(firstLine).toBe("replaced"); + }); + + test("u undoes last change", async ({ page }) => { + const before = await page.getByTestId("content").textContent(); + + await page.keyboard.press("d"); + await page.keyboard.press("d"); + + const afterDelete = await page.getByTestId("content").textContent(); + expect(afterDelete).not.toBe(before); + + await page.keyboard.press("u"); + + const afterUndo = await page.getByTestId("content").textContent(); + expect(afterUndo).toBe(before); + }); + + test("v enters visual mode", async ({ page }) => { + await page.keyboard.press("v"); + await expect(page.getByTestId("mode")).toHaveText("visual"); + }); + + test("V enters visual-line mode", async ({ page }) => { + await page.keyboard.press("V"); + await expect(page.getByTestId("mode")).toHaveText("visual-line"); + }); + + test("visual mode delete removes selected text", async ({ page }) => { + await page.keyboard.press("v"); + await page.keyboard.press("l"); + await page.keyboard.press("l"); + await page.keyboard.press("l"); + await page.keyboard.press("l"); + await page.keyboard.press("d"); + + await expect(page.getByTestId("mode")).toHaveText("normal"); + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^, vimee!/); + }); + + test("r replaces character under cursor", async ({ page }) => { + await page.keyboard.press("r"); + await page.keyboard.press("Z"); + + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^Zello/); + await expect(page.getByTestId("mode")).toHaveText("normal"); + }); + + test("J joins current line with next", async ({ page }) => { + const before = await page.getByTestId("content").textContent(); + const linesBefore = before!.split("\n").length; + + await page.keyboard.press("J"); + + const after = await page.getByTestId("content").textContent(); + const linesAfter = after!.split("\n").length; + expect(linesAfter).toBe(linesBefore - 1); + expect(after).toMatch(/vimee! This is/); + }); + + test("search with / finds text", async ({ page }) => { + await page.keyboard.press("/"); + await expect(page.getByTestId("mode")).toHaveText("command-line"); + await page.keyboard.type("line 2"); + await page.keyboard.press("Enter"); + await expect(page.getByTestId("mode")).toHaveText("normal"); + }); + + test("$ moves to end of line, 0 moves to start", async ({ page }) => { + await page.keyboard.press("$"); + await page.keyboard.press("a"); + await page.keyboard.type("!"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + const firstLine = content!.split("\n")[0]; + expect(firstLine).toMatch(/!$/); + + await page.keyboard.press("0"); + await page.keyboard.press("i"); + await page.keyboard.type(">"); + await page.keyboard.press("Escape"); + + const content2 = await page.getByTestId("content").textContent(); + expect(content2).toMatch(/^>/); + }); }); diff --git a/e2e/tests/shiki-editor.test.ts b/e2e/tests/shiki-editor.test.ts index 5a115e8..1dea307 100644 --- a/e2e/tests/shiki-editor.test.ts +++ b/e2e/tests/shiki-editor.test.ts @@ -77,4 +77,163 @@ test.describe("shiki-editor", () => { await page.keyboard.press(":"); await expect(page.getByTestId("mode")).toHaveText("command-line"); }); + + test("a appends after cursor", async ({ page }) => { + await page.keyboard.press("a"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("Z"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^HZ/); + }); + + test("A appends at end of line", async ({ page }) => { + await page.keyboard.press("A"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("END"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + const firstLine = content!.split("\n")[0]; + expect(firstLine).toMatch(/END$/); + }); + + test("I inserts at beginning of line", async ({ page }) => { + await page.keyboard.press("l"); + await page.keyboard.press("l"); + await page.keyboard.press("I"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("START"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^START/); + }); + + test("O opens new line above", async ({ page }) => { + await page.keyboard.press("j"); + await page.keyboard.press("O"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("above"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + const lines = content!.split("\n"); + expect(lines[1]).toBe("above"); + }); + + test("x deletes character at cursor", async ({ page }) => { + await page.keyboard.press("x"); + + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^ello, vimee!/); + }); + + test("D deletes to end of line", async ({ page }) => { + await page.keyboard.press("l"); + await page.keyboard.press("D"); + + const content = await page.getByTestId("content").textContent(); + const firstLine = content!.split("\n")[0]; + expect(firstLine).toBe("H"); + }); + + test("cc changes entire line", async ({ page }) => { + await page.keyboard.press("c"); + await page.keyboard.press("c"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("replaced"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + const firstLine = content!.split("\n")[0]; + expect(firstLine).toBe("replaced"); + }); + + test("u undoes last change", async ({ page }) => { + const before = await page.getByTestId("content").textContent(); + + await page.keyboard.press("d"); + await page.keyboard.press("d"); + + const afterDelete = await page.getByTestId("content").textContent(); + expect(afterDelete).not.toBe(before); + + await page.keyboard.press("u"); + + const afterUndo = await page.getByTestId("content").textContent(); + expect(afterUndo).toBe(before); + }); + + test("v enters visual mode", async ({ page }) => { + await page.keyboard.press("v"); + await expect(page.getByTestId("mode")).toHaveText("visual"); + }); + + test("V enters visual-line mode", async ({ page }) => { + await page.keyboard.press("V"); + await expect(page.getByTestId("mode")).toHaveText("visual-line"); + }); + + test("visual mode delete removes selected text", async ({ page }) => { + await page.keyboard.press("v"); + await page.keyboard.press("l"); + await page.keyboard.press("l"); + await page.keyboard.press("l"); + await page.keyboard.press("l"); + await page.keyboard.press("d"); + + await expect(page.getByTestId("mode")).toHaveText("normal"); + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^, vimee!/); + }); + + test("r replaces character under cursor", async ({ page }) => { + await page.keyboard.press("r"); + await page.keyboard.press("Z"); + + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^Zello/); + await expect(page.getByTestId("mode")).toHaveText("normal"); + }); + + test("J joins current line with next", async ({ page }) => { + const before = await page.getByTestId("content").textContent(); + const linesBefore = before!.split("\n").length; + + await page.keyboard.press("J"); + + const after = await page.getByTestId("content").textContent(); + const linesAfter = after!.split("\n").length; + expect(linesAfter).toBe(linesBefore - 1); + expect(after).toMatch(/vimee! This is/); + }); + + test("search with / finds text", async ({ page }) => { + await page.keyboard.press("/"); + await expect(page.getByTestId("mode")).toHaveText("command-line"); + await page.keyboard.type("line 2"); + await page.keyboard.press("Enter"); + await expect(page.getByTestId("mode")).toHaveText("normal"); + }); + + test("$ moves to end of line, 0 moves to start", async ({ page }) => { + await page.keyboard.press("$"); + await page.keyboard.press("a"); + await page.keyboard.type("!"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + const firstLine = content!.split("\n")[0]; + expect(firstLine).toMatch(/!$/); + + await page.keyboard.press("0"); + await page.keyboard.press("i"); + await page.keyboard.type(">"); + await page.keyboard.press("Escape"); + + const content2 = await page.getByTestId("content").textContent(); + expect(content2).toMatch(/^>/); + }); }); diff --git a/e2e/tests/textarea.test.ts b/e2e/tests/textarea.test.ts index 088e268..caec3f8 100644 --- a/e2e/tests/textarea.test.ts +++ b/e2e/tests/textarea.test.ts @@ -83,4 +83,186 @@ test.describe("textarea", () => { await page.keyboard.press(":"); await expect(page.getByTestId("mode")).toHaveText("command-line"); }); + + // --- Insert mode variants --- + + test("a appends after cursor", async ({ page }) => { + await page.keyboard.press("a"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("Z"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + // 'a' appends after first char, so "H" + "Z" + "ello..." + expect(content).toMatch(/^HZ/); + }); + + test("A appends at end of line", async ({ page }) => { + await page.keyboard.press("A"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("END"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + const firstLine = content!.split("\n")[0]; + expect(firstLine).toMatch(/END$/); + }); + + test("I inserts at beginning of line", async ({ page }) => { + // Move to middle of line first + await page.keyboard.press("l"); + await page.keyboard.press("l"); + await page.keyboard.press("I"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("START"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^START/); + }); + + test("O opens new line above", async ({ page }) => { + await page.keyboard.press("j"); // go to line 2 + await page.keyboard.press("O"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("above"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + const lines = content!.split("\n"); + expect(lines[1]).toBe("above"); + }); + + // --- Deletion variants --- + + test("x deletes character at cursor", async ({ page }) => { + await page.keyboard.press("x"); + + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^ello, vimee!/); + }); + + test("D deletes to end of line", async ({ page }) => { + await page.keyboard.press("l"); // move to 'e' + await page.keyboard.press("D"); + + const content = await page.getByTestId("content").textContent(); + const firstLine = content!.split("\n")[0]; + expect(firstLine).toBe("H"); + }); + + // --- Change --- + + test("cc changes entire line", async ({ page }) => { + await page.keyboard.press("c"); + await page.keyboard.press("c"); + await expect(page.getByTestId("mode")).toHaveText("insert"); + await page.keyboard.type("replaced"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + const firstLine = content!.split("\n")[0]; + expect(firstLine).toBe("replaced"); + }); + + // --- Undo --- + + test("u undoes last change", async ({ page }) => { + const before = await page.getByTestId("content").textContent(); + + await page.keyboard.press("d"); + await page.keyboard.press("d"); + + const afterDelete = await page.getByTestId("content").textContent(); + expect(afterDelete).not.toBe(before); + + await page.keyboard.press("u"); + + const afterUndo = await page.getByTestId("content").textContent(); + expect(afterUndo).toBe(before); + }); + + // --- Visual mode --- + + test("v enters visual mode", async ({ page }) => { + await page.keyboard.press("v"); + await expect(page.getByTestId("mode")).toHaveText("visual"); + }); + + test("V enters visual-line mode", async ({ page }) => { + await page.keyboard.press("V"); + await expect(page.getByTestId("mode")).toHaveText("visual-line"); + }); + + test("visual mode delete removes selected text", async ({ page }) => { + await page.keyboard.press("v"); + await page.keyboard.press("l"); + await page.keyboard.press("l"); + await page.keyboard.press("l"); + await page.keyboard.press("l"); + await page.keyboard.press("d"); + + await expect(page.getByTestId("mode")).toHaveText("normal"); + const content = await page.getByTestId("content").textContent(); + // "Hello" (5 chars) should be deleted + expect(content).toMatch(/^, vimee!/); + }); + + // --- Replace --- + + test("r replaces character under cursor", async ({ page }) => { + await page.keyboard.press("r"); + await page.keyboard.press("Z"); + + const content = await page.getByTestId("content").textContent(); + expect(content).toMatch(/^Zello/); + await expect(page.getByTestId("mode")).toHaveText("normal"); + }); + + // --- Join lines --- + + test("J joins current line with next", async ({ page }) => { + const before = await page.getByTestId("content").textContent(); + const linesBefore = before!.split("\n").length; + + await page.keyboard.press("J"); + + const after = await page.getByTestId("content").textContent(); + const linesAfter = after!.split("\n").length; + expect(linesAfter).toBe(linesBefore - 1); + // First two lines should be joined with a space + expect(after).toMatch(/vimee! This is/); + }); + + // --- Search --- + + test("search with / finds text", async ({ page }) => { + await page.keyboard.press("/"); + await expect(page.getByTestId("mode")).toHaveText("command-line"); + await page.keyboard.type("line 2"); + await page.keyboard.press("Enter"); + await expect(page.getByTestId("mode")).toHaveText("normal"); + }); + + // --- Line motions --- + + test("$ moves to end of line, 0 moves to start", async ({ page }) => { + await page.keyboard.press("$"); + await page.keyboard.press("a"); + await page.keyboard.type("!"); + await page.keyboard.press("Escape"); + + const content = await page.getByTestId("content").textContent(); + const firstLine = content!.split("\n")[0]; + expect(firstLine).toMatch(/!$/); + + // Now go back to start with 0 + await page.keyboard.press("0"); + await page.keyboard.press("i"); + await page.keyboard.type(">"); + await page.keyboard.press("Escape"); + + const content2 = await page.getByTestId("content").textContent(); + expect(content2).toMatch(/^>/); + }); });