Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const nodeArgs = [
'spec',
'--test-force-exit',
'--test',
'--test-timeout=30000',
'--test-timeout=60000',
...flags,
...files,
];
Expand Down
8 changes: 7 additions & 1 deletion src/tools/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ async function fillFormElement(
if (aXNode && aXNode.role === 'combobox') {
await selectOption(handle, aXNode, value);
} else {
await handle.asLocator().fill(value);
// Increase timeout for longer input values.
const timeoutPerChar = 10; // ms
const fillTimeout =
context.getSelectedPage().getDefaultTimeout() +
value.length * timeoutPerChar;
await handle.asLocator().setTimeout(fillTimeout).fill(value);
}
} finally {
void handle.dispose();
Expand All @@ -183,6 +188,7 @@ export const fill = defineTool({
},
handler: async (request, response, context) => {
await context.waitForEventsAfterAction(async () => {
await context.getSelectedPage().keyboard.type(request.params.value);
await fillFormElement(
request.params.uid,
request.params.value,
Expand Down
32 changes: 32 additions & 0 deletions tests/tools/input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,38 @@ describe('input', () => {
assert.strictEqual(selectedValue, 'v2');
});
});

it('fills out a textarea with long text', async () => {
await withMcpContext(async (response, context) => {
const page = context.getSelectedPage();
await page.setContent(html`<textarea />`);
await page.focus('textarea');
await context.createTextSnapshot();
await page.setDefaultTimeout(1000);
await fill.handler(
{
params: {
uid: '1_1',
value: '1'.repeat(3000),
},
},
response,
context,
);
assert.strictEqual(
response.responseLines[0],
'Successfully filled out the element',
);
assert.ok(response.includeSnapshot);
assert.ok(
await page.evaluate(() => {
return (
document.body.querySelector('textarea')?.value.length === 3_000
);
}),
);
});
});
});

describe('drags', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/tools/performance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('performance', () => {
});
});

it.only('supports filePath', async () => {
it('supports filePath', async () => {
const rawData = loadTraceAsBuffer('basic-trace.json.gz');
// rawData is the decompressed buffer (based on loadTraceAsBuffer implementation).
// We want to simulate saving it as a .gz file, so the tool should compress it.
Expand Down