Files
myeasycms-v2/apps/e2e/tests/team-accounts/team-accounts.po.ts
giancarlo d078e0021c Add end-to-end tests for user and team billing features
This commit introduces end-to-end tests for the user and team billing features. It also enhances existing billing configurations, logging, and error handling mechanisms. Refactoring has been done to simplify the code and make it more readable. Adjustments have also been made in the visual aspects of some components. The addition of these tests will help ensure the reliability of the billing features.
2024-04-14 17:15:04 +08:00

80 lines
2.3 KiB
TypeScript

import { expect, Page } from '@playwright/test';
import { AuthPageObject } from '../authentication/auth.po';
export class TeamAccountsPageObject {
private readonly page: Page;
public auth: AuthPageObject;
constructor(page: Page) {
this.page = page;
this.auth = new AuthPageObject(page);
}
async setup(params = this.createTeamName()) {
await this.auth.signUpFlow('/home');
await this.createTeam(params);
}
async getTeamFromSelector(teamSlug: string) {
await this.openAccountsSelector();
return this.page.locator(`[data-test="account-selector-team"][data-value="${teamSlug}"]`);
}
async selectAccount(teamName: string) {
await this.page.click(`[data-test="account-selector-team"][data-name="${teamName}"]`);
}
async getTeams() {
await this.openAccountsSelector();
return this.page.locator('[data-test="account-selector-team"]');
}
async goToSettings() {
await this.page.locator('a', {
hasText: 'Settings',
}).click();
}
async goToBilling() {
await this.page.locator('a', {
hasText: 'Billing',
}).click();
}
async openAccountsSelector() {
await this.page.click('[data-test="account-selector-trigger"]');
}
async createTeam({ teamName, slug } = this.createTeamName()) {
await this.openAccountsSelector();
await this.page.click('[data-test="create-team-account-trigger"]');
await this.page.fill('[data-test="create-team-form"] input', teamName);
await this.page.click('[data-test="create-team-form"] button:last-child');
}
async updateName(name: string) {
await this.page.fill('[data-test="update-team-account-name-form"] input', name);
await this.page.click('[data-test="update-team-account-name-form"] button');
}
async deleteAccount(teamName: string) {
await this.page.click('[data-test="delete-team-trigger"]');
expect(await this.page.locator('[data-test="delete-team-form-confirm-input"]').isVisible()).toBeTruthy();
await this.page.fill('[data-test="delete-team-form-confirm-input"]', teamName);
await this.page.click('[data-test="delete-team-form-confirm-button"]');
}
createTeamName() {
const random = (Math.random() * 100000000).toFixed(0);
const teamName = `Team-Name-${random}`;
const slug = `team-name-${random}`;
return { teamName, slug };
}
}