mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-03-14 05:03:49 +08:00
test(e2e): fix preflight fixture scope and path handling
This commit is contained in:
@@ -26,7 +26,7 @@ mvn -q -pl server -DskipTests package
|
|||||||
cd tests/e2e
|
cd tests/e2e
|
||||||
npm install
|
npm install
|
||||||
npx playwright install --with-deps chromium
|
npx playwright install --with-deps chromium
|
||||||
pip3 install -r tests/e2e/requirements.txt
|
pip3 install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Generate fixtures and start fixture server:
|
3. Generate fixtures and start fixture server:
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { execFileSync } from 'node:child_process';
|
import { execFileSync } from 'node:child_process';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
const fixturesDir = path.resolve(process.cwd(), 'tests/e2e/fixtures');
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
const fixturesDir = path.resolve(__dirname, '..', 'fixtures');
|
||||||
fs.mkdirSync(fixturesDir, { recursive: true });
|
fs.mkdirSync(fixturesDir, { recursive: true });
|
||||||
|
|
||||||
const write = (name, content) => fs.writeFileSync(path.join(fixturesDir, name), content);
|
const write = (name, content) => fs.writeFileSync(path.join(fixturesDir, name), content);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { test, expect } from '@playwright/test';
|
import { test, expect, request as playwrightRequest } from '@playwright/test';
|
||||||
|
|
||||||
const fixtureBase = process.env.FIXTURE_BASE_URL || 'http://127.0.0.1:18080';
|
const fixtureBase = process.env.FIXTURE_BASE_URL || 'http://127.0.0.1:18080';
|
||||||
|
|
||||||
@@ -11,12 +11,14 @@ async function openPreview(request: any, fileUrl: string) {
|
|||||||
return request.get(`/onlinePreview?url=${encoded}`);
|
return request.get(`/onlinePreview?url=${encoded}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
test.beforeAll(async ({ request }) => {
|
test.beforeAll(async () => {
|
||||||
|
const api = await playwrightRequest.newContext();
|
||||||
const required = ['sample.txt', 'sample.docx', 'sample.xlsx', 'sample.pptx', 'sample.zip'];
|
const required = ['sample.txt', 'sample.docx', 'sample.xlsx', 'sample.pptx', 'sample.zip'];
|
||||||
for (const name of required) {
|
for (const name of required) {
|
||||||
const resp = await request.get(`${fixtureBase}/${name}`);
|
const resp = await api.get(`${fixtureBase}/${name}`);
|
||||||
expect(resp.ok(), `fixture missing or unavailable: ${name}`).toBeTruthy();
|
expect(resp.ok(), `fixture missing or unavailable: ${name}`).toBeTruthy();
|
||||||
}
|
}
|
||||||
|
await api.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('01 home/index reachable', async ({ request }) => {
|
test('01 home/index reachable', async ({ request }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user