test(library): cover the Delete… review failure and close-only paths; record coverage floors (#443)

This commit is contained in:
Vito Sansevero
2026-10-28 19:47:32 -07:00
parent 323f2617d8
commit cd82cdcd1b
3 changed files with 37 additions and 10 deletions
@@ -167,3 +167,22 @@ test('a restore since the page loaded, a failed backup, a busy job and an unconf
await expect(toast(page)).toHaveText('The library was restored or moved since this page loaded. Nothing was deleted or archived.');
expect(byText(await items(request),'Dog landscape')).toBeDefined();
});
test('a failed review keeps the selection, and a selection nothing can change opens the close-only review',async({page,request})=>{
const before=await items(request);const guarded=byText(before,'Library extra 0000');
await expect(await request.post('/prompt_manager/bulk/tags',{data:{prompt_ids:[guarded.id],tags:['__protected__']}})).toBeOK();
await page.goto(route);await expect(cards(page)).toHaveCount(before.length);
await box(page,guarded.id).check();
await page.route(`**${PREVIEW}`,item=>item.fulfill({status:500,contentType:'application/json',body:JSON.stringify({success:false,code:'review-failed',error:'x'})}),{times:1});
await bar(page).getByRole('button',{name:'Delete…',exact:true}).click();
await expect(toast(page)).toHaveText('The selected prompts could not be reviewed. Try again.');
await expect(box(page,guarded.id)).toBeChecked();
await expect(bar(page).getByRole('button',{name:'Delete…',exact:true})).not.toHaveAttribute('aria-disabled','true');
await openReview(page);
await expect(review(page)).toHaveAccessibleName('Delete selected prompts');
await expect(review(page).locator('p.small').last()).toHaveText('None of the selected prompts can be deleted or archived.');
await expect(review(page).locator('.dialog-actions > button')).toHaveText(['Close']);
await review(page).getByRole('button',{name:'Close',exact:true}).click();
await expect(bar(page).getByRole('button',{name:'Delete…',exact:true})).not.toHaveAttribute('aria-disabled','true');
expect(byText(await items(request),'Library extra 0000')).toBeDefined();
});
@@ -488,13 +488,15 @@ test('a restore seen finishing keeps New prompt open and reloads the Library aft
test('library heading offers Export then + New prompt, and New opens the saved prompt history',async({page,request})=>{
await page.goto(`${workspace}#/library`);await expect(page.locator('article[data-prompt-id]').first()).toBeVisible();
const actions=headingActions(page).locator('button');
expect(await visibleNames(actions)).toEqual(['Export','+ New prompt']);
// D152 (#443): Show archived prompts (N) comes first, a plain toggle.
expect(await visibleNames(actions)).toEqual(['Show archived prompts (0)','Export','+ New prompt']);
await expect(actions.nth(0)).toHaveAttribute('aria-pressed','false');await expect(actions.nth(0)).not.toHaveClass(/ca-primary/);
// One image is counted in the singular.
const f=page.fixture;await expect(page.locator(`article[data-prompt-id="${f.positive_id}"]`).getByText('1 image',{exact:true})).toHaveCount(1);
await expect(actions.nth(0)).toHaveAccessibleName('Export full Library JSON');await expect(actions.nth(0)).not.toHaveClass(/ca-primary/);
await expect(actions.nth(1)).toHaveClass(/\bca-primary\b/);
for(const index of [0,1])expect((await actions.nth(index).boundingBox()).height).toBeGreaterThanOrEqual(32);
await actions.nth(1).click();const dialog=editorDialog(page);await expect(dialog.getByRole('heading',{name:'New prompt',exact:true})).toBeVisible();await ready(dialog);
await expect(actions.nth(1)).toHaveAccessibleName('Export full Library JSON');await expect(actions.nth(1)).not.toHaveClass(/ca-primary/);
await expect(actions.nth(2)).toHaveClass(/\bca-primary\b/);
for(const index of [0,1,2])expect((await actions.nth(index).boundingBox()).height).toBeGreaterThanOrEqual(32);
await actions.nth(2).click();const dialog=editorDialog(page);await expect(dialog.getByRole('heading',{name:'New prompt',exact:true})).toBeVisible();await ready(dialog);
await field(dialog,'Title').fill('Harbor at dawn');await field(dialog,'Positive prompt').fill('A quiet harbor at dawn');await field(dialog,'Negative prompt (optional)').fill('fog, noise');
await button(dialog,'Save').click();await expect(dialog).toHaveCount(0);
const created=(await(await request.get('/prompt_manager/library?text=quiet%20harbor')).json()).items[0];
+11 -5
View File
@@ -73,7 +73,7 @@
},
"metadata-autocomplete.js": {
"lines": 98,
"branches": 82,
"branches": 83,
"functions": 85,
"statements": 98
},
@@ -353,6 +353,12 @@
"functions": 98,
"statements": 98
},
"workspace/library-delete.mjs": {
"lines": 98,
"branches": 95,
"functions": 92,
"statements": 98
},
"workspace/library-editor-state.mjs": {
"lines": 96,
"branches": 92,
@@ -379,8 +385,8 @@
},
"workspace/library-selection.mjs": {
"lines": 98,
"branches": 86,
"functions": 84,
"branches": 87,
"functions": 89,
"statements": 98
},
"workspace/library-state.mjs": {
@@ -392,7 +398,7 @@
"workspace/library.mjs": {
"lines": 96,
"branches": 85,
"functions": 96,
"functions": 97,
"statements": 96
},
"workspace/local-inspection.mjs": {
@@ -535,7 +541,7 @@
},
"workspace/system-backups.mjs": {
"lines": 95,
"branches": 88,
"branches": 89,
"functions": 94,
"statements": 95
},