From 8903562629bfc83797c45274f73600039a450410 Mon Sep 17 00:00:00 2001 From: andreiklimenok Date: Wed, 7 Nov 2018 11:05:56 +0100 Subject: [PATCH 1/3] :white_check_mark: fix flaky tests, upgrade cypress --- package.json | 2 +- test/cypress/e2e/activity.spec.js | 2 +- test/cypress/e2e/{bookmarks.js => bookmarks.spec.js} | 0 test/cypress/e2e/delegates.spec.js | 3 +-- test/cypress/e2e/help.spec.js | 2 +- test/cypress/e2e/settings.spec.js | 2 +- test/cypress/e2e/transfer.spec.js | 3 +-- test/cypress/e2e/txDetails.spec.js | 8 ++++---- 8 files changed, 10 insertions(+), 12 deletions(-) rename test/cypress/e2e/{bookmarks.js => bookmarks.spec.js} (100%) diff --git a/package.json b/package.json index 1f3c8d6059..e6b6d6aa31 100644 --- a/package.json +++ b/package.json @@ -117,7 +117,7 @@ "cpx": "=1.5.0", "css-hot-loader": "=1.3.1", "css-loader": "0.28.7", - "cypress": "3.1.0", + "cypress": "3.1.1", "del-cli": "1.1.0", "electron": "1.8.8", "electron-builder": "19.32.2", diff --git a/test/cypress/e2e/activity.spec.js b/test/cypress/e2e/activity.spec.js index 23cf3b7e56..db8561099d 100644 --- a/test/cypress/e2e/activity.spec.js +++ b/test/cypress/e2e/activity.spec.js @@ -22,7 +22,7 @@ const ss = { /** * To remove the effect of activating the All tab back after full load */ -const waitBeforeChangeTabAfterLoading = () => cy.wait(1500); // TODO Update when #1400 is done +const waitBeforeChangeTabAfterLoading = () => cy.wait(2000); // TODO Update when #1400 is done describe('Dashboard Activity', () => { describe('Latest activity', () => { diff --git a/test/cypress/e2e/bookmarks.js b/test/cypress/e2e/bookmarks.spec.js similarity index 100% rename from test/cypress/e2e/bookmarks.js rename to test/cypress/e2e/bookmarks.spec.js diff --git a/test/cypress/e2e/delegates.spec.js b/test/cypress/e2e/delegates.spec.js index a2b6239b4f..ed97d753a8 100644 --- a/test/cypress/e2e/delegates.spec.js +++ b/test/cypress/e2e/delegates.spec.js @@ -39,8 +39,7 @@ describe('Delegates', () => { cy.addLocalStorage('settings', 'advancedMode', true); cy.autologin(accounts.genesis.passphrase, networks.devnet.node); cy.visit(urls.dashboard); - cy.wait(200); // Wait for wallet sidebar button to appear - cy.get(ss.sidebarMenuDelegatesBtn).click(); + cy.get(ss.sidebarMenuDelegatesBtn).should('have.css', 'opacity', '1').click(); cy.url().should('contain', urls.delegates); cy.get(ss.confirmVotesSidebar).find(ss.nextButton); }); diff --git a/test/cypress/e2e/help.spec.js b/test/cypress/e2e/help.spec.js index 81a9d2068c..a1a03da3ce 100644 --- a/test/cypress/e2e/help.spec.js +++ b/test/cypress/e2e/help.spec.js @@ -25,7 +25,7 @@ describe('Help', () => { it('opens by sidebar button', () => { cy.autologin(accounts.genesis.passphrase, networks.devnet.node); cy.visit('/'); - cy.get(ss.sidebarMenuHelpBtn).click(); + cy.get(ss.sidebarMenuHelpBtn).should('have.css', 'opacity', '1').click(); cy.url().should('contain', 'help'); checkHelpPageLoaded(); }); diff --git a/test/cypress/e2e/settings.spec.js b/test/cypress/e2e/settings.spec.js index 49f0748997..3dddc6b1a9 100644 --- a/test/cypress/e2e/settings.spec.js +++ b/test/cypress/e2e/settings.spec.js @@ -26,7 +26,7 @@ describe('Settings', () => { it('opens by sidebar button', () => { cy.visit('/'); - cy.get(ss.sidebarMenuSettingsBtn).click(); + cy.get(ss.sidebarMenuSettingsBtn).should('have.css', 'opacity', '1').click(); cy.url().should('contain', 'setting'); checkSettingsPageLoaded(); }); diff --git a/test/cypress/e2e/transfer.spec.js b/test/cypress/e2e/transfer.spec.js index 6aeb378e80..008f4e3e5c 100644 --- a/test/cypress/e2e/transfer.spec.js +++ b/test/cypress/e2e/transfer.spec.js @@ -64,8 +64,7 @@ describe('Transfer', () => { it('Wallet page opens by sidebar button', () => { cy.autologin(accounts.genesis.passphrase, networks.devnet.node); cy.visit(urls.dashboard); - cy.wait(100); - cy.get(ss.sidebarMenuWalletBtn).click(); + cy.get(ss.sidebarMenuWalletBtn).should('have.css', 'opacity', '1').click(); cy.url().should('contain', 'wallet'); checkWalletPageLoaded(); }); diff --git a/test/cypress/e2e/txDetails.spec.js b/test/cypress/e2e/txDetails.spec.js index a430217a0a..58290bddf4 100644 --- a/test/cypress/e2e/txDetails.spec.js +++ b/test/cypress/e2e/txDetails.spec.js @@ -44,7 +44,7 @@ describe('Tx details', () => { cy.get(ss.txAmount).should('have.text', '-5'); cy.get(ss.txFee).should('have.text', '0.1'); cy.get(ss.txConfirmations).should('have.text', ''); - cy.get(ss.txId).contains(/^\d{19}/); + cy.get(ss.txId).contains(/^\d{1,20}/); cy.get(ss.txReference).should('have.text', 'test-details'); // After confirmation cy.get(ss.txDate, { timeout: txConfirmationTimeout }).contains(new Date().getFullYear()); @@ -62,7 +62,7 @@ describe('Tx details', () => { cy.get(ss.txRemovedVotes).should('not.exist'); cy.get(ss.txFee).should('have.text', '1'); cy.get(ss.txConfirmations).contains(/^\d/); - cy.get(ss.txId).contains(/^\d{19}/); + cy.get(ss.txId).contains(/^\d{1,20}/); cy.get(ss.txReference).should('have.text', '-'); }); @@ -80,7 +80,7 @@ describe('Tx details', () => { cy.get(ss.txRemovedVotes).should('not.exist'); // cy.get(ss.txFee).should('have.text', '25'); cy.get(ss.txConfirmations).contains(/^\d/); - cy.get(ss.txId).contains(/^\d{19}/); + cy.get(ss.txId).contains(/^\d{1,20}/); cy.get(ss.txReference).should('have.text', '-'); }); @@ -95,7 +95,7 @@ describe('Tx details', () => { cy.get(ss.txRemovedVotes).should('not.exist'); cy.get(ss.txFee).should('have.text', '5'); cy.get(ss.txConfirmations).contains(/^\d/); - cy.get(ss.txId).contains(/^\d{19}/); + cy.get(ss.txId).contains(/^\d{1,20}/); cy.get(ss.txReference).should('have.text', '-'); }); }); From abbaba807a24e55d68690098ea773c04ee2604d4 Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Wed, 7 Nov 2018 12:33:23 +0100 Subject: [PATCH 2/3] :bug: Fix regexps for transactionId and address --- src/utils/regex.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/regex.js b/src/utils/regex.js index 755b54df82..afbed6699c 100644 --- a/src/utils/regex.js +++ b/src/utils/regex.js @@ -1,5 +1,5 @@ export default { - address: /^\d{1,21}[L]$/, - transactionId: /^[0-9]+$/, + address: /^[1-9]\d{0,19}L$/, + transactionId: /^[1-9]\d{0,19}$/, amount: /^\d+(\.\d{1,8})?$/, }; From e6c08ccbb5116a729f66ee7f96086fed92a28128 Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Wed, 7 Nov 2018 12:33:55 +0100 Subject: [PATCH 3/3] :recycle: Use transactionId regex from const file --- test/cypress/e2e/txDetails.spec.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/cypress/e2e/txDetails.spec.js b/test/cypress/e2e/txDetails.spec.js index 58290bddf4..b5132c046d 100644 --- a/test/cypress/e2e/txDetails.spec.js +++ b/test/cypress/e2e/txDetails.spec.js @@ -1,6 +1,7 @@ import accounts from '../../constants/accounts'; import networks from '../../constants/networks'; import urls from '../../constants/urls'; +import regex from '../../../src/utils/regex'; const ss = { nextBtn: '.send-next-button', @@ -44,7 +45,7 @@ describe('Tx details', () => { cy.get(ss.txAmount).should('have.text', '-5'); cy.get(ss.txFee).should('have.text', '0.1'); cy.get(ss.txConfirmations).should('have.text', ''); - cy.get(ss.txId).contains(/^\d{1,20}/); + cy.get(ss.txId).contains(regex.transactionId); cy.get(ss.txReference).should('have.text', 'test-details'); // After confirmation cy.get(ss.txDate, { timeout: txConfirmationTimeout }).contains(new Date().getFullYear()); @@ -62,7 +63,7 @@ describe('Tx details', () => { cy.get(ss.txRemovedVotes).should('not.exist'); cy.get(ss.txFee).should('have.text', '1'); cy.get(ss.txConfirmations).contains(/^\d/); - cy.get(ss.txId).contains(/^\d{1,20}/); + cy.get(ss.txId).contains(regex.transactionId); cy.get(ss.txReference).should('have.text', '-'); }); @@ -80,7 +81,7 @@ describe('Tx details', () => { cy.get(ss.txRemovedVotes).should('not.exist'); // cy.get(ss.txFee).should('have.text', '25'); cy.get(ss.txConfirmations).contains(/^\d/); - cy.get(ss.txId).contains(/^\d{1,20}/); + cy.get(ss.txId).contains(regex.transactionId); cy.get(ss.txReference).should('have.text', '-'); }); @@ -95,7 +96,7 @@ describe('Tx details', () => { cy.get(ss.txRemovedVotes).should('not.exist'); cy.get(ss.txFee).should('have.text', '5'); cy.get(ss.txConfirmations).contains(/^\d/); - cy.get(ss.txId).contains(/^\d{1,20}/); + cy.get(ss.txId).contains(regex.transactionId); cy.get(ss.txReference).should('have.text', '-'); }); });