Skip to content

Commit 166709b

Browse files
committed
refactor: Extract AXE_NOT_AVAILABLE_MESSAGE constant to deduplicate test assertions
Replace 55 inline string duplicates across 10 UI automation test files with a shared constant exported from axe-helpers.
1 parent 0d79ce5 commit 166709b

11 files changed

Lines changed: 71 additions & 61 deletions

File tree

src/mcp/tools/ui-automation/__tests__/button.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from '../../../../test-utils/mock-executors.ts';
1212
import { schema, handler, buttonLogic } from '../button.ts';
1313
import type { CommandExecutor } from '../../../../utils/execution/index.ts';
14+
import { AXE_NOT_AVAILABLE_MESSAGE } from '../../../../utils/axe-helpers.ts';
1415

1516
describe('Button Plugin', () => {
1617
describe('Export Field Validation (Literal)', () => {
@@ -323,7 +324,7 @@ describe('Button Plugin', () => {
323324
content: [
324325
{
325326
type: 'text' as const,
326-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
327+
text: AXE_NOT_AVAILABLE_MESSAGE,
327328
},
328329
],
329330
isError: true,
@@ -343,7 +344,7 @@ describe('Button Plugin', () => {
343344
content: [
344345
{
345346
type: 'text' as const,
346-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
347+
text: AXE_NOT_AVAILABLE_MESSAGE,
347348
},
348349
],
349350
isError: true,

src/mcp/tools/ui-automation/__tests__/gesture.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from '../../../../test-utils/mock-executors.ts';
1212
import { sessionStore } from '../../../../utils/session-store.ts';
1313
import { schema, handler, gestureLogic } from '../gesture.ts';
14+
import { AXE_NOT_AVAILABLE_MESSAGE } from '../../../../utils/axe-helpers.ts';
1415

1516
describe('Gesture Plugin', () => {
1617
beforeEach(() => {
@@ -342,7 +343,7 @@ describe('Gesture Plugin', () => {
342343
content: [
343344
{
344345
type: 'text' as const,
345-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
346+
text: AXE_NOT_AVAILABLE_MESSAGE,
346347
},
347348
],
348349
isError: true,
@@ -362,7 +363,7 @@ describe('Gesture Plugin', () => {
362363
content: [
363364
{
364365
type: 'text' as const,
365-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
366+
text: AXE_NOT_AVAILABLE_MESSAGE,
366367
},
367368
],
368369
isError: true,

src/mcp/tools/ui-automation/__tests__/key_press.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from '../../../../test-utils/mock-executors.ts';
1313
import { sessionStore } from '../../../../utils/session-store.ts';
1414
import { schema, handler, key_pressLogic } from '../key_press.ts';
15+
import { AXE_NOT_AVAILABLE_MESSAGE } from '../../../../utils/axe-helpers.ts';
1516

1617
function createDefaultMockAxeHelpers() {
1718
return {
@@ -21,7 +22,7 @@ function createDefaultMockAxeHelpers() {
2122
content: [
2223
{
2324
type: 'text' as const,
24-
text: 'AXe tool not found. UI automation features are not available.\\n\\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\\nEnsure bundled artifacts are included or PATH is configured.',
25+
text: AXE_NOT_AVAILABLE_MESSAGE,
2526
},
2627
],
2728
isError: true,
@@ -201,7 +202,7 @@ describe('Key Press Tool', () => {
201202
content: [
202203
{
203204
type: 'text' as const,
204-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
205+
text: AXE_NOT_AVAILABLE_MESSAGE,
205206
},
206207
],
207208
isError: true,
@@ -288,7 +289,7 @@ describe('Key Press Tool', () => {
288289
content: [
289290
{
290291
type: 'text' as const,
291-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
292+
text: AXE_NOT_AVAILABLE_MESSAGE,
292293
},
293294
],
294295
isError: true,
@@ -308,7 +309,7 @@ describe('Key Press Tool', () => {
308309
content: [
309310
{
310311
type: 'text' as const,
311-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
312+
text: AXE_NOT_AVAILABLE_MESSAGE,
312313
},
313314
],
314315
isError: true,

src/mcp/tools/ui-automation/__tests__/key_sequence.test.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from '../../../../test-utils/mock-executors.ts';
1212
import { sessionStore } from '../../../../utils/session-store.ts';
1313
import { schema, handler, key_sequenceLogic } from '../key_sequence.ts';
14+
import { AXE_NOT_AVAILABLE_MESSAGE } from '../../../../utils/axe-helpers.ts';
1415

1516
describe('Key Sequence Tool', () => {
1617
beforeEach(() => {
@@ -86,7 +87,7 @@ describe('Key Sequence Tool', () => {
8687
content: [
8788
{
8889
type: 'text' as const,
89-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
90+
text: AXE_NOT_AVAILABLE_MESSAGE,
9091
},
9192
],
9293
isError: true,
@@ -131,7 +132,7 @@ describe('Key Sequence Tool', () => {
131132
content: [
132133
{
133134
type: 'text' as const,
134-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
135+
text: AXE_NOT_AVAILABLE_MESSAGE,
135136
},
136137
],
137138
isError: true,
@@ -179,7 +180,7 @@ describe('Key Sequence Tool', () => {
179180
content: [
180181
{
181182
type: 'text' as const,
182-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
183+
text: AXE_NOT_AVAILABLE_MESSAGE,
183184
},
184185
],
185186
isError: true,
@@ -224,7 +225,7 @@ describe('Key Sequence Tool', () => {
224225
content: [
225226
{
226227
type: 'text' as const,
227-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
228+
text: AXE_NOT_AVAILABLE_MESSAGE,
228229
},
229230
],
230231
isError: true,
@@ -277,7 +278,7 @@ describe('Key Sequence Tool', () => {
277278
content: [
278279
{
279280
type: 'text' as const,
280-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
281+
text: AXE_NOT_AVAILABLE_MESSAGE,
281282
},
282283
],
283284
isError: true,
@@ -316,7 +317,7 @@ describe('Key Sequence Tool', () => {
316317
content: [
317318
{
318319
type: 'text' as const,
319-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
320+
text: AXE_NOT_AVAILABLE_MESSAGE,
320321
},
321322
],
322323
isError: true,
@@ -346,7 +347,7 @@ describe('Key Sequence Tool', () => {
346347
content: [
347348
{
348349
type: 'text' as const,
349-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
350+
text: AXE_NOT_AVAILABLE_MESSAGE,
350351
},
351352
],
352353
isError: true,
@@ -366,7 +367,7 @@ describe('Key Sequence Tool', () => {
366367
content: [
367368
{
368369
type: 'text' as const,
369-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
370+
text: AXE_NOT_AVAILABLE_MESSAGE,
370371
},
371372
],
372373
isError: true,
@@ -387,7 +388,7 @@ describe('Key Sequence Tool', () => {
387388
content: [
388389
{
389390
type: 'text' as const,
390-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
391+
text: AXE_NOT_AVAILABLE_MESSAGE,
391392
},
392393
],
393394
isError: true,
@@ -426,7 +427,7 @@ describe('Key Sequence Tool', () => {
426427
content: [
427428
{
428429
type: 'text' as const,
429-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
430+
text: AXE_NOT_AVAILABLE_MESSAGE,
430431
},
431432
],
432433
isError: true,
@@ -460,7 +461,7 @@ describe('Key Sequence Tool', () => {
460461
content: [
461462
{
462463
type: 'text' as const,
463-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
464+
text: AXE_NOT_AVAILABLE_MESSAGE,
464465
},
465466
],
466467
isError: true,
@@ -494,7 +495,7 @@ describe('Key Sequence Tool', () => {
494495
content: [
495496
{
496497
type: 'text' as const,
497-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
498+
text: AXE_NOT_AVAILABLE_MESSAGE,
498499
},
499500
],
500501
isError: true,

src/mcp/tools/ui-automation/__tests__/long_press.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as z from 'zod';
77
import { createMockExecutor, mockProcess } from '../../../../test-utils/mock-executors.ts';
88
import { sessionStore } from '../../../../utils/session-store.ts';
99
import { schema, handler, long_pressLogic } from '../long_press.ts';
10+
import { AXE_NOT_AVAILABLE_MESSAGE } from '../../../../utils/axe-helpers.ts';
1011

1112
describe('Long Press Plugin', () => {
1213
beforeEach(() => {
@@ -343,7 +344,7 @@ describe('Long Press Plugin', () => {
343344
content: [
344345
{
345346
type: 'text' as const,
346-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
347+
text: AXE_NOT_AVAILABLE_MESSAGE,
347348
},
348349
],
349350
isError: true,
@@ -365,7 +366,7 @@ describe('Long Press Plugin', () => {
365366
content: [
366367
{
367368
type: 'text' as const,
368-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
369+
text: AXE_NOT_AVAILABLE_MESSAGE,
369370
},
370371
],
371372
isError: true,

src/mcp/tools/ui-automation/__tests__/snapshot_ui.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as z from 'zod';
77
import { createMockExecutor, createNoopExecutor } from '../../../../test-utils/mock-executors.ts';
88
import type { CommandExecutor } from '../../../../utils/execution/index.ts';
99
import { schema, handler, snapshot_uiLogic } from '../snapshot_ui.ts';
10+
import { AXE_NOT_AVAILABLE_MESSAGE } from '../../../../utils/axe-helpers.ts';
1011

1112
describe('Snapshot UI Plugin', () => {
1213
describe('Export Field Validation (Literal)', () => {
@@ -133,7 +134,7 @@ describe('Snapshot UI Plugin', () => {
133134
content: [
134135
{
135136
type: 'text' as const,
136-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
137+
text: AXE_NOT_AVAILABLE_MESSAGE,
137138
},
138139
],
139140
isError: true,
@@ -152,7 +153,7 @@ describe('Snapshot UI Plugin', () => {
152153
content: [
153154
{
154155
type: 'text' as const,
155-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
156+
text: AXE_NOT_AVAILABLE_MESSAGE,
156157
},
157158
],
158159
isError: true,

src/mcp/tools/ui-automation/__tests__/swipe.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { SystemError } from '../../../../utils/responses/index.ts';
99
import { sessionStore } from '../../../../utils/session-store.ts';
1010

1111
import { schema, handler, type AxeHelpers, swipeLogic, type SwipeParams } from '../swipe.ts';
12+
import { AXE_NOT_AVAILABLE_MESSAGE } from '../../../../utils/axe-helpers.ts';
1213

1314
// Helper function to create mock axe helpers
1415
function createMockAxeHelpers(): AxeHelpers {
@@ -19,7 +20,7 @@ function createMockAxeHelpers(): AxeHelpers {
1920
content: [
2021
{
2122
type: 'text' as const,
22-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
23+
text: AXE_NOT_AVAILABLE_MESSAGE,
2324
},
2425
],
2526
isError: true,
@@ -36,7 +37,7 @@ function createMockAxeHelpersWithNullPath(): AxeHelpers {
3637
content: [
3738
{
3839
type: 'text' as const,
39-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
40+
text: AXE_NOT_AVAILABLE_MESSAGE,
4041
},
4142
],
4243
isError: true,
@@ -423,7 +424,7 @@ describe('Swipe Tool', () => {
423424
content: [
424425
{
425426
type: 'text' as const,
426-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
427+
text: AXE_NOT_AVAILABLE_MESSAGE,
427428
},
428429
],
429430
isError: true,

src/mcp/tools/ui-automation/__tests__/tap.test.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { createMockExecutor } from '../../../../test-utils/mock-executors.ts';
88
import { sessionStore } from '../../../../utils/session-store.ts';
99

1010
import { schema, handler, type AxeHelpers, tapLogic } from '../tap.ts';
11+
import { AXE_NOT_AVAILABLE_MESSAGE } from '../../../../utils/axe-helpers.ts';
1112

1213
// Helper function to create mock axe helpers
1314
function createMockAxeHelpers(): AxeHelpers {
@@ -18,7 +19,7 @@ function createMockAxeHelpers(): AxeHelpers {
1819
content: [
1920
{
2021
type: 'text',
21-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
22+
text: AXE_NOT_AVAILABLE_MESSAGE,
2223
},
2324
],
2425
isError: true,
@@ -35,7 +36,7 @@ function createMockAxeHelpersWithNullPath(): AxeHelpers {
3536
content: [
3637
{
3738
type: 'text',
38-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
39+
text: AXE_NOT_AVAILABLE_MESSAGE,
3940
},
4041
],
4142
isError: true,
@@ -803,7 +804,7 @@ describe('Tap Plugin', () => {
803804
content: [
804805
{
805806
type: 'text',
806-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
807+
text: AXE_NOT_AVAILABLE_MESSAGE,
807808
},
808809
],
809810
isError: true,
@@ -833,7 +834,7 @@ describe('Tap Plugin', () => {
833834
content: [
834835
{
835836
type: 'text',
836-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
837+
text: AXE_NOT_AVAILABLE_MESSAGE,
837838
},
838839
],
839840
isError: true,
@@ -863,7 +864,7 @@ describe('Tap Plugin', () => {
863864
content: [
864865
{
865866
type: 'text',
866-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
867+
text: AXE_NOT_AVAILABLE_MESSAGE,
867868
},
868869
],
869870
isError: true,
@@ -891,7 +892,7 @@ describe('Tap Plugin', () => {
891892
content: [
892893
{
893894
type: 'text',
894-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
895+
text: AXE_NOT_AVAILABLE_MESSAGE,
895896
},
896897
],
897898
isError: true,
@@ -919,7 +920,7 @@ describe('Tap Plugin', () => {
919920
content: [
920921
{
921922
type: 'text',
922-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
923+
text: AXE_NOT_AVAILABLE_MESSAGE,
923924
},
924925
],
925926
isError: true,
@@ -947,7 +948,7 @@ describe('Tap Plugin', () => {
947948
content: [
948949
{
949950
type: 'text',
950-
text: 'AXe tool not found. UI automation features are not available.\n\nInstall AXe (brew tap cameroncooke/axe && brew install axe) or set XCODEBUILDMCP_AXE_PATH.\nEnsure bundled artifacts are included or PATH is configured.',
951+
text: AXE_NOT_AVAILABLE_MESSAGE,
951952
},
952953
],
953954
isError: true,

0 commit comments

Comments
 (0)