Skip to content

Commit 25acbc1

Browse files
committed
test(mcp): fix tests
1 parent db5059b commit 25acbc1

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

src/tools/__tests__/changeCustomer.test.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ vi.mock("../../utils/util.js", () => ({
2525
})),
2626
}));
2727

28+
// Mock the validateUser function
29+
vi.mock("../validateUser.js", () => ({
30+
handleValidateUserRequest: vi.fn(() => ({
31+
content: [
32+
{
33+
type: "text",
34+
text: "User validation successful:\nDomain: example.com (the domain of the user, make it bold)\nEmail: user@example.com",
35+
},
36+
],
37+
})),
38+
}));
39+
2840
describe("changeCustomer", () => {
2941
beforeEach(() => {
3042
vi.clearAllMocks();
@@ -74,7 +86,7 @@ describe("changeCustomer", () => {
7486

7587
expect(updateCallback).toHaveBeenCalledWith(newContext);
7688
expect(createSuccessResponse).toHaveBeenCalledWith(
77-
"Customer context successfully changed from 'old-customer' to 'new-customer-123'"
89+
"Customer context successfully changed to 'example.com (the domain of the user, make it bold)\nEmail: user@example.com'"
7890
);
7991
});
8092

@@ -92,7 +104,7 @@ describe("changeCustomer", () => {
92104

93105
expect(updateCallback).toHaveBeenCalledWith(newContext);
94106
expect(createSuccessResponse).toHaveBeenCalledWith(
95-
"Customer context successfully changed to 'new-customer-123'"
107+
"Customer context successfully changed to 'example.com (the domain of the user, make it bold)\nEmail: user@example.com'"
96108
);
97109
});
98110

@@ -109,7 +121,7 @@ describe("changeCustomer", () => {
109121
);
110122

111123
expect(createSuccessResponse).toHaveBeenCalledWith(
112-
"Customer context successfully changed from 'old-customer' to 'new-customer-123'"
124+
"Customer context successfully changed to 'example.com (the domain of the user, make it bold)\nEmail: user@example.com'"
113125
);
114126
});
115127

src/tools/__tests__/dimensions.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ Type: fixed
6767
const response = await handleDimensionsRequest(mockArgs, mockToken);
6868

6969
expect(makeDoitRequest).toHaveBeenCalledWith(
70-
"https://api.doit.com/analytics/v1/dimensions?filter=type%3Afixed&pageToken=next-page&maxResults=60",
70+
"https://api.doit.com/analytics/v1/dimensions?filter=type%3Afixed&pageToken=next-page&maxResults=300",
7171
mockToken,
72-
{ method: "GET" }
72+
{ method: "GET", customerContext: undefined }
7373
);
7474
expect(createSuccessResponse).toHaveBeenCalledWith(
7575
expect.stringContaining("Found 1 dimensions (filtered by: type:fixed)")
@@ -93,9 +93,9 @@ Type: fixed
9393
const response = await handleDimensionsRequest(mockArgs, mockToken);
9494

9595
expect(makeDoitRequest).toHaveBeenCalledWith(
96-
"https://api.doit.com/analytics/v1/dimensions?filter=type%3Ainvalid&maxResults=60",
96+
"https://api.doit.com/analytics/v1/dimensions?filter=type%3Ainvalid&maxResults=300",
9797
mockToken,
98-
{ method: "GET" }
98+
{ method: "GET", customerContext: undefined }
9999
);
100100
expect(createErrorResponse).toHaveBeenCalledWith(
101101
"No dimensions found, please check the filter parameter, try without filter if you don't know the exact value of the key"
@@ -117,9 +117,9 @@ Type: fixed
117117
const response = await handleDimensionsRequest(mockArgs, mockToken);
118118

119119
expect(makeDoitRequest).toHaveBeenCalledWith(
120-
"https://api.doit.com/analytics/v1/dimensions?maxResults=60",
120+
"https://api.doit.com/analytics/v1/dimensions?maxResults=300",
121121
mockToken,
122-
{ method: "GET" }
122+
{ method: "GET", customerContext: undefined }
123123
);
124124
expect(createErrorResponse).toHaveBeenCalledWith(
125125
"Failed to retrieve dimensions data"

src/tools/__tests__/validateUser.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ describe("validateUser", () => {
4848
{ appendParams: true, method: "GET" }
4949
);
5050
expect(createSuccessResponse).toHaveBeenCalledWith(
51-
"User validation successful:\nDomain: example.com\nEmail: user@example.com"
51+
"User validation successful:\nDomain: example.com (the domain of the user, make it bold)\nEmail: user@example.com"
5252
);
5353
expect(response).toEqual({
5454
content: [
5555
{
5656
type: "text",
57-
text: "User validation successful:\nDomain: example.com\nEmail: user@example.com",
57+
text: "User validation successful:\nDomain: example.com (the domain of the user, make it bold)\nEmail: user@example.com",
5858
},
5959
],
6060
});

0 commit comments

Comments
 (0)