@hubspot/cli 7.9.0 → 7.9.1-experimental.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +5 -4
- package/commands/__tests__/getStarted.test.js +10 -0
- package/commands/__tests__/project.test.js +2 -0
- package/commands/account/__tests__/rename.test.js +42 -0
- package/commands/account/auth.js +10 -14
- package/commands/account/clean.js +11 -19
- package/commands/account/createOverride.js +17 -23
- package/commands/account/info.js +8 -5
- package/commands/account/list.js +13 -18
- package/commands/account/remove.js +23 -22
- package/commands/account/removeOverride.js +8 -16
- package/commands/account/rename.d.ts +1 -1
- package/commands/account/rename.js +6 -3
- package/commands/account/use.js +19 -8
- package/commands/app/__tests__/migrate.test.js +8 -4
- package/commands/app/migrate.js +2 -2
- package/commands/auth.js +18 -14
- package/commands/cms/theme/preview.js +1 -4
- package/commands/config/migrate.js +5 -5
- package/commands/config/set.js +1 -2
- package/commands/customObject/createSchema.js +2 -3
- package/commands/customObject/updateSchema.js +2 -3
- package/commands/getStarted.js +15 -22
- package/commands/hubdb/__tests__/list.test.js +1 -0
- package/commands/hubdb/list.js +2 -2
- package/commands/hubdb.d.ts +1 -1
- package/commands/init.js +36 -32
- package/commands/project/__tests__/deploy.test.js +10 -5
- package/commands/project/__tests__/devUnifiedFlow.test.js +6 -4
- package/commands/project/__tests__/logs.test.js +4 -0
- package/commands/project/__tests__/updateDeps.test.js +142 -0
- package/commands/project/__tests__/validate.test.js +2 -2
- package/commands/project/cloneApp.js +2 -2
- package/commands/project/create.js +0 -1
- package/commands/project/deploy.js +2 -2
- package/commands/project/dev/deprecatedFlow.js +4 -5
- package/commands/project/dev/index.js +14 -4
- package/commands/project/dev/unifiedFlow.js +4 -5
- package/commands/project/listBuilds.js +7 -1
- package/commands/project/logs.js +2 -3
- package/commands/project/profile/add.js +6 -7
- package/commands/project/profile/delete.js +2 -2
- package/commands/project/updateDeps.d.ts +6 -0
- package/commands/project/updateDeps.js +80 -0
- package/commands/project/upload.js +9 -3
- package/commands/project/validate.js +9 -3
- package/commands/project/watch.js +7 -2
- package/commands/project.js +2 -0
- package/commands/sandbox/__tests__/create.test.js +14 -5
- package/commands/sandbox/create.js +4 -5
- package/commands/sandbox/delete.js +23 -20
- package/commands/testAccount/__tests__/create.test.js +68 -0
- package/commands/testAccount/create.d.ts +8 -0
- package/commands/testAccount/create.js +135 -45
- package/commands/testAccount/delete.js +9 -8
- package/commands/testAccount/importData.d.ts +1 -1
- package/lang/en.d.ts +3199 -3185
- package/lang/en.js +52 -14
- package/lib/__tests__/buildAccount.test.js +22 -30
- package/lib/__tests__/commonOpts.test.js +9 -13
- package/lib/__tests__/dependencyManagement.test.js +273 -1
- package/lib/__tests__/developerTestAccounts.test.js +29 -17
- package/lib/__tests__/importData.test.js +20 -10
- package/lib/__tests__/oauth.test.js +19 -8
- package/lib/__tests__/sandboxSync.test.js +33 -11
- package/lib/__tests__/sandboxes.test.js +30 -19
- package/lib/__tests__/usageTracking.test.js +10 -10
- package/lib/__tests__/validation.test.js +32 -32
- package/lib/accountTypes.d.ts +9 -9
- package/lib/accountTypes.js +2 -4
- package/lib/app/__tests__/migrate.test.js +15 -0
- package/lib/app/__tests__/migrate_legacy.test.js +9 -0
- package/lib/app/migrate_legacy.d.ts +2 -2
- package/lib/buildAccount.d.ts +4 -4
- package/lib/buildAccount.js +7 -14
- package/lib/commonOpts.js +5 -8
- package/lib/configMigrate.d.ts +2 -2
- package/lib/configMigrate.js +42 -18
- package/lib/configOptions.js +3 -2
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +6 -0
- package/lib/dependencyManagement.d.ts +8 -2
- package/lib/dependencyManagement.js +75 -12
- package/lib/developerTestAccounts.d.ts +3 -3
- package/lib/developerTestAccounts.js +4 -7
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +1 -1
- package/lib/doctor/DiagnosticInfoBuilder.js +9 -6
- package/lib/doctor/Doctor.js +4 -3
- package/lib/doctor/__tests__/Diagnosis.test.js +4 -3
- package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.js +17 -9
- package/lib/doctor/__tests__/Doctor.test.js +14 -0
- package/lib/importData.js +8 -7
- package/lib/links.js +5 -5
- package/lib/mcp/__tests__/setup.test.d.ts +1 -0
- package/lib/mcp/__tests__/setup.test.js +127 -0
- package/lib/mcp/setup.d.ts +4 -12
- package/lib/mcp/setup.js +34 -1
- package/lib/middleware/__test__/commandTargetingUtils.test.js +3 -3
- package/lib/middleware/__test__/configMiddleware.test.js +23 -22
- package/lib/middleware/__test__/gitMiddleware.test.js +9 -7
- package/lib/middleware/autoUpdateMiddleware.d.ts +3 -1
- package/lib/middleware/autoUpdateMiddleware.js +10 -2
- package/lib/middleware/commandTargetingUtils.js +2 -2
- package/lib/middleware/configMiddleware.d.ts +6 -1
- package/lib/middleware/configMiddleware.js +36 -15
- package/lib/middleware/gitMiddleware.js +8 -4
- package/lib/npm.d.ts +3 -0
- package/lib/npm.js +6 -0
- package/lib/oauth.d.ts +2 -2
- package/lib/oauth.js +8 -10
- package/lib/projects/__tests__/AppDevModeInterface.test.js +17 -6
- package/lib/projects/__tests__/DevServerManager.test.js +1 -0
- package/lib/projects/__tests__/LocalDevProcess.test.js +1 -0
- package/lib/projects/__tests__/components.test.js +148 -24
- package/lib/projects/__tests__/deploy.test.js +1 -0
- package/lib/projects/__tests__/platformVersion.test.js +5 -1
- package/lib/projects/__tests__/projects.test.js +13 -42
- package/lib/projects/components.js +76 -20
- package/lib/projects/config.js +5 -9
- package/lib/projects/create/__tests__/v2.test.js +11 -0
- package/lib/projects/localDev/AppDevModeInterface.js +2 -2
- package/lib/projects/localDev/DevServerManager_DEPRECATED.js +2 -2
- package/lib/projects/localDev/LocalDevLogger.js +4 -4
- package/lib/projects/localDev/LocalDevManager_DEPRECATED.js +3 -3
- package/lib/projects/localDev/helpers/account.d.ts +10 -10
- package/lib/projects/localDev/helpers/account.js +6 -11
- package/lib/projects/platformVersion.js +1 -1
- package/lib/projects/urls.js +5 -6
- package/lib/prompts/__tests__/createDeveloperTestAccountConfigPrompt.test.d.ts +1 -0
- package/lib/prompts/__tests__/createDeveloperTestAccountConfigPrompt.test.js +153 -0
- package/lib/prompts/__tests__/downloadProjectPrompt.test.js +7 -5
- package/lib/prompts/accountNamePrompt.js +3 -3
- package/lib/prompts/accountsPrompt.d.ts +1 -1
- package/lib/prompts/accountsPrompt.js +6 -7
- package/lib/prompts/confirmImportDataPrompt.js +2 -2
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.d.ts +5 -0
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +76 -66
- package/lib/prompts/downloadProjectPrompt.d.ts +1 -0
- package/lib/prompts/downloadProjectPrompt.js +5 -2
- package/lib/prompts/importDataTestAccountSelectPrompt.js +4 -5
- package/lib/prompts/personalAccessKeyPrompt.js +2 -2
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +3 -3
- package/lib/prompts/projectDevTargetAccountPrompt.js +5 -7
- package/lib/prompts/sandboxesPrompt.js +7 -8
- package/lib/prompts/setAsDefaultAccountPrompt.js +7 -6
- package/lib/sandboxSync.d.ts +2 -2
- package/lib/sandboxSync.js +3 -9
- package/lib/sandboxes.d.ts +4 -4
- package/lib/sandboxes.js +6 -11
- package/lib/serverlessLogs.js +2 -2
- package/lib/theme/__tests__/migrate.test.js +15 -0
- package/lib/ui/index.js +6 -3
- package/lib/usageTracking.js +15 -8
- package/lib/validation.js +13 -11
- package/mcp-server/tools/cms/HsCreateFunctionTool.js +8 -2
- package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +4 -4
- package/mcp-server/tools/cms/HsCreateModuleTool.js +8 -2
- package/mcp-server/tools/cms/HsCreateTemplateTool.js +8 -2
- package/mcp-server/tools/cms/HsFunctionLogsTool.d.ts +4 -4
- package/mcp-server/tools/cms/HsFunctionLogsTool.js +6 -2
- package/mcp-server/tools/cms/HsListFunctionsTool.js +5 -1
- package/mcp-server/tools/cms/HsListTool.js +5 -1
- package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.js +1 -0
- package/mcp-server/tools/index.js +4 -0
- package/mcp-server/tools/project/AddFeatureToProjectTool.d.ts +1 -1
- package/mcp-server/tools/project/AddFeatureToProjectTool.js +9 -3
- package/mcp-server/tools/project/CreateProjectTool.js +8 -2
- package/mcp-server/tools/project/CreateTestAccountTool.d.ts +41 -0
- package/mcp-server/tools/project/CreateTestAccountTool.js +150 -0
- package/mcp-server/tools/project/DeployProjectTool.d.ts +1 -1
- package/mcp-server/tools/project/DeployProjectTool.js +8 -2
- package/mcp-server/tools/project/DocFetchTool.d.ts +1 -1
- package/mcp-server/tools/project/DocFetchTool.js +9 -5
- package/mcp-server/tools/project/DocsSearchTool.d.ts +1 -1
- package/mcp-server/tools/project/DocsSearchTool.js +12 -8
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +1 -1
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +11 -7
- package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +1 -1
- package/mcp-server/tools/project/GetApplicationInfoTool.js +11 -7
- package/mcp-server/tools/project/GetBuildStatusTool.d.ts +26 -0
- package/mcp-server/tools/project/GetBuildStatusTool.js +164 -0
- package/mcp-server/tools/project/GetConfigValuesTool.d.ts +1 -1
- package/mcp-server/tools/project/GetConfigValuesTool.js +11 -7
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +1 -1
- package/mcp-server/tools/project/GuidedWalkthroughTool.js +7 -3
- package/mcp-server/tools/project/UploadProjectTools.d.ts +9 -3
- package/mcp-server/tools/project/UploadProjectTools.js +51 -5
- package/mcp-server/tools/project/ValidateProjectTool.d.ts +1 -1
- package/mcp-server/tools/project/ValidateProjectTool.js +7 -3
- package/mcp-server/tools/project/__tests__/CreateTestAccountTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/CreateTestAccountTool.test.js +454 -0
- package/mcp-server/tools/project/__tests__/DocFetchTool.test.js +5 -1
- package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +25 -13
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +7 -5
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +7 -5
- package/mcp-server/tools/project/__tests__/GetBuildStatusTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetBuildStatusTool.test.js +240 -0
- package/mcp-server/tools/project/__tests__/GetConfigValuesTool.test.js +8 -6
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +56 -4
- package/mcp-server/utils/__tests__/content.test.js +21 -20
- package/mcp-server/utils/__tests__/feedbackTracking.test.js +33 -28
- package/mcp-server/utils/content.d.ts +1 -1
- package/mcp-server/utils/content.js +2 -2
- package/mcp-server/utils/feedbackTracking.d.ts +1 -1
- package/mcp-server/utils/feedbackTracking.js +3 -3
- package/mcp-server/utils/toolUsageTracking.js +4 -3
- package/package.json +8 -7
- package/lang/en.lyaml +0 -1508
- package/lib/lang.d.ts +0 -8
- package/lib/lang.js +0 -72
- package/mcp-server/utils/__tests__/cliConfig.test.js +0 -110
- package/mcp-server/utils/cliConfig.d.ts +0 -1
- package/mcp-server/utils/cliConfig.js +0 -12
- /package/{mcp-server/utils/__tests__/cliConfig.test.d.ts → commands/project/__tests__/updateDeps.test.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GetApplicationInfoTool } from '../GetApplicationInfoTool.js';
|
|
2
|
-
import {
|
|
2
|
+
import { getConfigDefaultAccountIfExists } from '@hubspot/local-dev-lib/config';
|
|
3
3
|
import { http } from '@hubspot/local-dev-lib/http';
|
|
4
4
|
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
5
5
|
import { mcpFeedbackRequest } from '../../../utils/feedbackTracking.js';
|
|
@@ -10,7 +10,7 @@ vi.mock('@hubspot/local-dev-lib/errors/index');
|
|
|
10
10
|
vi.mock('@hubspot/local-dev-lib/config');
|
|
11
11
|
vi.mock('../../../utils/feedbackTracking');
|
|
12
12
|
const mockMcpFeedbackRequest = mcpFeedbackRequest;
|
|
13
|
-
const
|
|
13
|
+
const mockGetConfigDefaultAccountIfExists = getConfigDefaultAccountIfExists;
|
|
14
14
|
const mockHttp = http;
|
|
15
15
|
const mockIsHubSpotHttpError = isHubSpotHttpError;
|
|
16
16
|
describe('mcp-server/tools/project/GetApplicationInfoTool', () => {
|
|
@@ -42,7 +42,9 @@ describe('mcp-server/tools/project/GetApplicationInfoTool', () => {
|
|
|
42
42
|
describe('handler', () => {
|
|
43
43
|
const input = { absoluteCurrentWorkingDirectory: '/test/dir' };
|
|
44
44
|
beforeEach(() => {
|
|
45
|
-
|
|
45
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue({
|
|
46
|
+
accountId: 123456789,
|
|
47
|
+
});
|
|
46
48
|
mockIsHubSpotHttpError.mockReturnValue(false);
|
|
47
49
|
});
|
|
48
50
|
it('should return application information successfully', async () => {
|
|
@@ -67,7 +69,7 @@ describe('mcp-server/tools/project/GetApplicationInfoTool', () => {
|
|
|
67
69
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
70
|
mockHttp.get.mockResolvedValue(mockResponse);
|
|
69
71
|
const result = await tool.handler(input);
|
|
70
|
-
expect(
|
|
72
|
+
expect(mockGetConfigDefaultAccountIfExists).toHaveBeenCalledWith();
|
|
71
73
|
expect(mockHttp.get).toHaveBeenCalledWith(123456789, {
|
|
72
74
|
url: 'app/feature/utilization/public/v3/insights/apps',
|
|
73
75
|
});
|
|
@@ -81,7 +83,7 @@ describe('mcp-server/tools/project/GetApplicationInfoTool', () => {
|
|
|
81
83
|
});
|
|
82
84
|
});
|
|
83
85
|
it('should return error when account ID cannot be determined', async () => {
|
|
84
|
-
|
|
86
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue(undefined);
|
|
85
87
|
const result = await tool.handler(input);
|
|
86
88
|
expect(result).toEqual({
|
|
87
89
|
content: [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { GetBuildStatusTool } from '../GetBuildStatusTool.js';
|
|
2
|
+
import { fetchProjectBuilds, getBuildStatus, } from '@hubspot/local-dev-lib/api/projects';
|
|
3
|
+
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
4
|
+
import { getProjectConfig, validateProjectConfig, } from '../../../../lib/projects/config.js';
|
|
5
|
+
import { mcpFeedbackRequest } from '../../../utils/feedbackTracking.js';
|
|
6
|
+
import { getConfigDefaultAccountIfExists } from '@hubspot/local-dev-lib/config';
|
|
7
|
+
vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
|
|
8
|
+
vi.mock('../../../utils/toolUsageTracking');
|
|
9
|
+
vi.mock('@hubspot/local-dev-lib/api/projects');
|
|
10
|
+
vi.mock('@hubspot/local-dev-lib/errors/index');
|
|
11
|
+
vi.mock('../../../../lib/projects/config.js');
|
|
12
|
+
vi.mock('../../../utils/feedbackTracking');
|
|
13
|
+
vi.mock('@hubspot/local-dev-lib/config');
|
|
14
|
+
const mockMcpFeedbackRequest = mcpFeedbackRequest;
|
|
15
|
+
const mockFetchProjectBuilds = fetchProjectBuilds;
|
|
16
|
+
const mockGetBuildStatus = getBuildStatus;
|
|
17
|
+
const mockIsHubSpotHttpError = isHubSpotHttpError;
|
|
18
|
+
const mockGetProjectConfig = getProjectConfig;
|
|
19
|
+
const mockValidateProjectConfig = validateProjectConfig;
|
|
20
|
+
const mockGetConfigDefaultAccountIfExists = getConfigDefaultAccountIfExists;
|
|
21
|
+
const TEST_ACCOUNT_ID = 123456789;
|
|
22
|
+
const TEST_PROJECT_NAME = 'test-project';
|
|
23
|
+
const TEST_PROJECT_PATH = '/test/project';
|
|
24
|
+
const TEST_WORKING_DIR = '/test';
|
|
25
|
+
const TEST_PLATFORM_VERSION = '2025.2';
|
|
26
|
+
function createMockBuild(overrides = {}) {
|
|
27
|
+
return {
|
|
28
|
+
buildId: 10,
|
|
29
|
+
status: 'FAILURE',
|
|
30
|
+
createdAt: '2025-11-18T21:50:50.632Z',
|
|
31
|
+
enqueuedAt: null,
|
|
32
|
+
finishedAt: '2025-11-20T22:32:07.008Z',
|
|
33
|
+
startedAt: '2025-11-18T21:50:50.632Z',
|
|
34
|
+
subbuildStatuses: [
|
|
35
|
+
{
|
|
36
|
+
buildName: 'my-card',
|
|
37
|
+
buildType: 'CARD',
|
|
38
|
+
status: 'FAILURE',
|
|
39
|
+
errorMessage: 'There were errors building this component:\n - The preview image file /app/cards/assets/preview.png was not found. Make sure the file exists in /app/cards and try again.',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
buildName: 'my-app',
|
|
43
|
+
buildType: 'APPLICATION',
|
|
44
|
+
status: 'SUCCESS',
|
|
45
|
+
errorMessage: '',
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
buildErrorMessage: 'The source code for this project is too large. HubSpot projects have a maximum size limit of 50.0 MB.',
|
|
49
|
+
platformVersion: TEST_PLATFORM_VERSION,
|
|
50
|
+
deployable: true,
|
|
51
|
+
deployableState: 'DEPLOYABLE',
|
|
52
|
+
...overrides,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function createMockProjectConfig(overrides = {}) {
|
|
56
|
+
return {
|
|
57
|
+
name: TEST_PROJECT_NAME,
|
|
58
|
+
srcDir: 'src',
|
|
59
|
+
platformVersion: TEST_PLATFORM_VERSION,
|
|
60
|
+
...overrides,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function createBuildListResponse(builds) {
|
|
64
|
+
return {
|
|
65
|
+
data: {
|
|
66
|
+
results: builds,
|
|
67
|
+
paging: undefined,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function createBuildDetailsResponse(build) {
|
|
72
|
+
return {
|
|
73
|
+
data: build,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function expectTextContent(result, ...expectedStrings) {
|
|
77
|
+
expectedStrings.forEach(str => {
|
|
78
|
+
expect(result.content[1].text).toContain(str);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
describe('mcp-server/tools/project/GetBuildStatusTool', () => {
|
|
82
|
+
let mockMcpServer;
|
|
83
|
+
let tool;
|
|
84
|
+
let mockRegisteredTool;
|
|
85
|
+
beforeEach(() => {
|
|
86
|
+
vi.clearAllMocks();
|
|
87
|
+
// @ts-expect-error Not mocking the whole thing
|
|
88
|
+
mockMcpServer = {
|
|
89
|
+
registerTool: vi.fn(),
|
|
90
|
+
};
|
|
91
|
+
mockRegisteredTool = {};
|
|
92
|
+
mockMcpServer.registerTool.mockReturnValue(mockRegisteredTool);
|
|
93
|
+
mockMcpFeedbackRequest.mockResolvedValue('');
|
|
94
|
+
tool = new GetBuildStatusTool(mockMcpServer);
|
|
95
|
+
// Default mock implementations
|
|
96
|
+
mockIsHubSpotHttpError.mockReturnValue(false);
|
|
97
|
+
mockGetProjectConfig.mockResolvedValue({
|
|
98
|
+
projectConfig: createMockProjectConfig(),
|
|
99
|
+
projectDir: TEST_PROJECT_PATH,
|
|
100
|
+
});
|
|
101
|
+
mockValidateProjectConfig.mockImplementation(() => { });
|
|
102
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue({
|
|
103
|
+
accountId: TEST_ACCOUNT_ID,
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
describe('register', () => {
|
|
107
|
+
it('should register tool with correct parameters', () => {
|
|
108
|
+
const result = tool.register();
|
|
109
|
+
expect(mockMcpServer.registerTool).toHaveBeenCalledWith('get-build-status', expect.objectContaining({
|
|
110
|
+
title: 'Get HubSpot Projects Build Status and Errors',
|
|
111
|
+
description: expect.stringContaining('Retrieves build status and error messages for HubSpot projects'),
|
|
112
|
+
inputSchema: expect.any(Object),
|
|
113
|
+
}), expect.any(Function));
|
|
114
|
+
expect(result).toBe(mockRegisteredTool);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
describe('handler', () => {
|
|
118
|
+
const baseInput = {
|
|
119
|
+
absoluteProjectPath: TEST_PROJECT_PATH,
|
|
120
|
+
absoluteCurrentWorkingDirectory: TEST_WORKING_DIR,
|
|
121
|
+
buildId: undefined,
|
|
122
|
+
limit: 5,
|
|
123
|
+
};
|
|
124
|
+
describe('error handling', () => {
|
|
125
|
+
it('should return error when account ID cannot be determined', async () => {
|
|
126
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue(undefined);
|
|
127
|
+
const result = await tool.handler(baseInput);
|
|
128
|
+
expect(result).toEqual({
|
|
129
|
+
content: [
|
|
130
|
+
{
|
|
131
|
+
type: 'text',
|
|
132
|
+
text: TEST_WORKING_DIR,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
type: 'text',
|
|
136
|
+
text: 'No account ID found. Please run `hs account auth` to configure an account, or set a default account with `hs account use <account>`',
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
});
|
|
140
|
+
expect(mockFetchProjectBuilds).not.toHaveBeenCalled();
|
|
141
|
+
});
|
|
142
|
+
it('should return error when specific build for provided buildId is not found', async () => {
|
|
143
|
+
const error = new Error('Build not found');
|
|
144
|
+
// @ts-expect-error Adding status property
|
|
145
|
+
error.status = 404;
|
|
146
|
+
mockIsHubSpotHttpError.mockReturnValue(true);
|
|
147
|
+
mockGetBuildStatus.mockRejectedValue(error);
|
|
148
|
+
const result = await tool.handler({ ...baseInput, buildId: 999 });
|
|
149
|
+
expectTextContent(result, 'Build not found');
|
|
150
|
+
});
|
|
151
|
+
it('should handle HubSpot HTTP errors', async () => {
|
|
152
|
+
const error = new Error('API Error');
|
|
153
|
+
mockIsHubSpotHttpError.mockReturnValue(true);
|
|
154
|
+
mockFetchProjectBuilds.mockRejectedValue(error);
|
|
155
|
+
const result = await tool.handler(baseInput);
|
|
156
|
+
expectTextContent(result, 'API Error');
|
|
157
|
+
});
|
|
158
|
+
it('should handle generic errors', async () => {
|
|
159
|
+
const error = new Error('Generic error');
|
|
160
|
+
mockIsHubSpotHttpError.mockReturnValue(false);
|
|
161
|
+
mockFetchProjectBuilds.mockRejectedValue(error);
|
|
162
|
+
const result = await tool.handler(baseInput);
|
|
163
|
+
expectTextContent(result, 'Generic error');
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
describe('list view (no buildId)', () => {
|
|
167
|
+
it('should return recent builds when no buildId is provided', async () => {
|
|
168
|
+
const mockBuild = createMockBuild();
|
|
169
|
+
mockFetchProjectBuilds.mockResolvedValue(
|
|
170
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
171
|
+
createBuildListResponse([mockBuild]));
|
|
172
|
+
const result = await tool.handler(baseInput);
|
|
173
|
+
expect(mockGetProjectConfig).toHaveBeenCalledWith(TEST_PROJECT_PATH);
|
|
174
|
+
expect(mockFetchProjectBuilds).toHaveBeenCalledWith(TEST_ACCOUNT_ID, TEST_PROJECT_NAME, { limit: 5 });
|
|
175
|
+
expectTextContent(result, `Recent builds for '${TEST_PROJECT_NAME}':`, 'Build #10 - FAILURE', 'The source code for this project is too large');
|
|
176
|
+
});
|
|
177
|
+
it('should return error when no builds exist', async () => {
|
|
178
|
+
mockFetchProjectBuilds.mockResolvedValue(
|
|
179
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
180
|
+
createBuildListResponse([]));
|
|
181
|
+
const result = await tool.handler(baseInput);
|
|
182
|
+
expectTextContent(result, `No builds found for project '${TEST_PROJECT_NAME}'`);
|
|
183
|
+
});
|
|
184
|
+
it('should handle successful builds', async () => {
|
|
185
|
+
const successBuild = createMockBuild({
|
|
186
|
+
buildId: 11,
|
|
187
|
+
status: 'SUCCESS',
|
|
188
|
+
buildErrorMessage: undefined,
|
|
189
|
+
subbuildStatuses: [
|
|
190
|
+
{
|
|
191
|
+
buildName: 'my-app',
|
|
192
|
+
buildType: 'APPLICATION',
|
|
193
|
+
status: 'SUCCESS',
|
|
194
|
+
errorMessage: '',
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
});
|
|
198
|
+
mockFetchProjectBuilds.mockResolvedValue(
|
|
199
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
200
|
+
createBuildListResponse([successBuild]));
|
|
201
|
+
const result = await tool.handler(baseInput);
|
|
202
|
+
expectTextContent(result, 'Build #11 - SUCCESS ✓');
|
|
203
|
+
expect(result.content[1].text).not.toContain('Error:');
|
|
204
|
+
});
|
|
205
|
+
it('should display all subbuilds (success and failure)', async () => {
|
|
206
|
+
const buildWithSubbuilds = createMockBuild({
|
|
207
|
+
subbuildStatuses: [
|
|
208
|
+
{
|
|
209
|
+
buildName: 'my-webhooks',
|
|
210
|
+
buildType: 'WEBHOOKS',
|
|
211
|
+
status: 'SUCCESS',
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
buildName: 'my-app',
|
|
215
|
+
buildType: 'APPLICATION',
|
|
216
|
+
status: 'FAILURE',
|
|
217
|
+
errorMessage: 'Duplicate UID',
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
});
|
|
221
|
+
mockFetchProjectBuilds.mockResolvedValue(
|
|
222
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
223
|
+
createBuildListResponse([buildWithSubbuilds]));
|
|
224
|
+
const result = await tool.handler(baseInput);
|
|
225
|
+
expectTextContent(result, 'Subbuilds:', '✓ my-webhooks (WEBHOOKS): SUCCESS', '⚠️ my-app (APPLICATION): FAILURE', 'Error: Duplicate UID');
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
describe('detail view (with buildId)', () => {
|
|
229
|
+
it('should return specific build details when buildId is provided', async () => {
|
|
230
|
+
const mockBuild = createMockBuild();
|
|
231
|
+
mockGetBuildStatus.mockResolvedValue(
|
|
232
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
233
|
+
createBuildDetailsResponse(mockBuild));
|
|
234
|
+
const result = await tool.handler({ ...baseInput, buildId: 10 });
|
|
235
|
+
expect(mockGetBuildStatus).toHaveBeenCalledWith(TEST_ACCOUNT_ID, TEST_PROJECT_NAME, 10);
|
|
236
|
+
expectTextContent(result, 'Build #10 Details', 'Status: FAILURE', `Platform Version: ${TEST_PLATFORM_VERSION}`, 'Build Error:');
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
});
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { GetConfigValuesTool } from '../GetConfigValuesTool.js';
|
|
2
2
|
import { getIntermediateRepresentationSchema, mapToInternalType, } from '@hubspot/project-parsing-lib';
|
|
3
|
-
import {
|
|
3
|
+
import { getConfigDefaultAccountIfExists } from '@hubspot/local-dev-lib/config';
|
|
4
4
|
import { mcpFeedbackRequest } from '../../../utils/feedbackTracking.js';
|
|
5
5
|
vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
|
|
6
6
|
vi.mock('@hubspot/project-parsing-lib');
|
|
7
|
-
vi.mock('
|
|
7
|
+
vi.mock('@hubspot/local-dev-lib/config');
|
|
8
8
|
vi.mock('../../../utils/toolUsageTracking');
|
|
9
9
|
vi.mock('../../../utils/feedbackTracking');
|
|
10
10
|
const mockMcpFeedbackRequest = mcpFeedbackRequest;
|
|
11
11
|
const mockGetIntermediateRepresentationSchema = getIntermediateRepresentationSchema;
|
|
12
12
|
const mockMapToInternalType = mapToInternalType;
|
|
13
|
-
const
|
|
13
|
+
const mockGetConfigDefaultAccountIfExists = getConfigDefaultAccountIfExists;
|
|
14
14
|
describe('mcp-server/tools/project/GetConfigValuesTool', () => {
|
|
15
15
|
let mockMcpServer;
|
|
16
16
|
let tool;
|
|
@@ -51,7 +51,9 @@ describe('mcp-server/tools/project/GetConfigValuesTool', () => {
|
|
|
51
51
|
absoluteCurrentWorkingDirectory: '/foo',
|
|
52
52
|
};
|
|
53
53
|
beforeEach(() => {
|
|
54
|
-
|
|
54
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue({
|
|
55
|
+
accountId: 123456789,
|
|
56
|
+
});
|
|
55
57
|
});
|
|
56
58
|
it('should return config schema when component type exists', async () => {
|
|
57
59
|
const mockSchema = {
|
|
@@ -66,7 +68,7 @@ describe('mcp-server/tools/project/GetConfigValuesTool', () => {
|
|
|
66
68
|
mockGetIntermediateRepresentationSchema.mockResolvedValue(mockSchema);
|
|
67
69
|
mockMapToInternalType.mockReturnValue('internal-card-type');
|
|
68
70
|
const result = await tool.handler(input);
|
|
69
|
-
expect(
|
|
71
|
+
expect(mockGetConfigDefaultAccountIfExists).toHaveBeenCalled();
|
|
70
72
|
expect(mockGetIntermediateRepresentationSchema).toHaveBeenCalledWith({
|
|
71
73
|
platformVersion: '2025.2',
|
|
72
74
|
projectSourceDir: '',
|
|
@@ -139,7 +141,7 @@ describe('mcp-server/tools/project/GetConfigValuesTool', () => {
|
|
|
139
141
|
});
|
|
140
142
|
});
|
|
141
143
|
it('should handle null account id', async () => {
|
|
142
|
-
|
|
144
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue(undefined);
|
|
143
145
|
const result = await tool.handler(input);
|
|
144
146
|
expect(result).toEqual({
|
|
145
147
|
content: [
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { UploadProjectTools } from '../UploadProjectTools.js';
|
|
2
|
+
import { getAllHsProfiles } from '@hubspot/project-parsing-lib';
|
|
3
|
+
import { getProjectConfig } from '../../../../lib/projects/config.js';
|
|
2
4
|
import { runCommandInDir } from '../../../utils/project.js';
|
|
3
5
|
import { mcpFeedbackRequest } from '../../../utils/feedbackTracking.js';
|
|
4
6
|
vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
|
|
7
|
+
vi.mock('@hubspot/project-parsing-lib');
|
|
8
|
+
vi.mock('../../../../lib/projects/config.js');
|
|
5
9
|
vi.mock('../../../utils/project');
|
|
6
10
|
vi.mock('../../../utils/toolUsageTracking');
|
|
7
11
|
vi.mock('../../../utils/feedbackTracking');
|
|
8
12
|
const mockMcpFeedbackRequest = mcpFeedbackRequest;
|
|
9
13
|
const mockRunCommandInDir = runCommandInDir;
|
|
14
|
+
const mockGetProjectConfig = getProjectConfig;
|
|
15
|
+
const mockGetAllHsProfiles = getAllHsProfiles;
|
|
10
16
|
describe('mcp-server/tools/project/UploadProjectTools', () => {
|
|
11
17
|
let mockMcpServer;
|
|
12
18
|
let tool;
|
|
@@ -20,6 +26,15 @@ describe('mcp-server/tools/project/UploadProjectTools', () => {
|
|
|
20
26
|
mockRegisteredTool = {};
|
|
21
27
|
mockMcpServer.registerTool.mockReturnValue(mockRegisteredTool);
|
|
22
28
|
mockMcpFeedbackRequest.mockResolvedValue('');
|
|
29
|
+
mockGetProjectConfig.mockResolvedValue({
|
|
30
|
+
projectConfig: {
|
|
31
|
+
srcDir: 'src',
|
|
32
|
+
name: 'test-project',
|
|
33
|
+
platformVersion: '2025.2',
|
|
34
|
+
},
|
|
35
|
+
projectDir: '/test/project',
|
|
36
|
+
});
|
|
37
|
+
mockGetAllHsProfiles.mockResolvedValue([]);
|
|
23
38
|
tool = new UploadProjectTools(mockMcpServer);
|
|
24
39
|
});
|
|
25
40
|
describe('register', () => {
|
|
@@ -37,6 +52,7 @@ describe('mcp-server/tools/project/UploadProjectTools', () => {
|
|
|
37
52
|
const input = {
|
|
38
53
|
absoluteCurrentWorkingDirectory: '/test/dir',
|
|
39
54
|
absoluteProjectPath: '/test/project',
|
|
55
|
+
uploadMessage: 'Test upload message',
|
|
40
56
|
};
|
|
41
57
|
it('should upload project successfully', async () => {
|
|
42
58
|
mockRunCommandInDir.mockResolvedValue({
|
|
@@ -44,7 +60,9 @@ describe('mcp-server/tools/project/UploadProjectTools', () => {
|
|
|
44
60
|
stderr: '',
|
|
45
61
|
});
|
|
46
62
|
const result = await tool.handler(input);
|
|
47
|
-
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', 'hs project upload
|
|
63
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', expect.stringContaining('hs project upload'));
|
|
64
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', expect.stringContaining('--force-create'));
|
|
65
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', expect.stringContaining('--message "Test upload message"'));
|
|
48
66
|
expect(result).toEqual({
|
|
49
67
|
content: [
|
|
50
68
|
{ type: 'text', text: 'Project uploaded successfully' },
|
|
@@ -68,13 +86,44 @@ describe('mcp-server/tools/project/UploadProjectTools', () => {
|
|
|
68
86
|
mockRunCommandInDir.mockRejectedValue(error);
|
|
69
87
|
await expect(tool.handler(input)).rejects.toThrow('Upload failed');
|
|
70
88
|
});
|
|
71
|
-
it('should use force-create
|
|
89
|
+
it('should use force-create and message flags', async () => {
|
|
72
90
|
mockRunCommandInDir.mockResolvedValue({
|
|
73
91
|
stdout: 'Project created and uploaded',
|
|
74
92
|
stderr: '',
|
|
75
93
|
});
|
|
76
94
|
await tool.handler(input);
|
|
77
|
-
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', 'hs project upload
|
|
95
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', expect.stringContaining('hs project upload'));
|
|
96
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', expect.stringContaining('--force-create'));
|
|
97
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', expect.stringContaining('--message "Test upload message"'));
|
|
98
|
+
});
|
|
99
|
+
it('should use profiles', async () => {
|
|
100
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
101
|
+
stdout: 'Project created and uploaded',
|
|
102
|
+
stderr: '',
|
|
103
|
+
});
|
|
104
|
+
await tool.handler({
|
|
105
|
+
...input,
|
|
106
|
+
profile: 'dev',
|
|
107
|
+
});
|
|
108
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', expect.stringContaining('hs project upload'));
|
|
109
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', expect.stringContaining('--force-create'));
|
|
110
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', expect.stringContaining('--message "Test upload message"'));
|
|
111
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', expect.stringContaining('--profile "dev"'));
|
|
112
|
+
});
|
|
113
|
+
it('should prompt for profile if not specified and the project requires them', async () => {
|
|
114
|
+
mockGetAllHsProfiles.mockResolvedValue(['prod', 'dev']);
|
|
115
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
116
|
+
stdout: 'Project created and uploaded',
|
|
117
|
+
stderr: '',
|
|
118
|
+
});
|
|
119
|
+
const result = await tool.handler(input);
|
|
120
|
+
expect(mockRunCommandInDir).not.toHaveBeenCalled();
|
|
121
|
+
expect(result.content).toEqual([
|
|
122
|
+
{
|
|
123
|
+
type: 'text',
|
|
124
|
+
text: 'Ask the user which profile they would like to use for the upload.',
|
|
125
|
+
},
|
|
126
|
+
]);
|
|
78
127
|
});
|
|
79
128
|
it('should handle empty stdout and stderr', async () => {
|
|
80
129
|
mockRunCommandInDir.mockResolvedValue({
|
|
@@ -95,9 +144,12 @@ describe('mcp-server/tools/project/UploadProjectTools', () => {
|
|
|
95
144
|
const differentInput = {
|
|
96
145
|
absoluteCurrentWorkingDirectory: '/test/dir',
|
|
97
146
|
absoluteProjectPath: '/different/path/to/project',
|
|
147
|
+
uploadMessage: 'Different test upload message',
|
|
98
148
|
};
|
|
99
149
|
await tool.handler(differentInput);
|
|
100
|
-
expect(mockRunCommandInDir).toHaveBeenCalledWith('/different/path/to/project', 'hs project upload
|
|
150
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/different/path/to/project', expect.stringContaining('hs project upload'));
|
|
151
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/different/path/to/project', expect.stringContaining('--force-create'));
|
|
152
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/different/path/to/project', expect.stringContaining('--message "Different test upload message"'));
|
|
101
153
|
});
|
|
102
154
|
it('should handle very long output', async () => {
|
|
103
155
|
const longOutput = 'A'.repeat(10000);
|
|
@@ -3,7 +3,6 @@ import { mcpFeedbackRequest } from '../feedbackTracking.js';
|
|
|
3
3
|
vi.mock('../feedbackTracking');
|
|
4
4
|
const mockMcpFeedbackRequest = mcpFeedbackRequest;
|
|
5
5
|
describe('mcp-server/utils/content', () => {
|
|
6
|
-
const mockWorkingDirectory = '/test/working/directory';
|
|
7
6
|
beforeEach(() => {
|
|
8
7
|
vi.clearAllMocks();
|
|
9
8
|
});
|
|
@@ -34,8 +33,8 @@ describe('mcp-server/utils/content', () => {
|
|
|
34
33
|
describe('formatTextContents', () => {
|
|
35
34
|
it('should format single output without feedback', async () => {
|
|
36
35
|
mockMcpFeedbackRequest.mockResolvedValue('');
|
|
37
|
-
const result = await formatTextContents(
|
|
38
|
-
expect(mockMcpFeedbackRequest).
|
|
36
|
+
const result = await formatTextContents('Test output');
|
|
37
|
+
expect(mockMcpFeedbackRequest).toHaveBeenCalled();
|
|
39
38
|
expect(result).toEqual({
|
|
40
39
|
content: [
|
|
41
40
|
{
|
|
@@ -47,7 +46,7 @@ describe('mcp-server/utils/content', () => {
|
|
|
47
46
|
});
|
|
48
47
|
it('should format multiple outputs without feedback', async () => {
|
|
49
48
|
mockMcpFeedbackRequest.mockResolvedValue('');
|
|
50
|
-
const result = await formatTextContents(
|
|
49
|
+
const result = await formatTextContents('First output', 'Second output', 'Third output');
|
|
51
50
|
expect(result).toEqual({
|
|
52
51
|
content: [
|
|
53
52
|
{ type: 'text', text: 'First output' },
|
|
@@ -59,8 +58,8 @@ describe('mcp-server/utils/content', () => {
|
|
|
59
58
|
it('should append feedback message when feedback is returned', async () => {
|
|
60
59
|
const feedbackMessage = 'Please share your feedback!';
|
|
61
60
|
mockMcpFeedbackRequest.mockResolvedValue(feedbackMessage);
|
|
62
|
-
const result = await formatTextContents(
|
|
63
|
-
expect(mockMcpFeedbackRequest).
|
|
61
|
+
const result = await formatTextContents('Command output');
|
|
62
|
+
expect(mockMcpFeedbackRequest).toHaveBeenCalled();
|
|
64
63
|
expect(result).toEqual({
|
|
65
64
|
content: [
|
|
66
65
|
{ type: 'text', text: 'Command output' },
|
|
@@ -71,7 +70,7 @@ describe('mcp-server/utils/content', () => {
|
|
|
71
70
|
it('should append feedback to multiple outputs', async () => {
|
|
72
71
|
const feedbackMessage = 'Feedback request message';
|
|
73
72
|
mockMcpFeedbackRequest.mockResolvedValue(feedbackMessage);
|
|
74
|
-
const result = await formatTextContents(
|
|
73
|
+
const result = await formatTextContents('First output', 'Second output');
|
|
75
74
|
expect(result).toEqual({
|
|
76
75
|
content: [
|
|
77
76
|
{ type: 'text', text: 'First output' },
|
|
@@ -82,7 +81,7 @@ describe('mcp-server/utils/content', () => {
|
|
|
82
81
|
});
|
|
83
82
|
it('should filter out undefined outputs', async () => {
|
|
84
83
|
mockMcpFeedbackRequest.mockResolvedValue('');
|
|
85
|
-
const result = await formatTextContents(
|
|
84
|
+
const result = await formatTextContents('First output', undefined, 'Third output', undefined);
|
|
86
85
|
expect(result).toEqual({
|
|
87
86
|
content: [
|
|
88
87
|
{ type: 'text', text: 'First output' },
|
|
@@ -92,7 +91,7 @@ describe('mcp-server/utils/content', () => {
|
|
|
92
91
|
});
|
|
93
92
|
it('should not call mcpFeedbackRequest when no outputs provided', async () => {
|
|
94
93
|
mockMcpFeedbackRequest.mockResolvedValue('Feedback message');
|
|
95
|
-
const result = await formatTextContents(
|
|
94
|
+
const result = await formatTextContents();
|
|
96
95
|
expect(mockMcpFeedbackRequest).not.toHaveBeenCalled();
|
|
97
96
|
expect(result).toEqual({
|
|
98
97
|
content: [],
|
|
@@ -100,24 +99,24 @@ describe('mcp-server/utils/content', () => {
|
|
|
100
99
|
});
|
|
101
100
|
it('should call mcpFeedbackRequest but not add feedback when all outputs are undefined and feedback is empty', async () => {
|
|
102
101
|
mockMcpFeedbackRequest.mockResolvedValue('');
|
|
103
|
-
const result = await formatTextContents(
|
|
102
|
+
const result = await formatTextContents(undefined, undefined);
|
|
104
103
|
// mcpFeedbackRequest is still called because outputs.length > 0, but content is empty
|
|
105
|
-
expect(mockMcpFeedbackRequest).
|
|
104
|
+
expect(mockMcpFeedbackRequest).toHaveBeenCalled();
|
|
106
105
|
expect(result).toEqual({
|
|
107
106
|
content: [],
|
|
108
107
|
});
|
|
109
108
|
});
|
|
110
109
|
it('should handle empty string outputs and still request feedback', async () => {
|
|
111
110
|
mockMcpFeedbackRequest.mockResolvedValue('');
|
|
112
|
-
const result = await formatTextContents(
|
|
113
|
-
expect(mockMcpFeedbackRequest).
|
|
111
|
+
const result = await formatTextContents('');
|
|
112
|
+
expect(mockMcpFeedbackRequest).toHaveBeenCalled();
|
|
114
113
|
expect(result).toEqual({
|
|
115
114
|
content: [{ type: 'text', text: '' }],
|
|
116
115
|
});
|
|
117
116
|
});
|
|
118
117
|
it('should not add feedback when empty string is returned from mcpFeedbackRequest', async () => {
|
|
119
118
|
mockMcpFeedbackRequest.mockResolvedValue('');
|
|
120
|
-
const result = await formatTextContents(
|
|
119
|
+
const result = await formatTextContents('Output 1', 'Output 2');
|
|
121
120
|
// Should not have a third content item with empty feedback
|
|
122
121
|
expect(result.content).toHaveLength(2);
|
|
123
122
|
expect(result).toEqual({
|
|
@@ -137,7 +136,7 @@ describe('mcp-server/utils/content', () => {
|
|
|
137
136
|
|
|
138
137
|
Say: "📝 **Before we continue, would you mind sharing feedback on your experience with the HubSpot Developer MCP?** Your input helps us improve: [Share feedback here](https://app.hubspot.com/l/product-updates/in-beta?rollout=239890)"`;
|
|
139
138
|
mockMcpFeedbackRequest.mockResolvedValue(realisticFeedback);
|
|
140
|
-
const result = await formatTextContents(
|
|
139
|
+
const result = await formatTextContents('Project created successfully');
|
|
141
140
|
expect(result.content).toHaveLength(2);
|
|
142
141
|
expect(result.content[0]).toEqual({
|
|
143
142
|
type: 'text',
|
|
@@ -149,16 +148,18 @@ describe('mcp-server/utils/content', () => {
|
|
|
149
148
|
});
|
|
150
149
|
expect(result.content[1].text).toContain('FEEDBACK REQUEST');
|
|
151
150
|
});
|
|
152
|
-
it('should
|
|
153
|
-
const customDirectory = '/custom/working/directory';
|
|
151
|
+
it('should not require absoluteCurrentWorkingDirectory parameter', async () => {
|
|
154
152
|
mockMcpFeedbackRequest.mockResolvedValue('');
|
|
155
|
-
await formatTextContents(
|
|
156
|
-
expect(mockMcpFeedbackRequest).
|
|
153
|
+
const result = await formatTextContents('Test output');
|
|
154
|
+
expect(mockMcpFeedbackRequest).toHaveBeenCalled();
|
|
155
|
+
expect(result).toEqual({
|
|
156
|
+
content: [{ type: 'text', text: 'Test output' }],
|
|
157
|
+
});
|
|
157
158
|
});
|
|
158
159
|
it('should await mcpFeedbackRequest and handle async properly', async () => {
|
|
159
160
|
const feedbackPromise = Promise.resolve('Async feedback message');
|
|
160
161
|
mockMcpFeedbackRequest.mockReturnValue(feedbackPromise);
|
|
161
|
-
const result = await formatTextContents(
|
|
162
|
+
const result = await formatTextContents('Output');
|
|
162
163
|
expect(result.content).toHaveLength(2);
|
|
163
164
|
expect(result.content[1].text).toBe('Async feedback message');
|
|
164
165
|
});
|