Skip to content

fix: fix PdfGenerator test failures and improve test coverage#294

Merged
baoduy merged 5 commits into
mainfrom
dev
May 22, 2026
Merged

fix: fix PdfGenerator test failures and improve test coverage#294
baoduy merged 5 commits into
mainfrom
dev

Conversation

@baoduy
Copy link
Copy Markdown
Owner

@baoduy baoduy commented May 22, 2026

Summary

Fixed all 3 failing PdfGenerator tests and added new tests to improve coverage across three projects.

Changes

DKNet.Svc. Fixed 3 failing testsPdfGenerators

Root cause: ConvertHtmlAsync, ConvertMarkdownFileAsync, and ConvertMultipleMarkdownFilesAsync tests were racing to download Chrome concurrently, causing a file-lock IOException.

Fix: Added ChromeDownloadFixture (pre-downloads Chrome once via PuppeteerSharp) and [Collection("PdfGeneratorChrome")] to serialize PDF generation tests.

Result: 175/175 passing (was 172/175)

DKNet.AspCore. Improved coverageIdempotency

New tests added (54 total, was 35):

  • covers IsValid() for null/empty/whitespace keys, key too long, invalid formatIdempotentKeyInfoTests
  • covers IsExpired for null ExpiresAt, future, and past expiryCachedResponseTests
  • covers expired response removal, separate keys per endpoint/methodIdempotencyStoreEdgeCaseTests
  • Integration tests for key-too-long and invalid-format requests returning 400

DKNet.EfCore. Improved coverageDataAuthorization

New tests added (20 total, was 14):

  • covers DataAuthExtensions.GetQueryFilterKeyDataAuthorizationEdgeCaseTests
  • exercises DataOwnerHook early-return branchDataAuthorizationEmptyOwnerKeyTests
  • exercises empty accessibility keys filter branchDataAuthorizationEmptyAccessibleKeysTests

baoduy and others added 2 commits May 21, 2026 17:39
- Fix DKNet.Svc.PdfGenerators: 3 tests were failing with Chrome download
  race conditions. Added ChromeDownloadFixture with [Collection] to
  pre-download Chrome once and serialize PDF generation tests.
  All 175 tests now pass (was 172 pass / 3 fail).

- Improve DKNet.AspCore.Idempotency coverage (from 60.2% line / 48.2% branch):
  - Added IdempotentKeyInfoTests: covers IsValid() for null/empty/whitespace
    keys, key too long, invalid format, valid key, and CompositeKey property
  - Added CachedResponseTests: covers IsExpired for null ExpiresAt, future,
    and past expiry
  - Added IdempotencyStoreEdgeCaseTests: covers expired response removal,
    null ExpiresAt handling, separate keys per endpoint and method
  - Added integration tests for keys that are too long or have invalid format
  Total: 54 tests (was 35)

- Improve DKNet.EfCore.DataAuthorization coverage (from 77.7% line / 62.5% branch):
  - Added InternalsVisibleTo for test project
  - Added EmptyOwnerKeyProvider / EmptyAccessibleKeysProvider test helpers
  - Added DataAuthorizationEdgeCaseTests: covers DataAuthExtensions.GetQueryFilterKey,
    empty ownerKey hook early-return path, and empty AccessibleKeys query filter
    branch (all entities visible when no ownership filter applied)
  Total: 20 tests (was 14)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@baoduy baoduy temporarily deployed to github-pages May 22, 2026 01:57 — with GitHub Pages Inactive
@github-actions
Copy link
Copy Markdown

📊 Code Coverage Report

| Metric | Coverage |
|--------|----------|
| **Line Coverage** | 86.8% |
| **Branch Coverage** | 81.4% |
| **Method Coverage** | 85.1% |

**Lines:** 3218/undefined covered
**Branches:** 1225/undefined covered

📈 [View Full Coverage Report](https://github.com/baoduy/DKNet/actions/runs/26263986082)

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.62%. Comparing base (3e9465a) to head (51c6bfe).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #294      +/-   ##
==========================================
- Coverage   84.43%   83.62%   -0.82%     
==========================================
  Files         159      159              
  Lines        3655     3706      +51     
  Branches      564      575      +11     
==========================================
+ Hits         3086     3099      +13     
- Misses        412      444      +32     
- Partials      157      163       +6     
Flag Coverage Δ
unittests 83.62% <ø> (-0.82%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@baoduy baoduy merged commit 7b89ade into main May 22, 2026
8 of 13 checks passed
baoduy added a commit that referenced this pull request May 22, 2026
test: improve coverage for PR #294 gap files
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