mirror of
https://github.com/mermaid-js/mermaid-live-editor.git
synced 2026-11-04 08:59:08 +00:00
test: insert newlines as text instead of pressing Enter
Monaco looks up word-based quick suggestions asynchronously in the editor worker. At synthetic typing speed the list can still show the word being typed when Enter arrives, and Enter then accepts it as a no-op replacement instead of breaking the line. That dropped the newline in "should update diagram after entire text is removed" about one run in eight once keystrokes stopped rendering synchronously. keyboard.insertText dispatches only an input event, so no suggestion can be accepted. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
1a2a1469b5
commit
981f90ec3a
1 file changed
+11
-1
+11
-1
@@ -30,7 +30,17 @@ export class EditorPage {
|
||||
if (newline) {
|
||||
await this.page.keyboard.press('Enter');
|
||||
}
|
||||
await this.page.keyboard.type(text, { delay: 10 });
|
||||
// Line breaks are inserted as text rather than pressed as Enter: Monaco's
|
||||
// word-based quick suggestions resolve asynchronously, and an Enter that
|
||||
// lands while the list is open accepts the suggestion instead of breaking
|
||||
// the line, which at synthetic typing speed happens often enough to flake.
|
||||
const lines = text.split('\n');
|
||||
for (const [index, line] of lines.entries()) {
|
||||
if (index > 0) {
|
||||
await this.page.keyboard.insertText('\n');
|
||||
}
|
||||
await this.page.keyboard.type(line, { delay: 10 });
|
||||
}
|
||||
}
|
||||
|
||||
async clearEditor() {
|
||||
|
||||
Reference in new issue
Block a user