Skip to content

Commit 1b8f95c

Browse files
committed
refactor(options): mode option for e2e testing
1 parent f8bcb72 commit 1b8f95c

17 files changed

Lines changed: 755 additions & 294 deletions

src/__tests__/__snapshots__/options.defaults.test.ts.snap

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ exports[`options defaults should return specific properties: defaults 1`] = `
55
"contextPath": "/",
66
"contextUrl": "file:///",
77
"docsPath": "/documentation",
8+
"docsPathSlug": "documentation:",
89
"http": {
910
"allowedHosts": [],
1011
"allowedOrigins": [],
@@ -21,8 +22,27 @@ exports[`options defaults should return specific properties: defaults 1`] = `
2122
},
2223
"maxDocsToLoad": 500,
2324
"maxSearchLength": 256,
25+
"mode": "programmatic",
26+
"modeOptions": {
27+
"cli": {},
28+
"programmatic": {},
29+
"test": {},
30+
},
2431
"name": "@patternfly/patternfly-mcp",
2532
"nodeVersion": 22,
33+
"patternflyOptions": {
34+
"availableResourceVersions": [
35+
"v6",
36+
],
37+
"default": {
38+
"defaultVersion": "v6",
39+
"versionStrategy": "highest",
40+
"versionWhitelist": [
41+
"@patternfly/react-core",
42+
"@patternfly/patternfly",
43+
],
44+
},
45+
},
2646
"pfExternal": "https://raw.githubusercontent.com/patternfly/patternfly-org/fb05713aba75998b5ecf5299ee3c1a259119bd74/packages/documentation-site/patternfly-docs/content",
2747
"pfExternalAccessibility": "https://raw.githubusercontent.com/patternfly/patternfly-org/fb05713aba75998b5ecf5299ee3c1a259119bd74/packages/documentation-site/patternfly-docs/content/accessibility",
2848
"pfExternalChartsDesign": "https://raw.githubusercontent.com/patternfly/patternfly-org/fb05713aba75998b5ecf5299ee3c1a259119bd74/packages/documentation-site/patternfly-docs/content/design-guidelines/charts",

src/__tests__/__snapshots__/options.test.ts.snap

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ exports[`parseCliOptions should attempt to parse args with --allowed-hosts 1`] =
1616
"stderr": false,
1717
"transport": "stdio",
1818
},
19+
"modeOptions": {
20+
"cli": {},
21+
"programmatic": {},
22+
"test": {},
23+
},
1924
"pluginIsolation": undefined,
2025
"toolModules": [],
2126
}
@@ -37,6 +42,11 @@ exports[`parseCliOptions should attempt to parse args with --allowed-origins 1`]
3742
"stderr": false,
3843
"transport": "stdio",
3944
},
45+
"modeOptions": {
46+
"cli": {},
47+
"programmatic": {},
48+
"test": {},
49+
},
4050
"pluginIsolation": undefined,
4151
"toolModules": [],
4252
}
@@ -55,6 +65,11 @@ exports[`parseCliOptions should attempt to parse args with --http and --host 1`]
5565
"stderr": false,
5666
"transport": "stdio",
5767
},
68+
"modeOptions": {
69+
"cli": {},
70+
"programmatic": {},
71+
"test": {},
72+
},
5873
"pluginIsolation": undefined,
5974
"toolModules": [],
6075
}
@@ -73,6 +88,11 @@ exports[`parseCliOptions should attempt to parse args with --http and --port 1`]
7388
"stderr": false,
7489
"transport": "stdio",
7590
},
91+
"modeOptions": {
92+
"cli": {},
93+
"programmatic": {},
94+
"test": {},
95+
},
7696
"pluginIsolation": undefined,
7797
"toolModules": [],
7898
}
@@ -91,6 +111,11 @@ exports[`parseCliOptions should attempt to parse args with --http and invalid --
91111
"stderr": false,
92112
"transport": "stdio",
93113
},
114+
"modeOptions": {
115+
"cli": {},
116+
"programmatic": {},
117+
"test": {},
118+
},
94119
"pluginIsolation": undefined,
95120
"toolModules": [],
96121
}
@@ -107,6 +132,11 @@ exports[`parseCliOptions should attempt to parse args with --http flag 1`] = `
107132
"stderr": false,
108133
"transport": "stdio",
109134
},
135+
"modeOptions": {
136+
"cli": {},
137+
"programmatic": {},
138+
"test": {},
139+
},
110140
"pluginIsolation": undefined,
111141
"toolModules": [],
112142
}
@@ -123,6 +153,11 @@ exports[`parseCliOptions should attempt to parse args with --log-level flag 1`]
123153
"stderr": false,
124154
"transport": "stdio",
125155
},
156+
"modeOptions": {
157+
"cli": {},
158+
"programmatic": {},
159+
"test": {},
160+
},
126161
"pluginIsolation": undefined,
127162
"toolModules": [],
128163
}
@@ -139,6 +174,11 @@ exports[`parseCliOptions should attempt to parse args with --log-stderr flag and
139174
"stderr": true,
140175
"transport": "stdio",
141176
},
177+
"modeOptions": {
178+
"cli": {},
179+
"programmatic": {},
180+
"test": {},
181+
},
142182
"pluginIsolation": undefined,
143183
"toolModules": [],
144184
}
@@ -155,6 +195,11 @@ exports[`parseCliOptions should attempt to parse args with --tool 1`] = `
155195
"stderr": false,
156196
"transport": "stdio",
157197
},
198+
"modeOptions": {
199+
"cli": {},
200+
"programmatic": {},
201+
"test": {},
202+
},
158203
"pluginIsolation": undefined,
159204
"toolModules": [
160205
"my-tool",
@@ -174,6 +219,11 @@ exports[`parseCliOptions should attempt to parse args with --verbose flag 1`] =
174219
"stderr": false,
175220
"transport": "stdio",
176221
},
222+
"modeOptions": {
223+
"cli": {},
224+
"programmatic": {},
225+
"test": {},
226+
},
177227
"pluginIsolation": undefined,
178228
"toolModules": [],
179229
}
@@ -190,6 +240,11 @@ exports[`parseCliOptions should attempt to parse args with --verbose flag and --
190240
"stderr": false,
191241
"transport": "stdio",
192242
},
243+
"modeOptions": {
244+
"cli": {},
245+
"programmatic": {},
246+
"test": {},
247+
},
193248
"pluginIsolation": undefined,
194249
"toolModules": [],
195250
}
@@ -206,6 +261,11 @@ exports[`parseCliOptions should attempt to parse args with other arguments 1`] =
206261
"stderr": false,
207262
"transport": "stdio",
208263
},
264+
"modeOptions": {
265+
"cli": {},
266+
"programmatic": {},
267+
"test": {},
268+
},
209269
"pluginIsolation": undefined,
210270
"toolModules": [],
211271
}

src/__tests__/__snapshots__/server.getResources.test.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ exports[`promiseQueue should execute promises in order: allSettled 1`] = `
9393

9494
exports[`resolveLocalPathFunction should return a consistent path, basic 1`] = `"/lorem-ipsum.md"`;
9595

96+
exports[`resolveLocalPathFunction should return a consistent path, documentation slug 1`] = `"/documentation/guidelines/README.md"`;
97+
9698
exports[`resolveLocalPathFunction should return a consistent path, url, file 1`] = `"file://someDirectory/dolor-sit.md"`;
9799

98100
exports[`resolveLocalPathFunction should return a consistent path, url, http 1`] = `"http://example.com/dolor-sit.md"`;

src/__tests__/index.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe('main', () => {
7979

8080
mockRunServer.mockRejectedValue(error);
8181

82-
await main();
82+
await expect(async () => main()).rejects.toThrow(error.message);
8383

8484
expect(consoleErrorSpy).toHaveBeenCalledWith('Failed to start server:', error);
8585
expect(processExitSpy).toHaveBeenCalledWith(1);
@@ -89,33 +89,33 @@ describe('main', () => {
8989
{
9090
description: 'parseCliOptions',
9191
error: new Error('Failed to parse CLI options'),
92-
message: 'Failed to start server:',
92+
message: 'Set options error, failed to start server:',
9393
method: main
9494
},
9595
{
9696
description: 'setOptions',
9797
error: new Error('Failed to set options'),
98-
message: 'Failed to start server:',
98+
message: 'Set options error, failed to start server:',
9999
method: main
100100
},
101101
{
102102
description: 'parseCliOptions, with start alias',
103103
error: new Error('Failed to parse CLI options'),
104-
message: 'Failed to start server:',
104+
message: 'Set options error, failed to start server:',
105105
method: start
106106
},
107107
{
108108
description: 'setOptions, with start alias',
109109
error: new Error('Failed to set options'),
110-
message: 'Failed to start server:',
110+
message: 'Set options error, failed to start server:',
111111
method: start
112112
}
113113
])('should handle errors, $description', async ({ error, message, method }) => {
114114
mockSetOptions.mockImplementation(() => {
115115
throw error;
116116
});
117117

118-
await method();
118+
await expect(async () => method()).rejects.toThrow(error.message);
119119

120120
expect(consoleErrorSpy).toHaveBeenCalledWith(message, error);
121121
expect(processExitSpy).toHaveBeenCalledWith(1);

0 commit comments

Comments
 (0)