Warn before deleting a file other people share

A feed with other subscribers labels the button Delete for everyone and
names them in the confirmation. The server decides: if anyone else has
starred the item or not played it, DELETE returns 409 with the reason and
only ?force=true proceeds. A feed's header says when it is shared, which
answers why a file nobody here asked for exists.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AdXho5tTkjFLeUXKbEjKBh
This commit is contained in:
2026-09-11 02:37:07 +00:00
parent f0d03c79c8
commit 686851b448
2 changed files with 39 additions and 9 deletions

View File

@@ -305,7 +305,7 @@ test('a second person has their own feeds and their own read state', async ({ br
});
test('deleting a shared file warns that it is everyone\'s copy', async ({ page }) => {
// Admin and Sam both subscribe to Test Show by now; the daemon downloaded one file.
// Admin and Sam both subscribe to Test Show by now, and the daemon downloaded a file.
await page.getByText('Test Show').click();
await page.locator('.tabs button', { hasText: 'Downloaded' }).click();
const row = page.locator('.ep').first();
@@ -313,13 +313,23 @@ test('deleting a shared file warns that it is everyone\'s copy', async ({ page }
await row.click();
const del = page.locator('#detail button', { hasText: 'Delete' });
await expect(del).toHaveText(/Delete for everyone/);
await expect(del).toHaveText('Delete for everyone');
// First prompt: the browser confirm. Say yes, then decline the server's warning, and
// the file must still be there.
page.once('dialog', d => d.accept());
const second = new Promise(resolve => page.once('dialog', d => { resolve(d.message()); d.dismiss(); }));
// Two prompts: the page's own, then the server's, because someone else has not played
// it. Accept the first, decline the second, and the file must survive.
const seen = [];
page.on('dialog', d => {
seen.push(d.message());
if (seen.length === 1) d.accept();
else d.dismiss();
});
await del.click();
expect(await second).toContain('one copy of this file');
await expect(page.locator('#detail button', { hasText: 'Delete' })).toBeVisible();
await expect.poll(() => seen.length, { timeout: 10_000 }).toBe(2);
expect(seen[0]).toContain('shared with 1 other person');
expect(seen[1]).toContain('one copy of this file');
await page.reload();
await page.getByText('Test Show').click();
await page.locator('.tabs button', { hasText: 'Downloaded' }).click();
await expect(page.locator('.ep').first()).toBeVisible({ timeout: 20_000 });
});