From 1321b31ae4533e39b001bc46389c1631a33d674a Mon Sep 17 00:00:00 2001 From: giancarlo Date: Sun, 14 Apr 2024 14:01:44 +0800 Subject: [PATCH] Split full flow test --- .../e2e/tests/invitations/invitations.spec.ts | 102 ++++++++++-------- 1 file changed, 57 insertions(+), 45 deletions(-) diff --git a/apps/e2e/tests/invitations/invitations.spec.ts b/apps/e2e/tests/invitations/invitations.spec.ts index b858d3edd..6815c229c 100644 --- a/apps/e2e/tests/invitations/invitations.spec.ts +++ b/apps/e2e/tests/invitations/invitations.spec.ts @@ -12,51 +12,6 @@ test.describe('Invitations', () => { await invitations.setup(); }); - test('Full invite flow', async () => { - await invitations.navigateToMembers(); - await invitations.openInviteForm(); - - const invites = [ - { - email: invitations.auth.createRandomEmail(), - role: 'member' - }, - { - email: invitations.auth.createRandomEmail(), - role: 'member' - }, - ]; - - await invitations.inviteMembers(invites); - - const firstEmail = invites[0]!.email; - - await expect(await invitations.getInvitations()).toHaveCount(2) - - // sign out and sign in with the first email - await invitations.auth.signOut(); - - await invitations.auth.visitConfirmEmailLink(invites[0]!.email); - - console.log(`Signing up with ${firstEmail}`); - - await invitations.auth.signUp({ - email: firstEmail, - password: 'password', - repeatPassword: 'password' - }); - - await invitations.auth.visitConfirmEmailLink(firstEmail); - - console.log(`Accepting invitation as ${firstEmail}`); - - await invitations.acceptInvitation(); - - await invitations.teamAccounts.openAccountsSelector(); - - await expect(await invitations.teamAccounts.getTeams()).toHaveCount(1); - }); - test('users can delete invites', async () => { await invitations.navigateToMembers(); await invitations.openInviteForm(); @@ -103,3 +58,60 @@ test.describe('Invitations', () => { await expect(row.locator('[data-test="member-role-badge"]')).toHaveText('owner'); }); }); + +test.describe('Full Invitation Flow', () => { + let page: Page; + let invitations: InvitationsPageObject; + + test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); + invitations = new InvitationsPageObject(page); + + await invitations.setup(); + }); + + test('should invite users and let users accept an invite', async () => { + await invitations.navigateToMembers(); + await invitations.openInviteForm(); + + const invites = [ + { + email: invitations.auth.createRandomEmail(), + role: 'member' + }, + { + email: invitations.auth.createRandomEmail(), + role: 'member' + }, + ]; + + await invitations.inviteMembers(invites); + + const firstEmail = invites[0]!.email; + + await expect(await invitations.getInvitations()).toHaveCount(2) + + // sign out and sign in with the first email + await invitations.auth.signOut(); + + await invitations.auth.visitConfirmEmailLink(invites[0]!.email); + + console.log(`Signing up with ${firstEmail}`); + + await invitations.auth.signUp({ + email: firstEmail, + password: 'password', + repeatPassword: 'password' + }); + + await invitations.auth.visitConfirmEmailLink(firstEmail); + + console.log(`Accepting invitation as ${firstEmail}`); + + await invitations.acceptInvitation(); + + await invitations.teamAccounts.openAccountsSelector(); + + await expect(await invitations.teamAccounts.getTeams()).toHaveCount(1); + }); +});