n8n/packages/testing/playwright/pages/components/ResourceMoveModal.ts
n8n-cat-bot[bot] 3dfd48bc40
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
chore: Route move-to-folder option through the existing ResourceMoveModal component (#33151)
Co-authored-by: n8n-cat-bot[bot] <n8n-cat-bot[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 22:56:21 +00:00

66 lines
2.0 KiB
TypeScript

import type { Locator } from '@playwright/test';
import { FloatingUiHelper } from './FloatingUiHelper';
/**
* Page object for interacting with move resource modals (MoveToFolderModal for workflows, ProjectMoveResourceModal for credentials).
*/
export class ResourceMoveModal extends FloatingUiHelper {
getProjectSelect(): Locator {
return this.page.getByTestId('project-sharing-select');
}
getProjectSelectCredential(): Locator {
return this.page.getByTestId('project-move-resource-modal-select');
}
getMoveConfirmButton(): Locator {
return this.page.getByTestId('confirm-move-folder-button');
}
getMoveCredentialButton(): Locator {
return this.page.getByRole('button', { name: 'Move credential' });
}
getFolderSelect(): Locator {
return this.page.getByTestId('move-to-folder-dropdown');
}
getFolderOption(folderName: string): Locator {
// move-to-folder options teleport out of the modal root (el-select popper), so resolve page-scoped
return this.page.getByTestId('move-to-folder-option').filter({ hasText: folderName });
}
async openProjectSelect(): Promise<void> {
await this.getProjectSelectCredential().locator('input').click();
}
getProjectOptions(): Locator {
return this.getVisiblePopoverOption();
}
async selectProjectOption(projectNameOrEmail: string): Promise<void> {
const options = this.getVisiblePopoverOption();
// Try to find by exact text (project name or email)
const byExact = options.filter({ hasText: projectNameOrEmail });
if ((await byExact.count()) > 0) {
await byExact.click();
} else {
// For personal projects, the email is not shown, so try matching by name part of email
const namePart = projectNameOrEmail.split('@')[0].replace(/[.-]/g, ' ');
await options
.filter({ hasText: new RegExp(namePart, 'i') })
.first()
.click();
}
}
async clickMoveCredentialButton(): Promise<void> {
await this.getMoveCredentialButton().click();
}
async clickConfirmMoveButton(): Promise<void> {
await this.getMoveConfirmButton().click();
}
}