|
| 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<{ |
| 52 | + uid: string; |
| 53 | + value: string; |
| 54 | + }>; |
| 55 | + assert.strictEqual(elements.length, 3); |
| 56 | + |
| 57 | + const uids = new Set(elements.map(e => e.uid)); |
| 58 | + assert.strictEqual( |
| 59 | + uids.size, |
| 60 | + 3, |
| 61 | + 'fill_form should target three distinct elements', |
| 62 | + ); |
| 63 | + |
| 64 | + const values = elements.map(e => e.value).sort(); |
| 65 | + assert.deepStrictEqual(values, ['2 vCPU, 4GB RAM', 'true', 'true']); |
| 66 | + }, |
| 67 | +}; |
0 commit comments