Mercurial
comparison mrjunejune/test/latex_editor_test.js @ 245:3843bb6253ac
[tools] Debounce live LaTeX preview
Co-authored-by: Copilot <[email protected]>
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Mon, 03 Aug 2026 18:23:36 -0700 |
| parents | b8aa08503378 |
| children | 4f2b50bc78e7 |
comparison
equal
deleted
inserted
replaced
| 244:b8aa08503378 | 245:3843bb6253ac |
|---|---|
| 234 assert.equal( | 234 assert.equal( |
| 235 await page.locator('#downloadButton').getAttribute('download'), | 235 await page.locator('#downloadButton').getAttribute('download'), |
| 236 'document.pdf', | 236 'document.pdf', |
| 237 ); | 237 ); |
| 238 | 238 |
| 239 let livePreviewRequests = 0; | |
| 240 const countLivePreviewRequest = request => { | |
| 241 if (request.url().endsWith('/api/latex/render')) livePreviewRequests++; | |
| 242 }; | |
| 243 page.on('request', countLivePreviewRequest); | |
| 244 const livePreviewResponse = page.waitForResponse(response => | |
| 245 response.url().endsWith('/api/latex/render') && | |
| 246 response.status() === 200 | |
| 247 ); | |
| 248 await page.locator('#latexSource').fill(valid.replace('API.', 'API change one.')); | |
| 249 await page.waitForTimeout(100); | |
| 250 await page.locator('#latexSource').fill(valid.replace('API.', 'API change two.')); | |
| 251 await page.waitForTimeout(100); | |
| 252 await page.locator('#latexSource').fill(valid.replace('API.', 'API final change.')); | |
| 253 await livePreviewResponse; | |
| 254 await page.locator('#latexStatus[data-state="ready"]').waitFor(); | |
| 255 page.off('request', countLivePreviewRequest); | |
| 256 assert.equal(livePreviewRequests, 1); | |
| 257 | |
| 239 await page.locator('#autoCompile').uncheck(); | 258 await page.locator('#autoCompile').uncheck(); |
| 240 await page.locator('#latexSource').fill( | 259 await page.locator('#latexSource').fill( |
| 241 String.raw`\documentclass{article}\begin{document}\badcommand\end{document}`, | 260 String.raw`\documentclass{article}\begin{document}\badcommand\end{document}`, |
| 242 ); | 261 ); |
| 243 testingExpectedFailure = true; | 262 testingExpectedFailure = true; |