Skip to content

test(shared-notes): wait for the cursor to leave a diagram before typing - #26435

Merged
antobinary merged 1 commit into
bigbluebutton:v4.0.x-developfrom
antobinary:test-400-math-diagram-wait-for-click
Nov 12, 2026
Merged

antobinary merged 1 commit into
bigbluebutton:v4.0.x-developfrom
antobinary:test-400-math-diagram-wait-for-click

Conversation

@antobinary

Copy link
Copy Markdown
Member

What does this PR do?

Makes the BlockNote math and diagram tests wait for a click to reach the editor before they type. It affects two clicks in sharednotes/blocknote/math-diagram.ts: the one on "Notes" in Diagrams stay light cards in dark mode, and the one on the slot in the insertFromSlashMenu helper. Test change only, 3 lines.

Why

Diagrams stay light cards in dark mode failed both attempts in the CI run of #26432, which does not touch shared notes. The editor held Notes with nothing typed after it, then Notesore the switch on the retry, where the test expects Notes before the switch. Since the test landed with #26221 on 2026-11-03 it has failed 12 attempts in 9 CI runs, both attempts in 3 of them.

After Escape, a diagram or block equation keeps the cursor with its source popup closed. While the cursor sits in such a block, SourceBlockWithPreviewExtension in @blocknote/core drops every printable key, and Backspace or Delete remove the block. On a plain click ProseMirror lets the browser move the caret and learns of it only from the asynchronous selectionchange event. The test pressed End and typed right after clicking "Notes", so its keys overtook that event and were dropped while ProseMirror still had the cursor in the diagram. Whatever came after the event landed at the end of "Notes". The 1.5 s pause before the click does not help, because the late event belongs to the click itself. Nobody types within milliseconds of a click, so this is the test's race and not a client bug.

insertFromSlashMenu has the same race when it clicks "diagram slot" right after closing the block equation. There the dropped key is Backspace, and the equation is deleted: Equations and diagrams render for every participant in run 42115106453, and Markdown export keeps equations and diagrams in run 41897184851.

After both clicks the test now waits until no diagram or equation is marked selected (ProseMirror-selectednode). That clears once the editor has taken the click, about 30 ms after it in the replay below. The second click on "Notes", before Control+Z, needs no wait, because BlockNote does not drop Ctrl shortcuts.

How was it tested?

Replayed the test's clicks and keys against the client built from ed6ce71b06 (BlockNote 0.56, as on this branch's base) and read the editor afterwards:

Case Before This PR
Click "Notes" after closing the diagram, then type 0 of 8: Notes, as in the first CI attempt 8 of 8
Click "diagram slot" after closing the block equation 0 of 5: equation deleted 5 of 5
Editor takes the click on "Notes" late 0 of 3 (after the 4th key): Notesore the switch, as in the CI retry 3 of 3 (after 500 ms)

The replay does not run the spec itself; the CI run of this PR does. eslint and prettier pass on both files, and so does the Playwright project's typecheck.

Not in this PR

TXT export keeps formulas with <, > and & flakes on a different race, which #26410 fixes. The two PRs change different lines of math-diagram.ts and merge cleanly in either order.

Closes Issue(s)

None.

"Diagrams stay light cards in dark mode" failed both attempts in the CI
run of an unrelated PR (run 42127401054). The editor held "Notes" with
nothing typed after it, then "Notesore the switch" on the retry, where
the test expects "Notes before the switch". The test has failed 12
attempts in 9 CI runs since it landed on 2026-11-03.

After Escape, a diagram or block equation keeps the cursor with its
source popup closed. While the cursor sits in such a block, BlockNote's
SourceBlockWithPreviewExtension (@blocknote/core) drops every printable
key, and Backspace or Delete remove the block. On a plain click
ProseMirror lets the browser move the caret and learns of it only from
the asynchronous selectionchange event. The test pressed End and typed
right after clicking "Notes", so its keys overtook that event and were
dropped while ProseMirror still had the cursor in the diagram. Whatever
came after the event landed at the end of "Notes". The 1.5 s pause
before the click does not help, because the late event belongs to the
click itself. Nobody types within milliseconds of a click, so this is
the test's race and not a client bug.

insertFromSlashMenu has the same race when it clicks "diagram slot"
right after closing the block equation. There the dropped key is
Backspace, and the equation is deleted ("Equations and diagrams render
for every participant" in run 42115106453, "Markdown export keeps
equations and diagrams" in run 41897184851).

After both clicks the test now waits until no diagram or equation is
marked selected (ProseMirror-selectednode), which clears once the
editor has taken the click. The second click on "Notes", before
Control+Z, needs no wait, because BlockNote does not drop Ctrl
shortcuts.

Replaying the test's clicks and keys against the client built from
ed6ce71 (BlockNote 0.56, as on this base): the click on "Notes" left
0 of 8 runs correct before and 8 of 8 with the wait, and the click on
"diagram slot" kept the equation in 0 of 5 runs before and 5 of 5 with
the wait. Making the editor take the click only after the fourth key
reproduces the retry's "Notesore the switch" in 3 of 3 runs.
@antobinary antobinary added this to the Release 4.0 milestone Nov 6, 2026
@antobinary
antobinary requested a review from GuiLeme November 6, 2026 12:15
@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The changes add a selector for a selected BlockNote preview and check that no such preview is visible after clicking a block in the slash-menu helper and dark-mode test.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Other

Merge Risk: Minimal · up to b4060

No concrete merge-blocking regression is established. The added waits address editor timing; whether they eliminate every reported race remains unverified.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title describes the wait for the editor selection to leave a diagram before typing.
Description check Passed The description explains the selection wait added to the BlockNote tests and its purpose.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Additional comments: 1

bigbluebutton-tests/playwright/sharednotes/blocknote/math-diagram.ts: 1

29-29: Minor · Potential issue · Quick win

Unverified finding
We couldn't verify this from the code. It is shown for review, not as a verified issue.

A zero selected-preview count does not establish that the clicked block has received the editor selection. The same check is used in the dark-mode test.

The assertion can pass immediately, allowing Backspace to delete the previously selected equation or text to be typed at the wrong location.

This can occur when: After Escape, the click's selection update is pending while no selected-preview class is currently present in the DOM.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 36d602fe-35de-485c-a1fd-b21d0a83b96b
Commits

Reviewing files that changed from the base of the PR and between 28d54de and b406054.

Files selected for processing: 2

  • bigbluebutton-tests/playwright/core/elements.ts
  • bigbluebutton-tests/playwright/sharednotes/blocknote/math-diagram.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

✅ Automated tests have passed!

@antobinary
antobinary merged commit df67a37 into bigbluebutton:v4.0.x-develop Nov 12, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants