n8n/packages/testing/playwright/pages/components/AddResource.ts
n8n-cat-bot[bot] 37bc8230d8
chore: Adopt ActionToggle component across page objects (#32933)
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-25 08:10:22 +00:00

49 lines
1.4 KiB
TypeScript

import type { Locator, Page } from '@playwright/test';
import { ActionToggle } from './ActionToggle';
/**
* AddResource component for creating workflows, credentials, folders, and data tables.
* Represents the "add resource" functionality in the project header.
*
* @example
* // Access via workflows page
* await n8n.workflows.addResource.workflow();
* await n8n.workflows.addResource.credential();
* await n8n.workflows.addResource.folder();
* await n8n.workflows.addResource.dataTable();
*/
export class AddResource {
private readonly actionToggle: ActionToggle;
constructor(private page: Page) {
this.actionToggle = new ActionToggle(this.page);
}
getWorkflowButton(): Locator {
return this.page.getByTestId('add-resource-workflow');
}
async workflow(): Promise<void> {
await this.getWorkflowButton().click();
}
async credential(): Promise<void> {
await this.page.getByTestId('add-resource-credential').click();
}
async folder(): Promise<void> {
await this.page.getByTestId('add-resource').click();
await this.actionToggle.getAction('folder').click();
}
async dataTable(fromDataTableTab: boolean = true): Promise<void> {
if (fromDataTableTab) {
await this.page.getByTestId('add-resource-dataTable').click();
} else {
await this.page.getByTestId('add-resource').click();
await this.actionToggle.getAction('dataTable').click();
}
}
}