test: add PDF export endpoint coverage and run in CI (closes #72) by bradjin8 · Pull Request #82 · cppalliance/cppa-cursor-browser · GitHub
Skip to content

test: add PDF export endpoint coverage and run in CI (closes #72)#82

Merged
wpak-ai merged 2 commits into
masterfrom
feat/unit-test-for-pdf-export
May 27, 2026
Merged

test: add PDF export endpoint coverage and run in CI (closes #72)#82
wpak-ai merged 2 commits into
masterfrom
feat/unit-test-for-pdf-export

Conversation

@bradjin8

@bradjin8 bradjin8 commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add tests/test_pdf_export.py with 8 Flask test-client cases for POST /api/generate-pdf: normal markdown export, empty body defaults, unsafe title filename sanitization, empty markdown, long content, Unicode/emoji, simulated PDF engine failure (500), and malformed markdown payload (500).
  • Add a lightweight pdf_client fixture in conftest.py so PDF tests do not need the full workspace_storage setup.
  • Include tests/test_pdf_export.py in the CI pytest step so the new tests actually run in the matrix (previously only test_api_endpoints.py was executed).

Closes #72.

API note: The PDF route accepts { markdown, title } from the browser after client-side markdown conversion (download.js). It does not look up conversations by ID on the server; invalid tab IDs are handled by /api/workspaces/.../tabs (covered in test_api_endpoints.py). Server-side error coverage uses a mocked FPDF.output failure and a non-string markdown field.

Test plan

  • python -m pytest tests/test_pdf_export.py tests/test_api_endpoints.py -v
  • python -m pytest tests/ -q (full suite)
  • CI green on PR (ubuntu/windows/macos × Python 3.10–3.13)

Summary by CodeRabbit

  • Tests

    • Added comprehensive test suite for PDF export endpoint covering normal operation, edge cases (empty content, long content, unicode/emoji), and error handling scenarios.
  • Chores

    • Updated test automation workflow to include PDF export tests in CI pipeline.

Review Change Stack

@bradjin8 bradjin8 self-assigned this May 27, 2026
@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown

@bradjin8 bradjin8 requested a review from clean6378-max-it May 27, 2026 16:18
@clean6378-max-it

Copy link
Copy Markdown
Collaborator

models/from_dict_validation.py — add a small tests/test_from_dict_validation.py asserting message text for require_non_empty_str_fields / require_non_empty_str_field: absent key → missing required field, wrong type → invalid field. test_schema_error_message_distinguishes_missing_from_invalid covers the contract generically but not these helpers post-f846aaf.

models/from_dict_validation.py:69 — expand require_truthy docstring to note falsy values (None, "", 0) are treated as missing (matches prior CliSessionMeta behavior).

@bradjin8

bradjin8 commented May 27, 2026

Copy link
Copy Markdown
Collaborator Author

models/from_dict_validation.py — add a small tests/test_from_dict_validation.py asserting message text for require_non_empty_str_fields / require_non_empty_str_field: absent key → missing required field, wrong type → invalid field. test_schema_error_message_distinguishes_missing_from_invalid covers the contract generically but not these helpers post-f846aaf.

models/from_dict_validation.py:69 — expand require_truthy docstring to note falsy values (None, "", 0) are treated as missing (matches prior CliSessionMeta behavior).

both findings are already satisfied on the current tree

  • tests/test_from_dict_validation.py exists and includes focused helper coverage:
    require_non_empty_str_field: absent key → "missing required field", wrong type → "invalid field".
    require_non_empty_str_fields: absent key → "missing required field", wrong type → "invalid field".
  • models/from_dict_validation.py has the expanded require_truthy docstring at line ~69 explicitly stating falsy values (None, "", 0, etc.) are treated as missing.

@clean6378-max-it

Copy link
Copy Markdown
Collaborator

@clean6378-max-it clean6378-max-it requested a review from wpak-ai May 27, 2026 18:01
@wpak-ai wpak-ai merged commit 46bda64 into master May 27, 2026
16 checks passed
@wpak-ai wpak-ai deleted the feat/unit-test-for-pdf-export branch May 27, 2026 18:15
bradjin8 added a commit that referenced this pull request May 28, 2026
#82 is PR for PDF export tests (issue #72), not the _-prefix rename.
Reference issue #73 for decoupling API handlers from service internals.

Co-authored-by: Cursor <cursoragent@cursor.com>
bradjin8 added a commit that referenced this pull request May 28, 2026
#82 is PR for PDF export tests (issue #72), not the _-prefix rename.
Reference issue #73 for decoupling API handlers from service internals.
bradjin8 added a commit that referenced this pull request May 29, 2026
#82 is PR for PDF export tests (issue #72), not the _-prefix rename.
Reference issue #73 for decoupling API handlers from service internals.
wpak-ai pushed a commit that referenced this pull request May 29, 2026
* feat: initial implement of changelog and versioning policy

* removed: yet to be released v0.1.0

* docs: fix CHANGELOG issue refs for PDF tests and API decoupling

#82 is PR for PDF export tests (issue #72), not the _-prefix rename.
Reference issue #73 for decoupling API handlers from service internals.
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.

Add unit tests for PDF export endpoint

3 participants