|
| 1 | +import { test } from "../../setup/setupScript.js"; |
| 2 | +import { BASE_URL } from "../../utils/const.js"; |
| 3 | +import { compareDocToSnapshot, focusOnEditor } from "../../utils/editor.js"; |
| 4 | +import { executeSlashCommand } from "../../utils/slashmenu.js"; |
| 5 | + |
| 6 | +test.beforeEach(async ({ page }) => { |
| 7 | + await page.goto(BASE_URL); |
| 8 | +}); |
| 9 | + |
| 10 | +test.describe("Check Table interactions", () => { |
| 11 | + test("Should be able to type in cell", async ({ page }) => { |
| 12 | + await focusOnEditor(page); |
| 13 | + await executeSlashCommand(page, "table"); |
| 14 | + await page.keyboard.type("Table Cell"); |
| 15 | + |
| 16 | + await compareDocToSnapshot(page, "cellTyping.json"); |
| 17 | + }); |
| 18 | + test("Tab should cycle cells", async ({ page }) => { |
| 19 | + await focusOnEditor(page); |
| 20 | + await executeSlashCommand(page, "table"); |
| 21 | + // Cycle to sixth (last) cell. |
| 22 | + for (let i = 0; i < 5; i++) { |
| 23 | + await page.keyboard.press("Tab"); |
| 24 | + } |
| 25 | + await page.keyboard.type("Table Cell"); |
| 26 | + // Cycle back to first cell. |
| 27 | + for (let i = 0; i < 5; i++) { |
| 28 | + await page.keyboard.press("Shift+Tab"); |
| 29 | + } |
| 30 | + await page.keyboard.type("Table Cell"); |
| 31 | + |
| 32 | + await compareDocToSnapshot(page, "tabCells.json"); |
| 33 | + }); |
| 34 | + test("Arrow keys should move cells", async ({ page }) => { |
| 35 | + await focusOnEditor(page); |
| 36 | + await executeSlashCommand(page, "table"); |
| 37 | + // Move down to second (last) cell in column and third (last) cell in row. |
| 38 | + page.keyboard.press("ArrowDown"); |
| 39 | + for (let i = 0; i < 2; i++) { |
| 40 | + await page.keyboard.press("ArrowRight"); |
| 41 | + } |
| 42 | + await page.keyboard.type("Table Cell"); |
| 43 | + // Cycle back to first cell. |
| 44 | + page.keyboard.press("ArrowUp"); |
| 45 | + for (let i = 0; i < 2; i++) { |
| 46 | + await page.keyboard.press("ArrowLeft"); |
| 47 | + } |
| 48 | + await page.keyboard.type("Table Cell"); |
| 49 | + |
| 50 | + await compareDocToSnapshot(page, "arrowKeyCells.json"); |
| 51 | + }); |
| 52 | +}); |
0 commit comments