Skip to content

Commit

Permalink
Merge pull request #150 from Agoric/test/reduce-flakiness-for-wallet-…
Browse files Browse the repository at this point in the history
…setup

test: updated tests to reduce flakiness for wallet setup
  • Loading branch information
frazarshad authored Jun 11, 2024
2 parents f203655 + 1847df8 commit a82009a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
24 changes: 4 additions & 20 deletions tests/e2e/specs/swap-tokens.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,10 @@ describe('Swap Tokens Tests', () => {
selectedChains: ['Agoric'],
});

cy.getWalletAddress('Agoric').then(
address => (walletAddress.value = address)
);

// Provision IST for wallet
cy.origin(
'https://emerynet.faucet.agoric.net',
{ args: { walletAddress, DEFAULT_TIMEOUT } },
({ walletAddress, DEFAULT_TIMEOUT }) => {
cy.visit('/');
cy.get('[id="address"]').first().type(walletAddress.value);
cy.get('[type="radio"][value="client"]').click();
cy.get('[name="clientType"]').select('REMOTE_WALLET');

cy.get('[type="submit"]').first().click();
cy.get('body')
.contains('success', { timeout: DEFAULT_TIMEOUT })
.should('exist');
}
);
cy.getWalletAddress('Agoric').then(address => {
// provision IST
cy.provisionFromFaucet(address, 'client', 'REMOTE_WALLET');
});
}
});

Expand Down
21 changes: 21 additions & 0 deletions tests/e2e/support.js
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
import '@agoric/synpress/support/index';
import { FACUET_HEADERS, FACUET_URL, DEFAULT_TIMEOUT } from './utils';

Cypress.Commands.add(
'provisionFromFaucet',
(walletAddress, command, clientType) => {
cy.request({
method: 'POST',
url: FACUET_URL,
body: {
address: walletAddress,
command,
clientType,
},
headers: FACUET_HEADERS,
timeout: 4 * DEFAULT_TIMEOUT,
retryOnStatusCodeFailure: true,
}).then(resp => {
expect(resp.body).to.eq('success');
});
}
);
8 changes: 8 additions & 0 deletions tests/e2e/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@ export const phrasesList = {
isLocal: true,
},
};

export const FACUET_URL = 'https://emerynet.faucet.agoric.net/go';

export const FACUET_HEADERS = {
Accept:
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'Content-Type': 'application/x-www-form-urlencoded',
};

0 comments on commit a82009a

Please sign in to comment.