test(e2e): add rar smoke coverage and align archive deps

This commit is contained in:
kl
2026-03-09 11:19:27 +08:00
parent 4ab383709c
commit 8dd9b78c48
3 changed files with 9 additions and 3 deletions

View File

@@ -6,7 +6,7 @@ This folder contains a first MVP of end-to-end automated tests.
- Basic preview smoke checks for common file types (txt/md/json/xml/csv/html/png)
- Office Phase-2 smoke checks (docx/xlsx/pptx)
- Archive smoke checks (zip/tar/tgz/7z)
- Archive smoke checks (zip/tar/tgz/7z/rar)
- Basic endpoint reachability
- Security regression checks for blocked internal-network hosts (`10.*`) on:
- `/onlinePreview`
@@ -31,7 +31,7 @@ npx playwright install --with-deps chromium
pip3 install -r requirements.txt
```
> Prerequisite: ensure `zip`, `tar`, and `7z` (or `bsdtar` fallback) are available in PATH for archive fixtures.
> Prerequisite: ensure `python3`, `zip`, and `7z` (or `bsdtar` as a fallback) are available in PATH for archive fixtures.
3. Generate fixtures and start fixture server:

View File

@@ -79,7 +79,7 @@ try {
}
});
} catch (err) {
console.error('Failed to create archive fixtures. Ensure tar/zip/7z (or bsdtar) are available in PATH.');
console.error('Failed to create archive fixtures. Ensure python3, zip, 7z (or bsdtar) are available in PATH.');
throw err instanceof Error ? err : new Error(String(err));
} finally {
fs.rmSync(archiveWork, { recursive: true, force: true });

View File

@@ -28,6 +28,7 @@ test.beforeAll(async () => {
'sample.tar',
'sample.tgz',
'sample.7z',
'sample.rar',
];
try {
@@ -115,6 +116,11 @@ test('15 7z preview', async ({ request }) => {
expect(resp.status()).toBe(200);
});
test('16 rar preview', async ({ request }) => {
const resp = await openPreview(request, `${fixtureBase}/sample.rar`);
expect(resp.status()).toBe(200);
});
test('17 security: block 10.x host in onlinePreview', async ({ request }) => {
const resp = await openPreview(request, `http://10.1.2.3/a.pdf`);
const body = await resp.text();