From 265a1e6e2ac0e868099e5a84b1d553c1d768c6fa Mon Sep 17 00:00:00 2001 From: Lydia Tools Date: Sun, 1 Nov 2026 13:08:06 +0800 Subject: [PATCH] Wait for async snapshot error in browser check --- tests/compare-browser.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/compare-browser.cjs b/tests/compare-browser.cjs index 1a915db..5b410ed 100644 --- a/tests/compare-browser.cjs +++ b/tests/compare-browser.cjs @@ -14,7 +14,7 @@ const repo=(id,full_name,stars)=>({id,full_name,html_url:'https://github.com/'+f await page.waitForFunction(()=>!document.getElementById('result').hidden);assert.match(await page.locator('#rows').innerText(),/example\/renamed/);assert.match(await page.locator('#rows').innerText(),/example\/old/);assert.match(await page.locator('#rows').innerText(),/\+7/);assert.match(await page.locator('#missing').innerText(),/1.*1/);assert.match(await page.locator('#scope').innerText(),/不完整/); await page.setViewportSize({width:390,height:844});assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);await page.screenshot({path:path.join(os.tmpdir(),'gapcue-compare-mobile.png'),fullPage:true}); await page.locator('#language').click();await page.waitForFunction(()=>document.getElementById('scope').textContent.includes('incomplete'));assert.match(await page.locator('#scope').innerText(),/incomplete/); - await page.locator('#second').setInputFiles({name:'bad.json',mimeType:'application/json',buffer:Buffer.from('{bad')});assert.match(await page.locator('#status').innerText(),/Could not read/);assert.equal(await page.locator('#result').isHidden(),true); + await page.locator('#second').setInputFiles({name:'bad.json',mimeType:'application/json',buffer:Buffer.from('{bad')});await page.waitForFunction(()=>document.getElementById('status').innerText.includes('Could not read'));assert.match(await page.locator('#status').innerText(),/Could not read/);assert.equal(await page.locator('#result').isHidden(),true); const offline=await browser.newContext({offline:true});try{const p=await offline.newPage();await p.goto(pathToFileURL(path.join(__dirname,'../app/compare.html')).href);await p.locator('#first').setInputFiles(aPath);await p.locator('#second').setInputFiles(bPath);await p.waitForFunction(()=>!document.getElementById('result').hidden);assert.match(await p.locator('#rows').innerText(),/\+7/);}finally{await offline.close()} assert.deepEqual(errors,[]);console.log('Repository snapshots: downloads, stable IDs, partial results, language, malformed input, mobile and offline passed.'); }finally{await ctx.close();await browser.close();await new Promise(r=>server.close(r))}