Skip to content

Commit 1c9282f

Browse files
author
Piotr Paulski
committed
test: add eval targetting fill_form use with <select> and <checkbox> elements
1 parent def53dd commit 1c9282f

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* @license
3+
* Copyright 2026 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import assert from 'node:assert';
8+
9+
import type {TestScenario} from '../eval_gemini.ts';
10+
11+
export const scenario: TestScenario = {
12+
prompt:
13+
'Go to <TEST_URL>, fill the form with size = 2 CPUs and components = [docker, nginx].',
14+
maxTurns: 3,
15+
htmlRoute: {
16+
path: '/input_test.html',
17+
htmlContent: `
18+
<form action="/post" method="POST">
19+
<div>
20+
<label for="size">CPU/Memory size:</label>
21+
<select id="size" name="size" required>
22+
<option value="small">1 vCPU, 2GB RAM</option>
23+
<option value="medium">2 vCPU, 4GB RAM</option>
24+
<option value="large">4 vCPU, 8GB RAM</option>
25+
</select>
26+
</div>
27+
<br>
28+
<div>
29+
<p>Pre-installed components:</p>
30+
<input type="checkbox" id="docker" name="components" value="docker">
31+
<label for="docker">Docker</label><br>
32+
<input type="checkbox" id="nodejs" name="components" value="nodejs">
33+
<label for="nodejs">Node.js</label><br>
34+
<input type="checkbox" id="python" name="components" value="python">
35+
<label for="python">Python</label><br>
36+
<input type="checkbox" id="nginx" name="components" value="nginx">
37+
<label for="nginx">Nginx</label>
38+
</div>
39+
<button type="submit">Spawn Server</button>
40+
</form>
41+
`,
42+
},
43+
expectations: calls => {
44+
assert.strictEqual(calls.length, 3);
45+
assert.ok(
46+
calls[0].name === 'navigate_page' || calls[0].name === 'new_page',
47+
);
48+
assert.strictEqual(calls[1].name, 'take_snapshot');
49+
assert.strictEqual(calls[2].name, 'fill_form');
50+
51+
const elements = calls[2].args.elements as Array<{uid: string; value: string}>;
52+
assert.strictEqual(elements.length, 3);
53+
54+
const uids = new Set(elements.map(e => e.uid));
55+
assert.strictEqual(uids.size, 3, 'fill_form should target three distinct elements');
56+
57+
const values = elements.map(e => e.value).sort();
58+
assert.deepStrictEqual(values, ['2 vCPU, 4GB RAM', 'true', 'true']);
59+
},
60+
};

0 commit comments

Comments
 (0)