test: add unit and integration tests for various components and features#1009
test: add unit and integration tests for various components and features#1009frank-zsy merged 11 commits intohypertrons:masterfrom
Conversation
- Implement tests for developer activity openrank trends component. - Create tests for developer hovercard info component. - Add tests for developer networks component. - Implement tests for fast-pr component. - Create helper functions for launching extension context and cleaning up. - Add tests for OSS-GPT component. - Implement tests for perceptor layout and tab components. - Create tests for repo activity openrank trends and racing bar components. - Add tests for repo fork tooltip and header labels components. - Implement tests for repo issue tooltip and networks components. - Create tests for repo PR tooltip and sidebar labels components. - Add tests for repo star tooltip component.
There was a problem hiding this comment.
Pull request overview
Adds a Vitest + Playwright testing setup to improve automated coverage across helper utilities, feature orchestration, and browser-extension UI/content-script behavior.
Changes:
- Introduces Vitest config + a shared test setup with a mocked
chromeextension API for unit/integration tests. - Adds Playwright config and a large set of E2E specs covering the popup/options pages and multiple content-script features.
- Updates npm scripts/devDependencies to run unit, integration, coverage, and E2E suites; updates
.gitignoreand minor CSS formatting.
Reviewed changes
Copilot reviewed 52 out of 54 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | Adds Vitest configuration (jsdom, setup file, include pattern). |
| playwright.config.ts | Adds Playwright test-runner configuration for E2E suite. |
| package.json | Adds test scripts and devDependencies for Vitest/Playwright/jsdom. |
| .gitignore | Ignores Playwright artifacts and coverage outputs. |
| src/pages/Options/index.css | Minor formatting change for font-family declaration. |
| tests/setup.ts | Global Vitest afterEach cleanup and chrome-storage reset. |
| tests/mocks/chrome-api.ts | Provides a mocked chrome API (runtime + storage) for tests. |
| tests/unit/wait-for.test.ts | Unit tests for polling helper (waitFor). |
| tests/unit/sleep.test.ts | Unit tests for timer-based sleep helper. |
| tests/unit/should-feature-run.test.ts | Unit tests for feature gating logic. |
| tests/unit/request.test.ts | Unit tests for fetch wrapper behavior. |
| tests/unit/linear-map.test.ts | Unit tests for numeric mapping/clamping helper. |
| tests/unit/judge-interval.test.ts | Unit tests for interval calculation and zoom handler wiring. |
| tests/unit/is-restoration-visit.test.ts | Unit tests for Turbo restoration-visit detection. |
| tests/unit/is-platform-flags.test.ts | Unit tests for platform detection helpers (GitHub/Gitee/Perceptor). |
| tests/unit/is-null.test.ts | Unit tests for null/empty checks. |
| tests/unit/i18n.test.ts | Smoke checks for i18n initialization/resources. |
| tests/unit/github-token.test.ts | Unit tests for GitHub token storage helpers. |
| tests/unit/gitee-token.test.ts | Unit tests for Gitee token storage/refresh behavior. |
| tests/unit/get-platform.test.ts | Unit tests for platform selection logic. |
| tests/unit/get-github-theme.test.ts | Unit tests for GitHub theme detection logic. |
| tests/unit/get-github-repo-info.test.ts | Unit tests for GitHub repo-name/meta helpers. |
| tests/unit/get-github-developer-info.test.ts | Unit tests for GitHub developer-name/meta helpers. |
| tests/unit/get-gitee-repo-info.test.ts | Unit tests for Gitee repo-name/meta helpers. |
| tests/unit/get-gitee-developer-info.test.ts | Unit tests for Gitee developer-name/meta helpers. |
| tests/unit/generate-data-by-month.test.ts | Unit tests for month-series normalization helper. |
| tests/unit/formatter.test.ts | Unit tests for numeric formatting helpers. |
| tests/unit/exists.test.ts | Unit tests for DOM selector existence helper. |
| tests/integration/options-storage.test.ts | Integration tests for defaults + persistence in options storage. |
| tests/integration/feature-manager.test.ts | Integration tests for feature-manager behavior (enable/disable/restore/id parsing). |
| tests/integration/api-common.test.ts | Integration tests for API common utilities (metric + meta cache). |
| tests/e2e/extension-smoke.spec.ts | Basic E2E smoke tests for popup/options rendering. |
| tests/e2e/extension-popup.spec.ts | E2E checks for popup interactions + console error hygiene. |
| tests/e2e/extension-options.spec.ts | E2E checks for options page sections/controls + console error hygiene. |
| tests/e2e/extension-flows.spec.ts | E2E user-flow tests (popup→options, persistence after reload). |
| tests/e2e/extension-components.spec.ts | E2E component-level checks for options/popup UI pieces. |
| tests/e2e/content-scripts/helpers.ts | Shared Playwright helpers for launching extension + navigating to a target repo. |
| tests/e2e/content-scripts/repo-star-tooltip.component.spec.ts | E2E checks for star tooltip injection behavior. |
| tests/e2e/content-scripts/repo-sidebar-labels.component.spec.ts | E2E checks for sidebar label injection/link behavior. |
| tests/e2e/content-scripts/repo-pr-tooltip.component.spec.ts | E2E checks for PR tooltip behavior with network mocking. |
| tests/e2e/content-scripts/repo-networks.component.spec.ts | E2E checks for repo networks on perceptor routes. |
| tests/e2e/content-scripts/repo-issue-tooltip.component.spec.ts | E2E checks for issue tooltip wiring. |
| tests/e2e/content-scripts/repo-header-labels.component.spec.ts | E2E checks for header labels + hover tooltips. |
| tests/e2e/content-scripts/repo-fork-tooltip.component.spec.ts | E2E checks for fork tooltip wiring. |
| tests/e2e/content-scripts/repo-activity-racing-bar.component.spec.ts | E2E checks for racing-bar rendering and interaction. |
| tests/e2e/content-scripts/repo-activity-openrank-trends.component.spec.ts | E2E checks for openrank trends rendering rules. |
| tests/e2e/content-scripts/perceptor-tab.component.spec.ts | E2E checks for perceptor tab rendering/navigation. |
| tests/e2e/content-scripts/perceptor-layout.component.spec.ts | E2E checks for perceptor layout slot scaffolding. |
| tests/e2e/content-scripts/oss-gpt.component.spec.ts | E2E checks for OSS-GPT feature enablement + widget UI. |
| tests/e2e/content-scripts/fast-pr.component.spec.ts | E2E checks for fast-pr iframe + message-driven UI/cache. |
| tests/e2e/content-scripts/developer-networks.component.spec.ts | E2E checks for developer networks section/modal. |
| tests/e2e/content-scripts/developer-hovercard-info.component.spec.ts | E2E checks for hovercard augmentation. |
| tests/e2e/content-scripts/developer-activity-openrank-trends.component.spec.ts | E2E checks for developer activity/openrank trends section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
So right now we need to trigger e2e test in local env, do we need to add the test in workflows or these tests are designed to run in local env? |
Yes, the plan is to have all the tests, including unit tests, components tests, and e2e tests in our ci pipeline. But for the e2e tests, we can run the smoke tests only for PRs and only run the full tests on merges if it takes a lot of time or resources to run the full e2e tests. |
This pull request is in the type of (more info about types):
Related issues (all available keywords):
Details
This pull request introduces a comprehensive end-to-end (E2E) testing setup using Playwright and Vitest, significantly improving test coverage for content script features in the extension. It adds new test scripts for major UI components, configures Playwright for E2E testing, and updates project dependencies and scripts to support the new test infrastructure.
E2E Testing Infrastructure and Coverage:
playwright.config.ts) to enable and standardize E2E test execution.tests/e2e/content-scripts/helpers.ts) for launching, cleaning up, and interacting with the extension in a browser context.New E2E Test Suites for Content Scripts:
developer-activity-openrank-trends.component.spec.ts)developer-hovercard-info.component.spec.ts)developer-networks.component.spec.ts)fast-pr.component.spec.ts)oss-gpt.component.spec.ts)perceptor-layout.component.spec.ts)perceptor-tab.component.spec.ts)Project Scripts and Dependency Updates:
package.jsonto add scripts for running, watching, and collecting coverage for tests using Vitest and Playwright.jsdomas development dependencies to support the new testing framework. [1] [2]Minor Style Adjustment:
src/pages/Options/index.cssfor improved readability.## Brief InformationChecklist
Others