Skip to content

Commit

Permalink
✅ Make cypress wait for request to finish before asserting
Browse files Browse the repository at this point in the history
  • Loading branch information
massao committed Apr 8, 2019
1 parent dd92822 commit 43afbdd
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions test/cypress/e2e/wallet.spec.js
Expand Up @@ -68,13 +68,18 @@ describe('Wallet', () => {
address: '2581762640681118072L',
username: 'genesis_51',
};

beforeEach(() => {
cy.server();
cy.route('/api/accounts?address=**').as('requestAccountData');
});

it('Delegate -> Address, Name & Label are correct', () => {
cy.autologin(accounts.genesis.passphrase, networks.devnet.node);
cy.visit(`${urls.accounts}/${topDelegate.address}`);
cy.wait(1);
cy.url().should('contain', topDelegate.address);
cy.get(ss.accountAddress).contains(topDelegate.address);
cy.get(ss.accountName).contains(topDelegate.username);
// cy.get(ss.accountName).contains(topDelegate.username);
cy.get(ss.accountLabel).contains('Delegate #1');
});

Expand All @@ -100,21 +105,19 @@ describe('Wallet', () => {
cy.get(ss.accountLabel).contains('Followed Account');
});

// TODO Unskip after fix 1900
it('Send LSK to this account', () => {
cy.autologin(accounts.genesis.passphrase, networks.devnet.node);
cy.visit(`${urls.accounts}/${accounts.delegate.address}`);
cy.wait(1);
cy.wait('@requestAccountData');
cy.get(ss.sendToThisAccountBtn).click();
cy.url().should('contain', urls.send);
cy.get(ss.recipientInput).should('have.value', accounts.delegate.address);
});

// TODO Unskip after fix 1900
it('Add / Remove bookmark', () => {
cy.autologin(accounts.genesis.passphrase, networks.devnet.node);
cy.visit(`${urls.accounts}/${accounts.genesis.address}`);
cy.wait(1);
cy.wait('@requestAccountData');
cy.get(ss.followAccountBtn).contains('Bookmark account');
cy.get(ss.followAccountBtn).click();
cy.get(ss.titleInput).type('Bob');
Expand All @@ -123,10 +126,11 @@ describe('Wallet', () => {
expect(getFollowedAccountObjFromLS()[0].address).to.equal(accounts.genesis.address);
expect(getFollowedAccountObjFromLS()[0].title).to.equal('Bob');
});
cy.route('/api/delegates?**').as('requestDelegatesData');
cy.reload();
cy.wait('@requestDelegatesData');
cy.get(ss.accountName).contains('Bob');
cy.get(ss.followAccountBtn).contains('Account bookmarked');
cy.wait(1);
cy.get(ss.followAccountBtn).click();
cy.get(ss.confirmAddToBookmarks).click()
.should(() => {
Expand All @@ -135,11 +139,10 @@ describe('Wallet', () => {
cy.get(ss.accountName).contains('Account');
});

// TODO Unskip after fix 1900
it('Cant change bookmark name for bookmarked delegate', () => {
cy.autologin(accounts.genesis.passphrase, networks.devnet.node);
cy.visit(`${urls.accounts}/${accounts.delegate.address}`);
cy.wait(1);
cy.wait('@requestAccountData');
cy.get(ss.followAccountBtn).contains('Bookmark account');
cy.get(ss.followAccountBtn).click();
cy.get(ss.titleInput).type('Bob');
Expand Down Expand Up @@ -197,8 +200,11 @@ describe('Wallet', () => {
});

it('Shows delegate statistics for other', () => {
cy.server();
cy.route('/api/accounts?address=**').as('requestAccountData');
cy.autologin(accounts.genesis.passphrase, networks.devnet.node);
cy.visit(`${urls.accounts}/${accounts.delegate.address}`);
cy.wait('@requestAccountData');
cy.get(ss.delegateStatisticsTab).should('be.visible');
cy.get(ss.delegateStatisticsTab).click();
cy.get(ss.delegateStatsUptime).contains(/\d%/);
Expand Down

0 comments on commit 43afbdd

Please sign in to comment.