fix: keep release notes readable and stabilize mobile verification
This commit is contained in:
1 parent
f161322532
commit
0d19ade4d8
2 files changed
+9
-2
No files matched your search
@@ -21,6 +21,7 @@ test('authenticated update endpoint returns the checker result',async t=>{
|
||||
t.after(async()=>{server.closeAllConnections();await new Promise(resolve=>server.close(resolve));fs.rmSync(dir,{recursive:true,force:true});});
|
||||
const base='http://127.0.0.1:'+server.address().port;
|
||||
const call=(route,body,cookie)=>fetch(base+route,{method:body===undefined?'GET':'POST',headers:{...(body?{'Content-Type':'application/json','Origin':base}:{}),...(cookie?{Cookie:cookie}:{})},body:body===undefined?undefined:JSON.stringify(body)});
|
||||
assert.equal((await call('/api/update')).status,401);
|
||||
const login=await call('/api/login',{username:'admin',password:'Update-test-123'});const cookie=login.headers.get('set-cookie').split(';')[0];
|
||||
const response=await call('/api/update',undefined,cookie);assert.equal(response.status,200);assert.deepEqual(await response.json(),{status:'none',currentVersion:'0.1.0',latest:null});
|
||||
});
|
||||
@@ -40,11 +41,17 @@ test('sidebar displays the current version and a newer release after checking',a
|
||||
const dialog=page.getByRole('dialog',{name:'系统更新',exact:true});await dialog.waitFor();
|
||||
await dialog.getByText('发现新版本 v0.2.0',{exact:true}).waitFor();
|
||||
assert.equal(await dialog.locator('img').count(),0);assert.match(await dialog.locator('pre').textContent(),/<img src=x/);
|
||||
const contrast=await dialog.locator('pre').evaluate(node=>{
|
||||
const canvas=document.createElement('canvas');canvas.width=canvas.height=1;const context=canvas.getContext('2d');
|
||||
const luminance=value=>{context.fillStyle=value;context.fillRect(0,0,1,1);const parts=Array.from(context.getImageData(0,0,1,1).data).slice(0,3).map(v=>{v/=255;return v<=.04045?v/12.92:((v+.055)/1.055)**2.4;});return parts[0]*.2126+parts[1]*.7152+parts[2]*.0722;};
|
||||
const style=getComputedStyle(node),a=luminance(style.color),b=luminance(style.backgroundColor);return (Math.max(a,b)+.05)/(Math.min(a,b)+.05);
|
||||
});assert.ok(contrast>=4.5,'release notes must remain readable on their background');
|
||||
assert.match(await dialog.textContent(),/2026/);assert.equal(await dialog.getByRole('link',{name:'前往发行页面'}).getAttribute('href'),state.latest.url);
|
||||
await dialog.getByRole('button',{name:'关闭',exact:true}).click();await dialog.waitFor({state:'hidden'});
|
||||
state={status:'unavailable',currentVersion:'0.1.0',latest:null};await page.getByRole('button',{name:'检查更新',exact:true}).click();await dialog.getByText('暂时无法检查更新',{exact:true}).waitFor();
|
||||
assert.match(await page.locator('#app-version').textContent(),/v0\.1\.0/);
|
||||
await page.keyboard.press('Escape');await page.setViewportSize({width:390,height:844});await page.getByRole('button',{name:'展开菜单',exact:true}).click();
|
||||
await page.keyboard.press('Escape');await dialog.waitFor({state:'hidden'});await page.setViewportSize({width:390,height:844});await page.getByRole('button',{name:'展开菜单',exact:true}).click();
|
||||
await page.locator('#sidebar-menu.show').waitFor();await page.waitForFunction(()=>!document.querySelector('#sidebar-menu').classList.contains('collapsing'));
|
||||
await page.getByRole('button',{name:'检查更新',exact:true}).click();await dialog.waitFor();assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);
|
||||
assert.deepEqual(errors,[]);
|
||||
});
|
||||
Reference in new issue
Block a user