Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions tests/e2e/pages/admin/roles-create.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { Page } from '@playwright/test';

export class AdminRolesCreatePage {
constructor(private page: Page) {}

async goto() {
await this.page.goto('/admin/roles/create');
}

get heading() {
return this.page.getByRole('heading', { name: /create role/i });
}

get nameInput() {
return this.page.getByLabel(/name/i);
}

get descriptionInput() {
return this.page.getByLabel(/description/i);
}

get submitButton() {
return this.page.getByRole('button', { name: /create role/i });
}

permissionCheckbox(permission: string) {
return this.page.getByLabel(permission);
}

async createRole(name: string, description?: string) {
await this.nameInput.fill(name);
if (description) {
await this.descriptionInput.fill(description);
}
await this.submitButton.click();
await this.page.waitForLoadState('networkidle');
}
}
51 changes: 51 additions & 0 deletions tests/e2e/pages/admin/roles-edit.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import type { Page } from '@playwright/test';

export class AdminRolesEditPage {
constructor(private page: Page) {}

get heading() {
return this.page.getByRole('heading', { name: /edit role/i });
}

// Tabs
get detailsTab() {
return this.page.getByRole('tab', { name: /details/i });
}

get permissionsTab() {
return this.page.getByRole('tab', { name: /permissions/i });
}

get usersTab() {
return this.page.getByRole('tab', { name: /users/i });
}

// Details tab
get nameInput() {
return this.page.getByLabel(/name/i);
}

get descriptionInput() {
return this.page.getByLabel(/description/i);
}

get saveButton() {
return this.page.getByRole('button', { name: /save/i });
}

// Permissions tab
permissionCheckbox(permission: string) {
return this.page.getByLabel(permission);
}

get savePermissionsButton() {
return this.page.getByRole('button', { name: /save permissions/i });
}

async updateName(name: string) {
await this.detailsTab.click();
await this.nameInput.fill(name);
await this.saveButton.click();
await this.page.waitForLoadState('networkidle');
}
}
40 changes: 40 additions & 0 deletions tests/e2e/pages/admin/roles.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { Page } from '@playwright/test';

export class AdminRolesPage {
constructor(private page: Page) {}

async goto() {
await this.page.goto('/admin/roles');
}

get heading() {
return this.page.getByRole('heading', { name: /roles/i });
}

get createButton() {
return this.page
.getByRole('link', { name: /create role/i })
.or(this.page.getByRole('button', { name: /create role/i }));
}

roleRow(name: string) {
return this.page.getByRole('row').filter({ hasText: name });
}

editButton(name: string) {
return this.roleRow(name)
.getByRole('link', { name: /edit/i })
.or(this.roleRow(name).getByRole('button', { name: /edit/i }));
}

deleteButton(name: string) {
return this.roleRow(name).getByRole('button', { name: /delete/i });
}

get confirmDeleteButton() {
return this.page
.getByRole('alertdialog')
.or(this.page.getByRole('dialog'))
.getByRole('button', { name: /confirm|delete|yes/i });
}
}
63 changes: 63 additions & 0 deletions tests/e2e/pages/admin/users-create.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import type { Page } from '@playwright/test';

export class AdminUsersCreatePage {
constructor(private page: Page) {}

async goto() {
await this.page.goto('/admin/users/create');
}

get heading() {
return this.page.getByRole('heading', { name: /create user/i });
}

get displayNameInput() {
return this.page.getByLabel(/display name/i);
}

get emailInput() {
return this.page.getByLabel('Email', { exact: true });
}

get passwordInput() {
return this.page.getByLabel('Password', { exact: true });
}

get confirmPasswordInput() {
return this.page.getByLabel(/confirm password/i);
}

get emailConfirmedCheckbox() {
return this.page.getByLabel(/email confirmed/i);
}

get submitButton() {
return this.page.getByRole('button', { name: /create user/i });
}

roleCheckbox(roleName: string) {
return this.page.getByLabel(roleName);
}

async createUser(
displayName: string,
email: string,
password: string,
options?: { confirmEmail?: boolean; roles?: string[] },
) {
await this.displayNameInput.fill(displayName);
await this.emailInput.fill(email);
await this.passwordInput.fill(password);
await this.confirmPasswordInput.fill(password);
if (options?.confirmEmail) {
await this.emailConfirmedCheckbox.check();
}
if (options?.roles) {
for (const role of options.roles) {
await this.roleCheckbox(role).check();
}
}
await this.submitButton.click();
await this.page.waitForLoadState('networkidle');
}
}
94 changes: 94 additions & 0 deletions tests/e2e/pages/admin/users-edit.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import type { Page } from '@playwright/test';

export class AdminUsersEditPage {
constructor(private page: Page) {}

get heading() {
return this.page.getByRole('heading', { name: /edit user/i });
}

// Tabs
get detailsTab() {
return this.page.getByRole('tab', { name: /details/i });
}

get rolesTab() {
return this.page.getByRole('tab', { name: /roles/i });
}

get securityTab() {
return this.page.getByRole('tab', { name: /security/i });
}

get sessionsTab() {
return this.page.getByRole('tab', { name: /sessions/i });
}

// Details tab
get displayNameInput() {
return this.page.getByLabel(/display name/i);
}

get emailInput() {
return this.page.getByLabel(/email/i);
}

get saveDetailsButton() {
return this.page.getByRole('button', { name: /save/i });
}

get deactivateButton() {
return this.page.getByRole('button', { name: /deactivate/i });
}

get reactivateButton() {
return this.page.getByRole('button', { name: /reactivate/i });
}

// Security tab
get lockButton() {
return this.page.getByRole('button', { name: /^lock$/i });
}

get unlockButton() {
return this.page.getByRole('button', { name: /unlock/i });
}

get newPasswordInput() {
return this.page
.getByLabel('New Password', { exact: true })
.or(this.page.getByLabel(/new password/i));
}

get confirmNewPasswordInput() {
return this.page.getByLabel(/confirm/i);
}

get resetPasswordButton() {
return this.page.getByRole('button', { name: /reset password/i });
}

// Roles tab
roleCheckbox(roleName: string) {
return this.page.getByLabel(roleName);
}

get saveRolesButton() {
return this.page.getByRole('button', { name: /save/i });
}

// Dialog confirmation
get confirmButton() {
return this.page
.getByRole('alertdialog')
.or(this.page.getByRole('dialog'))
.getByRole('button', { name: /confirm|yes|continue/i });
}

async updateDisplayName(name: string) {
await this.detailsTab.click();
await this.displayNameInput.fill(name);
await this.saveDetailsButton.click();
await this.page.waitForLoadState('networkidle');
}
}
43 changes: 43 additions & 0 deletions tests/e2e/pages/admin/users.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { Page } from '@playwright/test';

export class AdminUsersPage {
constructor(private page: Page) {}

async goto() {
await this.page.goto('/admin/users');
}

get heading() {
return this.page.getByRole('heading', { name: /users/i });
}

get createButton() {
return this.page
.getByRole('link', { name: /create user/i })
.or(this.page.getByRole('button', { name: /create user/i }));
}

get searchInput() {
return this.page.getByPlaceholder(/search/i);
}

get searchButton() {
return this.page.getByRole('button', { name: /search/i });
}

userRow(email: string) {
return this.page.getByRole('row').filter({ hasText: email });
}

editButton(email: string) {
return this.userRow(email)
.getByRole('link', { name: /edit/i })
.or(this.userRow(email).getByRole('button', { name: /edit/i }));
}

async search(term: string) {
await this.searchInput.fill(term);
await this.searchButton.click();
await this.page.waitForLoadState('networkidle');
}
}
49 changes: 49 additions & 0 deletions tests/e2e/pages/audit-logs/browse.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type { Page } from '@playwright/test';

export class AuditLogsBrowsePage {
constructor(private page: Page) {}

async goto() {
await this.page.goto('/audit-logs/browse');
}

get heading() {
return this.page.getByRole('heading', { name: /audit/i });
}

get searchInput() {
return this.page.getByPlaceholder(/search/i);
}

get applyButton() {
return this.page.getByRole('button', { name: /apply/i });
}

get clearFiltersButton() {
return this.page.getByRole('button', { name: /clear/i });
}

get exportCsvButton() {
return this.page.getByRole('button', { name: /csv/i });
}

get exportJsonButton() {
return this.page.getByRole('button', { name: /json/i });
}

get tableRows() {
return this.page.locator('table tbody tr');
}

get nextPageButton() {
return this.page.getByRole('button', { name: /next/i });
}

get previousPageButton() {
return this.page.getByRole('button', { name: /previous/i });
}

entryRow(index: number) {
return this.page.locator('table tbody tr').nth(index);
}
}
Loading
Loading