Skip to content

Commit 142a273

Browse files
authored
fix(mcp): preserve directory for additional tab videos (#41680)
1 parent 6f3cce9 commit 142a273

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

packages/playwright-core/src/tools/backend/context.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ export class Context {
236236
const suffix = this._video.fileNames.length ? `-${this._video.fileNames.length}` : '';
237237
let fileName = this._video.fileName;
238238
if (fileName && suffix) {
239+
const dir = path.dirname(fileName);
239240
const ext = path.extname(fileName);
240-
fileName = path.basename(fileName, ext) + suffix + ext;
241+
fileName = path.join(dir, path.basename(fileName, ext) + suffix + ext);
241242
}
242243
this._video.fileNames.push(fileName);
243244
await page.screencast.start({ path: fileName, ...this._video.params });

tests/mcp/cli-devtools.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ test('tracing-start-stop', async ({ cli, server }, testInfo) => {
216216

217217
test('video-start-stop', async ({ cli, server }) => {
218218
await cli('open', server.HELLO_WORLD);
219-
const { output: videoStartOutput } = await cli('video-start', 'video.webm', '--size=400x300');
219+
const { output: videoStartOutput } = await cli('video-start', 'recordings/video.webm', '--size=400x300');
220220
expect(videoStartOutput).toContain('Video recording started.');
221221
const { output: tabNewOutput } = await cli('tab-new');
222222
expect(tabNewOutput).toContain('1: (current) [](about:blank)');
@@ -225,7 +225,7 @@ test('video-start-stop', async ({ cli, server }) => {
225225
const { output: tabCloseOutput } = await cli('tab-close');
226226
expect(tabCloseOutput).toContain(`0: (current) [](${server.EMPTY_PAGE})`);
227227
const { output: videoStopOutput } = await cli('video-stop');
228-
expect(videoStopOutput).toContain(`### Result\n- [Video](./video.webm)\n- [Video](./video-1.webm)`);
228+
expect(videoStopOutput).toContain(`### Result\n- [Video](recordings${path.sep}video.webm)\n- [Video](recordings${path.sep}video-1.webm)`);
229229
});
230230

231231
test('video-chapter', async ({ cli, server }) => {

0 commit comments

Comments
 (0)