-
Notifications
You must be signed in to change notification settings - Fork 8
feat(extension): default tab selector to the window's active tab #4756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7369cba
feat(extension): default tab selector to window active tab
iscekic 6e61c31
test(extension): Chrome E2E for active-tab default and non-inheritance
iscekic e3482d8
test(extension): Firefox E2E non-inheritance for target tab default
iscekic 94d09d9
fix(extension): re-resolve selectedTabId at persist-effect apply time
iscekic 1e8c684
Merge branch 'main' into feat/ext-default-active-tab
iscekic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
apps/extension/entrypoints/sidepanel/use-tab-debugger.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| // Use-tab-debugger transitively imports the WXT '#imports' virtual module; stub it so the graph loads under vitest. | ||
| // eslint-disable-next-line vitest/prefer-import-in-mock, jest/no-untyped-mock-factory | ||
| vi.mock('#imports', () => ({ | ||
| browser: { runtime: { sendMessage: vi.fn() }, tabs: { query: vi.fn() } }, | ||
| storage: { getItem: vi.fn(), setItem: vi.fn() }, | ||
| })); | ||
|
|
||
| // eslint-disable-next-line import/first | ||
| import { getActiveTabId } from './use-tab-debugger'; | ||
|
|
||
| describe('active tab id lookup', () => { | ||
| it('returns the active tab id when the query yields a numeric id', async () => { | ||
| const tabsApi = { | ||
| query: vi.fn().mockResolvedValue([{ id: 42 }]), | ||
| }; | ||
|
|
||
| await expect(getActiveTabId(tabsApi)).resolves.toBe(42); | ||
| expect(tabsApi.query).toHaveBeenCalledWith({ active: true, currentWindow: true }); | ||
| }); | ||
|
|
||
| it('returns undefined when the query yields no active tab', async () => { | ||
| const tabsApi = { | ||
| query: vi.fn().mockResolvedValue([]), | ||
| }; | ||
|
|
||
| await expect(getActiveTabId(tabsApi)).resolves.toBeUndefined(); | ||
| }); | ||
|
|
||
| it('returns undefined when the active tab id is not a number', async () => { | ||
| const tabsApi = { | ||
| query: vi.fn().mockResolvedValue([{ id: 'not-a-number' }]), | ||
| }; | ||
|
|
||
| await expect(getActiveTabId(tabsApi)).resolves.toBeUndefined(); | ||
| }); | ||
|
|
||
| it('returns undefined when the query rejects', async () => { | ||
| const tabsApi = { | ||
| query: vi.fn().mockRejectedValue(new Error('tabs.query failed')), | ||
| }; | ||
|
|
||
| await expect(getActiveTabId(tabsApi)).resolves.toBeUndefined(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.