(page: Page)
| 24 | } |
| 25 | |
| 26 | const readSourceState = async(page: Page) => { |
| 27 | await page.waitForFunction( |
| 28 | () => { |
| 29 | const root = document.querySelector('.source-code .CodeMirror') as |
| 30 | | (Element & { CodeMirror?: CMInstance }) |
| 31 | | null |
| 32 | if (!root || !root.CodeMirror) return false |
| 33 | const cm = root.CodeMirror |
| 34 | const last = cm.lastLine() |
| 35 | cm.getTokenAt({ line: last, ch: cm.getLine(last).length }, true) |
| 36 | return true |
| 37 | }, |
| 38 | null, |
| 39 | { timeout: 5000 } |
| 40 | ) |
| 41 | |
| 42 | return page.evaluate(() => { |
| 43 | const emTexts = Array.from(document.querySelectorAll('.source-code .CodeMirror .cm-em')).map( |
| 44 | (s) => s.textContent |
| 45 | ) |
| 46 | const mathInline = document.querySelectorAll('.source-code .CodeMirror .cm-math-inline').length |
| 47 | const mathBlock = document.querySelectorAll('.source-code .CodeMirror .cm-math-block').length |
| 48 | return { emTexts, mathInline, mathBlock } |
| 49 | }) |
| 50 | } |
| 51 | |
| 52 | test.describe('Source view: math tokenization (#4121)', () => { |
| 53 | let app: ElectronApplication |
no test coverage detected