|
| 1 | +import { expect } from "@playwright/test"; |
| 2 | +import { test } from "../../setup/setupScript.js"; |
| 3 | +import { ALERT_BLOCK_URL, SLASH_MENU_SELECTOR } from "../../utils/const.js"; |
| 4 | + |
| 5 | +// Regression test for https://github.com/TypeCellOS/BlockNote/issues/2531 |
| 6 | +// The slash menu should open when "/" is typed after a space inside a custom |
| 7 | +// block (isolating: true, separate contentDOM). Previously the menu failed to |
| 8 | +// open in this scenario. |
| 9 | +test.describe("Slash menu in custom (alert) block – issue #2531", () => { |
| 10 | + test.beforeEach(async ({ page }) => { |
| 11 | + await page.goto(ALERT_BLOCK_URL); |
| 12 | + await page.waitForSelector(".bn-editor"); |
| 13 | + }); |
| 14 | + |
| 15 | + test("opens slash menu when / is typed at end of alert block content (no preceding space)", async ({ |
| 16 | + page, |
| 17 | + }) => { |
| 18 | + // Click into the editable content area of the alert block |
| 19 | + const alertContent = page |
| 20 | + .locator('[data-content-type="alert"]') |
| 21 | + .first() |
| 22 | + .locator(".bn-inline-content"); |
| 23 | + await alertContent.click(); |
| 24 | + await page.keyboard.press("End"); |
| 25 | + |
| 26 | + await page.keyboard.type("/"); |
| 27 | + await expect(page.locator(SLASH_MENU_SELECTOR)).toBeVisible(); |
| 28 | + }); |
| 29 | + |
| 30 | + test("opens slash menu when / is typed after a space inside alert block (the regression)", async ({ |
| 31 | + page, |
| 32 | + }) => { |
| 33 | + // Click into the editable content area of the alert block |
| 34 | + const alertContent = page |
| 35 | + .locator('[data-content-type="alert"]') |
| 36 | + .first() |
| 37 | + .locator(".bn-inline-content"); |
| 38 | + await alertContent.click(); |
| 39 | + await page.keyboard.press("End"); |
| 40 | + |
| 41 | + // Type a space first — this is the scenario that broke the menu |
| 42 | + await page.keyboard.type(" "); |
| 43 | + await page.keyboard.type("/"); |
| 44 | + await expect(page.locator(SLASH_MENU_SELECTOR)).toBeVisible(); |
| 45 | + }); |
| 46 | +}); |
0 commit comments