Skip to content

test: add shared sanitized GitHub API fixtures - #245

Merged
Muskankr merged 1 commit into
Muskankr:mainfrom
Subodh-17:test/sanitized-github-api-fixtures
Nov 10, 2026
Merged

Muskankr merged 1 commit into
Muskankr:mainfrom
Subodh-17:test/sanitized-github-api-fixtures

Conversation

@Subodh-17

Copy link
Copy Markdown
Contributor

Summary

Closes #232 by introducing shared, privacy-sanitized GitHub API v3 JSON fixtures under fixtures/ for backend tests (pytest and unittest) and frontend mock API / Jest tests.

Changes

  • Added 16 shared JSON fixtures under fixtures/ covering users (4), repositories (6), languages (3), and public events (3), including standard, empty, fork-only, no-bio, large-collection (100 repos / 301 profile), and multi-page pagination scenarios (12 real sanitized responses, 1 derived 4-event subset, 3 deterministic synthetic datasets).
  • Documented fixture provenance, allowlist sanitization rules (email: null, private: false, public: true, removed node_id, payload.commits, and verbose hypermedia fields), and cross-stack usage in fixtures/README.md.
  • Added path-validated backend/tests/fixture_loader.py, session fixture fixture_loader in backend/tests/conftest.py, and backend/tests/test_fixtures_sanitization.py enforcing recursive node_id, email/token, event/privacy, language byte, and edge-case invariants.
  • Updated backend tests (test_github_routes.py, test_github_service.py, test_github_pagination.py, test_skill_service.py) to consume shared fixtures while preserving exact route assertions and exercising languages_empty.json, languages_single.json, and languages_multi.json.
  • Integrated shared fixtures into frontend mock data (frontend/mocks/fixtures/users.ts, repositories.ts, skills.ts) and frontend/mocks/handlers.ts (aligning /api/github/users/:username/repositories with backend RepositoryListSerializer metadata while retaining legacy octocat / count assertions), and added frontend/__tests__/githubFixtures.test.ts.
  • Updated docs/mock-api.md and CHANGELOG.md (Unreleased).

Verification

  • Targeted backend pytest (test_fixtures_sanitization.py, test_github_routes.py, test_github_service.py, test_github_pagination.py, test_skill_service.py): 62 passed (exit 0).
  • Backend unittest (python -m unittest discover -s tests -p "test_skill_service.py" -v from backend/): 12 passed (exit 0).
  • New frontend fixture Jest suite (npx jest __tests__/githubFixtures.test.ts): 11 passed (exit 0).
  • Existing mock API direct handler tests (handleMockApiRequest in __tests__/mockApi.test.ts): 10/10 passed.
  • Ruff (ruff check and ruff format --check on fixture_loader.py, test_fixtures_sanitization.py, conftest.py, test_github_routes.py, test_github_service.py, test_skill_service.py): passed (exit 0).
  • Prettier (npx prettier --check across all 24 Issue Create sanitized GitHub API fixtures for tests #232 JSON, Markdown, and TypeScript files): passed (exit 0).
  • git diff --check: passed (exit 0).
  • npx tsc --noEmit: 0 errors in Issue Create sanitized GitHub API fixtures for tests #232 files.
  • (Note: mypy is not installed in the local Python environment, and npm run build was not executed directly after the final edits on the workspace; 0 application files under app/ were modified.)

Existing baseline limitations

  • Full repository verification is not green on upstream base 37192a9:
    • Full backend pytest retains 1 failure reproduced on 37192a9 (tests/test_config_and_utils_typing.py::test_validation_utility_types rejecting @torvalds; 260 passed on the branch vs 243 passed on 37192a9) and exits with Windows teardown status -1073741819.
    • backend/tests/test_github_pagination.py retains pre-existing Ruff diagnostics on untouched lines (17: unused F401 Settings, 201: UP017 timezone.utc, 228: line wrap; repo-wide ruff format --check . fails on 25 upstream files), while all +43 added lines pass cleanly.
    • Full frontend Jest retains 27 failing suites and 6 failing jsdom Response-related E2E tests inside mockApi.test.ts reproduced identically on 37192a9 (16 passed, 27 failed suites; 223 passed, 6 failed tests vs base 15 passed, 27 failed; 212 passed, 6 failed due to upstream [email protected] vs [email protected], JSX syntax in .test.ts files, and missing Response in jsdom).
    • npx tsc --noEmit retains 23 pre-existing diagnostic lines in 4 .test.ts files containing JSX (activitySummary.test.ts, preferences.test.ts, profileHealth.test.ts, skillTimeline.test.ts).
    • npm run lint fails identically on 37192a9 (ESLint 10.14.0 vs eslint-plugin-react: contextOrFilename.getFilename is not a function), and npm run format:check referenced by CI is missing from frontend/package.json.

Testing

  • Fixture & cross-stack tests: backend/tests/test_fixtures_sanitization.py checks JSON validity, recursive node_id removal, absence of email/token/payload.commits, repository private: false, event public: true, language integer invariants, and edge-case counts/fields. Shared fixtures are integrated and verified across test_github_routes.py, test_github_service.py, test_github_pagination.py, test_skill_service.py, and frontend/__tests__/githubFixtures.test.ts (including deterministic fixedNow activity summary classification for events_active.json, events_occasional.json, and events_empty.json, @octocat-real consistency, and /repositories pagination metadata).
  • Upstream baseline reproduction: Backend pytest, ruff, frontend jest --ci, tsc --noEmit, and npm run lint were executed on an isolated detached worktree of 37192a9 to confirm every failing full-suite check pre-exists upstream.

Scope

No production application code (backend/app/, frontend/app/, frontend/components/, frontend/utils/) was modified. Changes are strictly limited to shared fixtures (fixtures/), test helpers and suites (backend/tests/, frontend/__tests__/), frontend mocks (frontend/mocks/), and documentation (fixtures/README.md, docs/mock-api.md, CHANGELOG.md).

@vercel

vercel Bot commented Nov 10, 2026

Copy link
Copy Markdown

@Subodh-17 is attempting to deploy a commit to the a2521729-9889's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added documentation Improvements or additions to documentation frontend backend labels Nov 10, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Congratulations on submitting your first pull request to OpenSourceMate!

  • Automated CI checks will test your changes shortly.
  • Please ensure your PR description links the corresponding issue (Fixes #<number>) and follows our Contributing Guide.
  • If you are new to Git workflows, check out our First Contribution Guide.
  • A maintainer will review your contribution soon. Thank you for your support!

@Muskankr
Muskankr merged commit 84f9b01 into Muskankr:main Nov 10, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend documentation Improvements or additions to documentation frontend level3 nsoc26

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create sanitized GitHub API fixtures for tests

2 participants