2023-09-25 06:49:36 -07:00
|
|
|
import { BasePage } from './base';
|
|
|
|
|
|
|
|
export class TemplatesPage extends BasePage {
|
|
|
|
url = '/templates';
|
|
|
|
|
|
|
|
getters = {
|
2023-12-22 06:07:05 -08:00
|
|
|
useTemplateButton: () => cy.getByTestId('use-template-button'),
|
|
|
|
templateCards: () => cy.getByTestId('template-card'),
|
|
|
|
firstTemplateCard: () => this.getters.templateCards().first(),
|
2024-01-15 13:19:24 -08:00
|
|
|
allCategoriesFilter: () => cy.getByTestId('template-filter-all-categories'),
|
|
|
|
searchInput: () => cy.getByTestId('template-search-input'),
|
|
|
|
categoryFilters: () => cy.get('[data-test-id^=template-filter]'),
|
|
|
|
categoryFilter: (category: string) => cy.getByTestId(`template-filter-${category}`),
|
|
|
|
collectionCountLabel: () => cy.getByTestId('collection-count-label'),
|
|
|
|
templateCountLabel: () => cy.getByTestId('template-count-label'),
|
|
|
|
templatesLoadingContainer: () => cy.getByTestId('templates-loading-container'),
|
|
|
|
expandCategoriesButton: () => cy.getByTestId('expand-categories-button'),
|
2023-09-25 06:49:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
actions = {
|
2023-11-27 07:18:10 -08:00
|
|
|
openSingleTemplateView: (templateId: number) => {
|
|
|
|
cy.visit(`${this.url}/${templateId}`);
|
|
|
|
cy.waitForLoad();
|
|
|
|
},
|
|
|
|
|
|
|
|
openOnboardingFlow: (id: number, name: string, workflow: object) => {
|
2023-09-25 06:49:36 -07:00
|
|
|
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');
|
2023-11-27 07:18:10 -08:00
|
|
|
cy.wait('@getWorkflow');
|
|
|
|
},
|
|
|
|
};
|
2023-09-25 06:49:36 -07:00
|
|
|
}
|