chore: generalize status & action as code (#188)

This commit is contained in:
Pavel Feldman
2025-04-15 12:54:45 -07:00
committed by GitHub
parent 4a19e18999
commit 795a9d578a
12 changed files with 187 additions and 88 deletions

View File

@@ -24,9 +24,11 @@ test('browser_navigate', async ({ client }) => {
url: 'data:text/html,<html><title>Title</title><body>Hello, world!</body></html>',
},
})).toHaveTextContent(`
Navigated to data:text/html,<html><title>Title</title><body>Hello, world!</body></html>
- Action: await page.goto('data:text/html,<html><title>Title</title><body>Hello, world!</body></html>');
- Ran code:
\`\`\`js
// Navigate to data:text/html,<html><title>Title</title><body>Hello, world!</body></html>
await page.goto('data:text/html,<html><title>Title</title><body>Hello, world!</body></html>');
\`\`\`
- Page URL: data:text/html,<html><title>Title</title><body>Hello, world!</body></html>
- Page Title: Title
@@ -53,9 +55,11 @@ test('browser_click', async ({ client }) => {
ref: 's1e3',
},
})).toHaveTextContent(`
Clicked "Submit button"
- Action: await page.getByRole('button', { name: 'Submit' }).click();
- Ran code:
\`\`\`js
// Click Submit button
await page.getByRole('button', { name: 'Submit' }).click();
\`\`\`
- Page URL: data:text/html,<html><title>Title</title><button>Submit</button></html>
- Page Title: Title
@@ -83,9 +87,11 @@ test('browser_select_option', async ({ client }) => {
values: ['bar'],
},
})).toHaveTextContent(`
Selected option in "Select"
- Action: await page.getByRole('combobox').selectOption(['bar']);
- Ran code:
\`\`\`js
// Select options [bar] in Select
await page.getByRole('combobox').selectOption(['bar']);
\`\`\`
- Page URL: data:text/html,<html><title>Title</title><select><option value="foo">Foo</option><option value="bar">Bar</option></select></html>
- Page Title: Title
@@ -114,9 +120,11 @@ test('browser_select_option (multiple)', async ({ client }) => {
values: ['bar', 'baz'],
},
})).toHaveTextContent(`
Selected option in "Select"
- Action: await page.getByRole('listbox').selectOption(['bar', 'baz']);
- Ran code:
\`\`\`js
// Select options [bar, baz] in Select
await page.getByRole('listbox').selectOption(['bar', 'baz']);
\`\`\`
- Page URL: data:text/html,<html><title>Title</title><select multiple><option value="foo">Foo</option><option value="bar">Bar</option><option value="baz">Baz</option></select></html>
- Page Title: Title
@@ -260,6 +268,10 @@ test('browser_resize', async ({ client }) => {
height: 780,
},
});
expect(response).toContainTextContent('Resized browser window');
expect(response).toContainTextContent(`- Ran code:
\`\`\`js
// Resize browser window to 390x780
await page.setViewportSize({ width: 390, height: 780 });
\`\`\``);
await expect.poll(() => client.callTool({ name: 'browser_snapshot' })).toContainTextContent('Window size: 390x780');
});

View File

@@ -41,6 +41,11 @@ test('cdp server reuse tab', async ({ cdpEndpoint, startClient }) => {
name: 'browser_snapshot',
arguments: {},
})).toHaveTextContent(`
- Ran code:
\`\`\`js
// <internal code to capture accessibility snapshot>
\`\`\`
- Page URL: data:text/html,hello world
- Page Title:
- Page Snapshot

View File

@@ -39,5 +39,5 @@ test('stitched aria frames', async ({ client }) => {
element: 'World',
ref: 'f1s1e3',
},
})).toContainTextContent('Clicked "World"');
})).toContainTextContent(`// Click World`);
});

View File

@@ -31,11 +31,16 @@ async function createTab(client: Client, title: string, body: string) {
test('create new tab', async ({ client }) => {
expect(await createTab(client, 'Tab one', 'Body one')).toHaveTextContent(`
Open tabs:
- Ran code:
\`\`\`js
// <internal code to open a new tab>
\`\`\`
### Open tabs
- 1: [] (about:blank)
- 2: (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 Title: Tab one
- Page Snapshot
@@ -44,12 +49,17 @@ Current tab:
\`\`\``);
expect(await createTab(client, 'Tab two', 'Body two')).toHaveTextContent(`
Open tabs:
- Ran code:
\`\`\`js
// <internal code to open a new tab>
\`\`\`
### Open tabs
- 1: [] (about:blank)
- 2: [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>)
Current tab:
### Current tab
- Page URL: data:text/html,<title>Tab two</title><body>Body two</body>
- Page Title: Tab two
- Page Snapshot
@@ -67,12 +77,17 @@ test('select tab', async ({ client }) => {
index: 2,
},
})).toHaveTextContent(`
Open tabs:
- Ran code:
\`\`\`js
// <internal code to select tab 2>
\`\`\`
### Open tabs
- 1: [] (about:blank)
- 2: (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>)
Current tab:
### Current tab
- Page URL: data:text/html,<title>Tab one</title><body>Body one</body>
- Page Title: Tab one
- Page Snapshot
@@ -90,11 +105,16 @@ test('close tab', async ({ client }) => {
index: 3,
},
})).toHaveTextContent(`
Open tabs:
- Ran code:
\`\`\`js
// <internal code to close tab 3>
\`\`\`
### Open tabs
- 1: [] (about:blank)
- 2: (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 Title: Tab one
- Page Snapshot