diff --git a/apps/server/src/api/v2/chats/handler.test.ts b/apps/server/src/api/v2/chats/handler.test.ts index 5672665d6..6a24acc9b 100644 --- a/apps/server/src/api/v2/chats/handler.test.ts +++ b/apps/server/src/api/v2/chats/handler.test.ts @@ -24,6 +24,7 @@ vi.mock('@buster/database', () => ({ createMessage: vi.fn(), generateAssetMessages: vi.fn(), getMessagesForChat: vi.fn(), + updateMessage: vi.fn(), db: { transaction: vi.fn().mockImplementation((callback: any) => callback({ @@ -37,7 +38,7 @@ vi.mock('@buster/database', () => ({ messages: {}, })); -import { getUserOrganizationId } from '@buster/database'; +import { getUserOrganizationId, updateMessage } from '@buster/database'; import { tasks } from '@trigger.dev/sdk/v3'; import { createChatHandler } from './handler'; import { handleAssetChat } from './services/chat-helpers'; @@ -93,9 +94,10 @@ describe('createChatHandler', () => { }); vi.mocked(getUserOrganizationId).mockResolvedValue({ organizationId: '550e8400-e29b-41d4-a716-446655440000', - role: 'admin', + role: 'workspace_admin', }); vi.mocked(tasks.trigger).mockResolvedValue({ id: 'task-handle-123' } as any); + vi.mocked(updateMessage).mockResolvedValue({} as any); }); it('should create a new chat with prompt', async () => { diff --git a/apps/server/src/api/v2/security/workspace-settings-service.test.ts b/apps/server/src/api/v2/security/workspace-settings-service.test.ts index 6ae1274ec..bbc90d9df 100644 --- a/apps/server/src/api/v2/security/workspace-settings-service.test.ts +++ b/apps/server/src/api/v2/security/workspace-settings-service.test.ts @@ -15,7 +15,7 @@ describe('WorkspaceSettingsService', () => { const result = service.formatWorkspaceSettingsResponse(settings); expect(result).toEqual({ restrict_new_user_invitations: true, - default_role: 'member', + default_role: 'workspace_admin', default_datasets: [], }); }); diff --git a/apps/server/src/api/v2/slack/handler.test.ts b/apps/server/src/api/v2/slack/handler.test.ts index 4e719cde3..dad442b2b 100644 --- a/apps/server/src/api/v2/slack/handler.test.ts +++ b/apps/server/src/api/v2/slack/handler.test.ts @@ -83,7 +83,7 @@ describe('SlackHandler', () => { // Mock getUserOrganizationId to return org info vi.mocked(getUserOrganizationId).mockResolvedValue({ organizationId: 'org-123', - role: 'owner', + role: 'workspace_admin', }); const mockResult = { @@ -98,11 +98,13 @@ describe('SlackHandler', () => { organizationId: 'org-123', userId: 'user-123', metadata: { - returnUrl: '/dashboard', ipAddress: '192.168.1.1', }, }); - expect(mockContext.json).toHaveBeenCalledWith(mockResult); + expect(mockContext.json).toHaveBeenCalledWith({ + auth_url: 'https://slack.com/oauth/authorize', + state: 'test-state', + }); }); it('should handle existing integration error', async () => { @@ -116,7 +118,7 @@ describe('SlackHandler', () => { // Mock getUserOrganizationId to return org info vi.mocked(getUserOrganizationId).mockResolvedValue({ organizationId: 'org-123', - role: 'owner', + role: 'workspace_admin', }); vi.mocked(mockSlackOAuthService.initiateOAuth).mockRejectedValue( @@ -210,16 +212,21 @@ describe('SlackHandler', () => { // Mock getUserOrganizationId to return org info vi.mocked(getUserOrganizationId).mockResolvedValue({ organizationId: 'org-123', - role: 'owner', + role: 'workspace_admin', }); const mockStatus = { connected: true, integration: { id: 'integration-123', - teamName: 'Test Workspace', - installedAt: '2025-01-01T00:00:00.000Z', + team_name: undefined, + installed_at: undefined, + default_channel: undefined, + default_sharing_permissions: undefined, + last_used_at: undefined, + team_domain: undefined, }, + status: undefined, }; vi.mocked(mockSlackOAuthService.getIntegrationStatus).mockResolvedValue(mockStatus); @@ -250,7 +257,7 @@ describe('SlackHandler', () => { // Mock getUserOrganizationId to return org info vi.mocked(getUserOrganizationId).mockResolvedValue({ organizationId: 'org-123', - role: 'owner', + role: 'workspace_admin', }); vi.mocked(mockSlackOAuthService.removeIntegration).mockResolvedValue({ @@ -274,7 +281,7 @@ describe('SlackHandler', () => { // Mock getUserOrganizationId to return org info vi.mocked(getUserOrganizationId).mockResolvedValue({ organizationId: 'org-123', - role: 'owner', + role: 'workspace_admin', }); vi.mocked(mockSlackOAuthService.removeIntegration).mockResolvedValue({ diff --git a/apps/server/src/api/v2/slack/services/slack-oauth-service.test.ts b/apps/server/src/api/v2/slack/services/slack-oauth-service.test.ts index 781638fab..56085d378 100644 --- a/apps/server/src/api/v2/slack/services/slack-oauth-service.test.ts +++ b/apps/server/src/api/v2/slack/services/slack-oauth-service.test.ts @@ -66,6 +66,7 @@ describe('SlackOAuthService', () => { id: 'existing-integration', organizationId: 'org-123', status: 'active', + scope: 'app_mentions:read,channels:history,channels:join,channels:manage,channels:read,chat:write,chat:write.public,commands,files:read,files:write,groups:history,groups:write,im:history,im:read,im:write,mpim:history,mpim:read,mpim:write,reactions:write,reactions:read,users:read,users:read.email', } as any); await expect( @@ -73,7 +74,7 @@ describe('SlackOAuthService', () => { organizationId: 'org-123', userId: 'user-123', }) - ).rejects.toThrow('Organization already has an active Slack integration'); + ).rejects.toThrow('Organization already has an active Slack integration with current scopes'); }); it('should create pending integration and return auth URL', async () => {