2021-02-20 08:19:14 +00:00
|
|
|
describe('Templates', () => {
|
|
|
|
it('Opens templates page', () => {
|
|
|
|
cy.resetDB();
|
|
|
|
cy.loginAndVisit('/campaigns/templates');
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('Counts default templates', () => {
|
2023-03-19 17:28:11 +00:00
|
|
|
cy.get('tbody td[data-label=Name]').should('have.length', 3);
|
2021-02-20 08:19:14 +00:00
|
|
|
});
|
|
|
|
|
2022-07-02 11:24:52 +00:00
|
|
|
it('Clones campaign template', () => {
|
2021-02-20 08:19:14 +00:00
|
|
|
cy.get('[data-cy=btn-clone]').first().click();
|
2023-03-19 17:28:11 +00:00
|
|
|
cy.get('.modal input').clear().type('cloned campaign').click();
|
2021-02-20 08:19:14 +00:00
|
|
|
cy.get('.modal button.is-primary').click();
|
|
|
|
cy.wait(250);
|
|
|
|
|
|
|
|
// Verify the newly created row.
|
2023-03-19 17:28:11 +00:00
|
|
|
cy.get('tbody td[data-label="Name"]').contains('td', 'cloned campaign');
|
2022-07-02 11:24:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Clones tx template', () => {
|
2023-03-19 17:28:11 +00:00
|
|
|
cy.get('tbody td[data-label="Name"]').contains('td', 'Sample transactional template').then((el) => {
|
|
|
|
cy.wrap(el).parent().find('[data-cy=btn-clone]').click();
|
|
|
|
cy.get('.modal input').clear().type('cloned tx').click();
|
|
|
|
cy.get('.modal button.is-primary').click();
|
|
|
|
cy.wait(250);
|
|
|
|
});
|
|
|
|
|
2022-07-02 11:24:52 +00:00
|
|
|
|
|
|
|
// Verify the newly created row.
|
2023-03-19 17:28:11 +00:00
|
|
|
cy.get('tbody td[data-label="Name"]').contains('td', 'cloned tx');
|
2021-02-20 08:19:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Edits template', () => {
|
|
|
|
cy.get('tbody td.actions [data-cy=btn-edit]').first().click();
|
|
|
|
cy.wait(250);
|
|
|
|
cy.get('input[name=name]').clear().type('edited');
|
2021-09-26 14:43:12 +00:00
|
|
|
cy.get('code-flask').shadow().find('.codeflask textarea').invoke('val', '<span>test</span> {{ template "content" . }}').trigger('input');
|
|
|
|
|
2021-05-16 09:56:38 +00:00
|
|
|
cy.get('.modal-card-foot button.is-primary').click();
|
2021-02-20 08:19:14 +00:00
|
|
|
cy.wait(250);
|
|
|
|
cy.get('tbody td[data-label="Name"] a').contains('edited');
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2022-07-02 12:05:31 +00:00
|
|
|
it('Previews campaign templates', () => {
|
2021-02-20 08:19:14 +00:00
|
|
|
// Edited one sould have a bare body.
|
|
|
|
cy.get('tbody [data-cy=btn-preview').eq(0).click();
|
|
|
|
cy.wait(500);
|
|
|
|
cy.get('.modal-card-body iframe').iframe(() => {
|
|
|
|
cy.get('span').first().contains('test');
|
|
|
|
cy.get('p').first().contains('Hi there');
|
|
|
|
});
|
2021-05-16 09:56:38 +00:00
|
|
|
cy.get('.modal-card-foot button').click();
|
2021-02-20 08:19:14 +00:00
|
|
|
|
|
|
|
// Cloned one should have the full template.
|
2023-03-19 17:28:11 +00:00
|
|
|
cy.get('tbody [data-cy=btn-preview').eq(3).click();
|
2021-02-20 08:19:14 +00:00
|
|
|
cy.wait(500);
|
|
|
|
cy.get('.modal-card-body iframe').iframe(() => {
|
|
|
|
cy.get('.wrap p').first().contains('Hi there');
|
|
|
|
cy.get('.footer a').first().contains('Unsubscribe');
|
|
|
|
});
|
2021-05-16 09:56:38 +00:00
|
|
|
cy.get('.modal-card-foot button').click();
|
2021-02-20 08:19:14 +00:00
|
|
|
});
|
|
|
|
|
2022-07-02 12:05:31 +00:00
|
|
|
it('Previews tx templates', () => {
|
2023-03-19 17:28:11 +00:00
|
|
|
cy.get('tbody td[data-label="Name"]').contains('td', 'cloned tx').then((el) => {
|
|
|
|
cy.wrap(el).parent().find('[data-cy=btn-preview]').click();
|
|
|
|
cy.wait(500);
|
|
|
|
cy.get('.modal-card-body iframe').iframe(() => {
|
|
|
|
cy.get('strong').first().contains('Order number');
|
|
|
|
});
|
|
|
|
cy.get('.modal-card-foot button').click();
|
2022-07-02 12:05:31 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-02-20 08:19:14 +00:00
|
|
|
it('Sets default', () => {
|
2023-03-19 17:28:11 +00:00
|
|
|
cy.get('tbody td[data-label="Name"]').contains('td', 'cloned campaign').then((el) => {
|
|
|
|
cy.wrap(el).parent().find('[data-cy=btn-set-default]').click();
|
|
|
|
cy.get('.modal button.is-primary').click();
|
2021-02-20 08:19:14 +00:00
|
|
|
|
|
|
|
});
|
2023-03-19 17:28:11 +00:00
|
|
|
|
|
|
|
// The original default shouldn't have default and the new one should have.
|
|
|
|
cy.get('tbody').contains('td', 'edited').parent().find('[data-cy=btn-delete]').should('exist');
|
|
|
|
cy.get('tbody').contains('td', 'cloned campaign').parent().find('[data-cy=btn-delete]').should('not.exist');
|
2021-02-20 08:19:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('Deletes template', () => {
|
2021-05-16 09:56:38 +00:00
|
|
|
cy.wait(250);
|
2022-07-02 11:24:52 +00:00
|
|
|
|
2023-03-19 17:28:11 +00:00
|
|
|
['Default archive template', 'Sample transactional template'].forEach((t) => {
|
|
|
|
cy.get('tbody td[data-label="Name"]').contains('td', t).then((el) => {
|
|
|
|
cy.wrap(el).parent().find('[data-cy=btn-delete]').click();
|
|
|
|
cy.get('.modal button.is-primary').click();
|
|
|
|
});
|
2022-07-02 11:24:52 +00:00
|
|
|
cy.wait(250);
|
|
|
|
})
|
|
|
|
|
2023-03-19 17:28:11 +00:00
|
|
|
cy.get('tbody td.actions').should('have.length', 3);
|
2021-02-20 08:19:14 +00:00
|
|
|
});
|
|
|
|
});
|