mirror of https://github.com/buster-so/buster.git
small lint and build fixes
This commit is contained in:
parent
40a612f10a
commit
754f38270d
|
@ -36,7 +36,7 @@ describe('github-app', () => {
|
|||
// Arrange
|
||||
const privateKey = '-----BEGIN RSA PRIVATE KEY-----\ntest-key\n-----END RSA PRIVATE KEY-----';
|
||||
const privateKeyBase64 = Buffer.from(privateKey).toString('base64');
|
||||
|
||||
|
||||
vi.mocked(getSecret).mockImplementation(async (key: string) => {
|
||||
if (key === 'GITHUB_APP_ID') return '123456';
|
||||
if (key === 'GITHUB_APP_PRIVATE_KEY_BASE64') return privateKeyBase64;
|
||||
|
@ -119,7 +119,8 @@ describe('github-app', () => {
|
|||
// Arrange
|
||||
vi.mocked(getSecret).mockImplementation(async (key: string) => {
|
||||
if (key === 'GITHUB_APP_ID') return '123456';
|
||||
if (key === 'GITHUB_APP_PRIVATE_KEY_BASE64') return Buffer.from('not-a-private-key').toString('base64');
|
||||
if (key === 'GITHUB_APP_PRIVATE_KEY_BASE64')
|
||||
return Buffer.from('not-a-private-key').toString('base64');
|
||||
if (key === 'GITHUB_WEBHOOK_SECRET') return 'test';
|
||||
throw new Error(`Unexpected key: ${key}`);
|
||||
});
|
||||
|
@ -136,7 +137,7 @@ describe('github-app', () => {
|
|||
// Arrange
|
||||
const privateKey = '-----BEGIN RSA PRIVATE KEY-----\ntest-key\n-----END RSA PRIVATE KEY-----';
|
||||
const privateKeyBase64 = Buffer.from(privateKey).toString('base64');
|
||||
|
||||
|
||||
vi.mocked(getSecret).mockImplementation(async (key: string) => {
|
||||
if (key === 'GITHUB_APP_ID') return '123456';
|
||||
if (key === 'GITHUB_APP_PRIVATE_KEY_BASE64') return privateKeyBase64;
|
||||
|
@ -162,7 +163,7 @@ describe('github-app', () => {
|
|||
// Arrange
|
||||
const privateKey = '-----BEGIN RSA PRIVATE KEY-----\ntest-key\n-----END RSA PRIVATE KEY-----';
|
||||
const privateKeyBase64 = Buffer.from(privateKey).toString('base64');
|
||||
|
||||
|
||||
vi.mocked(getSecret).mockImplementation(async (key: string) => {
|
||||
if (key === 'GITHUB_APP_ID') return '123456';
|
||||
if (key === 'GITHUB_APP_PRIVATE_KEY_BASE64') return privateKeyBase64;
|
||||
|
@ -175,7 +176,9 @@ describe('github-app', () => {
|
|||
});
|
||||
|
||||
// Act & Assert
|
||||
await expect(createGitHubApp()).rejects.toThrow('Failed to create GitHub App: Failed to create app');
|
||||
await expect(createGitHubApp()).rejects.toThrow(
|
||||
'Failed to create GitHub App: Failed to create app'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -28,9 +28,10 @@ describe('verify-webhook-signature', () => {
|
|||
// Default mock for getSecret
|
||||
vi.mocked(getSecret).mockImplementation(async (key: string) => {
|
||||
if (key === 'GITHUB_APP_ID') return '123456';
|
||||
if (key === 'GITHUB_APP_PRIVATE_KEY_BASE64') return Buffer.from(
|
||||
'-----BEGIN RSA PRIVATE KEY-----\ntest-key\n-----END RSA PRIVATE KEY-----'
|
||||
).toString('base64');
|
||||
if (key === 'GITHUB_APP_PRIVATE_KEY_BASE64')
|
||||
return Buffer.from(
|
||||
'-----BEGIN RSA PRIVATE KEY-----\ntest-key\n-----END RSA PRIVATE KEY-----'
|
||||
).toString('base64');
|
||||
if (key === 'GITHUB_WEBHOOK_SECRET') return 'test-webhook-secret';
|
||||
throw new Error(`Unexpected key: ${key}`);
|
||||
});
|
||||
|
@ -200,7 +201,9 @@ describe('verify-webhook-signature', () => {
|
|||
};
|
||||
|
||||
// Act & Assert
|
||||
await expect(verifyGitHubWebhook(payload, headers)).rejects.toThrow('Invalid webhook signature');
|
||||
await expect(verifyGitHubWebhook(payload, headers)).rejects.toThrow(
|
||||
'Invalid webhook signature'
|
||||
);
|
||||
});
|
||||
|
||||
it('should include error code in thrown error', async () => {
|
||||
|
|
|
@ -67,7 +67,6 @@ describe('githubWebhookValidator', () => {
|
|||
it('should validate a valid webhook request', async () => {
|
||||
const { app, headers, body } = createMockContext('sha256=test-signature');
|
||||
|
||||
|
||||
// Mock signature verification to return true
|
||||
vi.mocked(verifyGitHubWebhookSignature).mockReturnValue(true);
|
||||
|
||||
|
|
|
@ -49,10 +49,10 @@ describe('message-fetchers', () => {
|
|||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
|
||||
// Get the mocked db object from the module mock
|
||||
mockDb = vi.mocked(database.db);
|
||||
|
||||
|
||||
// Set up the mock chain to return itself for most methods
|
||||
mockDb.select.mockReturnValue(mockDb);
|
||||
mockDb.from.mockReturnValue(mockDb);
|
||||
|
@ -60,7 +60,7 @@ describe('message-fetchers', () => {
|
|||
mockDb.leftJoin.mockReturnValue(mockDb);
|
||||
mockDb.where.mockReturnValue(mockDb);
|
||||
mockDb.orderBy.mockReturnValue(mockDb);
|
||||
|
||||
|
||||
// Also mock getChatConversationHistory
|
||||
vi.mocked(database.getChatConversationHistory).mockResolvedValue([]);
|
||||
});
|
||||
|
@ -79,7 +79,7 @@ describe('message-fetchers', () => {
|
|||
};
|
||||
|
||||
mockDb.limit.mockResolvedValue([messageData]);
|
||||
|
||||
|
||||
// Mock getChatConversationHistory to return the expected messages
|
||||
vi.mocked(database.getChatConversationHistory).mockResolvedValue(
|
||||
messageData.rawLlmMessages as any
|
||||
|
@ -123,7 +123,7 @@ describe('message-fetchers', () => {
|
|||
};
|
||||
|
||||
mockDb.limit.mockResolvedValue([messageData]);
|
||||
|
||||
|
||||
// Mock getChatConversationHistory to return the expected messages
|
||||
vi.mocked(database.getChatConversationHistory).mockResolvedValue(
|
||||
messageData.rawLlmMessages as any
|
||||
|
|
|
@ -18,7 +18,12 @@ vi.mock('@buster/database', () => ({
|
|||
where: vi.fn(() => ({
|
||||
limit: vi.fn(() =>
|
||||
Promise.resolve([
|
||||
{ id: 'integration-1', defaultChannel: { id: 'C123' }, tokenVaultKey: 'vault-key-1', status: 'active' },
|
||||
{
|
||||
id: 'integration-1',
|
||||
defaultChannel: { id: 'C123' },
|
||||
tokenVaultKey: 'vault-key-1',
|
||||
status: 'active',
|
||||
},
|
||||
])
|
||||
),
|
||||
})),
|
||||
|
|
|
@ -84,29 +84,16 @@ describe('messagePostProcessingTask', () => {
|
|||
vi.clearAllMocks();
|
||||
// Mock BRAINTRUST_KEY for unit tests
|
||||
vi.stubEnv('BRAINTRUST_KEY', 'test-braintrust-key');
|
||||
|
||||
|
||||
// Get the mocked db object from the module mock
|
||||
mockDb = vi.mocked(database.db);
|
||||
|
||||
|
||||
// Set up the mock chain to return itself for most methods
|
||||
mockDb.update.mockReturnValue(mockDb);
|
||||
mockDb.set.mockReturnValue(mockDb);
|
||||
mockDb.where.mockReturnValue(mockDb);
|
||||
|
||||
// Also keep the old getDb mock for backward compatibility if still used
|
||||
const mockGetDb = {
|
||||
update: vi.fn().mockReturnThis(),
|
||||
set: vi.fn().mockReturnThis(),
|
||||
where: vi.fn().mockReturnThis(),
|
||||
select: vi.fn().mockReturnThis(),
|
||||
from: vi.fn().mockReturnThis(),
|
||||
limit: vi.fn().mockReturnThis(),
|
||||
orderBy: vi.fn().mockReturnThis(),
|
||||
};
|
||||
mockGetDb.where.mockReturnValue(mockGetDb);
|
||||
mockGetDb.limit.mockResolvedValue([{ tokenVaultKey: 'vault-key-123' }]);
|
||||
mockGetDb.orderBy.mockResolvedValue([]);
|
||||
vi.mocked(database.getDb).mockReturnValue(mockGetDb);
|
||||
|
||||
// No need to mock getDb since implementation imports and uses the exported `db` instance directly
|
||||
});
|
||||
|
||||
it('should process message successfully for initial message', async () => {
|
||||
|
|
|
@ -11,7 +11,6 @@ import type {
|
|||
} from '@buster/server-shared/message';
|
||||
import { logger, schemaTask } from '@trigger.dev/sdk/v3';
|
||||
import { currentSpan, initLogger, wrapTraced } from 'braintrust';
|
||||
import { z } from 'zod/v4';
|
||||
import {
|
||||
buildWorkflowInput,
|
||||
fetchMessageWithContext,
|
||||
|
@ -145,7 +144,7 @@ export const messagePostProcessingTask: ReturnType<
|
|||
hasRawLlmMessages: !!messageContext.rawLlmMessages,
|
||||
});
|
||||
|
||||
// Step 3: Build workflow input
|
||||
// Step 3: Build workflow inpu
|
||||
const workflowInput = buildWorkflowInput(
|
||||
messageContext,
|
||||
previousPostProcessingResults,
|
||||
|
|
Loading…
Reference in New Issue