Fix race conditions in Cypress tests (sigh).
This commit is contained in:
parent
1164afac5e
commit
acca61f2ca
1 changed files with 16 additions and 14 deletions
|
@ -27,8 +27,9 @@ describe('Campaigns', () => {
|
|||
|
||||
cy.get('a[data-cy=btn-attach]').click();
|
||||
cy.get('input[type=file]').attachFile('example.json');
|
||||
cy.get('.modal button.is-primary').click();
|
||||
cy.get('.modal .thumb a.link').click();
|
||||
cy.get('.modal button.is-primary:eq(0)').click();
|
||||
cy.wait(500);
|
||||
cy.get('.modal td[data-label=Name] a.link').click();
|
||||
cy.get('button[data-cy=btn-save]').click();
|
||||
cy.wait(500);
|
||||
|
||||
|
@ -40,7 +41,7 @@ describe('Campaigns', () => {
|
|||
|
||||
// Start.
|
||||
cy.get('button[data-cy=btn-start]').click();
|
||||
cy.get('.modal button.is-primary').click();
|
||||
cy.get('.modal button.is-primary:eq(0)').click();
|
||||
cy.wait(500);
|
||||
cy.get('tbody tr').eq(0).get('td[data-label=Status] .tag.running');
|
||||
});
|
||||
|
@ -81,7 +82,7 @@ describe('Campaigns', () => {
|
|||
|
||||
// Switch format to plain text.
|
||||
cy.get('label[data-cy=check-plain]').click();
|
||||
cy.get('.modal button.is-primary').click();
|
||||
cy.get('.modal button.is-primary:eq(0)').click();
|
||||
|
||||
// Enter body value.
|
||||
cy.get('textarea[name=content]').clear().type('new-content');
|
||||
|
@ -89,7 +90,7 @@ describe('Campaigns', () => {
|
|||
|
||||
// Schedule.
|
||||
cy.get('button[data-cy=btn-schedule]').click();
|
||||
cy.get('.modal button.is-primary').click();
|
||||
cy.get('.modal button.is-primary:eq(0)').click();
|
||||
|
||||
cy.wait(250);
|
||||
|
||||
|
@ -141,11 +142,11 @@ describe('Campaigns', () => {
|
|||
|
||||
// Switch format.
|
||||
cy.get(`label[data-cy=check-${c}]`).click();
|
||||
cy.get('.modal button.is-primary').click();
|
||||
cy.get('.modal button.is-primary:eq(0)').click();
|
||||
|
||||
// Check content.
|
||||
cy.get('button[data-cy=btn-preview]').click();
|
||||
cy.wait(200);
|
||||
cy.wait(500);
|
||||
cy.get("#iframe").then(($f) => {
|
||||
if (c === 'plain') {
|
||||
return;
|
||||
|
@ -164,7 +165,7 @@ describe('Campaigns', () => {
|
|||
// Clone the campaign.
|
||||
cy.get('[data-cy=btn-clone]').first().click();
|
||||
cy.get('.modal input').clear().type(`clone${n}`).click();
|
||||
cy.get('.modal button.is-primary').click();
|
||||
cy.get('.modal button.is-primary:eq(0)').click();
|
||||
cy.wait(250);
|
||||
cy.clickMenu('all-campaigns');
|
||||
cy.wait(100);
|
||||
|
@ -187,7 +188,7 @@ describe('Campaigns', () => {
|
|||
// Delete all visible lists.
|
||||
cy.get('tbody tr').each(() => {
|
||||
cy.get('tbody a[data-cy=btn-delete]').first().click();
|
||||
cy.get('.modal button.is-primary').click();
|
||||
cy.get('.modal button.is-primary:eq(0)').click();
|
||||
});
|
||||
|
||||
// Confirm deletion.
|
||||
|
@ -253,12 +254,13 @@ describe('Campaigns', () => {
|
|||
const plainBody = `hello${n} Demo Subscriber from Bengaluru`;
|
||||
const markdownBody = `**hello${n}** Demo Subscriber from Bengaluru`;
|
||||
|
||||
cy.log(`format = ${c}`)
|
||||
if (c === 'richtext') {
|
||||
cy.window().then((win) => {
|
||||
win.tinymce.editors[0].setContent(htmlBody);
|
||||
win.tinymce.editors[0].save();
|
||||
});
|
||||
cy.wait(200);
|
||||
cy.wait(500);
|
||||
} else if (c === 'html') {
|
||||
cy.get('code-flask').shadow().find('.codeflask textarea').invoke('val', htmlBody).trigger('input');
|
||||
} else if (c === 'markdown') {
|
||||
|
@ -272,7 +274,7 @@ describe('Campaigns', () => {
|
|||
|
||||
// Preview and match the body.
|
||||
cy.get('button[data-cy=btn-preview]').click();
|
||||
cy.wait(200);
|
||||
cy.wait(1000);
|
||||
cy.get("#iframe").then(($f) => {
|
||||
if (c === 'plain') {
|
||||
return;
|
||||
|
@ -284,7 +286,7 @@ describe('Campaigns', () => {
|
|||
cy.get('.modal-card-foot button').click();
|
||||
|
||||
cy.clickMenu('all-campaigns');
|
||||
cy.wait(250);
|
||||
cy.wait(500);
|
||||
|
||||
// Verify the newly created campaign in the table.
|
||||
cy.get('tbody td[data-label="Name"]').first().contains(`name${n}`);
|
||||
|
@ -316,13 +318,13 @@ describe('Campaigns', () => {
|
|||
it('Starts and cancels campaigns', () => {
|
||||
for (let n = 1; n <= 2; n++) {
|
||||
cy.get(`tbody tr:nth-child(${n}) [data-cy=btn-start]`).click();
|
||||
cy.get('.modal button.is-primary').click();
|
||||
cy.get('.modal button.is-primary:eq(0)').click();
|
||||
cy.wait(250);
|
||||
cy.get(`tbody tr:nth-child(${n}) td[data-label=Status] .tag.running`);
|
||||
|
||||
if (n > 1) {
|
||||
cy.get(`tbody tr:nth-child(${n}) [data-cy=btn-cancel]`).click();
|
||||
cy.get('.modal button.is-primary').click();
|
||||
cy.get('.modal button.is-primary:eq(0)').click();
|
||||
cy.wait(250);
|
||||
cy.get(`tbody tr:nth-child(${n}) td[data-label=Status] .tag.cancelled`);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue