mirror of
https://github.com/kekingcn/kkFileView.git
synced 2026-03-30 15:20:31 +00:00
Compare commits
3 Commits
master
...
fix/e2e-ph
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d0b14515f | ||
|
|
e845846d30 | ||
|
|
a7ad4b4fe4 |
15
.github/workflows/nightly-e2e.yml
vendored
15
.github/workflows/nightly-e2e.yml
vendored
@@ -55,10 +55,6 @@ jobs:
|
|||||||
npm ci
|
npm ci
|
||||||
npx playwright install --with-deps chromium
|
npx playwright install --with-deps chromium
|
||||||
|
|
||||||
- name: Generate E2E fixtures
|
|
||||||
working-directory: tests/e2e
|
|
||||||
run: npm run gen:all
|
|
||||||
|
|
||||||
- name: Start fixture server
|
- name: Start fixture server
|
||||||
run: |
|
run: |
|
||||||
cd tests/e2e/fixtures
|
cd tests/e2e/fixtures
|
||||||
@@ -97,20 +93,13 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Run smoke 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
|
|
||||||
run: npm run test:smoke
|
|
||||||
|
|
||||||
- name: Run perf suite
|
|
||||||
working-directory: tests/e2e
|
working-directory: tests/e2e
|
||||||
env:
|
env:
|
||||||
KK_BASE_URL: http://127.0.0.1:8012
|
KK_BASE_URL: http://127.0.0.1:8012
|
||||||
FIXTURE_BASE_URL: http://127.0.0.1:18080
|
FIXTURE_BASE_URL: http://127.0.0.1:18080
|
||||||
E2E_MAX_PREVIEW_MS: 20000
|
E2E_MAX_PREVIEW_MS: 20000
|
||||||
run: npm run test:perf
|
run: npm run test:ci
|
||||||
|
|
||||||
- name: Upload Playwright report
|
- name: Upload Playwright report
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ This folder contains a first MVP of end-to-end automated tests.
|
|||||||
- `/onlinePreview`
|
- `/onlinePreview`
|
||||||
- `/getCorsFile`
|
- `/getCorsFile`
|
||||||
- Basic performance smoke checks (configurable threshold): txt/docx/xlsx preview response time
|
- Basic performance smoke checks (configurable threshold): txt/docx/xlsx preview response time
|
||||||
|
- CI combined run command available via `npm run test:ci`
|
||||||
|
|
||||||
## Local run
|
## Local run
|
||||||
|
|
||||||
@@ -62,4 +63,7 @@ npm run test:smoke
|
|||||||
|
|
||||||
# perf smoke (self-contained; default threshold 15000ms)
|
# perf smoke (self-contained; default threshold 15000ms)
|
||||||
E2E_MAX_PREVIEW_MS=15000 npm run test:perf
|
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",
|
"pretest:smoke": "npm run gen:all",
|
||||||
"test:smoke": "playwright test specs/preview-smoke.spec.ts",
|
"test:smoke": "playwright test specs/preview-smoke.spec.ts",
|
||||||
"pretest:perf": "npm run gen:all",
|
"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": {
|
"devDependencies": {
|
||||||
"@playwright/test": "^1.55.0"
|
"@playwright/test": "^1.55.0"
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
import { test, expect, request as playwrightRequest } from '@playwright/test';
|
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 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 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 {
|
function b64(v: string): string {
|
||||||
return Buffer.from(v).toString('base64');
|
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 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;
|
const elapsed = Date.now() - started;
|
||||||
return { resp, elapsed };
|
return { resp, elapsed };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ function b64(v: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function openPreview(request: any, fileUrl: string) {
|
async function openPreview(request: any, fileUrl: string) {
|
||||||
const encoded = b64(fileUrl);
|
const encoded = encodeURIComponent(b64(fileUrl));
|
||||||
return request.get(`/onlinePreview?url=${encoded}`);
|
return request.get(`/onlinePreview?url=${encoded}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user