Compare commits
2 Commits
vscode-cli
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f83a808d39 | ||
|
|
54754d8be1 |
@@ -39,7 +39,9 @@ const wait = defineTool({
|
|||||||
const code: string[] = [];
|
const code: string[] = [];
|
||||||
|
|
||||||
if (params.time) {
|
if (params.time) {
|
||||||
code.push(`await new Promise(f => setTimeout(f, ${params.time!} * 1000));`);
|
const timeCode = `await new Promise(f => setTimeout(f, ${params.time!} * 1000));`;
|
||||||
|
code.push(timeCode);
|
||||||
|
response.addCode(timeCode);
|
||||||
await new Promise(f => setTimeout(f, Math.min(30000, params.time! * 1000)));
|
await new Promise(f => setTimeout(f, Math.min(30000, params.time! * 1000)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,12 +50,16 @@ const wait = defineTool({
|
|||||||
const goneLocator = params.textGone ? tab.page.getByText(params.textGone).first() : undefined;
|
const goneLocator = params.textGone ? tab.page.getByText(params.textGone).first() : undefined;
|
||||||
|
|
||||||
if (goneLocator) {
|
if (goneLocator) {
|
||||||
code.push(`await page.getByText(${JSON.stringify(params.textGone)}).first().waitFor({ state: 'hidden' });`);
|
const goneCode = `await page.getByText(${JSON.stringify(params.textGone)}).first().waitFor({ state: 'hidden' });`;
|
||||||
|
code.push(goneCode);
|
||||||
|
response.addCode(goneCode);
|
||||||
await goneLocator.waitFor({ state: 'hidden' });
|
await goneLocator.waitFor({ state: 'hidden' });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (locator) {
|
if (locator) {
|
||||||
code.push(`await page.getByText(${JSON.stringify(params.text)}).first().waitFor({ state: 'visible' });`);
|
const locatorCode = `await page.getByText(${JSON.stringify(params.text)}).first().waitFor({ state: 'visible' });`;
|
||||||
|
code.push(locatorCode);
|
||||||
|
response.addCode(locatorCode);
|
||||||
await locator.waitFor({ state: 'visible' });
|
await locator.waitFor({ state: 'visible' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ test('browser_wait_for(text)', async ({ client, server }) => {
|
|||||||
name: 'browser_wait_for',
|
name: 'browser_wait_for',
|
||||||
arguments: { text: 'Text to appear' },
|
arguments: { text: 'Text to appear' },
|
||||||
})).toHaveResponse({
|
})).toHaveResponse({
|
||||||
|
code: `await page.getByText("Text to appear").first().waitFor({ state: 'visible' });`,
|
||||||
pageState: expect.stringContaining(`- generic [ref=e3]: Text to appear`),
|
pageState: expect.stringContaining(`- generic [ref=e3]: Text to appear`),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -84,6 +85,23 @@ test('browser_wait_for(textGone)', async ({ client, server }) => {
|
|||||||
name: 'browser_wait_for',
|
name: 'browser_wait_for',
|
||||||
arguments: { textGone: 'Text to disappear' },
|
arguments: { textGone: 'Text to disappear' },
|
||||||
})).toHaveResponse({
|
})).toHaveResponse({
|
||||||
|
code: `await page.getByText("Text to disappear").first().waitFor({ state: 'hidden' });`,
|
||||||
pageState: expect.stringContaining(`- generic [ref=e3]: Text to appear`),
|
pageState: expect.stringContaining(`- generic [ref=e3]: Text to appear`),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('browser_wait_for(time)', async ({ client, server }) => {
|
||||||
|
server.setContent('/', `<body><div>Hello World</div></body>`, 'text/html');
|
||||||
|
|
||||||
|
await client.callTool({
|
||||||
|
name: 'browser_navigate',
|
||||||
|
arguments: { url: server.PREFIX },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(await client.callTool({
|
||||||
|
name: 'browser_wait_for',
|
||||||
|
arguments: { time: 1 },
|
||||||
|
})).toHaveResponse({
|
||||||
|
code: `await new Promise(f => setTimeout(f, 1 * 1000));`,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user