Compare commits
5 Commits
copilot/fi
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a233080f7 | ||
|
|
f4bc6447eb | ||
|
|
708aa6d6a5 | ||
|
|
c82a17ddfd | ||
|
|
8e0ccf770b |
@@ -101,7 +101,7 @@ export class Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async selectTab(index: number) {
|
async selectTab(index: number) {
|
||||||
this._currentTab = this._tabs[index - 1];
|
this._currentTab = this._tabs[index];
|
||||||
await this._currentTab.page.bringToFront();
|
await this._currentTab.page.bringToFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,13 +121,13 @@ export class Context {
|
|||||||
const title = await tab.title();
|
const title = await tab.title();
|
||||||
const url = tab.page.url();
|
const url = tab.page.url();
|
||||||
const current = tab === this._currentTab ? ' (current)' : '';
|
const current = tab === this._currentTab ? ' (current)' : '';
|
||||||
lines.push(`- ${i + 1}:${current} [${title}] (${url})`);
|
lines.push(`- ${i}:${current} [${title}] (${url})`);
|
||||||
}
|
}
|
||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
async closeTab(index: number | undefined) {
|
async closeTab(index: number | undefined) {
|
||||||
const tab = index === undefined ? this._currentTab : this._tabs[index - 1];
|
const tab = index === undefined ? this._currentTab : this._tabs[index];
|
||||||
await tab?.page.close();
|
await tab?.page.close();
|
||||||
return await this.listTabsMarkdown();
|
return await this.listTabsMarkdown();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,12 +34,6 @@ const close = defineTool({
|
|||||||
code: [`await page.close()`],
|
code: [`await page.close()`],
|
||||||
captureSnapshot: false,
|
captureSnapshot: false,
|
||||||
waitForNetwork: false,
|
waitForNetwork: false,
|
||||||
resultOverride: {
|
|
||||||
content: [{
|
|
||||||
type: 'text',
|
|
||||||
text: 'Browser closed successfully.',
|
|
||||||
}],
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ test('test reopen browser', async ({ startClient, server, mcpMode }) => {
|
|||||||
|
|
||||||
expect(await client.callTool({
|
expect(await client.callTool({
|
||||||
name: 'browser_close',
|
name: 'browser_close',
|
||||||
})).toContainTextContent('Browser closed successfully.');
|
})).toContainTextContent('No open pages available');
|
||||||
|
|
||||||
expect(await client.callTool({
|
expect(await client.callTool({
|
||||||
name: 'browser_navigate',
|
name: 'browser_navigate',
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ test('list initial tabs', async ({ client }) => {
|
|||||||
expect(await client.callTool({
|
expect(await client.callTool({
|
||||||
name: 'browser_tab_list',
|
name: 'browser_tab_list',
|
||||||
})).toHaveTextContent(`### Open tabs
|
})).toHaveTextContent(`### Open tabs
|
||||||
- 1: (current) [] (about:blank)`);
|
- 0: (current) [] (about:blank)`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('list first tab', async ({ client }) => {
|
test('list first tab', async ({ client }) => {
|
||||||
@@ -41,8 +41,8 @@ test('list first tab', async ({ client }) => {
|
|||||||
expect(await client.callTool({
|
expect(await client.callTool({
|
||||||
name: 'browser_tab_list',
|
name: 'browser_tab_list',
|
||||||
})).toHaveTextContent(`### Open tabs
|
})).toHaveTextContent(`### Open tabs
|
||||||
- 1: [] (about:blank)
|
- 0: [] (about:blank)
|
||||||
- 2: (current) [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)`);
|
- 1: (current) [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('create new tab', async ({ client }) => {
|
test('create new tab', async ({ client }) => {
|
||||||
@@ -53,8 +53,8 @@ test('create new tab', async ({ client }) => {
|
|||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
### Open tabs
|
### Open tabs
|
||||||
- 1: [] (about:blank)
|
- 0: [] (about:blank)
|
||||||
- 2: (current) [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
|
- 1: (current) [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
|
||||||
|
|
||||||
### Current tab
|
### Current tab
|
||||||
- Page URL: data:text/html,<title>Tab one</title><body>Body one</body>
|
- Page URL: data:text/html,<title>Tab one</title><body>Body one</body>
|
||||||
@@ -71,9 +71,9 @@ test('create new tab', async ({ client }) => {
|
|||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
### Open tabs
|
### Open tabs
|
||||||
- 1: [] (about:blank)
|
- 0: [] (about:blank)
|
||||||
- 2: [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
|
- 1: [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
|
||||||
- 3: (current) [Tab two] (data:text/html,<title>Tab two</title><body>Body two</body>)
|
- 2: (current) [Tab two] (data:text/html,<title>Tab two</title><body>Body two</body>)
|
||||||
|
|
||||||
### Current tab
|
### Current tab
|
||||||
- Page URL: data:text/html,<title>Tab two</title><body>Body two</body>
|
- Page URL: data:text/html,<title>Tab two</title><body>Body two</body>
|
||||||
@@ -90,18 +90,18 @@ test('select tab', async ({ client }) => {
|
|||||||
expect(await client.callTool({
|
expect(await client.callTool({
|
||||||
name: 'browser_tab_select',
|
name: 'browser_tab_select',
|
||||||
arguments: {
|
arguments: {
|
||||||
index: 2,
|
index: 1,
|
||||||
},
|
},
|
||||||
})).toHaveTextContent(`
|
})).toHaveTextContent(`
|
||||||
- Ran Playwright code:
|
- Ran Playwright code:
|
||||||
\`\`\`js
|
\`\`\`js
|
||||||
// <internal code to select tab 2>
|
// <internal code to select tab 1>
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
### Open tabs
|
### Open tabs
|
||||||
- 1: [] (about:blank)
|
- 0: [] (about:blank)
|
||||||
- 2: (current) [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
|
- 1: (current) [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
|
||||||
- 3: [Tab two] (data:text/html,<title>Tab two</title><body>Body two</body>)
|
- 2: [Tab two] (data:text/html,<title>Tab two</title><body>Body two</body>)
|
||||||
|
|
||||||
### Current tab
|
### Current tab
|
||||||
- Page URL: data:text/html,<title>Tab one</title><body>Body one</body>
|
- Page URL: data:text/html,<title>Tab one</title><body>Body one</body>
|
||||||
@@ -118,17 +118,17 @@ test('close tab', async ({ client }) => {
|
|||||||
expect(await client.callTool({
|
expect(await client.callTool({
|
||||||
name: 'browser_tab_close',
|
name: 'browser_tab_close',
|
||||||
arguments: {
|
arguments: {
|
||||||
index: 3,
|
index: 2,
|
||||||
},
|
},
|
||||||
})).toHaveTextContent(`
|
})).toHaveTextContent(`
|
||||||
- Ran Playwright code:
|
- Ran Playwright code:
|
||||||
\`\`\`js
|
\`\`\`js
|
||||||
// <internal code to close tab 3>
|
// <internal code to close tab 2>
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
### Open tabs
|
### Open tabs
|
||||||
- 1: [] (about:blank)
|
- 0: [] (about:blank)
|
||||||
- 2: (current) [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
|
- 1: (current) [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
|
||||||
|
|
||||||
### Current tab
|
### Current tab
|
||||||
- Page URL: data:text/html,<title>Tab one</title><body>Body one</body>
|
- Page URL: data:text/html,<title>Tab one</title><body>Body one</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user