Some checks failed
Admin | Playwright Tests / Admin | Playwright Tests | Shard 1 Of 6 (push) Failing after 37s
Admin | Playwright Tests / Admin | Playwright Tests | Shard 2 Of 6 (push) Failing after 7s
Admin | Playwright Tests / Admin | Playwright Tests | Shard 4 Of 6 (push) Failing after 7s
Admin | Playwright Tests / Admin | Playwright Tests | Shard 6 Of 6 (push) Failing after 6s
Linting Tests / PHP 8.3 test on ubuntu-latest (push) Failing after 5s
CI / PHP 8.3 test on ubuntu-latest (push) Failing after 6s
Skills Consistency / validate-skills (push) Successful in 10s
Admin | Playwright Tests / Admin | Playwright Tests | Shard 3 Of 6 (push) Failing after 7s
Admin | Playwright Tests / Admin | Playwright Tests | Shard 5 Of 6 (push) Failing after 6s
72 lines
2.7 KiB
TypeScript
72 lines
2.7 KiB
TypeScript
// groupPage.js
|
|
import { expect, Locator, Page } from '@playwright/test';
|
|
import { SettingsPage } from '../SettingsPage';
|
|
import { generateDescription, generateFirstName, generateName } from '../../utils/faker';
|
|
export type GroupData={
|
|
name:string,
|
|
description:string
|
|
}
|
|
export const groupData:GroupData={
|
|
name: generateFirstName()+" Group",
|
|
description: generateDescription().slice(0, 60),
|
|
}
|
|
|
|
export class GroupPage extends SettingsPage {
|
|
readonly page:Page;
|
|
readonly createGroupButton: Locator;
|
|
readonly saveGroupButton: Locator;
|
|
readonly nameInput: Locator;
|
|
readonly descriptionTextarea: Locator;
|
|
readonly successMessageGroupCreated: Locator;
|
|
readonly successMessageGroupUpdated: Locator;
|
|
|
|
constructor(page:Page) {
|
|
super(page);
|
|
this.page = page;
|
|
|
|
// Buttons
|
|
this.createGroupButton = page.getByRole("button", { name: "Create group" });
|
|
this.saveGroupButton = page.getByRole("button", { name: "Save Group" });
|
|
|
|
// Form fields
|
|
this.nameInput = page.locator('input[name="name"]');
|
|
this.descriptionTextarea = page.locator('textarea[name="description"]');
|
|
|
|
// Notifications
|
|
this.successMessageGroupCreated = page.getByText("Group created successfully.");
|
|
this.successMessageGroupUpdated = page.getByText("Group updated successfully.");
|
|
}
|
|
async createGroup(groupData:GroupData): Promise<void>
|
|
{
|
|
await this.createGroupButton.click();
|
|
await this.nameInput.fill(groupData.name);
|
|
await this.descriptionTextarea.fill(groupData.description);
|
|
await this.saveGroupButton.click();
|
|
await expect(this.successMessageGroupCreated.first()).toBeVisible();
|
|
await this.searchGroup(groupData.name);
|
|
await expect(this.page.getByText(groupData.name).first()).toBeVisible();
|
|
}
|
|
async updateGroup(groupData:GroupData): Promise<void>
|
|
{
|
|
await this.firstEditIcon.click();
|
|
await this.nameInput.fill(groupData.name);
|
|
await this.descriptionTextarea.fill(groupData.description);
|
|
await this.saveGroupButton.click();
|
|
await expect(this.successMessageGroupUpdated.first()).toBeVisible();
|
|
await this.searchGroup(groupData.name);
|
|
await expect(this.page.getByText(groupData.name).first()).toBeVisible();
|
|
}
|
|
async deleteGroup(): Promise<void>
|
|
{
|
|
await this.firstDeleteIcon.click();
|
|
await this.agreeButton.click();
|
|
await expect(this.successMessage.first()).toBeVisible();
|
|
}
|
|
async searchGroup(name:string): Promise<void>
|
|
{
|
|
await this.searchInputExact.fill(name);
|
|
await this.page.keyboard.press('Enter');
|
|
|
|
}
|
|
}
|