mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-03-13 05:20:22 +00:00
test(e2e): follow-up fixes after post-merge copilot findings (#718)
* test(e2e): follow-up fixes for post-merge copilot review feedback * test(e2e): guard E2E_MAX_PREVIEW_MS against sub-second values
This commit is contained in:
15
.github/workflows/nightly-e2e.yml
vendored
15
.github/workflows/nightly-e2e.yml
vendored
@@ -55,10 +55,6 @@ jobs:
|
||||
npm ci
|
||||
npx playwright install --with-deps chromium
|
||||
|
||||
- name: Generate E2E fixtures
|
||||
working-directory: tests/e2e
|
||||
run: npm run gen:all
|
||||
|
||||
- name: Start fixture server
|
||||
run: |
|
||||
cd tests/e2e/fixtures
|
||||
@@ -97,20 +93,13 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Run smoke suite
|
||||
working-directory: tests/e2e
|
||||
env:
|
||||
KK_BASE_URL: http://127.0.0.1:8012
|
||||
FIXTURE_BASE_URL: http://127.0.0.1:18080
|
||||
run: npm run test:smoke
|
||||
|
||||
- name: Run perf suite
|
||||
- name: Run nightly E2E suites
|
||||
working-directory: tests/e2e
|
||||
env:
|
||||
KK_BASE_URL: http://127.0.0.1:8012
|
||||
FIXTURE_BASE_URL: http://127.0.0.1:18080
|
||||
E2E_MAX_PREVIEW_MS: 20000
|
||||
run: npm run test:perf
|
||||
run: npm run test:ci
|
||||
|
||||
- name: Upload Playwright report
|
||||
if: always()
|
||||
|
||||
@@ -62,4 +62,7 @@ npm run test:smoke
|
||||
|
||||
# perf smoke (self-contained; default threshold 15000ms)
|
||||
E2E_MAX_PREVIEW_MS=15000 npm run test:perf
|
||||
|
||||
# CI-style combined run (single fixture generation)
|
||||
E2E_MAX_PREVIEW_MS=20000 npm run test:ci
|
||||
```
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
"pretest:smoke": "npm run gen:all",
|
||||
"test:smoke": "playwright test specs/preview-smoke.spec.ts",
|
||||
"pretest:perf": "npm run gen:all",
|
||||
"test:perf": "playwright test specs/perf-smoke.spec.ts"
|
||||
"test:perf": "playwright test specs/perf-smoke.spec.ts",
|
||||
"test:ci": "npm run gen:all && playwright test specs/preview-smoke.spec.ts specs/perf-smoke.spec.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.55.0"
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
import { test, expect, request as playwrightRequest } from '@playwright/test';
|
||||
import type { APIRequestContext } from '@playwright/test';
|
||||
|
||||
const fixtureBase = process.env.FIXTURE_BASE_URL || 'http://127.0.0.1:18080';
|
||||
const DEFAULT_MAX_MS = 15000;
|
||||
const envMaxMs = Number(process.env.E2E_MAX_PREVIEW_MS);
|
||||
const maxMs = Number.isFinite(envMaxMs) ? envMaxMs : 15000;
|
||||
const maxMs = Number.isFinite(envMaxMs) && envMaxMs >= 1 ? Math.floor(envMaxMs) : DEFAULT_MAX_MS;
|
||||
|
||||
function b64(v: string): string {
|
||||
return Buffer.from(v).toString('base64');
|
||||
}
|
||||
|
||||
async function timedPreview(request: any, fileUrl: string) {
|
||||
async function timedPreview(request: APIRequestContext, fileUrl: string) {
|
||||
const started = Date.now();
|
||||
const resp = await request.get(`/onlinePreview?url=${b64(fileUrl)}`);
|
||||
const resp = await request.get(`/onlinePreview?url=${encodeURIComponent(b64(fileUrl))}`);
|
||||
const elapsed = Date.now() - started;
|
||||
return { resp, elapsed };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user