mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-03-14 05:03:49 +08:00
test(e2e): address copilot review for fixture stability and CI python setup
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { execSync } from 'node:child_process';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
|
||||
const fixturesDir = path.resolve(process.cwd(), 'tests/e2e/fixtures');
|
||||
fs.mkdirSync(fixturesDir, { recursive: true });
|
||||
@@ -14,14 +14,17 @@ write('sample.xml', '<root><name>kkFileView</name><e2e>true</e2e></root>');
|
||||
write('sample.csv', 'name,value\nkkFileView,1\ne2e,1\n');
|
||||
write('sample.html', '<!doctype html><html><body><h1>kkFileView fixture</h1></body></html>');
|
||||
|
||||
// zip (contains txt)
|
||||
const zipWork = path.join(fixturesDir, 'zip-tmp');
|
||||
fs.mkdirSync(zipWork, { recursive: true });
|
||||
fs.writeFileSync(path.join(zipWork, 'inner.txt'), 'kkFileView zip inner file');
|
||||
try {
|
||||
execSync(`cd "${zipWork}" && zip -q -r "${path.join(fixturesDir, 'sample.zip')}" inner.txt`);
|
||||
} catch {
|
||||
// fallback: keep going if zip is not available locally
|
||||
// zip (contains txt) - only generate if missing to avoid noisy local diffs
|
||||
const zipPath = path.join(fixturesDir, 'sample.zip');
|
||||
if (!fs.existsSync(zipPath)) {
|
||||
const zipWork = path.join(fixturesDir, 'zip-tmp');
|
||||
fs.mkdirSync(zipWork, { recursive: true });
|
||||
fs.writeFileSync(path.join(zipWork, 'inner.txt'), 'kkFileView zip inner file');
|
||||
try {
|
||||
execFileSync('zip', ['-X', '-q', '-r', zipPath, 'inner.txt'], { cwd: zipWork });
|
||||
} catch {
|
||||
// fallback: keep going if zip is not available locally
|
||||
}
|
||||
}
|
||||
|
||||
// 1x1 png
|
||||
|
||||
Reference in New Issue
Block a user