mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
test: Credential test migration part 1 (#19420)
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { BasePage } from './BasePage';
|
||||
import { CredentialModal } from './components/CredentialModal';
|
||||
|
||||
export class CredentialsPage extends BasePage {
|
||||
readonly credentialModal = new CredentialModal(this.page.getByTestId('editCredential-modal'));
|
||||
|
||||
get emptyListCreateCredentialButton() {
|
||||
return this.page.getByRole('button', { name: 'Add first credential' });
|
||||
}
|
||||
@@ -10,14 +13,60 @@ export class CredentialsPage extends BasePage {
|
||||
}
|
||||
|
||||
get credentialCards() {
|
||||
return this.page.getByTestId('credential-cards');
|
||||
return this.page.getByTestId('resources-list-item');
|
||||
}
|
||||
|
||||
getCredentialByName(name: string) {
|
||||
return this.credentialCards.filter({ hasText: name }).first();
|
||||
}
|
||||
|
||||
get addResourceButton() {
|
||||
return this.page.getByTestId('add-resource');
|
||||
}
|
||||
get actionCredentialButton() {
|
||||
return this.page.getByTestId('action-credential');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new credential of the specified type
|
||||
* Create a credential from the credentials list, fill fields, save, and close the modal.
|
||||
* @param credentialType - The type of credential to create (e.g. 'Notion API')
|
||||
* @param fields - Key-value pairs for credential fields to fill
|
||||
*/
|
||||
async openNewCredentialDialogFromCredentialList(credentialType: string): Promise<void> {
|
||||
async createCredentialFromCredentialPicker(
|
||||
credentialType: string,
|
||||
fields: Record<string, string>,
|
||||
options?: { closeDialog?: boolean; name?: string },
|
||||
): Promise<void> {
|
||||
await this.page.getByRole('combobox', { name: 'Search for app...' }).fill(credentialType);
|
||||
await this.page
|
||||
.getByTestId('new-credential-type-select-option')
|
||||
.filter({ hasText: credentialType })
|
||||
.click();
|
||||
await this.page.getByTestId('new-credential-type-button').click();
|
||||
await this.credentialModal.addCredential(fields, {
|
||||
name: options?.name,
|
||||
closeDialog: options?.closeDialog,
|
||||
});
|
||||
}
|
||||
|
||||
async clearSearch() {
|
||||
await this.page.getByTestId('resources-list-search').clear();
|
||||
}
|
||||
|
||||
async sortByNameDescending() {
|
||||
await this.page.getByTestId('resources-list-sort').click();
|
||||
await this.page.getByText('Name (Z-A)').click();
|
||||
}
|
||||
|
||||
async sortByNameAscending() {
|
||||
await this.page.getByTestId('resources-list-sort').click();
|
||||
await this.page.getByText('Name (A-Z)').click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Select credential type without auto-saving (for tests that need to handle save manually)
|
||||
*/
|
||||
async selectCredentialType(credentialType: string): Promise<void> {
|
||||
await this.page.getByRole('combobox', { name: 'Search for app...' }).fill(credentialType);
|
||||
await this.page
|
||||
.getByTestId('new-credential-type-select-option')
|
||||
@@ -25,56 +74,4 @@ export class CredentialsPage extends BasePage {
|
||||
.click();
|
||||
await this.page.getByTestId('new-credential-type-button').click();
|
||||
}
|
||||
|
||||
async openCredentialSelector() {
|
||||
await this.page.getByRole('combobox', { name: 'Select Credential' }).click();
|
||||
}
|
||||
|
||||
async createNewCredential() {
|
||||
await this.clickByText('Create new credential');
|
||||
}
|
||||
|
||||
async fillCredentialField(fieldName: string, value: string) {
|
||||
const field = this.page
|
||||
.getByTestId(`parameter-input-${fieldName}`)
|
||||
.getByTestId('parameter-input-field');
|
||||
await field.click();
|
||||
await field.fill(value);
|
||||
}
|
||||
get saveCredentialButton() {
|
||||
return this.page.getByRole('button', { name: 'Save' });
|
||||
}
|
||||
|
||||
async saveCredential() {
|
||||
await this.clickButtonByName('Save');
|
||||
}
|
||||
|
||||
async closeCredentialDialog() {
|
||||
await this.clickButtonByName('Close this dialog');
|
||||
}
|
||||
|
||||
async createAndSaveNewCredential(fieldName: string, value: string) {
|
||||
await this.openCredentialSelector();
|
||||
await this.createNewCredential();
|
||||
await this.filLCredentialSaveClose(fieldName, value);
|
||||
}
|
||||
|
||||
async filLCredentialSaveClose(fieldName: string, value: string) {
|
||||
await this.fillCredentialField(fieldName, value);
|
||||
await this.saveCredential();
|
||||
await this.page.getByText('Connection tested successfully').waitFor({ state: 'visible' });
|
||||
await this.closeCredentialDialog();
|
||||
}
|
||||
|
||||
getOauthConnectButton() {
|
||||
return this.page.getByTestId('oauth-connect-button');
|
||||
}
|
||||
|
||||
getOauthConnectSuccessBanner() {
|
||||
return this.page.getByTestId('oauth-connect-success-banner');
|
||||
}
|
||||
|
||||
getSaveButton() {
|
||||
return this.page.getByTestId('credential-save-button');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user