补齐浏览器回归和发布指纹,更新应用访问说明

This commit is contained in:
fam
2026-09-21 12:12:25 +01:00
parent a0fefc5041
commit acfa02f96d
11 changed files with 118 additions and 8 deletions
+24
View File
@@ -0,0 +1,24 @@
import {test,expect} from '@playwright/test';
test('应用导航、搜索、旧文章与手机布局', async ({page})=>{
const errors=[]; page.on('pageerror',e=>errors.push(e.message));
await page.goto('/');
await expect(page.locator('#app-grid .app-card')).toHaveCount(23);
expect(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth)).toBe(true);
await page.getByRole('button',{name:'音乐',exact:true}).click();
await expect(page.locator('#app-grid .app-card:visible')).toHaveCount(3);
await page.getByRole('button',{name:'全部',exact:true}).click();
await page.getByRole('searchbox').fill('hedgehog');
await expect(page.locator('#app-grid .app-card:visible')).toHaveCount(1);
await page.getByRole('searchbox').fill('nothing-to-match');
await expect(page.locator('#empty')).toBeVisible();
await page.goto('/posts/claude-code-goal/');
await expect(page.locator('h1')).toContainText('Claude Code');
expect(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth)).toBe(true);
expect(errors).toEqual([]);
});
test('没有 JavaScript 仍能访问所有入口',async({browser})=>{
const context=await browser.newContext({javaScriptEnabled:false});
const page=await context.newPage();await page.goto('http://127.0.0.1:4176/');
await expect(page.locator('#app-grid .app-card:visible')).toHaveCount(23);
await context.close();
});
+4 -3
View File
@@ -38,11 +38,12 @@ class SiteTest(unittest.TestCase):
self.assertNotIn('PaperMod', (build.OUT/'index.html').read_text())
self.assertNotIn('Hugo', (build.OUT/'index.html').read_text())
def test_feeds(self):
self.assertEqual(len(ET.parse(build.OUT/'index.xml').findall('./channel/item')), 11)
self.assertEqual(len(ET.parse(build.OUT/'sitemap.xml').getroot()), 14)
count = sum(not build.load_post(p).get('draft') for p in (build.ROOT/'content/posts').glob('*.md'))
self.assertEqual(len(ET.parse(build.OUT/'index.xml').findall('./channel/item')), count)
self.assertEqual(len(ET.parse(build.OUT/'sitemap.xml').getroot()), count + 3)
def test_app_registry(self):
apps = json.loads((build.ROOT/'apps.json').read_text())
self.assertEqual(len(apps), 23)
self.assertGreaterEqual(len(apps), 23)
self.assertTrue(all(not urlsplit(a['url']).query and not urlsplit(a['url']).fragment for a in apps))
self.assertTrue(all(a['name'] and a['description'] and a['icon'] in build.ICONS for a in apps))