Browser suite: ipxd list, a feed that moves for good, Atom with a bare ampersand (#463)

API coverage 78.0% to 80.0% (9174 of 11467 lines): follow_move and the catalogue's list,
and the parser's retry of an escaped Atom feed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 00:51:04 +00:00
parent b22016cbe5
commit 2671d13489
2 changed files with 17 additions and 5 deletions

View File

@@ -702,10 +702,12 @@ test('a feed that starts failing says why, and after a day in words with somethi
await expect(page.locator('#content [data-ffail="newurl"]')).toBeVisible(); await expect(page.locator('#content [data-ffail="newurl"]')).toBeVisible();
} }
} }
// Back again: the error goes, and so does the banner. // Back again, from the address it moved to for good: the error goes, and the feed is read
await flip('ok'); // from there from now on.
await flip('moved');
await page.request.post('/api/fetch', { data: { feed: id, force: true } }); await page.request.post('/api/fetch', { data: { feed: id, force: true } });
await expect.poll(async () => (await feed()).last_error, { timeout: 20_000 }).toBeNull(); await expect.poll(async () => (await feed()).last_error, { timeout: 20_000 }).toBeNull();
await expect.poll(async () => (await feed()).url, { timeout: 20_000 }).toBe(`${F}/moved.xml`);
} finally { } finally {
await flip('ok'); await flip('ok');
await page.request.delete(`/api/feeds/${encodeURIComponent(id)}`); await page.request.delete(`/api/feeds/${encodeURIComponent(id)}`);
@@ -1133,8 +1135,9 @@ test('ipxd user adds, lists, renames and removes accounts, and says what is wron
fs.rmSync(dir, { recursive: true, force: true }); fs.rmSync(dir, { recursive: true, force: true });
fs.mkdirSync(path.join(dir, 'data'), { recursive: true }); fs.mkdirSync(path.join(dir, 'data'), { recursive: true });
fs.writeFileSync(path.join(dir, 'config.toml'), fs.writeFileSync(path.join(dir, 'config.toml'),
`[general]\ndownload_dir = "${dir}/downloads"\nsocket = "${dir}/ipx.sock"\n`); `[general]\ndownload_dir = "${dir}/downloads"\nsocket = "${dir}/ipx.sock"\nfetch_internal = ["127.0.0.1"]\n`);
const env = { ...process.env, IPX_CONFIG: path.join(dir, 'config.toml'), IPX_DATA_DIR: path.join(dir, 'data') }; const env = { ...process.env, IPX_CONFIG: path.join(dir, 'config.toml'), IPX_DATA_DIR: path.join(dir, 'data') };
const cli = (args: string[]) => execFileSync(setup.IPX_BIN, args, { env, encoding: 'utf8' });
const ipx = (args: string[], input = '') => execFileSync(setup.IPX_BIN, ['user', ...args], { env, input, encoding: 'utf8' }); 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`); }; const fails = (args: string[], input = '') => { try { ipx(args, input); } catch (e) { return said(e); } throw new Error(`${args} succeeded`); };
@@ -1156,6 +1159,11 @@ test('ipxd user adds, lists, renames and removes accounts, and says what is wron
expect(ipx(['rm', 'bea'])).toBe('removed bea\n'); expect(ipx(['rm', 'bea'])).toBe('removed bea\n');
expect(fails(['rm', 'bea'])).toContain('no such account: bea'); expect(fails(['rm', 'bea'])).toContain('no such account: bea');
expect(ipx(['list'])).not.toContain('bea'); expect(ipx(['list'])).not.toContain('bea');
// ipxd list: the feeds, each with its id on a line of its own.
expect(cli(['list'])).toContain('No feeds configured');
cli(['add', 'http://127.0.0.1:8792/cli.xml']);
expect(cli(['list'])).toMatch(/^ {4}id {11}\S+\n {4}url {10}http:\/\/127\.0\.0\.1:8792\/cli\.xml\n {4}last checked never$/m);
}); });
test('ipxd import subscribes the admin, and ipxd export writes the feeds out', async () => { test('ipxd import subscribes the admin, and ipxd export writes the feeds out', async () => {

View File

@@ -89,7 +89,7 @@ http.createServer((req, res) => {
next(); next();
return; return;
} }
// Feeds in the shapes the others are not (#463): Atom; RSS with a bare "&" and the iTunes and // Feeds in the shapes the others are not (#463): Atom and RSS each with a bare "&", the RSS with the iTunes and
// Media RSS fields; WordPress.com's posts as its API sends them; and replies that are no feed. // 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 at = `http://127.0.0.1:${port}`;
const shapes: Record<string, [string, string]> = { const shapes: Record<string, [string, string]> = {
@@ -97,7 +97,7 @@ http.createServer((req, res) => {
<feed xmlns="http://www.w3.org/2005/Atom"><title type="html">Atom&amp;#8217;s Show</title> <feed xmlns="http://www.w3.org/2005/Atom"><title type="html">Atom&amp;#8217;s Show</title>
<subtitle>An Atom feed</subtitle><link rel="alternate" href="${at}/atom.html"/><logo>${at}/art.jpg</logo> <subtitle>An Atom feed</subtitle><link rel="alternate" href="${at}/atom.html"/><logo>${at}/art.jpg</logo>
<id>urn:atom-show</id><updated>2026-01-01T00:00:00Z</updated> <id>urn:atom-show</id><updated>2026-01-01T00:00:00Z</updated>
<entry><id>urn:atom-1</id><title>Q&amp;A in Atom</title><updated>2026-01-02T00:00:00Z</updated> <entry><id>urn:atom-1</id><title>Q&A in Atom</title><updated>2026-01-02T00:00:00Z</updated>
<published>2026-01-02T00:00:00Z</published><link rel="alternate" href="${at}/atom-1.html"/> <published>2026-01-02T00:00:00Z</published><link rel="alternate" href="${at}/atom-1.html"/>
<link rel="enclosure" href="${at}/atom-1.mp3" type="audio/mpeg" length="40000"/> <link rel="enclosure" href="${at}/atom-1.mp3" type="audio/mpeg" length="40000"/>
<link rel="enclosure" href="${at}/atom-1.mp3?_=1" type="audio/mpeg" length="40000"/> <link rel="enclosure" href="${at}/atom-1.mp3?_=1" type="audio/mpeg" length="40000"/>
@@ -121,6 +121,9 @@ http.createServer((req, res) => {
guid: { rendered: `${at}/?p=1` }, link: `${at}/wp-1`, title: { rendered: 'WordPress &#8220;post&#8221;' }, guid: { rendered: `${at}/?p=1` }, link: `${at}/wp-1`, title: { rendered: 'WordPress &#8220;post&#8221;' },
date_gmt: '2026-01-04T12:00:00', content: { rendered: '<p>Post body</p>' }, jetpack_featured_media_url: `${at}/art.jpg`, date_gmt: '2026-01-04T12:00:00', content: { rendered: '<p>Post body</p>' }, jetpack_featured_media_url: `${at}/art.jpg`,
}])], }])],
// Where /flip.xml moves to for good.
'/moved.xml': ['application/rss+xml', `<?xml version="1.0"?><rss version="2.0"><channel><title>Flip Show</title>
<item><guid>flip-1</guid><title>Flip one</title></item></channel></rss>`],
'/said.txt': ['text/plain', 'Unable to establish a DB connection'], '/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'], '/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', ''], '/empty.xml': ['application/xml', ''],
@@ -132,6 +135,7 @@ http.createServer((req, res) => {
if (req.url?.startsWith('/flip?to=')) { flip = req.url.slice('/flip?to='.length); res.writeHead(204).end(); return; } if (req.url?.startsWith('/flip?to=')) { flip = req.url.slice('/flip?to='.length); res.writeHead(204).end(); return; }
if (req.url === '/flip.xml') { if (req.url === '/flip.xml') {
if (/^\d{3}$/.test(flip)) { res.writeHead(Number(flip)).end('no'); return; } if (/^\d{3}$/.test(flip)) { res.writeHead(Number(flip)).end('no'); return; }
if (flip === 'moved') { res.writeHead(301, { location: '/moved.xml' }).end(); return; }
if (flip === 'loop') { res.writeHead(302, { location: '/flip.xml' }).end(); return; } if (flip === 'loop') { res.writeHead(302, { location: '/flip.xml' }).end(); return; }
if (flip === 'drop') { req.socket.destroy(); return; } if (flip === 'drop') { req.socket.destroy(); return; }
const body = flip === 'text' ? 'Unable to establish a DB connection' const body = flip === 'text' ? 'Unable to establish a DB connection'