Align saved video actions and confirm storage removal

This commit is contained in:
Jonathan Sykes
2026-10-03 16:10:46 +08:00
parent cf9b6f4133
commit ca836e0cd2
8 changed files with 143 additions and 18 deletions

View File

@@ -23,6 +23,7 @@ for(const layout of ['classic','glass-stage'])for(const width of [390,1440])for(
await page.locator('#listPane').scrollIntoViewIfNeeded();
if(state==='downloads-empty') {await expect(page.locator('#listFilterBar')).toBeHidden();await expect(page.getByRole('button',{name:'View saved videos',exact:true})).toBeVisible();}
if(state==='downloads-populated') {await expect(page.getByRole('button',{name:/^Pause /})).toHaveCount(2);await expect(page.getByRole('button',{name:/^Retry /})).toHaveCount(1);}
await page.locator('.card').evaluateAll(async nodes => { await Promise.all(nodes.flatMap(node => node.getAnimations().map(animation => animation.finished.catch(() => {})))); });
if(capture)await page.screenshot({path:`/tmp/ytplayer-offline-${capture}-${layout}-${width}-${state}.png`});
});
@@ -36,3 +37,27 @@ test('download cancellation waits for confirmation and filtering keeps queue int
await expect(page.locator('.dl-row')).toHaveCount(1);
expect(await page.evaluate(()=>SaveQueue.pending().length)).toBe(4);
});
for(const layout of ['classic','glass-stage'])for(const width of [390,1440])test(`${layout} Saved actions do not overlap at ${width}px`,async({page})=>{
await page.setViewportSize({width,height:900});await fixture(page,layout,'saved-populated');
await expect(page.locator('.saved-file-action')).toHaveCount(6);
const bounds=await page.locator('.saved-file-actions').first().locator('button').evaluateAll(nodes=>nodes.map(n=>{const r=n.getBoundingClientRect();return {width:r.width,height:r.height,left:r.left,right:r.right,top:r.top};}));
expect(bounds[0].width).toBeGreaterThanOrEqual(44);expect(bounds[0].height).toBeGreaterThanOrEqual(44);
expect(bounds[1].left).toBeGreaterThanOrEqual(bounds[0].right);expect(bounds[1].top).toBe(bounds[0].top);
await expect(page.locator('.saved-storage-summary').getByRole('button',{name:'Clear all saved videos'})).toBeVisible();
});
test('saved deletion is confirmed and a storage failure retains the file',async({page})=>{
await fixture(page,'classic','saved-populated');
await page.evaluate(()=>{API.cacheDelete=async()=>({ok:false,error:'Disk busy'});});
await page.locator('.saved-file-action.danger').first().click();
await expect(page.getByRole('button',{name:'Delete saved file',exact:true})).toBeVisible();
await page.getByRole('button',{name:'Cancel',exact:true}).click();
await expect(page.locator('.saved-card')).toHaveCount(3);
await page.locator('.saved-file-action.danger').first().click();
await page.getByRole('button',{name:'Delete saved file',exact:true}).click();
await expect(page.locator('.saved-card')).toHaveCount(3);
await page.getByRole('button',{name:'Clear all saved videos'}).click();
await expect(page.getByRole('button',{name:'Clear all',exact:true})).toBeVisible();
await page.getByRole('button',{name:'Cancel',exact:true}).click();
await page.locator('#listFilterInput').fill('extended');
await expect(page.locator('.saved-card')).toHaveCount(1);
});