test: Add e2e tests for cred setup on workflow editor (no-changelog) (#8245)

## Summary

Follow-up to https://github.com/n8n-io/n8n/pull/8240

Adds e2e tests for the template credential setup in workflow editor


## Related tickets and issues

https://linear.app/n8n/issue/ADO-1463/feature-enable-users-to-close-and-re-open-the-setup
This commit is contained in:
Tomi Turtiainen
2024-01-08 11:35:18 +02:00
committed by GitHub
parent 3cf6704dbb
commit 008fd5a917
9 changed files with 144 additions and 42 deletions

View File

@@ -1,4 +1,5 @@
import { CredentialsModal, MessageBox } from './modals';
import * as formStep from '../composables/setup-template-form-step';
export type TemplateTestData = {
id: number;
@@ -24,17 +25,6 @@ export const getters = {
skipLink: () => cy.get('a:contains("Skip")'),
title: (title: string) => cy.get(`h1:contains(${title})`),
infoCallout: () => cy.getByTestId('info-callout'),
createAppCredentialsButton: (appName: string) =>
cy.get(`button:contains("Create new ${appName} credential")`),
appCredentialSteps: () => cy.getByTestId('setup-credentials-form-step'),
stepHeading: ($el: JQuery<HTMLElement>) =>
cy.wrap($el).findChildByTestId('credential-step-heading'),
stepDescription: ($el: JQuery<HTMLElement>) =>
cy.wrap($el).findChildByTestId('credential-step-description'),
};
export const visitTemplateCredentialSetupPage = (templateId: number) => {
cy.visit(`/templates/${templateId}/setup`);
};
export const enableTemplateCredentialSetupFeatureFlag = () => {
@@ -43,11 +33,17 @@ export const enableTemplateCredentialSetupFeatureFlag = () => {
});
};
export const visitTemplateCredentialSetupPage = (templateId: number) => {
cy.visit(`/templates/${templateId}/setup`);
formStep.getFormStep().eq(0).should('be.visible');
enableTemplateCredentialSetupFeatureFlag();
};
/**
* Fills in dummy credentials for the given app name.
*/
export const fillInDummyCredentialsForApp = (appName: string) => {
getters.createAppCredentialsButton(appName).click();
formStep.getCreateAppCredentialsButton(appName).click();
credentialsModal.getters.editCredentialModal().find('input:first()').type('test');
credentialsModal.actions.save(false);
credentialsModal.actions.close();
@@ -62,3 +58,13 @@ export const fillInDummyCredentialsForAppWithConfirm = (appName: string) => {
fillInDummyCredentialsForApp(appName);
messageBox.actions.cancel();
};
/**
* Finishes the credential setup by clicking the continue button.
*/
export const finishCredentialSetup = () => {
cy.intercept('POST', '/rest/workflows').as('createWorkflow');
getters.continueButton().should('be.enabled');
getters.continueButton().click();
cy.wait('@createWorkflow');
};