Skip to content

Commit f859ffb

Browse files
test(nx-mcp): update tests for token-efficient cache display
Co-authored-by: MaxKless <[email protected]>
1 parent f8f3e49 commit f859ffb

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

apps/nx-mcp-e2e/src/nx-project-details-compressed-targets.test.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,10 @@ describe('nx_project_details compressed targets', () => {
174174

175175
const targetsBlock = getCompressedTargetsBlock(result);
176176
expect(targetsBlock).toBeDefined();
177-
expect(targetsBlock).toContain(
178-
'target-nx-executor: @nx/webpack:webpack | cache: true',
177+
expect(targetsBlock).toContain('target-nx-executor: @nx/webpack:webpack');
178+
// Cache is true by default, so it should NOT be shown (token efficiency)
179+
expect(targetsBlock).not.toContain(
180+
'target-nx-executor: @nx/webpack:webpack | cache:',
179181
);
180182
});
181183

@@ -190,7 +192,7 @@ describe('nx_project_details compressed targets', () => {
190192
const targetsBlock = getCompressedTargetsBlock(result);
191193
expect(targetsBlock).toBeDefined();
192194
expect(targetsBlock).toContain(
193-
'target-custom-executor: @my-org/custom:build | cache: true',
195+
'target-custom-executor: @my-org/custom:build',
194196
);
195197
});
196198

@@ -205,7 +207,7 @@ describe('nx_project_details compressed targets', () => {
205207
const targetsBlock = getCompressedTargetsBlock(result);
206208
expect(targetsBlock).toBeDefined();
207209
expect(targetsBlock).toContain(
208-
"target-run-cmd-options: nx:run-commands - 'echo test' | cache: true",
210+
"target-run-cmd-options: nx:run-commands - 'echo test'",
209211
);
210212
});
211213

@@ -220,7 +222,7 @@ describe('nx_project_details compressed targets', () => {
220222
const targetsBlock = getCompressedTargetsBlock(result);
221223
expect(targetsBlock).toBeDefined();
222224
expect(targetsBlock).toContain(
223-
"target-run-cmd-array-single-str: nx:run-commands - 'npm build' | cache: true",
225+
"target-run-cmd-array-single-str: nx:run-commands - 'npm build'",
224226
);
225227
});
226228

@@ -235,7 +237,7 @@ describe('nx_project_details compressed targets', () => {
235237
const targetsBlock = getCompressedTargetsBlock(result);
236238
expect(targetsBlock).toBeDefined();
237239
expect(targetsBlock).toContain(
238-
"target-run-cmd-array-single-obj: nx:run-commands - 'npm test' | cache: true",
240+
"target-run-cmd-array-single-obj: nx:run-commands - 'npm test'",
239241
);
240242
});
241243

@@ -250,7 +252,7 @@ describe('nx_project_details compressed targets', () => {
250252
const targetsBlock = getCompressedTargetsBlock(result);
251253
expect(targetsBlock).toBeDefined();
252254
expect(targetsBlock).toContain(
253-
'target-run-cmd-array-multi: nx:run-commands - 3 commands | cache: true',
255+
'target-run-cmd-array-multi: nx:run-commands - 3 commands',
254256
);
255257
});
256258

@@ -264,9 +266,7 @@ describe('nx_project_details compressed targets', () => {
264266

265267
const targetsBlock = getCompressedTargetsBlock(result);
266268
expect(targetsBlock).toBeDefined();
267-
expect(targetsBlock).toContain(
268-
"deploy: nx:run-script - 'npm run deploy' | cache: true",
269-
);
269+
expect(targetsBlock).toContain("deploy: nx:run-script - 'npm run deploy'");
270270
});
271271

272272
it('should display nx:run-script target from package.json script - custom-hello', () => {
@@ -280,7 +280,7 @@ describe('nx_project_details compressed targets', () => {
280280
const targetsBlock = getCompressedTargetsBlock(result);
281281
expect(targetsBlock).toBeDefined();
282282
expect(targetsBlock).toContain(
283-
"custom-hello: nx:run-script - 'npm run custom-hello' | cache: true",
283+
"custom-hello: nx:run-script - 'npm run custom-hello'",
284284
);
285285
});
286286

@@ -295,7 +295,7 @@ describe('nx_project_details compressed targets', () => {
295295
const targetsBlock = getCompressedTargetsBlock(result);
296296
expect(targetsBlock).toBeDefined();
297297
expect(targetsBlock).toContain(
298-
'target-with-deps-string: @nx/js:tsc | depends: [build, test] | cache: true',
298+
'target-with-deps-string: @nx/js:tsc | depends: [build, test]',
299299
);
300300
});
301301

@@ -310,7 +310,7 @@ describe('nx_project_details compressed targets', () => {
310310
const targetsBlock = getCompressedTargetsBlock(result);
311311
expect(targetsBlock).toBeDefined();
312312
expect(targetsBlock).toContain(
313-
'target-with-deps-object: @nx/js:tsc | depends: [build, ^build] | cache: true',
313+
'target-with-deps-object: @nx/js:tsc | depends: [build, ^build]',
314314
);
315315
});
316316

@@ -339,8 +339,10 @@ describe('nx_project_details compressed targets', () => {
339339

340340
const targetsBlock = getCompressedTargetsBlock(result);
341341
expect(targetsBlock).toBeDefined();
342-
expect(targetsBlock).toContain(
343-
'target-with-cache: @nx/js:tsc | cache: true',
342+
// When cache is true (default), it should NOT be displayed (token efficiency)
343+
expect(targetsBlock).toContain('target-with-cache: @nx/js:tsc');
344+
expect(targetsBlock).not.toContain(
345+
'target-with-cache: @nx/js:tsc | cache:',
344346
);
345347
});
346348

@@ -405,7 +407,7 @@ describe('nx_project_details compressed targets', () => {
405407
const targetsBlock = getCompressedTargetsBlock(result);
406408
expect(targetsBlock).toBeDefined();
407409
expect(targetsBlock).toContain(
408-
'target-empty-cmds: nx:run-commands - 0 commands | cache: true',
410+
'target-empty-cmds: nx:run-commands - 0 commands',
409411
);
410412
});
411413

apps/nx-mcp-e2e/src/nx-project-details-select.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ describe('nx_project_details select', () => {
5555
expect(result.content[1]?.text).toContain(
5656
'To see full configuration for a specific target',
5757
);
58-
expect(result.content[1]?.text).toContain('cache:');
58+
// Cache should only appear when it's false (token efficiency)
59+
// So we should see "cache: false" somewhere, but not "cache: true"
60+
expect(result.content[1]?.text).not.toContain('cache: true');
5961

6062
// Third block should be External Dependencies
6163
expect(result.content[2]?.text).toContain('External Dependencies:');

0 commit comments

Comments
 (0)