Repository navigation
test: add BlockNote shared notes e2e tests (backport of #25165) - #25444
ramonlsouza merged 1 commit into
Conversation
…#25165) Backport of bigbluebutton#25165 (merged on v4.0.x-develop) to v3.0.x-develop, bringing the BlockNote shared-notes e2e coverage to the 3.0 line. Cherry-picked a9c0cd5 with two conflicts resolved: - core/elements.ts: added the BlockNote selectors block at the shared-notes export insertion point. - sharednotes/blocknote/util.ts (add/add): merged the new 4.0 helpers (startSharedNotesBlockNote, getBlockNoteReadOnlyLocator) with the existing 3.0 helpers already present from bigbluebutton#25225, keeping a single getBlockNoteEditorLocator. 3.0 adaptations in sharednotes.ts for element renames that only exist on 4.0: - sharedNotesSidebarButton to sharedNotes - messagesSidebarButton to chatButton - lock flow uses manageUsers + lockViewersButton (the 3.0 lock modal has no participant permissions tab) - make-presenter uses userListItem instead of usersListSidebarButton + moreOptionsUserItemButton The "Pin and unpin notes onto whiteboard" scenario is marked fixme on 3.0: a viewer whiteboard does not re-sync to the presenter presentation state after the presenter unpins shared notes (the canvas is not restored). That sync behavior only exists on 4.0.
WalkthroughAdds BlockNote-specific selectors and toolbar targeting, expands shared-notes Playwright coverage, and refactors BlockNote and Etherpad suites to initialize pages per test. New scenarios cover formatting, PDF export, collaboration, read-only access, whiteboard conversion, and pinning. Failed tests now attach browser videos before contexts close. Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant PlaywrightTest
participant BlockNoteSharedNotes
participant SharedNotesUI
participant ExportEndpoint
participant Whiteboard
PlaywrightTest->>BlockNoteSharedNotes: Initialize BlockNote shared notes
BlockNoteSharedNotes->>SharedNotesUI: Open and edit notes
SharedNotesUI-->>BlockNoteSharedNotes: Return editor content and formatting state
BlockNoteSharedNotes->>ExportEndpoint: Request PDF export
ExportEndpoint-->>BlockNoteSharedNotes: Return export request
BlockNoteSharedNotes->>Whiteboard: Convert or pin notes
Whiteboard-->>BlockNoteSharedNotes: Show slide or pinned text
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 `@bigbluebutton-tests/playwright/core/setup/fixtures.ts`:
- Around line 9-21: Update the auto fixture callback to depend on the Playwright
context fixture, ensuring teardown runs while the test context is available.
Replace the browser.contexts() discovery in the video collection flow with the
injected context while preserving video collection before context closure and
subsequent cleanup.
In `@bigbluebutton-tests/playwright/sharednotes/blocknote/sharednotes.ts`:
- Around line 248-263: Update the assertions on modEditorLocator and
userEditorLocator to verify the editors’ complete normalized text equals
“Jello,” rather than merely containing it. Preserve the existing synchronization
and timeout behavior while ensuring a failed Control+A replacement, such as
“HelloJello,” does not pass.
- Around line 107-114: Update the PDF export flow around the current request
wait and export click to wait for the matching response instead of only request
dispatch. Follow the validation pattern used by exportEmptyNotesAsPDF(),
asserting a successful response status and PDF content type while preserving the
existing endpoint matching and click behavior.
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e729d01c-8268-4fb9-adcf-5cfa6285dae7
📒 Files selected for processing (7)
bigbluebutton-html5/imports/ui/components/bn-shared-notes/component.tsxbigbluebutton-tests/playwright/core/elements.tsbigbluebutton-tests/playwright/core/setup/fixtures.tsbigbluebutton-tests/playwright/sharednotes/blocknote/sharednotes.spec.tsbigbluebutton-tests/playwright/sharednotes/blocknote/sharednotes.tsbigbluebutton-tests/playwright/sharednotes/blocknote/util.tsbigbluebutton-tests/playwright/sharednotes/etherpad/sharednotes.spec.ts
| async ({ browser }, use, testInfo) => { | ||
| // Before test | ||
| await use(); | ||
| // After test | ||
| // After test — collect video refs before closing (videos finalize on context close) | ||
| const contexts = browser.contexts(); | ||
| const videos: Video[] = []; | ||
| for (const ctx of contexts) { | ||
| for (const pg of ctx.pages()) { | ||
| const v = pg.video(); | ||
| if (v) videos.push(v); | ||
| } | ||
| } | ||
| await Promise.all(contexts.map((context) => context.close())); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
ast-grep outline bigbluebutton-tests/playwright/core/setup/fixtures.ts --view expanded
rg -nP --type=ts -C2 \
"from ['\"].*/core/setup/fixtures['\"]|async\s*\(\{[^}]*\b(page|context)\b" \
bigbluebutton-tests/playwrightRepository: bigbluebutton/bigbluebutton
Length of output: 50384
🏁 Script executed:
sed -n '1,120p' bigbluebutton-tests/playwright/core/setup/fixtures.tsRepository: bigbluebutton/bigbluebutton
Length of output: 1407
🌐 Web query:
Playwright test fixture teardown order auto fixture depends on context browser context pages video attachment teardown order
💡 Result:
In Playwright, fixture execution follows a strict dependency-based order [1][2][3]. For any given fixture, the setup phase occurs before the test or hook that requires it, and the teardown phase occurs after the fixture is no longer needed [1][4]. Key principles governing the teardown order: 1. Dependency Ordering: If fixture A depends on fixture B, B is set up before A, and B is torn down after A [1][5]. 2. LIFO (Last-In, First-Out) Teardown: Teardown generally proceeds in the reverse order of setup [2]. When multiple fixtures are torn down, those with narrower scopes (e.g., test-scoped) are typically torn down before those with broader scopes (e.g., worker-scoped) if they were initialized later [1][4]. 3. Scope Impact: - Test-scoped fixtures (like page and context) are torn down after each test [1][6]. - Worker-scoped fixtures (like browser) are torn down only when the worker process finishes [1][6]. Relationship to Context, Pages, and Videos: - Browser Context and Pages: The page fixture depends on the context fixture [7]. Consequently, the page is torn down before the context is torn down [1][4]. - Video Attachments: Video files are finalized and saved upon the closure of the browserContext [8]. Because the context fixture's teardown is responsible for closing the context, the video is generated and finalized as part of that teardown process [8]. - Auto Fixtures: Automatic fixtures (fixtures with auto: true) are set up before any test-specific or hook-specific fixtures [4][2]. During teardown, they are processed in the reverse order, meaning they are torn down after manual fixtures that were requested by the test [2]. Standard Teardown Sequence (Simplified): 1. Test body finishes [2]. 2. afterEach hooks run [2]. 3. Manual test-scoped fixtures are torn down [2]. 4. Auto test-scoped fixtures are torn down [2]. 5. context fixture is torn down (which closes the context and finalizes associated videos) [1][4][8]. 6. afterAll hooks run [2]. 7. Worker-scoped fixtures (e.g., browser) are torn down when the worker shuts down [4][2].
Citations:
- 1: https://playwright.dev/docs/test-fixtures
- 2: https://testdino.com/blog/playwright-fixtures
- 3: https://testomat.io/blog/what-is-the-use-of-fixtures-in-playwright/
- 4: https://github.com/microsoft/playwright/blob/main/docs/src/test-fixtures-js.md
- 5: https://vitalets.github.io/posts/playwright-in-pictures/how-fixtures-work/
- 6: https://github.com/microsoft/playwright-test/blob/master/docs/setup-teardown.md
- 7: https://playwright.dev/docs/next/api/class-fixtures
- 8: https://playwright.dev/docs/videos
🌐 Web query:
Playwright fixtures teardown order dependency auto fixture context page browser docs
💡 Result:
In Playwright, fixture execution and teardown follow a deterministic, dependency-based order. Execution Order and Dependency Rules: 1. Setup and Teardown: Each fixture is defined by a setup phase (before await use) and a teardown phase (after await use) [1][2][3]. The teardown code runs regardless of whether the test passes or fails [3]. 2. Dependency Order: If fixture A depends on fixture B, Playwright ensures B is set up before A [1][2][4]. Consequently, teardown occurs in the reverse order: A is torn down before B [1][5][3]. 3. Lazy Initialization: Non-automatic fixtures are initialized lazily, only when they are requested by a test or another active fixture [1][2][4]. 4. Scoping: Test-scoped fixtures are torn down after each test [1][2][4]. Worker-scoped fixtures (like the browser) are torn down only when the worker process finishes [1][2][3]. Automatic (Auto) Fixtures: Automatic fixtures (configured with { auto: true }) are set up for every test or worker, even if not explicitly requested by the test [1][2][3]. However, a known behavior is that an auto-fixture must be connected to the active fixture graph to execute—meaning it must either depend on a core fixture (like context or page) or be part of a dependency chain linked to the test [6]. Context, Page, and Browser: These are built-in fixtures [7][8]. - Browser (Worker-scoped): Initialized once per worker process and torn down at the end [1][8]. - Context and Page (Test-scoped): A new BrowserContext and Page are created for every test to ensure isolation, and they are torn down after each test finishes [7][8]. When multiple fixtures (including auto and manual) are used, Playwright resolves the entire graph, initializes all dependencies in the correct order, and tears them down in the exact reverse order [5][3]. Always ensure that teardown code following await use is properly awaited; failure to do so can result in race conditions or state leakage [9].
Citations:
- 1: https://github.com/microsoft/playwright/blob/main/docs/src/test-fixtures-js.md
- 2: https://playwright.dev/docs/test-fixtures
- 3: https://testdino.com/blog/playwright-fixtures
- 4: https://testomat.io/blog/what-is-the-use-of-fixtures-in-playwright/
- 5: https://vitalets.github.io/posts/playwright-in-pictures/how-fixtures-work/
- 6: [Bug]: {auto: true} fixtures don't run unless connected to the active fixture graph microsoft/playwright#38830
- 7: https://playwright.dev/docs/next/api/class-fixtures
- 8: https://github.com/microsoft/playwright-test/blob/master/docs/setup-teardown.md
- 9: https://stevekinney.com/courses/self-testing-ai-agents/fixtures-worker-scoped-test-scoped
Make this fixture depend on context.
Without that dependency, Playwright can tear down the test context before this auto fixture runs, so browser.contexts() may be empty and failed-test videos won't attach.
🤖 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 `@bigbluebutton-tests/playwright/core/setup/fixtures.ts` around lines 9 - 21,
Update the auto fixture callback to depend on the Playwright context fixture,
ensuring teardown runs while the test context is available. Replace the
browser.contexts() discovery in the video collection flow with the injected
context while preserving video collection before context closure and subsequent
cleanup.
| const [request] = await Promise.all([ | ||
| this.modPage.page.context().waitForEvent('request', { | ||
| predicate: (req) => req.url().includes('/hocuspocus/api/documents/') && req.url().includes('/export/pdf'), | ||
| timeout: ELEMENT_WAIT_EXTRA_LONG_TIME, | ||
| }), | ||
| this.modPage.waitAndClick(e.exportNotesAsPDF), | ||
| ]); | ||
| await expect(request.url(), 'should request the PDF export endpoint').toContain('/export/pdf'); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Validate the PDF response, not only request dispatch.
This passes even when export returns an error or non-PDF body. Wait for the matching response and assert its status and content type, as already done by exportEmptyNotesAsPDF().
Proposed fix
- const [request] = await Promise.all([
- this.modPage.page.context().waitForEvent('request', {
- predicate: (req) => req.url().includes('/hocuspocus/api/documents/') && req.url().includes('/export/pdf'),
+ const [response] = await Promise.all([
+ this.modPage.page.context().waitForEvent('response', {
+ predicate: (res) => res.url().includes('/hocuspocus/api/documents/')
+ && res.url().includes('/export/pdf'),
timeout: ELEMENT_WAIT_EXTRA_LONG_TIME,
}),
this.modPage.waitAndClick(e.exportNotesAsPDF),
]);
- await expect(request.url(), 'should request the PDF export endpoint').toContain('/export/pdf');
+ expect(response.status(), 'PDF export should succeed').toBe(200);
+ expect(response.headers()['content-type'] || '').toContain('application/pdf');📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const [request] = await Promise.all([ | |
| this.modPage.page.context().waitForEvent('request', { | |
| predicate: (req) => req.url().includes('/hocuspocus/api/documents/') && req.url().includes('/export/pdf'), | |
| timeout: ELEMENT_WAIT_EXTRA_LONG_TIME, | |
| }), | |
| this.modPage.waitAndClick(e.exportNotesAsPDF), | |
| ]); | |
| await expect(request.url(), 'should request the PDF export endpoint').toContain('/export/pdf'); | |
| const [response] = await Promise.all([ | |
| this.modPage.page.context().waitForEvent('response', { | |
| predicate: (res) => res.url().includes('/hocuspocus/api/documents/') && res.url().includes('/export/pdf'), | |
| timeout: ELEMENT_WAIT_EXTRA_LONG_TIME, | |
| }), | |
| this.modPage.waitAndClick(e.exportNotesAsPDF), | |
| ]); | |
| expect(response.status(), 'PDF export should succeed').toBe(200); | |
| expect(response.headers()['content-type'] || '').toContain('application/pdf'); |
🤖 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 `@bigbluebutton-tests/playwright/sharednotes/blocknote/sharednotes.ts` around
lines 107 - 114, Update the PDF export flow around the current request wait and
export click to wait for the matching response instead of only request dispatch.
Follow the validation pattern used by exportEmptyNotesAsPDF(), asserting a
successful response status and PDF content type while preserving the existing
endpoint matching and click behavior.
| // user waits for mod's text to sync, then selects all and replaces | ||
| await expect(userEditorLocator, 'should sync mod content to user before editing').toContainText('Hello', { | ||
| timeout: ELEMENT_WAIT_TIME, | ||
| }); | ||
| await userEditorLocator.click(); | ||
| await userEditorLocator.press('Control+A'); | ||
| await userEditorLocator.pressSequentially('Jello'); | ||
|
|
||
| await expect(modEditorLocator, 'should the shared notes contain the text "Jello" for the moderator').toContainText( | ||
| /Jello/, | ||
| { timeout: ELEMENT_WAIT_TIME }, | ||
| ); | ||
| await expect(userEditorLocator, 'should the shared notes contain the text "Jello" for the attendee').toContainText( | ||
| /Jello/, | ||
| { timeout: ELEMENT_WAIT_TIME }, | ||
| ); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Assert that the content was replaced completely.
toContainText(/Jello/) also passes for HelloJello, so a failed Control+A replacement remains undetected. Assert exact normalized text on both editors.
Proposed fix
- ).toContainText(
- /Jello/,
+ ).toHaveText(
+ 'Jello',
{ timeout: ELEMENT_WAIT_TIME },
);🤖 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 `@bigbluebutton-tests/playwright/sharednotes/blocknote/sharednotes.ts` around
lines 248 - 263, Update the assertions on modEditorLocator and userEditorLocator
to verify the editors’ complete normalized text equals “Jello,” rather than
merely containing it. Preserve the existing synchronization and timeout behavior
while ensuring a failed Control+A replacement, such as “HelloJello,” does not
pass.
✅ Automated tests have passed! |
19bd7e5
into
bigbluebutton:v3.0.x-develop


What does this PR do?
Backports #25165 (merged on
v4.0.x-develop) tov3.0.x-develop, bringing the BlockNote shared-notes e2e coverage to the 3.0 line. Adds 8 e2e tests mirroring the Etherpad suite (open, type, format, export PDF, export empty PDF, convert to presentation, multi-user edit, view without edit permission), plus the one-linedata-test="blockNoteToolbar"attribute on the toolbar that the suite selects on.Closes #25125 (the same issue the 4.0 PR closed, now for the 3.0 line).
Conflicts resolved (semantic, 2 of 7 files)
The cherry-pick of
a9c0cd5438produced two conflicts, both resolved by merging rather than overwriting:core/elements.ts(content): the BlockNote selectors block was added at the shared-notes export insertion point present on 3.0. No pre-existing duplicates.sharednotes/blocknote/util.ts(add/add): this file already existed on 3.0 from BlockNote - if someone clicks on a link, their name is embedded in the link #25225 with its own helpers (startBlockNoteSharedNotes,getBlockNoteEditorLocator->BLOCKNOTE_EDITOR,enableMarkdownNotesOptions,readLinkAndCursorState,getBlockNoteLinkLocator). The two new 4.0 helpers (startSharedNotesBlockNote,getBlockNoteReadOnlyLocator) were added alongside them, keeping a singlegetBlockNoteEditorLocatorsince[data-test="notes"] .bn-editorand#bn-notes-scroll-container .bn-editorresolve to the same element on 3.0.3.0 adaptations in
sharednotes.tsElement selectors that only exist under their 4.0 names were mapped to the 3.0 client conventions (verified against the 3.0 html5 source):
sharedNotesSidebarButton->sharedNotes,messagesSidebarButton->chatButton, the lock flow usesmanageUsers+lockViewersButton(the 3.0 lock-viewers modal has no participant-permissions tab), and the make-presenter flow usesuserListItem->makePresenter.Validation
Validated against a BBB 3.0 from-source environment running the branch:
util.tsmergeKnown limitation (pin/unpin test)
The 9th test, "Pin and unpin notes onto whiteboard", is kept as
test.fixmeon 3.0. The viewer whiteboard is not restored to the presenter presentation state after the presenter unpins the shared notes (observed consistently across 3 runs on 3.0, while the same scenario passes on 4.0). Whether this is a genuine 3.0 sync gap or a test-adaptation issue is not yet determined, so the scenario is reported as a known limitation rather than a passing case. The make-presenter / second-unpin path in the test body is therefore not exercised while the test is skipped.