-
Notifications
You must be signed in to change notification settings - Fork 0
feat(bulk): replace modals with anchored flyouts #38
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
12 commits
Select commit
Hold shift + click to select a range
bc119a1
feat(bulk): replace modals with anchored flyouts
fathiraz c6dab87
fix(transfer): return unresolved rows when eligibility resolver fails
cursoragent 0c36d80
fix(bulk): wire Mark flyout unlock to bulkUnlock (#39)
fathiraz ccc5d98
fix(bulk): route Mark unlock to bulkUnlock (#40)
fathiraz 7012203
fix(bulk-edit): await bulkUpdate dispatch before closing flyout (#41)
fathiraz 6c2d08b
fix(queue-store): clear phase hints on auto-dismiss (#42)
fathiraz 6d7f7d4
fix(ui): apply BulkFlyout bodySx to body container (#43)
fathiraz 0202ce0
fix(background): remove duplicate bulkUnlock handler registration
cursoragent e979a19
fix(bulk-rename): use local calendar date for {date} token
fathiraz a42ef6a
fix(bulk-flyouts): preserve assignees and harden rename fetch
fathiraz 07f21c3
fix(bulk-edit): use RadioGroup.Label for option pickers
fathiraz 838c46a
fix(bulk): address PR #38 review feedback
fathiraz 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| const hoisted = vi.hoisted(() => ({ | ||
| isBulkFull: vi.fn(() => false), | ||
| acquireBulk: vi.fn(), | ||
| releaseBulk: vi.fn(), | ||
| handlers: new Map< | ||
| string, | ||
| (msg: { data: unknown; sender: { tab?: { id?: number } } }) => Promise<unknown> | ||
| >(), | ||
| })) | ||
|
|
||
| vi.mock('@/lib/debug-logger', () => ({ | ||
| logger: { log: () => {}, warn: () => {}, error: () => {}, info: () => {} }, | ||
| })) | ||
|
|
||
| vi.mock('@/background/concurrency', () => ({ | ||
| isBulkFull: hoisted.isBulkFull, | ||
| acquireBulk: hoisted.acquireBulk, | ||
| releaseBulk: hoisted.releaseBulk, | ||
| })) | ||
|
|
||
| vi.mock('@/lib/messages', () => ({ | ||
| onMessage: (type: string, handler: (typeof hoisted.handlers) extends Map<string, infer H> ? H : never) => { | ||
| hoisted.handlers.set(type, handler) | ||
| }, | ||
| })) | ||
|
|
||
| vi.mock('@/background/cache', () => ({ takeCachedResolvedItems: vi.fn() })) | ||
| vi.mock('@/background/rest-helpers', () => ({ broadcastQueue: vi.fn(async () => {}) })) | ||
| vi.mock('@/background/relationship-helpers', () => ({ buildBulkRelationshipTasks: vi.fn(() => []) })) | ||
| vi.mock('@/background/project-helpers', () => ({ resolveProjectItemIds: vi.fn(async () => []) })) | ||
| vi.mock('@/lib/queue', () => ({ processQueue: vi.fn(async () => {}), sleep: vi.fn() })) | ||
| vi.mock('@/lib/graphql-client', () => ({ gql: vi.fn() })) | ||
|
|
||
| import { registerBulkUpdateHandler } from '@/background/bulk-update' | ||
|
|
||
| describe('bulkUpdate dispatch', () => { | ||
| beforeEach(() => { | ||
| hoisted.handlers.clear() | ||
| hoisted.isBulkFull.mockReset() | ||
| hoisted.acquireBulk.mockReset() | ||
| hoisted.releaseBulk.mockReset() | ||
| hoisted.isBulkFull.mockReturnValue(false) | ||
| registerBulkUpdateHandler() | ||
| }) | ||
|
|
||
| it('returns concurrent rejection without acquiring when bulk is full', async () => { | ||
| hoisted.isBulkFull.mockReturnValue(true) | ||
| const handler = hoisted.handlers.get('bulkUpdate') | ||
| expect(handler).toBeDefined() | ||
|
|
||
| const result = await handler!({ | ||
| data: { itemIds: ['a'], projectId: 'p', updates: [] }, | ||
| sender: { tab: { id: 1 } }, | ||
| }) | ||
|
|
||
| expect(result).toEqual({ ok: false, reason: 'concurrent' }) | ||
| expect(hoisted.acquireBulk).not.toHaveBeenCalled() | ||
| expect(hoisted.releaseBulk).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| it('returns ok and releases bulk slot after background work', async () => { | ||
| const handler = hoisted.handlers.get('bulkUpdate')! | ||
| const result = await handler({ | ||
| data: { itemIds: ['a'], projectId: 'p', updates: [] }, | ||
| sender: { tab: { id: 2 } }, | ||
| }) | ||
|
|
||
| expect(result).toEqual({ ok: true }) | ||
| expect(hoisted.acquireBulk).toHaveBeenCalledTimes(1) | ||
|
|
||
| await vi.waitFor(() => { | ||
| expect(hoisted.releaseBulk).toHaveBeenCalledTimes(1) | ||
| }) | ||
| }) | ||
| }) |
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,103 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
|
|
||
| import type { ResolvedItemWithTitle } from '@/background/types' | ||
| import { | ||
| classifyTransferEligibilityRows, | ||
| unresolvedTransferEligibilityRows, | ||
| } from '@/background/transfer-eligibility' | ||
| import { | ||
| decodeIssueNodeId, | ||
| decodeProjectItemDomId, | ||
| decodeProjectItemId, | ||
| decodeRepoName, | ||
| decodeRepoOwner, | ||
| } from '@/lib/schemas-decode' | ||
|
|
||
| function resolvedItem( | ||
| domId: string, | ||
| opts: { | ||
| typename: 'Issue' | 'PullRequest' | ||
| repoOwner: string | ||
| repoName: string | ||
| title?: string | ||
| }, | ||
| ): ResolvedItemWithTitle { | ||
| return { | ||
| domId: decodeProjectItemDomId(domId), | ||
| issueNodeId: decodeIssueNodeId('I_issue'), | ||
| projectItemId: decodeProjectItemId('PVT_item'), | ||
| repoOwner: decodeRepoOwner(opts.repoOwner), | ||
| repoName: decodeRepoName(opts.repoName), | ||
| title: opts.title ?? 'Example', | ||
| typename: opts.typename, | ||
| } | ||
| } | ||
|
|
||
| describe('unresolvedTransferEligibilityRows', () => { | ||
| it('returns one unresolved row per item id in order', () => { | ||
| const rows = unresolvedTransferEligibilityRows(['issue:1', 'issue:2']) | ||
| expect(rows).toEqual([ | ||
| { domId: 'issue:1', eligible: false, reason: 'unresolved' }, | ||
| { domId: 'issue:2', eligible: false, reason: 'unresolved' }, | ||
| ]) | ||
| }) | ||
| }) | ||
|
|
||
| describe('classifyTransferEligibilityRows', () => { | ||
| const targetOwner = 'acme' | ||
| const targetName = 'dest' | ||
|
|
||
| it('marks missing resolved items as unresolved', () => { | ||
| const rows = classifyTransferEligibilityRows( | ||
| ['issue:1', 'issue:2'], | ||
| [resolvedItem('issue:1', { typename: 'Issue', repoOwner: 'acme', repoName: 'src' })], | ||
| targetOwner, | ||
| targetName, | ||
| ) | ||
| expect(rows[0]).toMatchObject({ domId: 'issue:1', eligible: true }) | ||
| expect(rows[1]).toEqual({ domId: 'issue:2', eligible: false, reason: 'unresolved' }) | ||
| }) | ||
|
|
||
| it('marks pull requests ineligible', () => { | ||
| const rows = classifyTransferEligibilityRows( | ||
| ['issue:9'], | ||
| [resolvedItem('issue:9', { typename: 'PullRequest', repoOwner: 'acme', repoName: 'src' })], | ||
| targetOwner, | ||
| targetName, | ||
| ) | ||
| expect(rows[0]).toMatchObject({ | ||
| domId: 'issue:9', | ||
| eligible: false, | ||
| reason: 'pull-request', | ||
| title: 'Example', | ||
| }) | ||
| }) | ||
|
|
||
| it('marks same-repo items ineligible', () => { | ||
| const rows = classifyTransferEligibilityRows( | ||
| ['issue:3'], | ||
| [resolvedItem('issue:3', { typename: 'Issue', repoOwner: 'Acme', repoName: 'Dest' })], | ||
| targetOwner, | ||
| targetName, | ||
| ) | ||
| expect(rows[0]).toMatchObject({ | ||
| domId: 'issue:3', | ||
| eligible: false, | ||
| reason: 'same-repo', | ||
| }) | ||
| }) | ||
|
|
||
| it('marks cross-repo issues eligible', () => { | ||
| const rows = classifyTransferEligibilityRows( | ||
| ['issue:4'], | ||
| [resolvedItem('issue:4', { typename: 'Issue', repoOwner: 'acme', repoName: 'source' })], | ||
| targetOwner, | ||
| targetName, | ||
| ) | ||
| expect(rows[0]).toEqual({ | ||
| domId: 'issue:4', | ||
| eligible: true, | ||
| title: 'Example', | ||
| }) | ||
| }) | ||
| }) |
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
Oops, something went wrong.
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.