Ask in the page's own dialog, not confirm(), which the iOS app answered Cancel (#462)
Deleting a downloaded file from the iOS app did nothing: no DELETE reached ipx-web or ipx.
WKWebView answers confirm() Cancel without showing it unless the app implements the panel,
which 614f270 does (#453), but only once the app is rebuilt. ask() is a <dialog> of the
page's own, in the top layer, so it opens over a dialog already up (the file menu, Settings)
and leaves it as it was, and Escape answers it alone. Every confirm() in the page and the
admin page goes through it; the tests answer it rather than the browser's dialog, and the
warning before sharing a feed with its key in the address, untested before, now is.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,8 @@ import type { Locator, Page, Request } from '@playwright/test';
|
||||
declare global {
|
||||
interface Window { started: string[]; done: boolean; shared: ShareData[] }
|
||||
}
|
||||
/// Answers the page's own question (#462): yes, or Cancel.
|
||||
const answer = (page: Page, yes = true) => page.locator(`dialog.ask [value="${yes ? 'y' : ''}"]`).click();
|
||||
/// What a failed `ipx` command said, from execFileSync's error.
|
||||
const said = (e: unknown) => { const x = e as { stderr?: unknown, stdout?: unknown }; return String(x.stderr || x.stdout); };
|
||||
|
||||
@@ -865,18 +867,15 @@ test('deleting a shared file warns that it is everyone\'s copy', async ({ page }
|
||||
const del = page.locator('#modalCard [data-m="del"]');
|
||||
await expect(del).toHaveText(/^Delete from iPX, for everyone \(shared with 1 other person/);
|
||||
|
||||
// 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: string[] = [];
|
||||
page.on('dialog', d => {
|
||||
seen.push(d.message());
|
||||
if (seen.length === 1) d.accept();
|
||||
else d.dismiss();
|
||||
});
|
||||
// Two questions: the page's own, then the server's, because someone else has not played
|
||||
// it. Yes to the first, Cancel to the second, and the file must survive.
|
||||
await del.click();
|
||||
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');
|
||||
const ask = page.locator('dialog.ask');
|
||||
await expect(ask).toContainText('shared with 1 other person');
|
||||
await answer(page);
|
||||
await expect(ask).toContainText('one copy of this file');
|
||||
await answer(page, false);
|
||||
await expect(ask).toHaveCount(0);
|
||||
|
||||
await page.reload();
|
||||
await page.locator('.feed', { hasText: 'Test Show' }).click();
|
||||
@@ -913,8 +912,8 @@ test('an admin adds someone, makes them an admin, and removes them', async ({ pa
|
||||
(await (await page.request.get('/api/users')).json()).find((u: Account) => u.name === 'pat')?.admin
|
||||
).toBe(true);
|
||||
|
||||
page.once('dialog', d => d.accept());
|
||||
await row.locator('[data-a="rm"]').click();
|
||||
await answer(page);
|
||||
await expect(row).toHaveCount(0);
|
||||
});
|
||||
|
||||
@@ -1494,14 +1493,15 @@ test('the player keeps its speed and volume, marks an item played to its end rea
|
||||
});
|
||||
|
||||
test('a deleted file looks as if it was never downloaded', async ({ page }) => {
|
||||
// Other people subscribe to Picture Blog by now, so both prompts come; take them.
|
||||
page.on('dialog', d => d.accept());
|
||||
// Other people subscribe to Picture Blog by now, so both questions come; yes to each.
|
||||
await page.locator('.feed', { hasText: 'Picture Blog' }).click();
|
||||
const row = page.locator('.ep', { hasText: 'An Article' });
|
||||
await expect(row).toBeVisible({ timeout: 20_000 });
|
||||
await row.click();
|
||||
await page.locator('#files .encbox [data-a="more"]').last().click();
|
||||
await page.locator('#modalCard [data-m="del"]').click();
|
||||
await answer(page);
|
||||
await answer(page);
|
||||
|
||||
// No "reaped", no chip at all: just the way to get it again.
|
||||
await expect(row.locator('.kind.here')).toHaveCount(0);
|
||||
@@ -1575,8 +1575,8 @@ test('All Subscriptions marks everything read, across every feed', async ({ page
|
||||
await expect(page.locator('#epSearch')).toHaveAttribute('placeholder', 'Search');
|
||||
await expect(page.locator('#epSearch')).toHaveAccessibleName('Search All Subscriptions');
|
||||
|
||||
page.once('dialog', d => d.accept());
|
||||
await page.locator('#content .acts [data-a="readall"]').click();
|
||||
await answer(page);
|
||||
await expect(all.locator('.badge')).toHaveText('0');
|
||||
await page.locator('.tabs button', { hasText: 'Unread' }).click();
|
||||
await expect(page.locator('.ep')).toHaveCount(0);
|
||||
@@ -1880,8 +1880,8 @@ test('an admin removes a feed from the directory, and unblocks it (#206)', async
|
||||
await piper.locator('.show [data-a="drefresh"]').click();
|
||||
await expect(piper.locator('.toast', { hasText: 'Checked' })).toBeVisible();
|
||||
await expect(piper.locator('.show [data-a="dremove"]')).toHaveCount(1);
|
||||
piper.once('dialog', d => d.accept());
|
||||
await piper.locator('.show [data-a="dremove"]').click();
|
||||
await answer(piper);
|
||||
await expect(piper.locator('.show h2')).toHaveCount(0);
|
||||
expect(await listed()).not.toContain('Aardvark Radio');
|
||||
} finally {
|
||||
@@ -2318,10 +2318,8 @@ test('Share hands the feed, and an episode as a link to its page on ipx-play (#4
|
||||
const paid = await page.evaluate(() => api('/api/entries/paid-show/paid-1/share', { method: 'POST', body: '{}' }));
|
||||
expect(paid).toEqual({ url: null, why: 'private' });
|
||||
// Through the same menu all the same: the sheet needs a press of its own after that request
|
||||
// (#452), and a key in the address is warned of there, not asked with confirm(), which the iOS
|
||||
// app answers Cancel (#453).
|
||||
// (#452), and a key in the address is warned of there rather than asked first.
|
||||
await page.evaluate(async () => {
|
||||
window.confirm = () => false;
|
||||
const e = (await api('/api/feeds/paid-show/entries') as ListPage).entries[0];
|
||||
await shareEpisode({ ...e, link: 'https://www.patreon.com/posts/1?auth=secret123' }, null);
|
||||
});
|
||||
@@ -2341,6 +2339,22 @@ test('Share hands the feed, and an episode as a link to its page on ipx-play (#4
|
||||
await expect(page.locator('#modalCard')).not.toContainText('own access');
|
||||
await page.locator('#shlink').click();
|
||||
await expect.poll(() => page.evaluate(() => window.shared.at(-1)?.url)).toBe('https://www.patreon.com/glasscannon/posts/1');
|
||||
await page.keyboard.press('Escape');
|
||||
|
||||
// A feed whose address carries its key is asked about first, in the page's own dialog (#462):
|
||||
// Cancel shares nothing, and Escape closes the question alone.
|
||||
const before = await page.evaluate(() => window.shared.length);
|
||||
await page.locator('.feed', { hasText: 'Paid Show' }).click();
|
||||
await page.locator('#content .acts [data-a="share"]').click();
|
||||
await expect(page.locator('dialog.ask')).toContainText('includes your own access');
|
||||
await answer(page, false);
|
||||
await page.locator('#content .acts [data-a="share"]').click();
|
||||
await page.keyboard.press('Escape');
|
||||
await expect(page.locator('dialog.ask')).toHaveCount(0);
|
||||
expect(await page.evaluate(() => window.shared.length)).toBe(before);
|
||||
await page.locator('#content .acts [data-a="share"]').click();
|
||||
await answer(page);
|
||||
await expect.poll(() => page.evaluate(() => window.shared.at(-1)?.url)).toBe('http://127.0.0.1:8792/paid.xml?auth=secret123');
|
||||
});
|
||||
|
||||
test('a refresh button turns from the press to the end of the scan it asked for', async ({ page }) => {
|
||||
@@ -2771,8 +2785,8 @@ signalsTest('a Signal is renamed from its own page and deleted from there', asyn
|
||||
const one = async () => (await (await page.request.get('/api/signals')).json() as Signal[]).find(s => s.id === id);
|
||||
expect((await one())?.name).toBe('Bread and cakes');
|
||||
|
||||
page.once('dialog', d => d.accept());
|
||||
await page.locator('#content [data-a="rm"]').click();
|
||||
await answer(page);
|
||||
await expect(page.locator('.toast', { hasText: 'Deleted' })).toBeVisible();
|
||||
await expect(page.locator('#feedlist .feed.child', { hasText: 'Bread and cakes' })).toHaveCount(0);
|
||||
expect(await one()).toBeUndefined();
|
||||
@@ -2798,8 +2812,8 @@ signalsTest('Signals are turned on in Settings with a key TypeSafe takes, and of
|
||||
await page.locator('#stskey').fill('test-key');
|
||||
await page.locator('#stskey').blur();
|
||||
await expect(page.locator('#feedlist .sigs')).toHaveCount(1);
|
||||
page.once('dialog', d => d.accept());
|
||||
await page.locator('#ssigon').uncheck();
|
||||
await page.locator('#ssigon').click();
|
||||
await answer(page);
|
||||
await expect(page.locator('#feedlist .sigs')).toHaveCount(0);
|
||||
expect((await (await page.request.get('/api/me')).json()).typesafe_key_set).toBe(false);
|
||||
await page.keyboard.press('Escape');
|
||||
|
||||
Reference in New Issue
Block a user