Skip to content

Commit f26f7c6

Browse files
committed
Refactor template tests.
1 parent bc07a45 commit f26f7c6

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

frontend/cypress/integration/templates.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,27 @@ describe('Templates', () => {
66

77

88
it('Counts default templates', () => {
9-
cy.get('tbody td[data-label=Name]').should('have.length', 1);
9+
cy.get('tbody td[data-label=Name]').should('have.length', 2);
1010
});
1111

12-
it('Clones template', () => {
13-
// Clone the campaign.
12+
it('Clones campaign template', () => {
1413
cy.get('[data-cy=btn-clone]').first().click();
1514
cy.get('.modal input').clear().type('cloned').click();
1615
cy.get('.modal button.is-primary').click();
1716
cy.wait(250);
1817

1918
// Verify the newly created row.
20-
cy.get('tbody td[data-label="Name"]').eq(1).contains('cloned');
19+
cy.get('tbody td[data-label="Name"]').eq(2).contains('cloned');
20+
});
21+
22+
it('Clones tx template', () => {
23+
cy.get('tbody tr:nth-child(2) [data-cy=btn-clone]').click();
24+
cy.get('.modal input').clear().type('cloned').click();
25+
cy.get('.modal button.is-primary').click();
26+
cy.wait(250);
27+
28+
// Verify the newly created row.
29+
cy.get('tbody td[data-label="Name"]').eq(3).contains('cloned');
2130
});
2231

2332
it('Edits template', () => {
@@ -43,7 +52,7 @@ describe('Templates', () => {
4352
cy.get('.modal-card-foot button').click();
4453

4554
// Cloned one should have the full template.
46-
cy.get('tbody [data-cy=btn-preview').eq(1).click();
55+
cy.get('tbody [data-cy=btn-preview').eq(2).click();
4756
cy.wait(500);
4857
cy.get('.modal-card-body iframe').iframe(() => {
4958
cy.get('.wrap p').first().contains('Hi there');
@@ -53,15 +62,15 @@ describe('Templates', () => {
5362
});
5463

5564
it('Sets default', () => {
56-
cy.get('tbody td.actions').eq(1).find('[data-cy=btn-set-default]').click();
65+
cy.get('tbody td.actions').eq(2).find('[data-cy=btn-set-default]').click();
5766
cy.get('.modal button.is-primary').click();
5867

5968
// The original default shouldn't have default and the new one should have.
6069
cy.get('tbody td.actions').eq(0).then((el) => {
6170
cy.wrap(el).find('[data-cy=btn-delete]').should('exist');
6271
cy.wrap(el).find('[data-cy=btn-set-default]').should('exist');
6372
});
64-
cy.get('tbody td.actions').eq(1).then((el) => {
73+
cy.get('tbody td.actions').eq(2).then((el) => {
6574
cy.wrap(el).find('[data-cy=btn-delete]').should('not.exist');
6675
cy.wrap(el).find('[data-cy=btn-set-default]').should('not.exist');
6776
});
@@ -70,9 +79,13 @@ describe('Templates', () => {
7079

7180
it('Deletes template', () => {
7281
cy.wait(250);
73-
cy.get('tbody td.actions [data-cy=btn-delete]').first().click();
74-
cy.get('.modal button.is-primary').click();
75-
cy.wait(250);
82+
83+
[1, 1, 2].forEach((n) => {
84+
cy.get(`tbody tr:nth-child(${n}) td.actions [data-cy=btn-delete]`).click();
85+
cy.get('.modal button.is-primary').click();
86+
cy.wait(250);
87+
})
88+
7689
cy.get('tbody td.actions').should('have.length', 1);
7790
});
7891
});

0 commit comments

Comments
 (0)