Switch an item between its HTML and its Markdown (#285)
A feed that sends <source:markdown> beside its HTML (Scripting News) has its Markdown kept in entries.markdown, added to existing databases by an ALTER. A stored item gets it when a scan finds it told differently, the Markdown counting as a change, the way corrections arrive (#141). The API sends it as written and made HTML, cleaned by ammonia like the description. The item's page has a choice between its meta line and its buttons: HTML, Markdown or Markdown source, remembered in the browser. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -521,6 +521,35 @@ test('a show inside an OPML can be kept, and only it', async ({ page }) => {
|
||||
await expect(page.locator('#content [data-a="keep"]')).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('an item sent as HTML and Markdown switches between them', async ({ page }) => {
|
||||
const api = (p, init) => page.evaluate(([p, init]) => fetch(p, { headers: { 'Content-Type': 'application/json' }, ...init })
|
||||
.then((r) => r.json().catch(() => null)), [p, init]);
|
||||
const added = await api('/api/feeds', { method: 'POST', body: JSON.stringify({ url: 'http://127.0.0.1:8792/markdown.xml' }) });
|
||||
const id = added.id || added.feed?.id || 'markdown-blog';
|
||||
await page.reload();
|
||||
await page.locator('#feedlist .feed', { hasText: 'Markdown Blog' }).click({ timeout: 20_000 });
|
||||
await page.locator('#content .tabs button[data-f="all"]').click();
|
||||
await page.locator('.ep', { hasText: 'Both Ways' }).click();
|
||||
|
||||
// The publisher's HTML first; the choice is between the title and the item's buttons (#285).
|
||||
const view = page.locator('#detail .dmeta .tview');
|
||||
await expect(view).toHaveValue('html');
|
||||
await expect(page.locator('#detail .dbody b')).toHaveText('HTML');
|
||||
await view.selectOption('markdown');
|
||||
await expect(page.locator('#detail .dbody strong')).toHaveText('Markdown');
|
||||
await view.selectOption('source');
|
||||
await expect(page.locator('#detail .dbody pre.mdsrc')).toHaveText('The **Markdown** copy.');
|
||||
// Kept for the next item; set back so nothing after this sees it.
|
||||
expect(await page.evaluate(() => localStorage.getItem('ipx.textview'))).toBe('source');
|
||||
await view.selectOption('html');
|
||||
|
||||
// An item with no Markdown has no choice to make.
|
||||
await page.locator('#feedlist .feed', { hasText: 'Test Show' }).first().click();
|
||||
await page.locator('.ep').first().click();
|
||||
await expect(page.locator('#detail .tview')).toHaveCount(0);
|
||||
await api('/api/feeds/' + encodeURIComponent(id), { method: 'DELETE' });
|
||||
});
|
||||
|
||||
test('marking an OPML subscription read covers the feeds inside it', async ({ page }) => {
|
||||
await page.evaluate(() =>
|
||||
fetch('/api/fetch', {
|
||||
|
||||
8
tests/ui/fixtures/markdown.xml
Normal file
8
tests/ui/fixtures/markdown.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<rss version="2.0" xmlns:source="https://source.scripting.com/">
|
||||
<channel><title>Markdown Blog</title><link>http://127.0.0.1:8792/</link><description>HTML and Markdown both, as Scripting News sends.</description>
|
||||
<item><title>Both Ways</title><guid>md-1</guid>
|
||||
<pubDate>Mon, 01 Sep 2026 10:00:00 +0000</pubDate>
|
||||
<description><p>The <b>HTML</b> copy.</p></description>
|
||||
<source:markdown>The **Markdown** copy.</source:markdown></item>
|
||||
</channel></rss>
|
||||
Reference in New Issue
Block a user