n8n/packages/testing/playwright/composables/NodeDetailsViewComposer.ts
Declan Carroll 65b878221a
test: Resolve 45 janitor violations and update baseline (no-changelog) (#28161)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 10:34:00 +00:00

67 lines
2.2 KiB
TypeScript

import type { n8nPage } from '../pages/n8nPage';
/**
* A class for user interactions with Node Details View (NDV) that involve multi-step workflows.
*/
export class NodeDetailsViewComposer {
constructor(private readonly n8n: n8nPage) {}
/**
* Selects a workflow from the resource locator list by name
* @param paramName - The parameter name for the resource locator
* @param workflowName - The name of the workflow to select
*/
async selectWorkflowFromList(paramName: string, workflowName: string): Promise<void> {
await this.n8n.ndv.openResourceLocator(paramName);
const items = this.n8n.ndv.getResourceLocatorItems();
const targetItem = items.filter({ hasText: workflowName });
await targetItem.first().click();
}
/**
* Filters the resource locator list by search term
* @param paramName - The parameter name for the resource locator
* @param searchTerm - The term to search for
*/
async filterWorkflowList(paramName: string, searchTerm: string): Promise<void> {
await this.n8n.ndv.openResourceLocator(paramName);
await this.n8n.ndv.getResourceLocatorSearch(paramName).fill(searchTerm);
}
/**
* Selects the first workflow item from a filtered list
*/
async selectFirstFilteredWorkflow(): Promise<void> {
const items = this.n8n.ndv.getResourceLocatorItems();
await items.first().click();
}
/**
* Switches a resource locator to expression mode
* @param paramName - The parameter name for the resource locator
* @param workflowName - The workflow to select before switching to expression mode
*/
async switchToExpressionMode(paramName: string, workflowName?: string): Promise<void> {
if (workflowName) {
await this.selectWorkflowFromList(paramName, workflowName);
}
// Switch to expression mode
await this.n8n.ndv.getExpressionModeToggle().click();
}
/**
* Clicks add resource option to create a new sub-workflow
* @param paramName - The parameter name for the resource locator
*/
async createNewSubworkflow(paramName: string): Promise<void> {
await this.n8n.ndv.openResourceLocator(paramName);
const addResourceItem = this.n8n.ndv.getAddResourceItem().first();
await addResourceItem.waitFor({ state: 'visible' });
await addResourceItem.click();
}
}