Fix Cypress tests (settings security tab, new default tpls).

This commit is contained in:
Kailash Nadh 2023-03-19 22:58:11 +05:30
parent 3646e6d20a
commit 1bb9123333
3 changed files with 34 additions and 39 deletions

View file

@ -7,7 +7,7 @@ describe('Bounces', () => {
cy.resetDB(); cy.resetDB();
cy.loginAndVisit('/settings'); cy.loginAndVisit('/settings');
cy.get('.b-tabs nav a').eq(5).click(); cy.get('.b-tabs nav a').eq(6).click();
cy.get('[data-cy=btn-enable-bounce] .switch').click(); cy.get('[data-cy=btn-enable-bounce] .switch').click();
cy.get('[data-cy=btn-enable-bounce-webhook] .switch').click(); cy.get('[data-cy=btn-enable-bounce-webhook] .switch').click();
cy.get('[data-cy=btn-bounce-count] .plus').click(); cy.get('[data-cy=btn-bounce-count] .plus').click();

View file

@ -19,7 +19,7 @@ describe('Templates', () => {
.click(); .click();
// Enable / disable SMTP and delete one. // Enable / disable SMTP and delete one.
cy.get('.b-tabs nav a').eq(4).click(); cy.get('.b-tabs nav a').eq(5).click();
cy.get('.tab-item:visible [data-cy=btn-enable-smtp]').eq(1).click(); cy.get('.tab-item:visible [data-cy=btn-enable-smtp]').eq(1).click();
cy.get('.tab-item:visible [data-cy=btn-delete-smtp]').first().click(); cy.get('.tab-item:visible [data-cy=btn-delete-smtp]').first().click();
cy.get('.modal button.is-primary').click(); cy.get('.modal button.is-primary').click();

View file

@ -6,27 +6,30 @@ describe('Templates', () => {
it('Counts default templates', () => { it('Counts default templates', () => {
cy.get('tbody td[data-label=Name]').should('have.length', 2); cy.get('tbody td[data-label=Name]').should('have.length', 3);
}); });
it('Clones campaign template', () => { it('Clones campaign template', () => {
cy.get('[data-cy=btn-clone]').first().click(); cy.get('[data-cy=btn-clone]').first().click();
cy.get('.modal input').clear().type('cloned').click(); cy.get('.modal input').clear().type('cloned campaign').click();
cy.get('.modal button.is-primary').click(); cy.get('.modal button.is-primary').click();
cy.wait(250); cy.wait(250);
// Verify the newly created row. // Verify the newly created row.
cy.get('tbody td[data-label="Name"]').eq(2).contains('cloned'); cy.get('tbody td[data-label="Name"]').contains('td', 'cloned campaign');
}); });
it('Clones tx template', () => { it('Clones tx template', () => {
cy.get('tbody tr:nth-child(2) [data-cy=btn-clone]').click(); cy.get('tbody td[data-label="Name"]').contains('td', 'Sample transactional template').then((el) => {
cy.get('.modal input').clear().type('cloned').click(); cy.wrap(el).parent().find('[data-cy=btn-clone]').click();
cy.get('.modal button.is-primary').click(); cy.get('.modal input').clear().type('cloned tx').click();
cy.wait(250); cy.get('.modal button.is-primary').click();
cy.wait(250);
});
// Verify the newly created row. // Verify the newly created row.
cy.get('tbody td[data-label="Name"]').eq(3).contains('cloned'); cy.get('tbody td[data-label="Name"]').contains('td', 'cloned tx');
}); });
it('Edits template', () => { it('Edits template', () => {
@ -52,7 +55,7 @@ describe('Templates', () => {
cy.get('.modal-card-foot button').click(); cy.get('.modal-card-foot button').click();
// Cloned one should have the full template. // Cloned one should have the full template.
cy.get('tbody [data-cy=btn-preview').eq(2).click(); cy.get('tbody [data-cy=btn-preview').eq(3).click();
cy.wait(500); cy.wait(500);
cy.get('.modal-card-body iframe').iframe(() => { cy.get('.modal-card-body iframe').iframe(() => {
cy.get('.wrap p').first().contains('Hi there'); cy.get('.wrap p').first().contains('Hi there');
@ -62,48 +65,40 @@ describe('Templates', () => {
}); });
it('Previews tx templates', () => { it('Previews tx templates', () => {
// Edited one sould have a bare body. cy.get('tbody td[data-label="Name"]').contains('td', 'cloned tx').then((el) => {
cy.get('tbody tr:nth-child(2) [data-cy=btn-preview').click(); cy.wrap(el).parent().find('[data-cy=btn-preview]').click();
cy.wait(500); cy.wait(500);
cy.get('.modal-card-body iframe').iframe(() => { cy.get('.modal-card-body iframe').iframe(() => {
cy.get('strong').first().contains('Order number'); cy.get('strong').first().contains('Order number');
});
cy.get('.modal-card-foot button').click();
}); });
cy.get('.modal-card-foot button').click();
// Cloned one should have the full template.
cy.get('tbody tr:nth-child(4) [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();
}); });
it('Sets default', () => { it('Sets default', () => {
cy.get('tbody td.actions').eq(2).find('[data-cy=btn-set-default]').click(); cy.get('tbody td[data-label="Name"]').contains('td', 'cloned campaign').then((el) => {
cy.get('.modal button.is-primary').click(); cy.wrap(el).parent().find('[data-cy=btn-set-default]').click();
cy.get('.modal button.is-primary').click();
});
// The original default shouldn't have default and the new one should have. // The original default shouldn't have default and the new one should have.
cy.get('tbody td.actions').eq(0).then((el) => { cy.get('tbody').contains('td', 'edited').parent().find('[data-cy=btn-delete]').should('exist');
cy.wrap(el).find('[data-cy=btn-delete]').should('exist'); cy.get('tbody').contains('td', 'cloned campaign').parent().find('[data-cy=btn-delete]').should('not.exist');
cy.wrap(el).find('[data-cy=btn-set-default]').should('exist');
});
cy.get('tbody td.actions').eq(2).then((el) => {
cy.wrap(el).find('[data-cy=btn-delete]').should('not.exist');
cy.wrap(el).find('[data-cy=btn-set-default]').should('not.exist');
});
}); });
it('Deletes template', () => { it('Deletes template', () => {
cy.wait(250); cy.wait(250);
[1, 1, 2].forEach((n) => { ['Default archive template', 'Sample transactional template'].forEach((t) => {
cy.get(`tbody tr:nth-child(${n}) td.actions [data-cy=btn-delete]`).click(); cy.get('tbody td[data-label="Name"]').contains('td', t).then((el) => {
cy.get('.modal button.is-primary').click(); cy.wrap(el).parent().find('[data-cy=btn-delete]').click();
cy.get('.modal button.is-primary').click();
});
cy.wait(250); cy.wait(250);
}) })
cy.get('tbody td.actions').should('have.length', 1); cy.get('tbody td.actions').should('have.length', 3);
}); });
}); });