Flows with more than one person

Test what happens between people, such as a member who invites a new teammate, with a browser for each of them.

Some of the flows that matter most happen between people. A member invites a teammate, or a buyer sends a seller a message. To test one, describe it to Re:agent in the chat, and it uses a browser for each person, up to four in one flow, then saves what they all did as one test.

Each browser is separate, with its own sign-in and its own cookies, so the people in a flow never share a session. A person signs in as one test account at most, and if they open a second tab, it shares their account.

In an exploration started from setup or the chat, each subagent signs in as one role. A flow that passes from one person to another is one you describe in the chat, as Create a test in chat explains.

Before you start Link to Before you start

Give each person who signs in a test account of their own. For a flow where member invites a new teammate by email, Parcel needs one: member, a Password account that signs in and sends the invitation.

The teammate needs no account, because they sign up as a new user. A new user's browser gets a new address with its own test inbox and a password Rehearsal keeps, and so does every run of the test. Two people in one flow cannot share an inbox, so each person who reads mail is either a new user or has an account with an address of its own.

Make the person who receives an invitation a new user, not a test account. A test account's address stays the same, so after the first run that person has already joined, and if your app refuses to invite someone who already joined, the next run fails.

Describe the flow Link to Describe the flow

Name each person and say what they do, in the order it happens, then say what the last person should see at the end:

Output
Sign in as member and invite a new teammate to the team by email. The teammate opens the invitation, creates an account and should see the Parcel team.

Re:agent opens a browser for each person when the flow needs them, and each row says whose it is, such as Opened a browser on parcel.example as member and Opened a browser on parcel.example as a new user. The people can use different apps of the same project, such as an admin site and the main app, but every browser in a flow belongs to one project. When the test runs, a person on another app needs a public address registered in the project, and such a test runs only on the address it was saved on.

An app on your computer allows less. Every browser in a local flow goes through the same connection to the same address, so everyone stays on one app.

What you see Link to What you see

  • With one browser open, the panel's head names its person. With several, the head reads Browsers with a count, and each browser is named after its person below.
  • Re:agent takes one step at a time, in one browser at a time. If you go to watch a browser it is not using, Follow Re:agent takes you back to the one it is in.
  • A question about one browser names its person, such as "member: Which account should it use?", and the other browsers stay open while you answer.
  • Re:agent can close one person's browser when their part is done, and its row reads Closed the browser. Close this browser in the panel does the same for you.

Saving the flow Link to Saving the flow

When the last person sees what you described, Re:agent saves every person's steps together, in the order they happened, as one flow. Rehearsal then writes and checks the test the same way as any other, through the four stages Create a test in chat shows.

The test gives each person an app of their own, named after them, and takes their steps in the same order. Shortened, a test for this flow looks like this:

TypeScript
test('A new teammate joins from an invitation', { apps: ['member', 'teammate'] }, async ({ member, teammate }) => {  await test.step('Sign in as member', async () => {    await member.goto('/sign-in');    await member.getByLabel('Email').fill(secret('member-email'));    await member.getByLabel('Password').fill(secret('member-password'));    await member.getByRole('button', { name: 'Sign in' }).click();  });  await test.step('Invite the teammate', async () => {    await member.goto('/team');    await member.getByLabel('Email').fill(secret('teammate-email'));    await member.getByRole('button', { name: 'Send invitation' }).click();  });  const invitation = await test.step('Read the invitation', () =>    inbox('teammate').latest({ subject: 'invited', timeout: 60_000 }));  await test.step('Join from the invitation', async () => {    await teammate.goto(invitation.link());    await teammate.getByLabel('Password').fill(secret('teammate-password'));    await teammate.getByRole('button', { name: 'Join the team' }).click();  });  // ...});

secret('member-email') and secret('member-password') type the member's sign-in, and secret('teammate-email') types the teammate's new address into the invitation, so the file holds none of them. inbox('teammate') reads the teammate's own inbox for the invitation on every run, and secret('teammate-password') types the password Rehearsal keeps for the new user. At the end, the run checks the page of the person the flow ended with, here the teammate.

Good to know

A test cannot use a second tab yet. If one person opens another tab during the flow, the flow is saved, but the block in the chat says "This flow opens a second tab. Tests cannot use more than one tab yet." Ask Re:agent to keep each person to one tab. However many people take part, a run of the test counts as one test run.

Next steps Link to Next steps