Skip to content

Conversation

@Gyan172004
Copy link
Contributor

@Gyan172004 Gyan172004 commented Nov 14, 2025

Summary

#68
This pull request adds a complete testing setup for the docFiller extension. It introduces a full end-to-end (E2E) testing system using Playwright and also fixes the existing unit and integration test setup to make everything run smoothly.


What Was Done

E2E Test Infrastructure (Playwright)

  • New Test Suite: Added a fresh E2E test suite for Chromium.
  • Automatic Extension Loading: The test fixture now builds and loads the extension automatically in a clean browser for every run.
  • Extension ID Detection: Added a reliable, multi-step way to detect and cache the extension ID, so there’s no need to set it manually anymore.
  • Secure API Key Handling: Removed the hardcoded API key (caught by Gitleaks) and now load it from an environment variable (GEMINI_API_KEY).
  • Functional Tests: Added working tests that cover the main form-filling flow—turning on the extension, going to a form page, and checking that the fields are auto-filled by the AI.
  • Improved Test Flow: Updated the logic to make sure the extension is enabled before navigating to the form page, which is necessary for the content script to run correctly.

Unit & Integration Test Fixes (Vitest)

  • Restored Test Config: The vitest.config.ts file was empty; it’s now restored and properly set up.
  • Fixed Test Failures: Updated the browser mock to support the onStartup event, which fixed the failing background script tests.
  • Added Missing Dependency: Added the missing jsdom dependency needed by the test environment.
  • All Tests Passing: All 414 unit tests and 7 integration tests now pass successfully.

Documentation & Code Quality

  • New E2E Guide: Added a tests/e2e/README.md with clear steps on how to set up and run the E2E tests.
  • Code Cleanup: Removed unnecessary or overly detailed comments, keeping only what helps explain tricky parts.
  • Linting: Fixed all linting issues in the updated files.

- Implemented Playwright-based e2e tests for Chromium
- Auto-detects extension ID and caches for faster runs
- API keys from environment variables (secure)
- Tests verify full form-filling workflow
- 2 passing e2e tests: text field & email field auto-fill
- All 414 unit tests passing
- Firefox support pending (Chromium only for now)

Test infrastructure:
- Extension loads automatically with mock API key
- Detects extension from service workers
- Tests enable extension before navigating to forms
- Verifies real AI-generated form content

Files Added:
- tests/e2e/**/*.spec.ts - E2E test files
- tests/e2e/fixtures/extension-fixture.ts - Core test setup
- tests/e2e/README.md - Setup documentation

Files Modified:
- src/background/index.ts - Store extension ID for testing
- tests/mocks/browser.mock.ts - Added onStartup mock
- tests/unit/background/index.test.ts - Updated for new listener
- vitest.config.ts - Exclude e2e tests, restored config
- .gitignore - Ignore test artifacts
@github-actions github-actions bot added documentation Improvements or additions to documentation background labels Nov 14, 2025
- Implement dependency injection in LLMEngine for testability
- Convert all integration tests to use real Gemini API calls
- Add table-driven test approach for better maintainability
- Tests run sequentially with natural pipeline delays
- No mocking of LLM responses - full end-to-end testing
@github-actions github-actions bot added gpt-engine Everything about the GPTEngine core Related to docFiller core engine labels Nov 16, 2025
Gyandeep Katiyar added 3 commits November 16, 2025 10:27
- Use bracket notation for process.env access
- Add type guards (if (!response) return;) after response checks
- Fix null safety for response properties
- Remove async from beforeEach (no await needed)
- Replace any types with LLMResponse | null
- Remove console.warn statements
- Fix unused parameter in validate callback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

background config core Related to docFiller core engine documentation Improvements or additions to documentation gpt-engine Everything about the GPTEngine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant