Files
myeasycms-v2/apps/e2e/tests/team-accounts/team-accounts.po.ts
giancarlo 2ff08a971d Update Zod package, improve code formatting, and add awaiting indicators
This commit includes three main changes. First, it updates the Zod library from version 3.23.4 to 3.23.5 across all relevant packages. Second, code readability has been enhanced by formatting modifications in several TypeScript files. Lastly, the user feedback on certain operations such as creating a team or charging for a payment is strengthened, by displaying an awaiting indicator until the operation is complete.
2024-04-30 13:16:51 +07:00

99 lines
2.4 KiB
TypeScript

import { Page, expect } 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);
}
getTeamFromSelector(teamSlug: string) {
return this.page.locator(
`[data-test="account-selector-team"][data-value="${teamSlug}"]`,
);
}
selectAccount(teamName: string) {
return this.page.click(
`[data-test="account-selector-team"][data-name="${teamName}"]`,
);
}
getTeams() {
return this.page.locator('[data-test="account-selector-team"]');
}
goToSettings() {
return this.page
.locator('a', {
hasText: 'Settings',
})
.click();
}
goToBilling() {
return this.page
.locator('a', {
hasText: 'Billing',
})
.click();
}
openAccountsSelector() {
return 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');
await this.page.waitForURL(`/home/${slug}`);
}
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 };
}
}