n8n/packages/testing/playwright/pages/SettingsUsersPage.ts
Yuliia Pominchuk 0cc00f3436
Some checks are pending
CI: Master (Build, Test, Lint) / Build for Github Cache (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (22.22.3) (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (24.16.0) (push) Waiting to run
CI: Master (Build, Test, Lint) / Lint (push) Waiting to run
CI: Master (Build, Test, Lint) / Performance (push) Waiting to run
CI: Master (Build, Test, Lint) / Notify Slack on failure (push) Blocked by required conditions
refactor(editor): Remove N8N_ENV_FEAT_CUSTOM_INSTANCE_ROLES dark-launch flag (#33688)
2026-07-06 19:01:21 +00:00

91 lines
2.7 KiB
TypeScript

import type { Locator } from '@playwright/test';
import { BasePage } from './BasePage';
import { ActionToggle } from './components/ActionToggle';
export class SettingsUsersPage extends BasePage {
readonly actionToggle = new ActionToggle(this.page);
async goto(): Promise<void> {
await this.page.goto('/settings/users');
}
getSearchInput(): Locator {
return this.page.getByTestId('users-list-search');
}
getRow(email: string): Locator {
return this.page.getByRole('row', { name: email });
}
getAccountType(email: string) {
return this.getRow(email).getByTestId('user-role-dropdown');
}
clickAccountType(email: string) {
return this.getRow(email).getByTestId('user-role-dropdown').click();
}
async search(email: string) {
const searchInput = this.getSearchInput();
await searchInput.click();
await searchInput.fill(email);
}
async transferData(emailOrName: string) {
await this.page
.getByRole('radio', {
name: 'Transfer their workflows, credentials and data tables to another user or project',
})
// This doesn't work without force: true
// eslint-disable-next-line playwright/no-force-option
.click({ force: true });
await this.page.getByPlaceholder('Select project or user').click();
const projectSharingInfo = this.page.getByTestId('project-sharing-info');
// Try to find by email or name (personal projects now show "Personal space" instead of email)
const byEmail = projectSharingInfo.filter({ hasText: emailOrName });
if ((await byEmail.count()) > 0) {
await byEmail.click();
} else {
// For personal projects, try matching by name part of email
const namePart = emailOrName.split('@')[0].replace(/[.-]/g, ' ');
await projectSharingInfo
.filter({ hasText: new RegExp(namePart, 'i') })
.first()
.click();
}
await this.page.getByRole('button', { name: 'Delete' }).click();
}
async deleteData() {
await this.page
.getByRole('radio', {
name: 'Delete their workflows, credentials and data tables',
})
// This doesn't work without force: true
// eslint-disable-next-line playwright/no-force-option
.check({ force: true });
await this.page.getByPlaceholder('delete all data').fill('delete all data');
await this.page.getByRole('button', { name: 'Delete' }).click();
}
async selectAccountType(email: string, type: 'Admin' | 'Member') {
await this.clickAccountType(email);
await this.page
.getByRole('listbox')
.filter({ visible: true })
.getByRole('option', { name: new RegExp(`^${type}\\b`) })
.click();
}
async openActions(email: string) {
await this.actionToggle.open(this.getRow(email));
}
async clickDeleteUser(email: string) {
await this.openActions(email);
await this.actionToggle.getAction('delete').filter({ visible: true }).click();
}
}