n8n/cypress/pages/templates.ts
Tomi Turtiainen ac744d6702
test: Ado 1296 add e2e tests (#7792)
Adds e2e tests for the template credential setup.
2023-11-27 17:18:10 +02:00

54 lines
1.3 KiB
TypeScript

import { BasePage } from './base';
export class TemplatesPage extends BasePage {
url = '/templates';
getters = {
useTemplateButton: () => cy.get('[data-testid="use-template-button"]'),
};
actions = {
openSingleTemplateView: (templateId: number) => {
cy.visit(`${this.url}/${templateId}`);
cy.waitForLoad();
},
openOnboardingFlow: (id: number, name: string, workflow: object) => {
const apiResponse = {
id,
name,
workflow,
};
cy.intercept('POST', '/rest/workflows').as('createWorkflow');
cy.intercept('GET', `https://api.n8n.io/api/workflows/templates/${id}`, {
statusCode: 200,
body: apiResponse,
}).as('getTemplate');
cy.intercept('GET', 'rest/workflows/**').as('getWorkflow');
cy.visit(`/workflows/onboarding/${id}`);
cy.wait('@getTemplate');
cy.wait(['@createWorkflow', '@getWorkflow']);
},
importTemplate: (id: number, name: string, workflow: object) => {
const apiResponse = {
id,
name,
workflow,
};
cy.intercept('GET', `https://api.n8n.io/api/workflows/templates/${id}`, {
statusCode: 200,
body: apiResponse,
}).as('getTemplate');
cy.intercept('GET', 'rest/workflows/**').as('getWorkflow');
cy.visit(`/workflows/templates/${id}`);
cy.wait('@getTemplate');
cy.wait('@getWorkflow');
},
};
}