Skip to content

Commit d5eddeb

Browse files
W-21017986 MCP e2e Tests (#203)
* First draft e2e mcp tests * Attempt b2c-cli fix * Fix linting * Ignore e2e package.json files * Fix 3pl guard exclusion * 3pl guard exception --------- Co-authored-by: yhsieh1 <yhsieh@salesforce.com>
1 parent 362c935 commit d5eddeb

10 files changed

Lines changed: 615 additions & 12 deletions

File tree

.github/workflows/3pl-guard.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,14 @@ jobs:
123123
per_page: 100,
124124
});
125125
126+
// Exclude package.json under test/fixtures/ (e.g. e2e workspace-detection fixtures)
127+
const isUnderTestFixtures = (filename) =>
128+
filename.includes('/test/') && filename.includes('/fixtures/');
126129
const changedPackageJsonFiles = files
127130
.map((file) => file.filename)
128-
.filter((filename) => filename.endsWith('package.json'));
131+
.filter((filename) =>
132+
filename.endsWith('package.json') && !isUnderTestFixtures(filename),
133+
);
129134
130135
const findings = [];
131136
@@ -200,4 +205,4 @@ jobs:
200205
await addLabel(reviewLabel);
201206
core.setFailed(
202207
`Net-new third-party dependencies found: ${allNetNewDeps.join(', ')}. Add \`${approvalLabel}\` after review.`,
203-
);
208+
);

.github/workflows/e2e-tests.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,39 @@ jobs:
166166
if (context.eventName === 'schedule') {
167167
github.rest.issues.create(issue);
168168
}
169+
170+
mcp-e2e-tests:
171+
name: MCP E2E
172+
runs-on: ubuntu-latest
173+
timeout-minutes: 15
174+
steps:
175+
- uses: actions/checkout@v4
176+
- uses: actions/setup-node@v4
177+
with:
178+
node-version: '22.x'
179+
- name: Setup pnpm
180+
uses: pnpm/action-setup@v4
181+
with:
182+
version: 10.17.1
183+
- name: Get pnpm store directory
184+
id: pnpm-store
185+
shell: bash
186+
run: |
187+
echo "store_path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
188+
- name: Setup pnpm cache
189+
uses: actions/cache@v4
190+
with:
191+
path: ${{ steps.pnpm-store.outputs.store_path }}
192+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
193+
restore-keys: |
194+
${{ runner.os }}-pnpm-store-
195+
- name: Install dependencies
196+
run: pnpm install --frozen-lockfile
197+
- name: Build packages
198+
run: pnpm -r run build
199+
- name: Run MCP E2E tests
200+
working-directory: packages/b2c-dx-mcp
201+
env:
202+
SFCC_DISABLE_TELEMETRY: 'true'
203+
NODE_ENV: test
204+
run: pnpm run test:e2e:ci

packages/b2c-cli/test/functional/e2e/webdav-operations.test.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,29 @@ describe('WebDAV Operations E2E Tests', function () {
368368

369369
describe('Step 11: Verify Extracted Files', function () {
370370
it('should find extracted files in directory', async function () {
371-
await waitFor(async () => {
372-
const result = await runCLI([
371+
// Unzip visibility can be delayed on WebDAV; use longer timeout and poll every 1s
372+
try {
373+
await waitFor(
374+
async () => {
375+
const result = await runCLI([
376+
'webdav',
377+
'ls',
378+
remoteDirPath,
379+
'--server',
380+
serverHostname,
381+
'--root',
382+
'impex',
383+
'--json',
384+
]);
385+
if (result.exitCode !== 0) return false;
386+
const response = JSON.parse(toString(result.stdout));
387+
return response.entries?.some((e: any) => entryName(e) === testFileName);
388+
},
389+
420_000,
390+
1000,
391+
);
392+
} catch (error) {
393+
const diag = await runCLI([
373394
'webdav',
374395
'ls',
375396
remoteDirPath,
@@ -378,11 +399,10 @@ describe('WebDAV Operations E2E Tests', function () {
378399
'--root',
379400
'impex',
380401
'--json',
381-
]);
382-
if (result.exitCode !== 0) return false;
383-
const response = JSON.parse(toString(result.stdout));
384-
return response.entries?.some((e: any) => entryName(e) === testFileName);
385-
}, 300_000);
402+
]).then((r) => (r.exitCode === 0 ? toString(r.stdout) : `exit ${r.exitCode}: ${toString(r.stderr)}`));
403+
const msg = error instanceof Error ? error.message : String(error);
404+
throw new Error(`${msg}. Last LIST of ${remoteDirPath}: ${diag.slice(0, 500)}`);
405+
}
386406
});
387407
});
388408
});

packages/b2c-dx-mcp/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@
8484
"inspect": "mcp-inspector node bin/run.js --toolsets all --allow-non-ga-tools",
8585
"inspect:dev": "mcp-inspector node --conditions development bin/dev.js --toolsets all --allow-non-ga-tools",
8686
"pretest": "tsc --noEmit -p test",
87-
"test": "c8 mocha --forbid-only \"test/**/*.test.ts\"",
88-
"test:ci": "c8 mocha --forbid-only --reporter json --reporter-option output=test-results.json \"test/**/*.test.ts\"",
89-
"test:agent": "mocha --forbid-only --reporter min \"test/**/*.test.ts\"",
87+
"test": "c8 mocha --forbid-only --ignore 'test/e2e/**' \"test/**/*.test.ts\"",
88+
"test:ci": "c8 mocha --forbid-only --reporter json --reporter-option output=test-results.json --ignore 'test/e2e/**' \"test/**/*.test.ts\"",
89+
"test:agent": "mocha --forbid-only --reporter min --ignore 'test/e2e/**' \"test/**/*.test.ts\"",
90+
"test:e2e": "mocha --forbid-only \"test/e2e/**/*.test.ts\"",
91+
"test:e2e:ci": "mocha --forbid-only --reporter json --reporter-option output=test-results-e2e.json \"test/e2e/**/*.test.ts\"",
9092
"coverage": "c8 report",
9193
"posttest": "pnpm run lint",
9294
"prepack": "oclif manifest",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project name="app_custom" description="E2E test cartridge"/>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name": "e2e-empty", "private": true}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name": "e2e-pwav3", "dependencies": {"@salesforce/pwa-kit-react-sdk": "1.0.0"}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name": "e2e-storefront-next", "dependencies": {"@salesforce/storefront-next-runtime": "1.0.0"}}

0 commit comments

Comments
 (0)