From f26f7c60af2493173c45eab438555ab3c2f27770 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sat, 2 Jul 2022 16:54:52 +0530 Subject: [PATCH] Refactor template tests. --- frontend/cypress/integration/templates.js | 33 ++++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/frontend/cypress/integration/templates.js b/frontend/cypress/integration/templates.js index 8ad8ba06d..07d4a517b 100644 --- a/frontend/cypress/integration/templates.js +++ b/frontend/cypress/integration/templates.js @@ -6,18 +6,27 @@ describe('Templates', () => { it('Counts default templates', () => { - cy.get('tbody td[data-label=Name]').should('have.length', 1); + cy.get('tbody td[data-label=Name]').should('have.length', 2); }); - it('Clones template', () => { - // Clone the campaign. + it('Clones campaign template', () => { cy.get('[data-cy=btn-clone]').first().click(); cy.get('.modal input').clear().type('cloned').click(); cy.get('.modal button.is-primary').click(); cy.wait(250); // Verify the newly created row. - cy.get('tbody td[data-label="Name"]').eq(1).contains('cloned'); + cy.get('tbody td[data-label="Name"]').eq(2).contains('cloned'); + }); + + it('Clones tx template', () => { + cy.get('tbody tr:nth-child(2) [data-cy=btn-clone]').click(); + cy.get('.modal input').clear().type('cloned').click(); + cy.get('.modal button.is-primary').click(); + cy.wait(250); + + // Verify the newly created row. + cy.get('tbody td[data-label="Name"]').eq(3).contains('cloned'); }); it('Edits template', () => { @@ -43,7 +52,7 @@ describe('Templates', () => { cy.get('.modal-card-foot button').click(); // Cloned one should have the full template. - cy.get('tbody [data-cy=btn-preview').eq(1).click(); + cy.get('tbody [data-cy=btn-preview').eq(2).click(); cy.wait(500); cy.get('.modal-card-body iframe').iframe(() => { cy.get('.wrap p').first().contains('Hi there'); @@ -53,7 +62,7 @@ describe('Templates', () => { }); it('Sets default', () => { - cy.get('tbody td.actions').eq(1).find('[data-cy=btn-set-default]').click(); + cy.get('tbody td.actions').eq(2).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. @@ -61,7 +70,7 @@ describe('Templates', () => { cy.wrap(el).find('[data-cy=btn-delete]').should('exist'); cy.wrap(el).find('[data-cy=btn-set-default]').should('exist'); }); - cy.get('tbody td.actions').eq(1).then((el) => { + 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'); }); @@ -70,9 +79,13 @@ describe('Templates', () => { it('Deletes template', () => { cy.wait(250); - cy.get('tbody td.actions [data-cy=btn-delete]').first().click(); - cy.get('.modal button.is-primary').click(); - cy.wait(250); + + [1, 1, 2].forEach((n) => { + cy.get(`tbody tr:nth-child(${n}) td.actions [data-cy=btn-delete]`).click(); + cy.get('.modal button.is-primary').click(); + cy.wait(250); + }) + cy.get('tbody td.actions').should('have.length', 1); }); });