Invite a member and join
Turn an invitation between two people into a test, with a new teammate joining on every run.
This example makes a test of Parcel's team invitations, a flow with two people in it. Your test account member signs in and invites a new teammate by email, and the teammate opens the invitation, creates an account and lands on the team. You describe it in one message, Re:agent walks it in two browsers, and Rehearsal saves it as a test that does the same on every run.
Before you start Link to Before you start
The person who sends the invitation signs in, so the project needs a test account for them. In Settings, open Test accounts under the project and add a Password account named member, with the email address and password it signs in to Parcel with.
The teammate needs no account. A person who signs up in a flow gets a new address in the test inbox in every browser and on every run, so each run invites someone Parcel has never seen.
Ask Re:agent Link to Ask Re:agent
Open Re:agent, start a New chat and describe the flow: who takes part, what each one does, and what the last one should see.
Sign in as member and invite a new teammate to the Parcel team by email. The teammate opens the invitation, creates an account and should see the Parcel team.What the last person should see matters most, because it becomes the test's final check.
What Re:agent does Link to What Re:agent does
Re:agent opens a browser for each person, as Flows with more than one person describes, and the panel beside the chat shows both. Each step appears in the chat as it happens, such as:
- Opened a browser on parcel.example as member
- Opened a browser on parcel.example as a new user
- Clicked Send invitation
- Read the test inbox
- Clicked Join the team
Re:agent never sees a password: it types {{password}} and Rehearsal fills in the real one. When member invites the teammate, Rehearsal types the teammate's new address into the form in the same way, and the link Re:agent opens from the invitation is written down as {{link}}.
Once the teammate sees the team, Re:agent saves the flow, and a block in its reply follows the new test through Flow saved, Test written, First run passed and Verified in a fresh browser.
The test Link to The test
When both runs have passed, the test's card appears in the chat with Run now, Open test and Watch recording. The test behind it is a Retest test with one app per person, and it looks something like this:
import { expect, inbox, secret, test } from '@rehearsal-labs/retest';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 expect(member.getByRole('link', { name: 'Team' })).toBeVisible(); }); await test.step('Invite the teammate', async () => { await member.getByRole('link', { name: 'Team' }).click(); await member.getByLabel('Email').fill(secret('teammate-email')); await member.getByRole('button', { name: 'Send invitation' }).click(); await expect(member.getByText('Invitation sent')).toBeVisible(); }); 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(); }); await test.step('Check the teammate sees the team', async () => { await expect(teammate.getByRole('heading', { name: 'Parcel team' })).toBeVisible(); });});Each secret() names a value Retest types while the test runs: member's email address and password, then the teammate's new address and password. inbox('teammate').latest() waits up to a minute for the invitation to arrive. The file never holds an address, a password or the link.
Run it Link to Run it
Press Run now on the card, choose the screens in the dialog and press Run. The test is also under Tests, where Run test does the same, and from a terminal:
rehearsal run --test <test-id>rehearsal run wait <run-id>The test has two browsers but uses one test run per screen, like any other test.
Every run adds a new teammate to Parcel. Their addresses start with fresh- and end in @inbox.rehearsal.dev, so they are easy to find when you clear out your test data.