From b22016cbe523f84a9050169ea446100f4c36cde9 Mon Sep 17 00:00:00 2001
From: rays A subtitle not in the body<\/em><\/p>/);
+ expect(amp['Cut body']!.description).toBe('The whole description');
+ expect(amp['Cut body']!.image).toBe(`${F}/pic.png`);
+ expect(amp['Picture only']!.image).toBe(`${F}/amp-pic.png`);
+ expect((await feed('amp.xml')).feed_category).toBe('Games');
+
+ // WordPress.com's posts, as its API sends them, read as a feed.
+ await expect.poll(async () => Object.keys(await byTitle('wp.json')), { timeout: 20_000 })
+ .toEqual(['WordPress “post”']);
+
+ for (const id of Object.values(ids)) await page.request.delete(`/api/feeds/${encodeURIComponent(id)}`);
+});
+
+test('a feed that starts failing says why, and after a day in words with something to do (#463)', async ({ page }) => {
+ const F = 'http://127.0.0.1:8792';
+ const flip = (to: string) => page.request.get(`${F}/flip?to=${to}`);
+ await flip('ok');
+ const id = (await (await page.request.post('/api/feeds', { data: { url: `${F}/flip.xml` } })).json()).id as string;
+ const feed = async () => (await (await page.request.get('/api/feeds')).json() as Feed[]).find(f => f.id === id)!;
+ await expect.poll(async () => (await feed()).entries, { timeout: 20_000 }).toBe(1);
+ const db = path.join(setup.root, 'data', 'state.db');
+ try {
+ for (const [to, error, reason] of [
+ ['404', /HTTP 404/, 'took this feed down'],
+ ['403', /HTTP 403/, 'refuses'],
+ ['402', /HTTP 402/, 'paid plan'],
+ ['500', /HTTP 500/, null],
+ ['text', /the site sent/, 'sent a message'],
+ ['page', /got a web page, not a feed; it links .*moved\.xml/, 'The feed moved'],
+ ['garbled', /not RSS/, null],
+ ['loop', /redirect/i, null],
+ ['drop', /./, null],
+ ] as const) {
+ await flip(to);
+ await page.request.post('/api/fetch', { data: { feed: id, force: true } });
+ await expect.poll(async () => (await feed()).last_error ?? '', { timeout: 20_000 }).toMatch(error);
+ // A day in, which is when the page names a failure in words.
+ execFileSync('sqlite3', [db, `UPDATE feeds SET error_since = ${Math.floor(Date.now() / 1000) - 2 * 86_400} WHERE id = '${id}'`]);
+ const f = await feed();
+ if (reason) expect(f.failing?.reason, to).toContain(reason);
+ else expect(f.failing, to).toBeNull();
+ if (to === 'page') {
+ expect(f.failing?.new_url).toBe(`${F}/moved.xml`);
+ await page.reload();
+ await page.locator('#feedlist .feed', { hasText: 'Flip Show' }).click();
+ await expect(page.locator('#content .fail')).toContainText('The feed moved');
+ await expect(page.locator('#content [data-ffail="newurl"]')).toBeVisible();
+ }
+ }
+ // Back again: the error goes, and so does the banner.
+ await flip('ok');
+ await page.request.post('/api/fetch', { data: { feed: id, force: true } });
+ await expect.poll(async () => (await feed()).last_error, { timeout: 20_000 }).toBeNull();
+ } finally {
+ await flip('ok');
+ await page.request.delete(`/api/feeds/${encodeURIComponent(id)}`);
+ }
+});
+
test('an item sent as HTML and Markdown switches between them', async ({ page }) => {
const api = (p: string, init?: { method?: string, body?: string }) => page.evaluate(([p, init]) => fetch(p, { headers: { 'Content-Type': 'application/json' }, ...init })
.then((r) => r.json().catch(() => null)), [p, init] as const);
@@ -1028,6 +1127,37 @@ test('an export from one account imports into another', async ({ page, browser }
await ctx.close();
});
+test('ipxd user adds, lists, renames and removes accounts, and says what is wrong (#463)', async () => {
+ // Its own database, as the import test has, so the suite's accounts are not touched.
+ const dir = path.join(setup.root, 'cli-users');
+ fs.rmSync(dir, { recursive: true, force: true });
+ fs.mkdirSync(path.join(dir, 'data'), { recursive: true });
+ fs.writeFileSync(path.join(dir, 'config.toml'),
+ `[general]\ndownload_dir = "${dir}/downloads"\nsocket = "${dir}/ipx.sock"\n`);
+ const env = { ...process.env, IPX_CONFIG: path.join(dir, 'config.toml'), IPX_DATA_DIR: path.join(dir, 'data') };
+ const ipx = (args: string[], input = '') => execFileSync(setup.IPX_BIN, ['user', ...args], { env, input, encoding: 'utf8' });
+ const fails = (args: string[], input = '') => { try { ipx(args, input); } catch (e) { return said(e); } throw new Error(`${args} succeeded`); };
+
+ expect(ipx(['list'])).toContain('no accounts yet');
+ expect(fails(['add', 'ada'])).toContain('no password on stdin');
+ expect(fails(['add', ' '])).toContain('a name is required');
+ expect(ipx(['add', 'Ada'], 'adapassword\n')).toBe('added ada (admin)\n');
+ expect(fails(['add', 'ada'], 'x')).toContain('ada already exists');
+ expect(ipx(['add', 'bo', '--no-password'])).toBe('added bo, signs in through the proxy\n');
+ const list = ipx(['list']);
+ expect(list).toMatch(/^ada\s+admin\s+password\s+added \d{4}-\d\d-\d\d\s+never signed in$/m);
+ expect(list).toMatch(/^bo\s+proxy only\s+added /m);
+
+ expect(ipx(['passwd', 'ada'], 'newpassword')).toContain('password changed for ada');
+ expect(fails(['passwd', 'nobody'], 'x')).toContain('no such account: nobody');
+ expect(fails(['rename', 'bo', 'b;o'])).toContain('not a usable name');
+ expect(fails(['rename', 'bo', 'ada'])).toContain('ada already exists');
+ expect(ipx(['rename', 'bo', 'bea'])).toBe('renamed bo to bea\n');
+ expect(ipx(['rm', 'bea'])).toBe('removed bea\n');
+ expect(fails(['rm', 'bea'])).toContain('no such account: bea');
+ expect(ipx(['list'])).not.toContain('bea');
+});
+
test('ipxd import subscribes the admin, and ipxd export writes the feeds out', async () => {
// Its own config and database. The CLI works in-process, and the suite's running daemon
// reads config.toml once at start, so it would not see what the CLI added anyway.
diff --git a/tests/ui/fixtures/serve.ts b/tests/ui/fixtures/serve.ts
index c14f074..d00a421 100644
--- a/tests/ui/fixtures/serve.ts
+++ b/tests/ui/fixtures/serve.ts
@@ -6,6 +6,8 @@ import path from 'node:path';
const dir = import.meta.dirname;
const port = Number(process.env.FIXTURE_PORT || 8792);
+let flip = 'ok';
+
http.createServer((req, res) => {
// Jev, for Signals (#254): sure of an item whose text has a question's keyword in it. Refuses
// a request in the shape TypeSafe refuses, as it does (#257).
@@ -87,6 +89,59 @@ http.createServer((req, res) => {
next();
return;
}
+ // Feeds in the shapes the others are not (#463): Atom; RSS with a bare "&" and the iTunes and
+ // Media RSS fields; WordPress.com's posts as its API sends them; and replies that are no feed.
+ const at = `http://127.0.0.1:${port}`;
+ const shapes: Record
Post body
' }, jetpack_featured_media_url: `${at}/art.jpg`, + }])], + '/said.txt': ['text/plain', 'Unable to establish a DB connection'], + '/long.txt': ['text/plain', 'This site is down for maintenance and will be back shortly, thank you for your patience while we work'], + '/empty.xml': ['application/xml', ''], + '/garbled.xml': ['application/xml', '