Skip to content

feat: add e2e#472

Open
wuyiping0628 wants to merge 1 commit into
devfrom
wyp/add-e2e-0520
Open

feat: add e2e#472
wuyiping0628 wants to merge 1 commit into
devfrom
wyp/add-e2e-0520

Conversation

@wuyiping0628
Copy link
Copy Markdown
Collaborator

@wuyiping0628 wuyiping0628 commented May 22, 2026

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for editor demo functionality including character counter displays with real-time updates, Delta and HTML content synchronization and retrieval, header list navigation and visibility toggling, readonly editor mode behavior, and content initialization through multiple formats.

Review Change Stack

@github-actions github-actions Bot added e2e-test enhancement New feature or request labels May 22, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Walkthrough

This PR adds eight Playwright test specifications for TinyEditor demo features. Tests cover character counter limits, content export via Delta and HTML formats, interactive header list panels, readonly mode behavior, and Delta content initialization. All tests follow a consistent pattern: navigate to demo, verify UI visibility, check initial state, perform user interactions, and assert expected outcomes.

Changes

TinyEditor Demo E2E Test Suite

Layer / File(s) Summary
Character counter validation
packages/docs/fluent-editor/demos/counter.spec.ts, packages/docs/fluent-editor/demos/counter-count.spec.ts
Tests verify character counters initialize with correct limits (500 and 2000 characters) and update accurately when text is typed into the editor.
Content retrieval and synchronization
packages/docs/fluent-editor/demos/get-content-delta.spec.ts, packages/docs/fluent-editor/demos/get-content-html.spec.ts
Tests verify Delta JSON and HTML previews initialize correctly and remain synchronized with editor content as text is modified.
Interactive UI components and panels
packages/docs/fluent-editor/demos/header-list.spec.ts, packages/docs/fluent-editor/demos/header-list-container.spec.ts
Tests verify header list panels are initially hidden, become visible when toolbar buttons are clicked, display expected heading entries, and return to hidden state on subsequent clicks.
Editor modes and content initialization
packages/docs/fluent-editor/demos/readonly.spec.ts, packages/docs/fluent-editor/demos/set-content-delta.spec.ts
Tests verify readonly editor renders without toolbar and remains immutable after user interaction, and Delta-initialized editor renders expected content on page load.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

🐰 Eight tests hop into the warren,
Each one checks a feature's carry-on,
Counters count, content syncs bright,
Headers toggle left and right,
Readonly stands firm, Delta flows true—
The demo suite is testing through! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'feat: add e2e' is vague and generic, using non-descriptive terms that don't convey specific information about what e2e tests are being added or which components they cover. Provide a more specific title that describes which demos or features the e2e tests cover, such as 'feat: add e2e tests for counter, header-list, and content demos'.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wyp/add-e2e-0520

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

♻️ Duplicate comments (1)
packages/docs/fluent-editor/demos/counter-count.spec.ts (1)

4-4: ⚠️ Potential issue | 🟠 Major | ⚖️ Poor tradeoff

Replace hardcoded URL with environment-based configuration.

Same issue as counter.spec.ts: the hardcoded localhost:5173 URL will fail outside local development. Both test files should use Playwright's baseURL configuration.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/docs/fluent-editor/demos/counter-count.spec.ts` at line 4, Replace
the hardcoded absolute URL used in the test (the call await
page.goto('http://localhost:5173/tiny-editor/docs/demo/counter')) with a path
that relies on Playwright's baseURL config so tests run outside local dev;
change the argument to the relative path for the demo page (e.g.
'/tiny-editor/docs/demo/counter') so page.goto uses baseURL from Playwright
configuration rather than embedding localhost:5173.
🧹 Nitpick comments (10)
packages/docs/fluent-editor/demos/counter-count.spec.ts (1)

3-18: 💤 Low value

Consider extracting shared test logic to reduce duplication.

Both counter.spec.ts and counter-count.spec.ts follow an identical test structure with only selector indices and expected counter values differing. Extracting a shared helper function would improve maintainability.

♻️ Example helper function

Create a shared test utility:

// test-helpers/counter.ts
import { expect, Page } from '`@playwright/test`'

export async function testCounterDemo(
  page: Page,
  index: number,
  maxChars: number
) {
  const toolbar = page.locator('.ql-toolbar').nth(index)
  const editor = page.locator('.ql-editor').nth(index)
  const counter = page.locator('.ql-counter').nth(index)

  await expect(toolbar).toBeVisible()
  await expect(editor).toBeVisible()
  await expect(counter).toBeVisible()
  await expect(counter).toHaveText(`0/${maxChars} characters`)

  await editor.click()
  await page.keyboard.type('abc')
  await expect(counter).toHaveText(`3/${maxChars} characters`)
}

Then simplify both test files:

test('has toolbar and custom max character counter', async ({ page }) => {
  await page.goto('/tiny-editor/docs/demo/counter')
  await testCounterDemo(page, 1, 2000)
})
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/docs/fluent-editor/demos/counter-count.spec.ts` around lines 3 - 18,
Extract the duplicated Playwright assertions into a shared helper function
(e.g., export async function testCounterDemo(page: Page, index: number,
maxChars: number)) that locates toolbar/editor/counter using .nth(index),
asserts visibility and initial counter text, types 'abc' and asserts updated
counter text; then replace the body of both counter.spec.ts and
counter-count.spec.ts with a simple call to testCounterDemo(page, <index>,
<maxChars>) after navigating to the demo and add the necessary import from the
new test helper module.
packages/docs/fluent-editor/demos/counter.spec.ts (1)

6-8: ⚡ Quick win

Consider using test IDs for more robust selectors.

CSS class selectors like .ql-toolbar, .ql-editor, and .ql-counter are tied to Quill's internal implementation and may break if the library updates its DOM structure. Test-specific data attributes provide more stability.

🎯 Example using data-testid attributes

If the component markup supports it:

-  const toolbar = page.locator('.ql-toolbar').first()
-  const editor = page.locator('.ql-editor').first()
-  const counter = page.locator('.ql-counter').first()
+  const toolbar = page.getByTestId('counter-toolbar')
+  const editor = page.getByTestId('counter-editor')
+  const counter = page.getByTestId('counter-display')
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/docs/fluent-editor/demos/counter.spec.ts` around lines 6 - 8,
Replace fragile Quill class selectors in the test with stable test IDs: update
the component to add data-testid attributes (e.g., data-testid="editor-toolbar",
"editor-body", "editor-counter") if not already present, then change the
locators in the spec that use page.locator('.ql-toolbar'),
page.locator('.ql-editor'), and page.locator('.ql-counter') to use attribute
selectors like page.locator('[data-testid="editor-toolbar"]'),
page.locator('[data-testid="editor-body"]'), and
page.locator('[data-testid="editor-counter"]') so toolbar, editor, and counter
target stable test IDs instead of library classes.
packages/docs/fluent-editor/demos/get-content-delta.spec.ts (2)

4-4: ⚡ Quick win

Use configurable base URL instead of hardcoded localhost.

The hardcoded localhost:5173 URL reduces test portability across different environments (CI, staging, production). Consider using Playwright's baseURL configuration option and relative paths.

♻️ Proposed fix

In your playwright.config.ts, add:

use: {
  baseURL: process.env.BASE_URL || 'http://localhost:5173'
}

Then update the test:

-  await page.goto('http://localhost:5173/tiny-editor/docs/demo/get-content')
+  await page.goto('/tiny-editor/docs/demo/get-content')
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/docs/fluent-editor/demos/get-content-delta.spec.ts` at line 4,
Replace the hardcoded URL in the test's page.goto call with a relative path and
rely on Playwright's baseURL: update playwright.config.ts to set use.baseURL to
process.env.BASE_URL || 'http://localhost:5173', then change the test's
page.goto('http://localhost:5173/tiny-editor/docs/demo/get-content') to
page.goto('/tiny-editor/docs/demo/get-content') so the test uses the
configurable base URL; keep the same path segment used in the original page.goto
call.

17-17: ⚡ Quick win

Prefer .textContent over .innerText for better performance.

While both work for parsing JSON content, .textContent is faster and more reliable as it doesn't trigger reflow calculations. ESLint's unicorn/prefer-dom-node-text-content rule flags this.

♻️ Proposed fix
-  const initialDelta = JSON.parse(await preview.innerText())
+  const initialDelta = JSON.parse(await preview.textContent())
-  const updatedDelta = JSON.parse(await preview.innerText())
+  const updatedDelta = JSON.parse(await preview.textContent())

Also applies to: 30-30

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/docs/fluent-editor/demos/get-content-delta.spec.ts` at line 17, The
test uses preview.innerText() when parsing JSON into initialDelta; change calls
to use preview.textContent() instead (e.g., where initialDelta is assigned and
the other occurrence at the second instance) to avoid reflow and satisfy the
unicorn/prefer-dom-node-text-content rule—locate the preview.innerText() usages
in the spec (the expression assigning initialDelta and the other similar call)
and replace them with preview.textContent() before JSON.parse.
packages/docs/fluent-editor/demos/get-content-html.spec.ts (1)

12-12: ⚡ Quick win

Use configurable base URL instead of hardcoded localhost.

The hardcoded localhost:5173 URL reduces test portability across different environments (CI, staging, production). Consider using Playwright's baseURL configuration option and relative paths.

♻️ Proposed fix

In your playwright.config.ts, add:

use: {
  baseURL: process.env.BASE_URL || 'http://localhost:5173'
}

Then update the test:

-  await page.goto('http://localhost:5173/tiny-editor/docs/demo/get-content')
+  await page.goto('/tiny-editor/docs/demo/get-content')
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/docs/fluent-editor/demos/get-content-html.spec.ts` at line 12, The
test in get-content-html.spec.ts uses a hardcoded URL in the page.goto call;
switch to Playwright's baseURL instead by setting use.baseURL in
playwright.config.ts (e.g., bind it to process.env.BASE_URL with a fallback) and
change the page.goto call in get-content-html.spec.ts to a relative path like
'/tiny-editor/docs/demo/get-content' so tests run in different environments;
update any imports or test setup referencing the full URL to use the relative
path and ensure the environment variable is documented for CI.
packages/docs/fluent-editor/demos/header-list-container.spec.ts (1)

3-26: ⚡ Quick win

Consider consolidating duplicate test logic.

Both header-list.spec.ts and header-list-container.spec.ts navigate to the same URL and follow nearly identical test flows, differing only in block index and expected header content. This duplication could be reduced by using a parameterized test or extracting shared logic into helper functions.

♻️ Example consolidation approach
import { expect, test } from '`@playwright/test`'

test.describe('header list demos', () => {
  const testCases = [
    { blockIndex: 0, headerListIndex: 0, expectedHeaders: ['header 1', 'header 1.1', 'header 2'] },
    { blockIndex: 1, headerListIndex: 1, expectedHeaders: ['header 1', 'header 2.1.1', 'header 6'] }
  ]

  for (const { blockIndex, headerListIndex, expectedHeaders } of testCases) {
    test(`block ${blockIndex}: toggles header list panel`, async ({ page }) => {
      await page.goto('http://localhost:5173/tiny-editor/docs/demo/header-list')
      
      const block = page.locator('.vp-raw').nth(blockIndex)
      const toolbar = block.locator('.ql-toolbar').first()
      const editor = block.locator('.ql-editor').first()
      const headerList = block.locator('.header-list').first()
      const headerListBtn = toolbar.locator('.ql-header-list')

      await expect(toolbar).toBeVisible({ timeout: 30_000 })
      await expect(editor).toBeVisible({ timeout: 30_000 })
      await expect(headerListBtn).toBeVisible()
      await expect(editor.locator('h1').first()).toHaveText('header 1')
      await expect(headerList).toHaveClass(/is-hidden/)

      await headerListBtn.click()
      await expect(headerList).not.toHaveClass(/is-hidden/)
      for (const header of expectedHeaders) {
        await expect(headerList).toContainText(header)
      }

      await headerListBtn.click()
      await expect(headerList).toHaveClass(/is-hidden/)
    })
  }
})
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/docs/fluent-editor/demos/header-list-container.spec.ts` around lines
3 - 26, The two tests duplicate navigation and interaction logic; refactor by
extracting a parameterized test or helper to iterate cases (e.g., use a
test.describe with a testCases array) instead of duplicating code in
header-list.spec.ts and header-list-container.spec.ts; move shared steps
(page.goto, locating block via '.vp-raw'.nth(blockIndex), toolbar '.ql-toolbar',
editor '.ql-editor', headerList '.header-list', headerListBtn '.ql-header-list',
visibility checks and toggle/assert sequence) into the helper/loop and supply
different blockIndex/headerListIndex and expectedHeaders arrays so both
scenarios run from a single test implementation.
packages/docs/fluent-editor/demos/header-list.spec.ts (1)

4-4: ⚡ Quick win

Consider using configurable base URL.

The hardcoded localhost:5173 URL makes tests environment-dependent. Playwright's baseURL config option would improve portability.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/docs/fluent-editor/demos/header-list.spec.ts` at line 4, The test
currently hardcodes the host in the page.goto call (the string passed to
page.goto in header-list.spec.ts), which ties it to localhost:5173; change the
test to use the Playwright baseURL by calling page.goto with a relative path
(e.g., '/tiny-editor/docs/demo/header-list') or read from the test config so it
honors Playwright's baseURL setting in the config, ensuring portability across
environments.
packages/docs/fluent-editor/demos/set-content-delta.spec.ts (2)

4-4: ⚡ Quick win

Consider parameterizing the base URL.

The hardcoded localhost:5173 URL could be extracted to a configuration file or environment variable to support different environments (CI, staging, local dev with different ports).

📝 Example refactor
+const BASE_URL = process.env.BASE_URL || 'http://localhost:5173'
+
 test('should initialize editor with Delta content', async ({ page }) => {
-  await page.goto('http://localhost:5173/tiny-editor/docs/demo/set-content')
+  await page.goto(`${BASE_URL}/tiny-editor/docs/demo/set-content`)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/docs/fluent-editor/demos/set-content-delta.spec.ts` at line 4, The
test currently uses a hardcoded URL in the page.goto call
('http://localhost:5173/tiny-editor/docs/demo/set-content'); change it to read a
base URL from configuration or an environment variable (e.g., BASE_URL or a test
framework baseURL) and concatenate the path '/tiny-editor/docs/demo/set-content'
so the test can run in CI/staging/local with different hosts/ports; update the
reference in set-content-delta.spec.ts where page.goto is called to use the
configurable base URL.

6-6: ⚡ Quick win

Replace positional selector with a more specific locator.

Using .nth(1) to select the second toolbar is brittle and will break if the page structure changes (e.g., if another toolbar is added before this one). Consider using a more specific selector like an ID, data-testid attribute, or a scoped locator.

🎯 More stable selector options

Option 1: Use data-testid attribute in the component:

-  const toolbar = page.locator('.ql-toolbar').nth(1)
+  const toolbar = page.locator('[data-testid="set-content-delta-toolbar"]')

Option 2: Scope to parent container:

-  const toolbar = page.locator('.ql-toolbar').nth(1)
+  const toolbar = page.locator('`#editor-set-content-delta`').locator('.ql-toolbar')
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/docs/fluent-editor/demos/set-content-delta.spec.ts` at line 6, The
test uses a brittle positional selector by assigning toolbar =
page.locator('.ql-toolbar').nth(1); replace this with a more specific locator:
either add and use a stable attribute (e.g., data-testid on the toolbar
component and locate via page.locator('[data-testid="editor-toolbar"]')) or
scope the query to the editor container (e.g.,
page.locator('.editor-container').locator('.ql-toolbar') or similar) so the
toolbar variable targets the intended toolbar without using .nth(1).
packages/docs/fluent-editor/demos/readonly.spec.ts (1)

20-20: ⚡ Quick win

Consider parameterizing the base URL.

The hardcoded localhost:5173 URL could be extracted to a configuration file or environment variable to support different environments (CI, staging, local dev with different ports).

📝 Example refactor
+const BASE_URL = process.env.BASE_URL || 'http://localhost:5173'
+
 test('renders readonly editor without toolbar', async ({ page }) => {
-  await page.goto('http://localhost:5173/tiny-editor/docs/demo/readonly')
+  await page.goto(`${BASE_URL}/tiny-editor/docs/demo/readonly`)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/docs/fluent-editor/demos/readonly.spec.ts` at line 20, The test
currently hardcodes the base URL in the call to
page.goto('http://localhost:5173/tiny-editor/docs/demo/readonly'); change this
to use a configurable base URL (e.g., read from an environment variable like
BASE_URL or a test config constant) and compose the path
'/tiny-editor/docs/demo/readonly' against that base; update the reference in
readonly.spec.ts where page.goto(...) is called so CI/staging/local ports can be
overridden without changing the test file.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/docs/fluent-editor/demos/counter-count.spec.ts`:
- Around line 6-8: The test assumes there are at least two instances by using
.nth(1) on toolbar, editor, and counter which can cause flaky timeouts; before
calling .nth(1) check the locator counts (e.g., await toolbar.count()/await
editor.count()/await counter.count() or expect(await
toolbar.count()).toBeGreaterThan(1)) and fail with a clear assertion if fewer
than 2 exist, or replace .nth(1) with a more specific selector/test-id for the
second demo so you only target a known element.

In `@packages/docs/fluent-editor/demos/counter.spec.ts`:
- Line 4: The test currently calls page.goto with a hardcoded
'http://localhost:5173/tiny-editor/docs/demo/counter'; change it to use
Playwright's baseURL or an environment variable instead: configure baseURL in
playwright.config.ts (e.g., set use.baseURL = process.env.BASE_URL ||
'http://localhost:5173') and update the test's page.goto call in counter.spec.ts
to navigate using a relative path like '/tiny-editor/docs/demo/counter' (or
build the URL from process.env.BASE_URL) so CI/staging/prod can override the
host.

In `@packages/docs/fluent-editor/demos/get-content-html.spec.ts`:
- Line 27: Resolve both promises before asserting: await editor.innerHTML() into
a variable (e.g., editorHtml) and await preview.innerHTML() into a variable
(e.g., previewHtml), then call expect(previewHtml).toEqual(editorHtml). This
removes the double-await inside expect and ensures both HTML snapshots are
captured deterministically using the preview and editor handles.
- Around line 22-23: The test is using an incorrect double-await pattern with
the assertions; replace the `await expect(await editor.innerHTML())` and `await
expect(await preview.innerHTML())` usage by awaiting the inner promise and
passing its result to expect (i.e., use expect(await
editor.innerHTML()).toEqual(initialHtml) and expect(await
preview.innerHTML()).toEqual(initialHtml)), or alternatively use Playwright's
built-in async matchers like await expect(editor).toHaveJSProperty/ toHaveText
equivalent—update the assertions referencing editor.innerHTML and
preview.innerHTML accordingly so there is only one await per value and not an
outer await on expect.

In `@packages/docs/fluent-editor/demos/header-list-container.spec.ts`:
- Around line 6-10: The test currently selects headerList from page.locator
which is inconsistent with toolbar/editor scoped to block and can pick the wrong
element; change headerList to be scoped to block (use
block.locator('.header-list').first() or block.locator('.header-list').nth(0))
so headerList is found inside the same block as toolbar/editor and
headerListBtn.

In `@packages/docs/fluent-editor/demos/header-list.spec.ts`:
- Around line 6-10: The test scopes toolbar and editor to block.locator(...) but
headerList is selected from page.locator(...), causing possible flakiness;
change the headerList locator to be scoped to the same block (use
block.locator('.header-list').nth(0) or block.locator('.header-list').first())
so headerList targets the header list within the same block as toolbar/editor
(also ensure headerListBtn remains toolbar.locator('.ql-header-list')).

---

Duplicate comments:
In `@packages/docs/fluent-editor/demos/counter-count.spec.ts`:
- Line 4: Replace the hardcoded absolute URL used in the test (the call await
page.goto('http://localhost:5173/tiny-editor/docs/demo/counter')) with a path
that relies on Playwright's baseURL config so tests run outside local dev;
change the argument to the relative path for the demo page (e.g.
'/tiny-editor/docs/demo/counter') so page.goto uses baseURL from Playwright
configuration rather than embedding localhost:5173.

---

Nitpick comments:
In `@packages/docs/fluent-editor/demos/counter-count.spec.ts`:
- Around line 3-18: Extract the duplicated Playwright assertions into a shared
helper function (e.g., export async function testCounterDemo(page: Page, index:
number, maxChars: number)) that locates toolbar/editor/counter using
.nth(index), asserts visibility and initial counter text, types 'abc' and
asserts updated counter text; then replace the body of both counter.spec.ts and
counter-count.spec.ts with a simple call to testCounterDemo(page, <index>,
<maxChars>) after navigating to the demo and add the necessary import from the
new test helper module.

In `@packages/docs/fluent-editor/demos/counter.spec.ts`:
- Around line 6-8: Replace fragile Quill class selectors in the test with stable
test IDs: update the component to add data-testid attributes (e.g.,
data-testid="editor-toolbar", "editor-body", "editor-counter") if not already
present, then change the locators in the spec that use
page.locator('.ql-toolbar'), page.locator('.ql-editor'), and
page.locator('.ql-counter') to use attribute selectors like
page.locator('[data-testid="editor-toolbar"]'),
page.locator('[data-testid="editor-body"]'), and
page.locator('[data-testid="editor-counter"]') so toolbar, editor, and counter
target stable test IDs instead of library classes.

In `@packages/docs/fluent-editor/demos/get-content-delta.spec.ts`:
- Line 4: Replace the hardcoded URL in the test's page.goto call with a relative
path and rely on Playwright's baseURL: update playwright.config.ts to set
use.baseURL to process.env.BASE_URL || 'http://localhost:5173', then change the
test's page.goto('http://localhost:5173/tiny-editor/docs/demo/get-content') to
page.goto('/tiny-editor/docs/demo/get-content') so the test uses the
configurable base URL; keep the same path segment used in the original page.goto
call.
- Line 17: The test uses preview.innerText() when parsing JSON into
initialDelta; change calls to use preview.textContent() instead (e.g., where
initialDelta is assigned and the other occurrence at the second instance) to
avoid reflow and satisfy the unicorn/prefer-dom-node-text-content rule—locate
the preview.innerText() usages in the spec (the expression assigning
initialDelta and the other similar call) and replace them with
preview.textContent() before JSON.parse.

In `@packages/docs/fluent-editor/demos/get-content-html.spec.ts`:
- Line 12: The test in get-content-html.spec.ts uses a hardcoded URL in the
page.goto call; switch to Playwright's baseURL instead by setting use.baseURL in
playwright.config.ts (e.g., bind it to process.env.BASE_URL with a fallback) and
change the page.goto call in get-content-html.spec.ts to a relative path like
'/tiny-editor/docs/demo/get-content' so tests run in different environments;
update any imports or test setup referencing the full URL to use the relative
path and ensure the environment variable is documented for CI.

In `@packages/docs/fluent-editor/demos/header-list-container.spec.ts`:
- Around line 3-26: The two tests duplicate navigation and interaction logic;
refactor by extracting a parameterized test or helper to iterate cases (e.g.,
use a test.describe with a testCases array) instead of duplicating code in
header-list.spec.ts and header-list-container.spec.ts; move shared steps
(page.goto, locating block via '.vp-raw'.nth(blockIndex), toolbar '.ql-toolbar',
editor '.ql-editor', headerList '.header-list', headerListBtn '.ql-header-list',
visibility checks and toggle/assert sequence) into the helper/loop and supply
different blockIndex/headerListIndex and expectedHeaders arrays so both
scenarios run from a single test implementation.

In `@packages/docs/fluent-editor/demos/header-list.spec.ts`:
- Line 4: The test currently hardcodes the host in the page.goto call (the
string passed to page.goto in header-list.spec.ts), which ties it to
localhost:5173; change the test to use the Playwright baseURL by calling
page.goto with a relative path (e.g., '/tiny-editor/docs/demo/header-list') or
read from the test config so it honors Playwright's baseURL setting in the
config, ensuring portability across environments.

In `@packages/docs/fluent-editor/demos/readonly.spec.ts`:
- Line 20: The test currently hardcodes the base URL in the call to
page.goto('http://localhost:5173/tiny-editor/docs/demo/readonly'); change this
to use a configurable base URL (e.g., read from an environment variable like
BASE_URL or a test config constant) and compose the path
'/tiny-editor/docs/demo/readonly' against that base; update the reference in
readonly.spec.ts where page.goto(...) is called so CI/staging/local ports can be
overridden without changing the test file.

In `@packages/docs/fluent-editor/demos/set-content-delta.spec.ts`:
- Line 4: The test currently uses a hardcoded URL in the page.goto call
('http://localhost:5173/tiny-editor/docs/demo/set-content'); change it to read a
base URL from configuration or an environment variable (e.g., BASE_URL or a test
framework baseURL) and concatenate the path '/tiny-editor/docs/demo/set-content'
so the test can run in CI/staging/local with different hosts/ports; update the
reference in set-content-delta.spec.ts where page.goto is called to use the
configurable base URL.
- Line 6: The test uses a brittle positional selector by assigning toolbar =
page.locator('.ql-toolbar').nth(1); replace this with a more specific locator:
either add and use a stable attribute (e.g., data-testid on the toolbar
component and locate via page.locator('[data-testid="editor-toolbar"]')) or
scope the query to the editor container (e.g.,
page.locator('.editor-container').locator('.ql-toolbar') or similar) so the
toolbar variable targets the intended toolbar without using .nth(1).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 91f5dbe5-7fee-44e4-b92d-6222fd997a88

📥 Commits

Reviewing files that changed from the base of the PR and between c7f8992 and fa00a86.

📒 Files selected for processing (8)
  • packages/docs/fluent-editor/demos/counter-count.spec.ts
  • packages/docs/fluent-editor/demos/counter.spec.ts
  • packages/docs/fluent-editor/demos/get-content-delta.spec.ts
  • packages/docs/fluent-editor/demos/get-content-html.spec.ts
  • packages/docs/fluent-editor/demos/header-list-container.spec.ts
  • packages/docs/fluent-editor/demos/header-list.spec.ts
  • packages/docs/fluent-editor/demos/readonly.spec.ts
  • packages/docs/fluent-editor/demos/set-content-delta.spec.ts

Comment thread packages/docs/fluent-editor/demos/counter-count.spec.ts
Comment thread packages/docs/fluent-editor/demos/counter.spec.ts
Comment thread packages/docs/fluent-editor/demos/get-content-html.spec.ts
Comment thread packages/docs/fluent-editor/demos/get-content-html.spec.ts
Comment thread packages/docs/fluent-editor/demos/header-list-container.spec.ts
Comment thread packages/docs/fluent-editor/demos/header-list.spec.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e-test enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant