mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-03-14 05:03:49 +08:00
test(e2e): harden fixture preflight and remove duplicate generation
This commit is contained in:
5
.github/workflows/pr-e2e-mvp.yml
vendored
5
.github/workflows/pr-e2e-mvp.yml
vendored
@@ -55,11 +55,6 @@ jobs:
|
|||||||
npm install
|
npm install
|
||||||
npx playwright install --with-deps chromium
|
npx playwright install --with-deps chromium
|
||||||
|
|
||||||
- name: Generate fixtures
|
|
||||||
run: |
|
|
||||||
node tests/e2e/scripts/generate-fixtures.mjs
|
|
||||||
python3 tests/e2e/scripts/generate-office-fixtures.py
|
|
||||||
|
|
||||||
- name: Start fixture server
|
- name: Start fixture server
|
||||||
run: |
|
run: |
|
||||||
cd tests/e2e/fixtures
|
cd tests/e2e/fixtures
|
||||||
|
|||||||
@@ -24,8 +24,9 @@ if (!fs.existsSync(zipPath)) {
|
|||||||
fs.writeFileSync(path.join(zipWork, 'inner.txt'), 'kkFileView zip inner file');
|
fs.writeFileSync(path.join(zipWork, 'inner.txt'), 'kkFileView zip inner file');
|
||||||
try {
|
try {
|
||||||
execFileSync('zip', ['-X', '-q', '-r', zipPath, 'inner.txt'], { cwd: zipWork });
|
execFileSync('zip', ['-X', '-q', '-r', zipPath, 'inner.txt'], { cwd: zipWork });
|
||||||
} catch {
|
} catch (err) {
|
||||||
// fallback: keep going if zip is not available locally
|
console.error('Failed to create sample.zip fixture. Ensure "zip" is installed and available in PATH.');
|
||||||
|
throw err instanceof Error ? err : new Error(String(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,28 @@ async function openPreview(request: any, fileUrl: string) {
|
|||||||
|
|
||||||
test.beforeAll(async () => {
|
test.beforeAll(async () => {
|
||||||
const api = await playwrightRequest.newContext();
|
const api = await playwrightRequest.newContext();
|
||||||
const required = ['sample.txt', 'sample.docx', 'sample.xlsx', 'sample.pptx', 'sample.zip'];
|
const required = [
|
||||||
for (const name of required) {
|
'sample.txt',
|
||||||
const resp = await api.get(`${fixtureBase}/${name}`);
|
'sample.md',
|
||||||
expect(resp.ok(), `fixture missing or unavailable: ${name}`).toBeTruthy();
|
'sample.json',
|
||||||
|
'sample.xml',
|
||||||
|
'sample.csv',
|
||||||
|
'sample.html',
|
||||||
|
'sample.png',
|
||||||
|
'sample.docx',
|
||||||
|
'sample.xlsx',
|
||||||
|
'sample.pptx',
|
||||||
|
'sample.zip',
|
||||||
|
];
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (const name of required) {
|
||||||
|
const resp = await api.get(`${fixtureBase}/${name}`);
|
||||||
|
expect(resp.ok(), `fixture missing or unavailable: ${name}`).toBeTruthy();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
await api.dispose();
|
||||||
}
|
}
|
||||||
await api.dispose();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('01 home/index reachable', async ({ request }) => {
|
test('01 home/index reachable', async ({ request }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user