Repository navigation
fix(organization-search): hide the block where Search is off, isolate the Slack identity sweep in the People cron #10589
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
+150
−11
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
2107969
fix(organization-search): hide the block where its organization lacks…
waleedlatif1 86d5ab8
test(people): pass the route context the handler type expects
waleedlatif1 851d269
fix(organization-search): hide only the Organization Search block whe…
waleedlatif1 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,50 @@ | ||
| import { authInternalMock, authInternalMockFns } from '@sim/testing/mocks/auth-internal.mock' | ||
| import { createMockRequest } from '@sim/testing/mocks/request.mock' | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| const { syncDueDirectories, refreshDueSlackIdentities } = vi.hoisted(() => ({ | ||
| syncDueDirectories: vi.fn(), | ||
| refreshDueSlackIdentities: vi.fn(), | ||
| })) | ||
| vi.mock('@/lib/auth/internal', () => authInternalMock) | ||
| vi.mock('@/lib/people/sync/runner', () => ({ syncDueDirectories })) | ||
| vi.mock('@/lib/people/slack-identities', () => ({ refreshDueSlackIdentities })) | ||
|
|
||
| import { GET } from '@/app/api/cron/people-directory-sync/route' | ||
|
|
||
| function sweep() { | ||
| return GET( | ||
| createMockRequest('GET', undefined, {}, 'http://localhost:3000/api/cron/people-directory-sync'), | ||
| undefined | ||
| ) | ||
| } | ||
|
|
||
| describe('people directory sync cron', () => { | ||
| beforeEach(() => { | ||
| authInternalMockFns.mockVerifyCronAuth.mockReturnValue(null) | ||
| syncDueDirectories.mockReset().mockResolvedValue({ attempted: 3 }) | ||
| refreshDueSlackIdentities.mockReset().mockResolvedValue({ refreshed: 2 }) | ||
| }) | ||
|
|
||
| it('reports a directory sync that succeeded when only the Slack identity sweep failed', async () => { | ||
| refreshDueSlackIdentities.mockRejectedValue(new Error('connection terminated')) | ||
| const response = await sweep() | ||
| expect(response.status).toBe(200) | ||
| expect(await response.json()).toEqual({ | ||
| attempted: 3, | ||
| slackIdentitiesRefreshed: 0, | ||
| failed: ['slackIdentities'], | ||
| }) | ||
| }) | ||
|
|
||
| it('fails the invocation for a failed directory sweep, still reporting the Slack refresh', async () => { | ||
| syncDueDirectories.mockRejectedValue(new Error('connection terminated')) | ||
| const response = await sweep() | ||
| expect(response.status).toBe(500) | ||
| expect(await response.json()).toEqual({ | ||
| attempted: 0, | ||
| slackIdentitiesRefreshed: 2, | ||
| failed: ['directories'], | ||
| }) | ||
| }) | ||
| }) |
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
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.