From 56161ed2e19d01979279195fea8a020b4f69bf8e Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 23 Jan 2026 00:26:11 +0800 Subject: [PATCH] fix: format E2E tests and add helpers to knip ignore --- knip.json | 2 +- tests/e2e/api.e2e.test.ts | 10 ++--- tests/e2e/fixtures/test.md | 14 +++---- tests/e2e/helpers.ts | 78 +++++++++++++++++++++++++++++++++----- 4 files changed, 81 insertions(+), 23 deletions(-) diff --git a/knip.json b/knip.json index 88a90af..6ca17e6 100644 --- a/knip.json +++ b/knip.json @@ -5,7 +5,7 @@ "tailwind": { "entry": ["src/main.css"] }, - "ignore": ["src/i18n/**"], + "ignore": ["src/i18n/**", "tests/e2e/helpers.ts"], "ignoreDependencies": [], "ignoreExportsUsedInFile": true } diff --git a/tests/e2e/api.e2e.test.ts b/tests/e2e/api.e2e.test.ts index c1fcec8..b63c3ed 100644 --- a/tests/e2e/api.e2e.test.ts +++ b/tests/e2e/api.e2e.test.ts @@ -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"); diff --git a/tests/e2e/fixtures/test.md b/tests/e2e/fixtures/test.md index e4d4c78..efeb87f 100644 --- a/tests/e2e/fixtures/test.md +++ b/tests/e2e/fixtures/test.md @@ -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._ diff --git a/tests/e2e/helpers.ts b/tests/e2e/helpers.ts index 5bf9b13..c571d36 100644 --- a/tests/e2e/helpers.ts +++ b/tests/e2e/helpers.ts @@ -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); }