Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b250f7c
feat(run): declare peers, more users in one test
TanmayOG Nov 10, 2026
3808a29
feat(run): open a peer's app on the test's own target
TanmayOG Nov 10, 2026
22e20f9
feat(run): name each peer in records, reports, and the replay cache
TanmayOG Nov 10, 2026
5c3e4fb
feat(run): run a peer on another target
TanmayOG Nov 11, 2026
9d3ac4a
feat(run): reserve a slot of its own for each peer, a device on a phone
TanmayOG Nov 11, 2026
601a8a5
feat(run): refuse peers where they cannot run, with an error that say…
TanmayOG Nov 11, 2026
6909397
docs: two users in one test
TanmayOG Nov 11, 2026
b38c459
test(run): close every user's app on a timeout, an interrupt, and the…
TanmayOG Nov 11, 2026
42d50ae
test(report): keep a peer's facts closed to unknown keys
TanmayOG Nov 11, 2026
a357fd3
fix(run): stop the run when a peer's agent meets a model its provider…
TanmayOG Nov 11, 2026
6220565
docs: name the peers fields of report.json and the test listing
TanmayOG Nov 11, 2026
8c7c8fb
fix(run): run no more of a peer target's workers than the fit, whatev…
TanmayOG Nov 11, 2026
2720fa3
docs(engine): say prepare's workers counts peer slots, and slots reac…
TanmayOG Nov 11, 2026
cbd37a5
fix(run): settle every user's app after the last step, recording each…
TanmayOG Nov 11, 2026
856c027
fix(run): name the peer on a video its engine's host keeps by URL
TanmayOG Nov 11, 2026
07215f0
fix(run): refuse peers in a run with no config file before any engine…
TanmayOG Nov 11, 2026
1322c8c
fix(run): name the agent a peer runs as, and its target, on its model…
TanmayOG Nov 11, 2026
7dc3ff0
docs(runner): put ListedPair's comment back on it, and drop a stale o…
TanmayOG Nov 11, 2026
fe2bff8
fix(cache): keep a peer's recordings and baselines apart for each tar…
TanmayOG Nov 11, 2026
60abf96
fix(run): keep the AI trace module's types, which import ai, off the …
TanmayOG Nov 11, 2026
720f56b
fix(run): what a fresh review found, after the rebase onto main
TanmayOG Nov 14, 2026
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
5 changes: 5 additions & 0 deletions .changeset/peers-decision.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@e2e-dev/decision": patch
---

`decisionFilter()` counts a test as touched, and scores it so, when a setup file that saves one of its peers' sessions changed, as it does for the test's own session; a judged test's score is the highest of its own and its setups'.
5 changes: 5 additions & 0 deletions .changeset/peers-e2e.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"e2e": patch
---

Add `peers`: more users in one test, each on an app of its own. `test('pays Ava', { peers: { ava: { session: 'ava' } } }, async ({ app, peers }) => ...)` opens Ava's app before `beforeEach`, restores her saved session, and closes it with the test. A peer can run on another target (`target`), as another agent (`agent`, `agentContext`), and on a phone, where it takes a device of its own. Every step, file, app log line, and replay recording of a peer carries its name in the report, the terminal, Markdown, the trace page, `--step`, and `--ai-trace`; its files go in `peers/<name>/`. `EnginePrepareInfo.peerSlots` tells an engine how many of its `slots` are for peers. A suite's own fixture named `peers` keeps working; only a test that declares peers through it, or on a target whose engine contributes one, is refused.
5 changes: 5 additions & 0 deletions .changeset/peers-html-reporter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@e2e-dev/html-reporter": patch
---

The HTML report names the peer on each of its steps and app log lines, plays each user's video on a timeline of its own with a switch between users, and shows each user's screen at the failure under their name, on the page and in the copied prompt.
5 changes: 5 additions & 0 deletions .changeset/peers-mobile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@e2e-dev/mobile": patch
---

A test's peer on a device target takes a simulator or emulator of its own from the pool: `prepare` binds one device per worker and one per peer. A run that puts a peer on a target with a device provider fails before any test with `UNSUPPORTED_CAPABILITY`, before anything is leased. `mobileTools` calls from a peer's agent act on the peer's own device.
5 changes: 5 additions & 0 deletions .changeset/peers-web.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@e2e-dev/web": patch
---

A run that puts a test's peer on a target with a browser provider, or on a browser attached over CDP (`web({ connect })`), fails before any test with `UNSUPPORTED_CAPABILITY`, before anything is leased. A peer on a target that launches its own browser runs as usual.
12 changes: 11 additions & 1 deletion .github/workflows/mobile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,16 @@ jobs:
GITHUB_TOKEN: ${{ inputs.agent-device-version == '' && github.token || '' }}
E2E_MOBILE_BENCHMARK_IOS_APP: ${{ steps.app.outputs.app-path }}
E2E_MOBILE_BENCHMARK_COMMENT: ios${{ matrix.suite == 'agentic' && ' agent' || '' }}
E2E_RUN: node node_modules/e2e/dist/cli/bin.js run --target ios-simulator ${{ matrix.suite == 'agentic' && '--config e2e.agent.config.ts --output .e2e/agent' || '' }}
E2E_RUN: node node_modules/e2e/dist/cli/bin.js run --target ios-simulator --exclude-tag peers ${{ matrix.suite == 'agentic' && '--config e2e.agent.config.ts --output .e2e/agent' || '' }}
run: $E2E_RUN || $E2E_RUN --last-failed
# The two-user test runs on its own: its peer takes the second
# simulator, so in the run above it would leave the whole suite one
# worker. It posts no comment; a failure fails the job.
- name: Run the two-user test
if: ${{ matrix.suite == 'deterministic' }}
env:
E2E_MOBILE_BENCHMARK_IOS_APP: ${{ steps.app.outputs.app-path }}
E2E_RUN: node node_modules/e2e/dist/cli/bin.js run --target ios-simulator --tag peers --output .e2e/peers
run: $E2E_RUN || $E2E_RUN --last-failed
# The artifact upload below fails whenever the repository's quota is
# full, so the failure evidence goes into the log as well.
Expand All @@ -245,6 +254,7 @@ jobs:
path: &report-paths |
apps/mobile-benchmark/.e2e/report.json
apps/mobile-benchmark/.e2e/agent/report.json
apps/mobile-benchmark/.e2e/peers/report.json
if-no-files-found: warn
retention-days: 7
- name: Upload artifacts
Expand Down
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ suites that consume the built packages the way a user would.
can affect each test, packing test files into calls under the model's
size limit, 8 calls at a time, and leaves out the unlikely ones. It runs
every test on an `e2e.config` or lockfile change, and asks nothing about a
test whose test file, setup file, or stored screenshots changed. It scores
test whose test file, a setup file of its or a peer's session, or stored
screenshots changed. It scores
each test it keeps through `relevance` (1 for a touched test, the model's
probability for a judged one, 0.5 for one it did not judge), and the
runner starts each target's likeliest files first. A failed
Expand Down
5 changes: 4 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ included, is in the pixels the model gets. A text download (`.txt`,
`.csv`, `.json`, `.html`) is rewritten before it is registered or stored, every secret value becoming
`<secret:name>`; any other download is kept as served and marked
`incomplete`. Sessions are per-run, target-bound, encrypted
with a memory-only key, and deleted at cleanup.
with a memory-only key, and deleted at cleanup. A test with peers has one
set of secret values for all its users: a value any user typed or restored is
redacted from every user's model input and from every record of the attempt,
and a peer's session restores only on the peer's own target.

## Navigation and origins

Expand Down
1 change: 1 addition & 0 deletions apps/mobile-benchmark/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ yarn-error.*
# e2e run output
.e2e/results/
.e2e/agent/
.e2e/peers/
# .e2e/cache/ is not ignored: recordings committed there replay in CI (AGENTS.md, "Committed recordings").
.e2e/sessions/
.e2e/report.json
Expand Down
29 changes: 19 additions & 10 deletions apps/mobile-benchmark/tests/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,30 @@ function installs(): Installs {

/**
* `build`: installs the platform's build on this worker's device before its
* first test, and nothing when the run names none (the app is already on the
* device). The engine installs nothing on its own, so this is where the
* suite says it; the step shows in the first test's report.
* first test, and on the device of each peer a test declares, and nothing
* when the run names none (the app is already on the device). The engine
* installs nothing on its own, so this is where the suite says it; the step
* shows in the first test's report.
*/
export const test = base.extend<{ build: undefined }>({
build: async ({ device, platform }, use) => {
const build = BUILDS[platform];
if (build !== undefined) {
const pending = installs();
let install = pending.get(platform);
build: async ({ device, platform, peers }, use) => {
const pending = installs();
const installOnce = async (key: string, on: Device, build: string): Promise<void> => {
let install = pending.get(key);
if (install === undefined) {
install = device.installApp(build);
pending.set(platform, install);
install = on.installApp(build);
pending.set(key, install);
}
await install;
};
const build = BUILDS[platform];
if (build !== undefined) await installOnce(platform, device, build);
// A peer on a device of its own needs the build there too; a peer on a
// platform the run brings no build for (a browser) has no device to ask.
// In this suite a peer's name is one device for the worker's whole life.
for (const [name, peer] of Object.entries(peers)) {
const peerBuild = BUILDS[peer.platform];
if (peerBuild !== undefined) await installOnce(`${peer.platform} peer ${name}`, peer.device as Device, peerBuild);
}
await use(undefined);
},
Expand Down
55 changes: 55 additions & 0 deletions apps/mobile-benchmark/tests/two-users.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Two users in one test, each on a simulator of its own: the test's own user
* and a peer on the same target. The app keeps no shared state, so what the
* test shows is that each user's steps, and each user's `device`, reach that
* user's device and no other. Locator steps only, so it runs without a model.
*/

import type { Device } from '@e2e-dev/mobile';
import { expect, openScenario, test } from './fixtures.ts';

/** The simulators the run names for the iOS target, as `e2e.config.ts` reads them. */
const simulators = (process.env.E2E_MOBILE_BENCHMARK_IOS_DEVICE ?? '').split(',').filter((udid) => udid.trim() !== '').length;

// A peer takes a device of its own beside the worker's, so the scenario runs
// only where the run names two simulators, as CI does; a run with one would
// stop before its first test. Its peer takes the second simulator, so a run
// that holds it runs every other test on one worker: CI runs the suite with
// `--exclude-tag peers`, then this test alone with `--tag peers`. iOS only:
// CI's Android job has one emulator.
test.describe('two users', { tags: ['peers'], platforms: ['ios'], skip: simulators < 2 ? 'needs two simulators in E2E_MOBILE_BENCHMARK_IOS_DEVICE' : false }, () => {
test('each user types on its own device, and each device fixture drives its own', { peers: { second: {} } }, async ({ app, device, screen, peers }) => {
const second = { app: peers.second.app, device: peers.second.device as Device, screen: peers.second.screen };
// Two devices, under two agent-device sessions.
expect(second.device.unstable_raw.deviceId).not.toBe(device.unstable_raw.deviceId);
expect(second.device.unstable_raw.session).not.toBe(device.unstable_raw.session);
expect(peers.second.platform).toBe('ios');

await openScenario({ app, device, screen }, 'Control Inventory');
await openScenario(second, 'Control Inventory');

// What one user types shows on its own screen only.
await screen.getByRole('textbox', 'Name field').fill('Grace Hopper');
await expect(screen.getByTestId('name-echo')).toHaveText('name: Grace Hopper');
await expect(second.screen.getByTestId('name-echo')).toHaveText('name: Ada Lovelace');
await second.screen.getByRole('textbox', 'Name field').fill('Alan Turing');
await expect(second.screen.getByTestId('name-echo')).toHaveText('name: Alan Turing');
await expect(screen.getByTestId('name-echo')).toHaveText('name: Grace Hopper');

// Both act at once, each on its own device.
const mine = `first ${Date.now()}`;
const theirs = `second ${Date.now()}`;
await Promise.all([device.setClipboard(mine), second.device.setClipboard(theirs)]);
expect(await device.clipboard()).toBe(mine);
expect(await second.device.clipboard()).toBe(theirs);

// A device setting of one leaves the other's alone.
try {
await second.device.setAppearance('dark');
await expect(second.screen.getByTestId('color-scheme')).toHaveText('scheme: dark');
await expect(screen.getByTestId('color-scheme')).toHaveText('scheme: light');
} finally {
await second.device.setAppearance('light');
}
});
});
6 changes: 4 additions & 2 deletions apps/testbed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ here.
- `app/server.mjs` — dependency-free playground app. The runner starts and
stops it via the web engine's `command` option. The pages live under
`app/pages/` by group, each module exporting its routes and its nav
entries: `basics` (home, todos, forms, login/session, dashboard, wizard),
entries: `basics` (home, todos, forms, login/session, dashboard, wizard,
a message board two users share),
`interaction` (network, dialogs, board, pointer pad, iframes), `canvas`
(four pixels-only surfaces), `downloads` (a file and a long page), and
`controls` (control states, scrolling, the browser fixture's page, the
Expand All @@ -29,7 +30,8 @@ here.
credentials and secrets, plus one file per surface added since: control
states and the failure codes (`controls`), pointer coordinates and path
swipes (`pointer`), viewport and node scrolling (`scroll`), the `browser`
fixture's own verbs (`browser`), and the per-action speed floor (`speed`).
fixture's own verbs (`browser`), the per-action speed floor (`speed`),
and two users in one test (`peers`).
The files tagged `playwright` are Playwright's own `tests/page` specs (and
`tests/library/download.spec.ts`) at v1.64.1, ported to the public API:
each header names its source and the tests left out. `fail: 'reason'`
Expand Down
25 changes: 23 additions & 2 deletions apps/testbed/app/pages/basics.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
* The everyday pages: the landing page, a plans page of copy with inline
* links and emphasis (unlisted in the nav), a todo list kept in localStorage, a
* profile form, the cookie-session login and the dashboard behind it, a
* three-step wizard, and a checkout with one planted bug. What queries,
* fills, sessions, polling assertions, and judgments are dogfooded against.
* three-step wizard, a checkout with one planted bug, and a message board
* every visitor shares (two users in one test). What queries, fills,
* sessions, polling assertions, and judgments are dogfooded against.
*/

const nav = [
Expand All @@ -14,8 +15,13 @@ const nav = [
{ path: '/dashboard', label: 'Dashboard' },
{ path: '/wizard', label: 'Wizard' },
{ path: '/checkout', label: 'Checkout' },
{ path: '/messages', label: 'Messages' },
];

function escapeHtml(text) {
return text.replace(/[&<>"']/g, (char) => `&#${char.charCodeAt(0)};`);
}

const pages = {
'/': () => ({
title: 'Playground',
Expand Down Expand Up @@ -194,6 +200,21 @@ const pages = {
<a href="/logout">Sign out</a>`,
}),

// The board as `request.user` sees it: who they are, every message the
// server keeps (`request.messages`), and a form to post one.
'/messages': (request) => ({
title: 'Messages',
body: `<h1>Messages</h1>
<p>Signed in as <output aria-label="Signed in as">${request.user}</output></p>
<ul aria-label="Messages">
${(request.messages ?? []).map((message) => `<li>${escapeHtml(message.author)}: ${escapeHtml(message.text)}</li>`).join('\n ')}
</ul>
<form method="post" action="/messages">
<label>Message <input name="text" /></label>
<button type="submit">Post</button>
</form>`,
}),

// Planted bug: the pay button keeps the total from page load, so after a
// quantity change the summary and the button show different totals.
'/checkout': () => ({
Expand Down
15 changes: 15 additions & 0 deletions apps/testbed/app/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { playwrightRoutes } from './playwright/routes.mjs';

const PORT = Number(process.env.PORT ?? 4271);
const playwright = playwrightRoutes(PORT);
/** The message board every visitor shares: one user posts, any other sees it (the peers test). */
const messages = [];

function parseCookies(request) {
const header = request.headers.cookie ?? '';
Expand Down Expand Up @@ -64,6 +66,19 @@ const server = createServer(async (request, response) => {
}
return;
}
if (url.pathname === '/messages') {
const author = parseCookies(request).session === 'admin' ? 'admin' : 'guest';
if (request.method === 'POST') {
let body = '';
for await (const chunk of request) body += chunk;
const text = new URLSearchParams(body).get('text')?.trim();
if (text) messages.push({ author, text });
send(303, { location: '/messages' });
return;
}
html(render('/messages', { user: author, messages }));
return;
}
if (url.pathname === '/logout') {
send(303, { 'set-cookie': 'session=; Path=/; Max-Age=0', location: '/login' });
return;
Expand Down
2 changes: 2 additions & 0 deletions apps/testbed/e2e.lightpanda.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ import base from './e2e.config.ts';
*/
export default {
...base,
// Lightpanda is a browser provider, where a peer cannot run: the peers test is left out.
tests: ['tests/**/*.e2e.ts', '!tests/peers.e2e.ts'],
targets: base.targets.map((target) => ({ ...target, name: 'lightpanda', engine: web({ browser: lightpanda({ loadResources: ['iframe'] }) }) })),
} satisfies E2EConfig;
15 changes: 15 additions & 0 deletions apps/testbed/tests/peers.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { test, expect } from 'e2e';

// Two users in one test: the signed-in admin posts, and a second user, in a
// browser of its own and signed out, sees the post on the shared board.
test('a message the admin posts reaches a signed-out user', { session: 'admin', peers: { guest: {} } }, async ({ app, screen, peers }) => {
await app.open('/messages');
await expect(screen.getByRole('status', 'Signed in as')).toHaveText('admin');
await screen.getByLabel('Message').fill('Standup moved to 10:30');
await screen.getByRole('button', 'Post').tap();
await expect(screen.getByRole('list', 'Messages')).toContainText('admin: Standup moved to 10:30');

await peers.guest.app.open('/messages');
await expect(peers.guest.screen.getByRole('status', 'Signed in as')).toHaveText('guest');
await expect(peers.guest.screen.getByRole('list', 'Messages')).toContainText('admin: Standup moved to 10:30');
});
46 changes: 46 additions & 0 deletions docs/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,49 @@ Each name refers to an `agents` entry, a `credentials` entry, and a saved
session. When the personas don't need separate sessions,
[run one flow as several agents](/agents#one-flow-several-personas) instead.

## Two users in one test

Declare more users with [`peers`](/reference/test#peers). Each peer gets an
app of its own, next to the test's, and the test drives both:

```ts title="tests/payment.e2e.ts"
import { test } from '@e2e-dev/web';
import { expect } from 'e2e';

test('Ava sees the payment', { session: 'member', peers: { ava: { session: 'ava' } } }, async ({ app, screen, peers }) => {
await app.open('/pay');
await screen.getByRole('button', 'Pay Ava $3').tap();

await peers.ava.app.open('/activity');
await expect(peers.ava.screen.getByText('$3.00 from Member')).toBeVisible();
});
```

`peers.ava` has its own `app`, `screen`, `agent`, and `platform`, and its
engine's fixtures, such as `browser` or `device`. Those are typed `unknown`,
since the peer's target decides them: cast one to use it, as in
`peers.ava.device as Device`. A peer opens before `beforeEach` and closes
with the test, also when it fails.

- **Its own target.** Set `target: 'iphone'` to put the peer on another
target. The run must select it. The test still runs once on each selected
target, so pin the test's own side with `platforms: ['web']`.
- **Its own login.** A peer's `session` is saved by a setup test on the
peer's target. A phone restores no saved login, so a phone peer signs in
during the test.
- **Its own device.** A phone peer takes a simulator or emulator of its own:
see [Two users on two devices](/mobile#two-users-on-two-devices).
- **Its own records.** The report, the trace page, and the terminal name the
peer on each of its steps. Its files go in `peers/<name>/`, its replay
recordings are its own in each target and agent the test runs on, its
screenshot baselines in each target, and its agent sees only its own
earlier steps.
- **One set of secrets.** A secret either user types is redacted from what
every user's agent reads, and from every record of the attempt.

Where a peer can't run, such as a serial group or a hosted browser, and the
error each case gives, is in the [`peers` reference](/reference/test#peers).

## Next

<CardGroup cols={2}>
Expand All @@ -296,4 +339,7 @@ session. When the personas don't need separate sessions,
<Card title="Config reference" icon="sliders" href="/reference/config#credentials">
The `credentials` and `secrets` blocks.
</Card>
<Card title="Peer options" icon="users" href="/reference/test#peers">
Every option of a peer, and the errors.
</Card>
</CardGroup>
Loading