-
Notifications
You must be signed in to change notification settings - Fork 0
fix(users): filter removed members from tdc users by default
#10
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,75 @@ | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| // Mock the SDK so we can observe how `getWorkspaceUsers` invokes | ||
| // `client.workspaceUsers.getWorkspaceUsers`. The real filtering of | ||
| // removed users lives in the SDK (≥0.3.0), so the contract this test | ||
| // guards is "we pass `includeRemoved` through unchanged." | ||
| const getWorkspaceUsersMock = vi.hoisted(() => vi.fn().mockResolvedValue([])) | ||
|
|
||
| vi.mock('@doist/comms-sdk', () => ({ | ||
| CommsApi: class { | ||
| workspaceUsers = { getWorkspaceUsers: getWorkspaceUsersMock } | ||
| }, | ||
| })) | ||
|
|
||
| vi.mock('./auth.js', () => ({ | ||
| getApiToken: vi.fn().mockResolvedValue('test-token'), | ||
| })) | ||
|
|
||
| vi.mock('./permissions.js', () => ({ | ||
| ensureWriteAllowed: vi.fn(), | ||
| isMutatingMethod: vi.fn().mockReturnValue(false), | ||
| })) | ||
|
|
||
| vi.mock('./spinner.js', () => ({ | ||
| withSpinner: <T>(_label: unknown, fn: () => Promise<T>) => fn(), | ||
| })) | ||
|
|
||
| vi.mock('./progress.js', () => ({ | ||
| getProgressTracker: () => ({ isEnabled: () => false, emitApiCall: vi.fn() }), | ||
| })) | ||
|
|
||
| const { clearWorkspaceUserCache, getWorkspaceUsers } = await import('./api.js') | ||
|
|
||
| describe('getWorkspaceUsers', () => { | ||
| beforeEach(() => { | ||
| getWorkspaceUsersMock.mockClear() | ||
| clearWorkspaceUserCache() | ||
| }) | ||
|
|
||
| it('passes includeRemoved: undefined by default so the SDK applies its default filter', async () => { | ||
| await getWorkspaceUsers(1585) | ||
| expect(getWorkspaceUsersMock).toHaveBeenCalledWith({ | ||
| workspaceId: 1585, | ||
| includeRemoved: undefined, | ||
| }) | ||
| }) | ||
|
|
||
| it('forwards includeRemoved: true to the SDK', async () => { | ||
| await getWorkspaceUsers(1585, { includeRemoved: true }) | ||
| expect(getWorkspaceUsersMock).toHaveBeenCalledWith({ | ||
| workspaceId: 1585, | ||
| includeRemoved: true, | ||
| }) | ||
| }) | ||
|
|
||
| it('caches active and include-removed variants separately', async () => { | ||
| // First call seeds the active-only cache entry. | ||
| await getWorkspaceUsers(1585) | ||
| // Second call (same workspace, default flag) must hit cache → no extra SDK call. | ||
| await getWorkspaceUsers(1585) | ||
| expect(getWorkspaceUsersMock).toHaveBeenCalledTimes(1) | ||
|
|
||
| // Switching to include-removed must NOT collide with the active entry. | ||
| await getWorkspaceUsers(1585, { includeRemoved: true }) | ||
| expect(getWorkspaceUsersMock).toHaveBeenCalledTimes(2) | ||
| expect(getWorkspaceUsersMock).toHaveBeenLastCalledWith({ | ||
| workspaceId: 1585, | ||
| includeRemoved: true, | ||
| }) | ||
|
|
||
| // And the include-removed variant is itself cached. | ||
| await getWorkspaceUsers(1585, { includeRemoved: true }) | ||
| expect(getWorkspaceUsersMock).toHaveBeenCalledTimes(2) | ||
| }) | ||
| }) | ||
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
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.
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.