Add data testing attributes and adapt tests for team account invitations
This commit adds data testing attributes to key elements in the team account invitations features. It also modifies e2e tests to make use of these attributes. Additionally, it introduces minor tweaks to other parts of the system to better facilitate testing, such as adjustments in timeouts and update of some log messages.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Page } from '@playwright/test';
|
||||
import { expect, Page } from '@playwright/test';
|
||||
import { AuthPageObject } from '../authentication/auth.po';
|
||||
import { TeamAccountsPageObject } from '../team-accounts/team-accounts.po';
|
||||
|
||||
@@ -44,7 +44,7 @@ export class InvitationsPageObject {
|
||||
await form.locator('button[type="submit"]').click();
|
||||
}
|
||||
|
||||
public navigateToMembers() {
|
||||
navigateToMembers() {
|
||||
return this.page.locator('a', {
|
||||
hasText: 'Members',
|
||||
}).click();
|
||||
@@ -54,7 +54,47 @@ export class InvitationsPageObject {
|
||||
await this.page.locator('[data-test="invite-members-form-trigger"]').click();
|
||||
}
|
||||
|
||||
async getInvitations() {
|
||||
return this.page.locator('[data-test="invitation-email"]');
|
||||
}
|
||||
|
||||
private getInviteForm() {
|
||||
return this.page.locator('[data-test="invite-members-form"]');
|
||||
}
|
||||
|
||||
async deleteInvitation(email: string) {
|
||||
const actions = this.getInvitationRow(email).getByRole('button');
|
||||
|
||||
await actions.click();
|
||||
|
||||
await this.page.locator('[data-test="remove-invitation-trigger"]').click();
|
||||
|
||||
await this.page.click('[data-test="delete-invitation-form"] button[type="submit"]');
|
||||
}
|
||||
|
||||
getInvitationRow(email: string) {
|
||||
return this.page.getByRole('row', { name: email });
|
||||
}
|
||||
|
||||
async updateInvitation(email: string, role: string) {
|
||||
const row = this.getInvitationRow(email);
|
||||
const actions = row.getByRole('button');
|
||||
|
||||
await actions.click();
|
||||
|
||||
await this.page.locator('[data-test="update-invitation-trigger"]').click();
|
||||
|
||||
await this.page.click(`[data-test="role-selector-trigger"]`);
|
||||
await this.page.click(`[data-test="role-option-${role}"]`);
|
||||
|
||||
await this.page.click('[data-test="update-invitation-form"] button[type="submit"]');
|
||||
}
|
||||
|
||||
async acceptInvitation() {
|
||||
await this.page.locator('[data-test="join-team-form"] button[type="submit"]').click();
|
||||
|
||||
await this.page.waitForResponse(response => {
|
||||
return response.url().includes('/join') && response.request().method() === 'POST';
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Page, test } from '@playwright/test';
|
||||
import { expect, Page, test } from '@playwright/test';
|
||||
import { InvitationsPageObject } from './invitations.po';
|
||||
|
||||
test.describe('Invitations', () => {
|
||||
@@ -12,7 +12,7 @@ test.describe('Invitations', () => {
|
||||
await invitations.setup();
|
||||
});
|
||||
|
||||
test('user invite users', async ({page}) => {
|
||||
test('Full invite flow', async ({page}) => {
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
await invitations.navigateToMembers();
|
||||
@@ -30,5 +30,80 @@ test.describe('Invitations', () => {
|
||||
];
|
||||
|
||||
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, {
|
||||
deleteAfter: true
|
||||
});
|
||||
|
||||
await invitations.auth.signUp({
|
||||
email: firstEmail,
|
||||
password: 'password',
|
||||
repeatPassword: 'password'
|
||||
});
|
||||
|
||||
await invitations.auth.visitConfirmEmailLink(firstEmail);
|
||||
|
||||
await invitations.acceptInvitation();
|
||||
|
||||
await invitations.teamAccounts.openAccountsSelector();
|
||||
|
||||
await expect(await invitations.teamAccounts.getTeams()).toHaveCount(1);
|
||||
});
|
||||
|
||||
test('users can delete invites', async ({page}) => {
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
await invitations.navigateToMembers();
|
||||
await invitations.openInviteForm();
|
||||
|
||||
const email = invitations.auth.createRandomEmail();
|
||||
|
||||
const invites = [
|
||||
{
|
||||
email,
|
||||
role: 'member'
|
||||
},
|
||||
];
|
||||
|
||||
await invitations.inviteMembers(invites);
|
||||
|
||||
await expect(await invitations.getInvitations()).toHaveCount(1);
|
||||
|
||||
await invitations.deleteInvitation(email);
|
||||
|
||||
await expect(await invitations.getInvitations()).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('users can update invites', async ({page}) => {
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
await invitations.navigateToMembers();
|
||||
await invitations.openInviteForm();
|
||||
|
||||
const email = invitations.auth.createRandomEmail();
|
||||
|
||||
const invites = [
|
||||
{
|
||||
email,
|
||||
role: 'member'
|
||||
},
|
||||
];
|
||||
|
||||
await invitations.inviteMembers(invites);
|
||||
|
||||
await expect(await invitations.getInvitations()).toHaveCount(1);
|
||||
|
||||
await invitations.updateInvitation(email, 'owner');
|
||||
|
||||
const row = invitations.getInvitationRow(email);
|
||||
|
||||
await expect(row.locator('[data-test="member-role-badge"]')).toHaveText('owner');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user