Skip to content

fix(e2e): use native chrome API instead of browser polyfill in tests#3992

Merged
amitsingh-007 merged 5 commits into
mainfrom
fix/e2e-browser-api
May 2, 2026
Merged

fix(e2e): use native chrome API instead of browser polyfill in tests#3992
amitsingh-007 merged 5 commits into
mainfrom
fix/e2e-browser-api

Conversation

@amitsingh-007

@amitsingh-007 amitsingh-007 commented May 2, 2026

Copy link
Copy Markdown
Owner

Greptile Summary

This PR replaces the WXT browser polyfill with the native chrome API across all Playwright e2e test utilities and fixtures, adding @types/chrome for proper type support. It also bundles several unrelated cleanups: removing unused Props type exports and an unused getCurrentUser function, unexporting internal-only saveBookmarks/savePersons helpers in realtimeDBService.ts, and moving @bypass/trpc's runtime dependencies to peerDependencies.

Confidence Score: 5/5

Safe to merge — no logic bugs or regressions introduced.

All changed code is either test infrastructure (browser → chrome API swap, types), dead-code removal (unused exports/functions), or lockfile/workspace hygiene. The pnpm-lock.yaml was regenerated successfully, confirming the dependency changes resolve cleanly in the monorepo.

No files require special attention.

Reviews (5): Last reviewed commit: "Remove dead code" | Re-trigger Greptile

WXT v0.20 removed webextension-polyfill injection (wxt-dev/wxt#1084).
The browser global is no longer available in Playwright evaluate()
contexts. Switch to the native chrome.* API which is always available
in Chrome extension page and service worker contexts.

Fixes failing extension E2E tests after renovate dependency updates.
greptile-apps[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

@coderabbitai

coderabbitai Bot commented May 2, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Replaces in-page WebExtension API usage from browser.* to chrome.* across extension tests: storage calls (storage.local.get/set/remove) and history.search are switched to chrome in auth setup, background fixture, base fixture, history utils, and test utils. Adds a concrete TypeScript declaration for the global chrome (typed subset used by tests). Also reorders top-level keys in pnpm-workspace.yaml. No exported/public API signatures were changed.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning PR description lacks required template sections for version change assessment and extension requirements checklist. Add completion of the repository's PR template by checking version change requirement and confirming extension requirements are met.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: replacing browser polyfill with native chrome API in E2E tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/e2e-browser-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
apps/extension/tests/types.d.ts (1)

6-6: Install @types/chrome to replace the any type annotation with proper Chrome extension API signatures.

The declare const chrome: any satisfies the compiler but loses all type checking and IDE autocomplete for every chrome.* call (e.g., chrome.storage.local.get, chrome.history.search) in the test suite. The @types/chrome package provides complete ambient type definitions for the Chrome Extension APIs and is fully compatible with Playwright's evaluate() context.

♻️ Proposed refactor

Install the types package:

# in apps/extension/package.json devDependencies
+ "@types/chrome": "^0.1.38"

Then remove apps/extension/tests/types.d.ts entirely, since @types/chrome already declares chrome in the global ambient scope.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/extension/tests/types.d.ts` at line 6, Remove the manual `declare const
chrome: any` in apps/extension/tests/types.d.ts and instead install the
`@types/chrome` package so the global `chrome` symbol has proper Chrome
extension API typings; after installing `@types/chrome` delete the custom
types.d.ts file (or stop declaring `chrome`) so the ambient definitions from
`@types/chrome` provide autocomplete and type-checking for all `chrome.*` calls
(e.g., chrome.storage.local.get, chrome.history.search) in the tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/extension/tests/types.d.ts`:
- Line 6: Remove the manual `declare const chrome: any` in
apps/extension/tests/types.d.ts and instead install the `@types/chrome` package
so the global `chrome` symbol has proper Chrome extension API typings; after
installing `@types/chrome` delete the custom types.d.ts file (or stop declaring
`chrome`) so the ambient definitions from `@types/chrome` provide autocomplete
and type-checking for all `chrome.*` calls (e.g., chrome.storage.local.get,
chrome.history.search) in the tests.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8a324e73-352d-4557-ae0b-17c7ff85d12d

📥 Commits

Reviewing files that changed from the base of the PR and between cc5cdd2 and aba7db1.

📒 Files selected for processing (6)
  • apps/extension/tests/auth.setup.ts
  • apps/extension/tests/fixtures/background-fixture.ts
  • apps/extension/tests/fixtures/base-fixture.ts
  • apps/extension/tests/types.d.ts
  • apps/extension/tests/utils/history-utils.ts
  • apps/extension/tests/utils/test-utils.ts

- Add @types/chrome devDependency for proper Chrome API typing in tests
- Replace 'any' type declaration with triple-slash reference to @types/chrome
- Update JSDoc in test-utils.ts: browser.storage.local → chrome.storage.local
- Update comment in base-fixture.ts: browser.storage.local → chrome.storage.local

Addresses review comments on PR #3992.
- Remove @types/chrome dependency (WXT provides browser types, not chrome global)
- Add minimal types.d.ts declaring only chrome.storage and chrome.history APIs used in tests
- Keep comments and JSDoc updated to reference chrome.* instead of browser.*
- Add @types/chrome as devDependency to extension package
- Remove custom types.d.ts declaration
- @types/chrome provides full type safety for chrome.storage and chrome.history in test evaluate() contexts
@amitsingh-007 amitsingh-007 merged commit d5efc0a into main May 2, 2026
7 checks passed
@amitsingh-007 amitsingh-007 deleted the fix/e2e-browser-api branch May 2, 2026 12:57
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.

1 participant