fix: format E2E tests and add helpers to knip ignore

This commit is contained in:
Your Name 2026-01-23 00:26:11 +08:00
parent a9f6e1de6f
commit 56161ed2e1
4 changed files with 81 additions and 23 deletions

View file

@ -203,18 +203,16 @@ describe("i18n Module", () => {
describe("Transfer Module", () => {
test("Transfer 常數應該正確定義", async () => {
const { CHUNK_THRESHOLD_BYTES, CHUNK_SIZE_BYTES } = await import(
"../../src/transfer/constants"
);
const { CHUNK_THRESHOLD_BYTES, CHUNK_SIZE_BYTES } =
await import("../../src/transfer/constants");
expect(CHUNK_THRESHOLD_BYTES).toBe(10 * 1024 * 1024); // 10MB
expect(CHUNK_SIZE_BYTES).toBe(5 * 1024 * 1024); // 5MB
});
test("允許的封裝格式應該是 .tar", async () => {
const { ALLOWED_ARCHIVE_FORMAT, FORBIDDEN_ARCHIVE_FORMATS } = await import(
"../../src/transfer/constants"
);
const { ALLOWED_ARCHIVE_FORMAT, FORBIDDEN_ARCHIVE_FORMATS } =
await import("../../src/transfer/constants");
expect(ALLOWED_ARCHIVE_FORMAT).toBe(".tar");
expect(FORBIDDEN_ARCHIVE_FORMATS).toContain(".tar.gz");

View file

@ -23,12 +23,12 @@ def hello_world():
## Table Example
| Format | Type | Converter |
|--------|------|-----------|
| SVG | Image | Inkscape |
| PDF | Document | LibreOffice |
| MP4 | Video | FFmpeg |
| DOCX | Document | Pandoc |
| Format | Type | Converter |
| ------ | -------- | ----------- |
| SVG | Image | Inkscape |
| PDF | Document | LibreOffice |
| MP4 | Video | FFmpeg |
| DOCX | Document | Pandoc |
## List Example
@ -43,4 +43,4 @@ Thank you for using ConvertX!
---
*This document is used for E2E testing purposes.*
_This document is used for E2E testing purposes._

View file

@ -125,15 +125,75 @@ export function createTestSvg(outputPath: string): void {
export function createTestPng(outputPath: string): void {
// 最小的有效 PNG 檔案 (1x1 紅色像素)
const pngBuffer = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, // PNG signature
0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, // IHDR chunk
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, // 1x1 dimensions
0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, 0xde, // bit depth, color type, etc
0x00, 0x00, 0x00, 0x0c, 0x49, 0x44, 0x41, 0x54, // IDAT chunk
0x08, 0xd7, 0x63, 0xf8, 0xcf, 0xc0, 0x00, 0x00, // compressed data
0x01, 0x01, 0x01, 0x00, 0x18, 0xdd, 0x8d, 0xb4, // checksum
0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, // IEND chunk
0xae, 0x42, 0x60, 0x82,
0x89,
0x50,
0x4e,
0x47,
0x0d,
0x0a,
0x1a,
0x0a, // PNG signature
0x00,
0x00,
0x00,
0x0d,
0x49,
0x48,
0x44,
0x52, // IHDR chunk
0x00,
0x00,
0x00,
0x01,
0x00,
0x00,
0x00,
0x01, // 1x1 dimensions
0x08,
0x02,
0x00,
0x00,
0x00,
0x90,
0x77,
0x53,
0xde, // bit depth, color type, etc
0x00,
0x00,
0x00,
0x0c,
0x49,
0x44,
0x41,
0x54, // IDAT chunk
0x08,
0xd7,
0x63,
0xf8,
0xcf,
0xc0,
0x00,
0x00, // compressed data
0x01,
0x01,
0x01,
0x00,
0x18,
0xdd,
0x8d,
0xb4, // checksum
0x00,
0x00,
0x00,
0x00,
0x49,
0x45,
0x4e,
0x44, // IEND chunk
0xae,
0x42,
0x60,
0x82,
]);
writeFileSync(outputPath, pngBuffer);
}