n8n/cypress/pages/template-workflow.ts
Iván Ovejero af3ac2db28
refactor: Set up Cypress as pnpm workspace (no-changelog) (#6049)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
2024-06-10 15:49:50 +02:00

42 lines
941 B
TypeScript

import { BasePage } from './base';
export class TemplateWorkflowPage extends BasePage {
url = '/templates';
getters = {
useTemplateButton: () => cy.get('[data-test-id="use-template-button"]'),
description: () => cy.get('[data-test-id="template-description"]'),
};
actions = {
visit: (templateId: number) => {
cy.visit(`${this.url}/${templateId}`);
},
clickUseThisWorkflowButton: () => {
this.getters.useTemplateButton().click();
},
openTemplate: (
template: {
workflow: {
id: number;
name: string;
description: string;
user: { username: string };
image: Array<{ id: number; url: string }>;
};
},
templateHost: string,
) => {
cy.intercept('GET', `${templateHost}/api/templates/workflows/${template.workflow.id}`, {
statusCode: 200,
body: template,
}).as('getTemplate');
this.actions.visit(template.workflow.id);
cy.wait('@getTemplate');
},
};
}