fix(core): copilot test condition & retry (#8665)

This commit is contained in:
darkskygit
2024-11-04 06:17:06 +00:00
parent ee16ea7a5a
commit 2e7a7d5909
3 changed files with 19 additions and 16 deletions

View File

@@ -113,15 +113,22 @@ const focusToEditor = async (page: Page) => {
};
const getEditorContent = async (page: Page) => {
const lines = await page.$$('page-editor .inline-editor');
const contents = await Promise.all(lines.map(el => el.innerText()));
return (
contents
let content = '';
let retry = 3;
while (!content && retry > 0) {
const lines = await page.$$('page-editor .inline-editor');
const contents = await Promise.all(lines.map(el => el.innerText()));
content = contents
// cleanup zero width space
.map(c => c.replace(/\u200B/g, '').trim())
.filter(c => !!c)
.join('\n')
);
.join('\n');
if (!content) {
await page.waitForTimeout(500);
retry -= 1;
}
}
return content;
};
const switchToEdgelessMode = async (page: Page) => {