Skip to content

test: add unit and integration tests for various components and features#1009

Merged
frank-zsy merged 11 commits intohypertrons:masterfrom
wxharry:add-integration-tests
Apr 11, 2026
Merged

test: add unit and integration tests for various components and features#1009
frank-zsy merged 11 commits intohypertrons:masterfrom
wxharry:add-integration-tests

Conversation

@wxharry
Copy link
Copy Markdown
Collaborator

@wxharry wxharry commented Apr 8, 2026

This pull request is in the type of (more info about types):

  • build
  • ci
  • docs
  • feat
  • fix
  • perf
  • refactor
  • test

Related issues (all available keywords):

  • keyword #xxx

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:

  • Added Playwright configuration (playwright.config.ts) to enable and standardize E2E test execution.
  • Created a shared test helper (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:

  • Added E2E tests for the following features:
    • Developer Activity & OpenRank Trends (developer-activity-openrank-trends.component.spec.ts)
    • Developer Hovercard Info (developer-hovercard-info.component.spec.ts)
    • Developer Networks (developer-networks.component.spec.ts)
    • Fast-PR (fast-pr.component.spec.ts)
    • OSS-GPT (oss-gpt.component.spec.ts)
    • Perceptor Layout (perceptor-layout.component.spec.ts)
    • Perceptor Tab (perceptor-tab.component.spec.ts)

Project Scripts and Dependency Updates:

  • Updated package.json to add scripts for running, watching, and collecting coverage for tests using Vitest and Playwright.
  • Added Playwright, Vitest, and jsdom as development dependencies to support the new testing framework. [1] [2]

Minor Style Adjustment:

  • Minor formatting update in src/pages/Options/index.css for improved readability.## Brief Information

Checklist

Others

wxharry added 7 commits March 25, 2026 20:13
- 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.
Copilot AI review requested due to automatic review settings April 8, 2026 03:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 chrome extension 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 .gitignore and 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.

Comment thread package.json
Comment thread tests/unit/get-github-repo-info.test.ts
Comment thread tests/unit/get-gitee-repo-info.test.ts
Comment thread tests/e2e/content-scripts/helpers.ts
Comment thread tests/e2e/content-scripts/helpers.ts
Comment thread tests/e2e/content-scripts/helpers.ts
@wxharry wxharry self-assigned this Apr 8, 2026
@wxharry wxharry marked this pull request as draft April 8, 2026 04:04
@wxharry wxharry marked this pull request as ready for review April 8, 2026 05:29
@frank-zsy
Copy link
Copy Markdown
Contributor

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?

@wxharry
Copy link
Copy Markdown
Collaborator Author

wxharry commented Apr 8, 2026

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.

@frank-zsy frank-zsy merged commit 48cafed into hypertrons:master Apr 11, 2026
3 checks passed
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.

3 participants