Skip to content

test: gate PDF extraction scenarios when pdfjs-dist is absent - #218

Merged
Vantalens merged 2 commits into
mainfrom
fix/pdfjs-absent-test-gates
Sep 24, 2026
Merged

Vantalens merged 2 commits into
mainfrom
fix/pdfjs-absent-test-gates

Conversation

@Vantalens

Copy link
Copy Markdown
Owner

变更说明

PR #217 合并后,main 的 Enhanced CI(Node 24,coverage 任务)失败:该任务环境中 pdfjs-dist(optionalDependency)未安装成功——npm ci 对可选依赖安装失败不报错。PDF reader 回退到核心解析器后对本项目生成的 PDF 取不到正文,#216 引入的 PDF_TEXT_UNAVAILABLE 诚实错误(正确行为)使 format-validation-test 的 pdf → md/html/txt/json/xml/docx 六个用例失败。

本 PR 让测试套件在可选依赖缺失时行为确定:区分「提取能力缺失」(跳过并断言错误码正确)与「真回归」(pdfjs 可用却取不到正文,仍然失败)。不改变任何产品代码行为。

变更内容

  • format-validation-test.js:增加提取能力探针——pdfjs 缺失且样例取不到正文时,pdf → * 用例记为跳过;探针同时断言 PDF_TEXT_UNAVAILABLE 错误码正确
  • ocr-baseline-test.js 29c:混合页按页 OCR 场景依赖 PDF.js 页级检测,pdfjs 缺失时整组跳过并打印原因
  • pdf-reader-test.js 测试 11:混合页页数 / pagesWithoutText 断言依赖 PDF.js 提取,pdfjs 缺失时跳过并打印原因

测试验证

  • 本机隐藏 node_modules/pdfjs-dist 后完整 npm test 通过(复现并修复 Enhanced CI 失败场景)
  • 恢复 pdfjs-dist 后完整 npm test 通过(正常环境无回归)
  • 修复前本地复现与 CI 完全一致的 6 个 pdf → X 失败

相关 Issue

Refs #216

注意事项

可选依赖的安装抖动无法从仓库侧根除(npm 语义如此);本 PR 保证测试套件在该情况下确定性通过。若希望 CI 强保证提取能力覆盖,可后续在 Enhanced CI 增加一个显式断言 pdfjs-dist 安装成功的步骤(超出本 PR 范围)。

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Enhanced CI 在 main 的 Node 24 任务中 pdfjs-dist(optionalDependency)未装上(npm ci 对可选依赖安装失败不报错),导致 pdf → X 矩阵用例在缺少提取能力的环境下失败。

- format-validation-test:pdfjs 缺失且核心解析器取不到正文时,探针断言 PDF_TEXT_UNAVAILABLE 并跳过 pdf 输入用例;pdfjs 可用却取不到正文仍按回归失败
- ocr-baseline-test 29c:混合页按页 OCR 场景依赖 PDF.js 页级检测,缺失时整组跳过
- pdf-reader-test 测试 11:混合页页数/无文字页断言依赖 PDF.js 提取,缺失时跳过

本机双向验证:隐藏/恢复 node_modules/pdfjs-dist 各跑一遍完整 npm test 均通过。

Refs #216
@Vantalens
Vantalens force-pushed the fix/pdfjs-absent-test-gates branch from dc37a90 to 226c12b Compare September 24, 2026 06:12
@Vantalens
Vantalens merged commit 68ca60a into main Sep 24, 2026
8 checks passed
@Vantalens
Vantalens deleted the fix/pdfjs-absent-test-gates branch September 24, 2026 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant