2023-09-25 06:49:36 -07:00
|
|
|
import { TemplatesPage } from '../pages/templates';
|
2024-02-09 04:47:43 -08:00
|
|
|
import { WorkflowsPage } from '../pages/workflows';
|
|
|
|
import { MainSidebar } from '../pages/sidebar/main-sidebar';
|
2023-09-25 06:49:36 -07:00
|
|
|
|
|
|
|
const templatesPage = new TemplatesPage();
|
2024-02-09 04:47:43 -08:00
|
|
|
const workflowsPage = new WorkflowsPage();
|
|
|
|
const mainSidebar = new MainSidebar();
|
2023-09-25 06:49:36 -07:00
|
|
|
|
2024-02-09 04:47:43 -08:00
|
|
|
describe('Workflow templates', () => {
|
2024-01-15 13:19:24 -08:00
|
|
|
beforeEach(() => {
|
2024-02-09 04:47:43 -08:00
|
|
|
cy.intercept('GET', '**/rest/settings', (req) => {
|
|
|
|
// Disable cache
|
2024-05-17 01:53:15 -07:00
|
|
|
delete req.headers['if-none-match'];
|
2024-02-09 04:47:43 -08:00
|
|
|
req.reply((res) => {
|
|
|
|
if (res.body.data) {
|
|
|
|
// Disable custom templates host if it has been overridden by another intercept
|
|
|
|
res.body.data.templates = { enabled: true, host: 'https://api.n8n.io/api/' };
|
|
|
|
}
|
2023-12-22 06:07:05 -08:00
|
|
|
});
|
2024-02-09 04:47:43 -08:00
|
|
|
}).as('settingsRequest');
|
2023-12-22 06:07:05 -08:00
|
|
|
});
|
|
|
|
|
2024-02-09 04:47:43 -08:00
|
|
|
it('Opens website when clicking templates sidebar link', () => {
|
|
|
|
cy.visit(workflowsPage.url);
|
2024-05-17 01:53:15 -07:00
|
|
|
mainSidebar.getters.templates().should('be.visible');
|
2024-02-09 04:47:43 -08:00
|
|
|
// Templates should be a link to the website
|
2024-05-17 01:53:15 -07:00
|
|
|
mainSidebar.getters
|
|
|
|
.templates()
|
|
|
|
.parent('a')
|
|
|
|
.should('have.attr', 'href')
|
|
|
|
.and('include', 'https://n8n.io/workflows');
|
2024-02-21 04:09:16 -08:00
|
|
|
// Link should contain instance address and n8n version
|
2024-05-17 01:53:15 -07:00
|
|
|
mainSidebar.getters
|
|
|
|
.templates()
|
|
|
|
.parent('a')
|
|
|
|
.then(($a) => {
|
|
|
|
const href = $a.attr('href');
|
|
|
|
const params = new URLSearchParams(href);
|
|
|
|
// Link should have all mandatory parameters expected on the website
|
|
|
|
expect(decodeURIComponent(`${params.get('utm_instance')}`)).to.include(
|
|
|
|
window.location.origin,
|
|
|
|
);
|
|
|
|
expect(params.get('utm_n8n_version')).to.match(/[0-9]+\.[0-9]+\.[0-9]+/);
|
|
|
|
expect(params.get('utm_awc')).to.match(/[0-9]+/);
|
|
|
|
});
|
2024-02-09 04:47:43 -08:00
|
|
|
mainSidebar.getters.templates().parent('a').should('have.attr', 'target', '_blank');
|
2024-01-15 13:19:24 -08:00
|
|
|
});
|
|
|
|
|
2024-02-09 04:47:43 -08:00
|
|
|
it('Redirects to website when visiting templates page directly', () => {
|
2024-01-15 13:19:24 -08:00
|
|
|
cy.visit(templatesPage.url);
|
2024-02-09 04:47:43 -08:00
|
|
|
cy.origin('https://n8n.io', () => {
|
|
|
|
cy.url().should('include', 'https://n8n.io/workflows');
|
2024-05-17 01:53:15 -07:00
|
|
|
});
|
2024-01-15 13:19:24 -08:00
|
|
|
});
|
2023-09-25 06:49:36 -07:00
|
|
|
});
|