Skip to content

Add E2E blog scenario, edge-case tests, and mock GCS storage

Choose a tag to compare

released this 21 Oct 19:04
· 38 commits to working since this release

This release focuses on expanding test coverage and adding tooling to validate core behaviors against end-to-end workflows and edge cases.

Testing Improvements

  • Add end-to-end blog scenario test suite (tests/e2e/blog-scenario.test.ts) covering:

    • Full post/comment/reply workflow using createPrimaryGCSLibrary, createContainedGCSLibrary, and createContainedGCSLibrary2 (create/get/all/update/remove)
    • Custom finder usage via operations.find and a custom action via operations.action
    • Backed by createMockStorage for isolated, in-memory execution
    • Source: Add E2E and edge-case test suites with mock GCS storage and fixtures
  • Add invalid data edge-case tests (tests/edge-cases/invalid-data.test.ts) to assert validation failures in:

    • validateItem: rejects primary keys with invalid characters (e.g., forward/backslashes, null)
    • validateKey: wrong kt, empty pk, ComKey without locations, or with incorrect location count
    • validateLocations: wrong location count and missing kt/lk fields
    • validateFileName: empty and control-character-containing filenames
    • validateGCSConfig: invalid bucket names (uppercase, too short/long, empty) and invalid directory paths (leading slash, path traversal)
    • Source: Add tests/edge-cases/invalid-data.test.ts to assert failures in validateItem/validateKey/validateLocations and validateFileName/validateGCSConfig for bad characters, wrong types, and invalid bucket/paths
  • Add large dataset edge-case tests (tests/edge-cases/large-datasets.test.ts) for query safety and performance controls:

    • all(): throws when file count exceeds maxScanFiles
    • all(): respects downloadConcurrency when fetching multiple files
    • all(): throws when query operations are disabled
    • Uses PathBuilder and FileProcessor in conjunction with createMockStorage
    • Source: Add tests/edge-cases/large-datasets.test.ts to verify all() enforces maxScanFiles, respects downloadConcurrency, and throws when query operations are disabled (with PathBuilder and FileProcessor)

Test Utilities

  • Introduce in-memory mock GCS storage (tests/mocks/storageMock.ts):
    • MockStorage, MockBucket, MockFile classes and createMockStorage factory
    • Supports save/download/delete, list by prefix, signed URL generation, and metadata retrieval
    • Enables fast, deterministic test runs without external dependencies
    • Source: Introduce tests/mocks/storageMock.ts implementing MockStorage, MockBucket, MockFile, and createMockStorage for in-memory bucket/file behavior (save/download/delete, list by prefix, signed URL, metadata)

Fixtures

  • Add sample data fixtures and barrel export for tests (tests/fixtures):
    • users.ts, posts.ts, comments.ts and index.ts
    • Source: Add sample data fixtures in tests/fixtures/{users.ts,posts.ts,comments.ts} and barrel export in tests/fixtures/index.ts

Version

  • Bump package version to 4.4.9 (from 4.4.9-dev.0)
    • Source: Bump package version to 4.4.9 in package.json (from 4.4.9-dev.0)