test: Credential test migration part 1 (#19420)

This commit is contained in:
Declan Carroll
2025-09-12 12:32:04 +01:00
committed by GitHub
parent 752436d1e4
commit 1a1c07d6eb
18 changed files with 740 additions and 499 deletions

View File

@@ -0,0 +1,53 @@
import type { CreateCredentialDto } from '@n8n/api-types';
import type { n8nPage } from '../pages/n8nPage';
export class CredentialsComposer {
constructor(private readonly n8n: n8nPage) {}
/**
* Create a credential through the Credentials list UI.
* Expects the visible label of the credential type (e.g. 'Notion API').
*/
async createFromList(
credentialType: string,
fields: Record<string, string>,
options?: { name?: string; projectId?: string; closeDialog?: boolean },
) {
if (options?.projectId) {
await this.n8n.navigate.toCredentials(options.projectId);
} else {
await this.n8n.navigate.toCredentials();
}
// Open the "new credential" chooser: open add resource -> credential
await this.n8n.credentials.addResourceButton.click();
await this.n8n.credentials.actionCredentialButton.click();
await this.n8n.credentials.createCredentialFromCredentialPicker(credentialType, fields, {
name: options?.name,
closeDialog: options?.closeDialog,
});
}
/**
* Create a credential through the NDV flow.
* Type is implied by the open node's credential requirement.
*/
async createFromNdv(
fields: Record<string, string>,
options?: { name?: string; closeDialog?: boolean },
) {
await this.n8n.ndv.clickCreateNewCredential();
await this.n8n.canvas.credentialModal.addCredential(fields, {
name: options?.name,
closeDialog: options?.closeDialog,
});
}
/**
* Create a credential directly via API. Returns created credential object.
*/
async createFromApi(payload: CreateCredentialDto & { projectId?: string }) {
return await this.n8n.api.credentialApi.createCredential(payload);
}
}