From 0057dcbbcee54ebb786200599d834f324be2aa83 Mon Sep 17 00:00:00 2001 From: Fraz Arshad Date: Tue, 11 Jun 2024 17:08:41 +0500 Subject: [PATCH 1/2] test: updated tests to reduce flakiness for wallet setup --- tests/e2e/specs/swap-tokens.spec.js | 24 ++++-------------------- tests/e2e/support.js | 18 ++++++++++++++++++ tests/e2e/utils.js | 8 ++++++++ 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/tests/e2e/specs/swap-tokens.spec.js b/tests/e2e/specs/swap-tokens.spec.js index bd5f075..d223f97 100644 --- a/tests/e2e/specs/swap-tokens.spec.js +++ b/tests/e2e/specs/swap-tokens.spec.js @@ -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'); + }); } }); diff --git a/tests/e2e/support.js b/tests/e2e/support.js index 73d2d1f..86122a8 100644 --- a/tests/e2e/support.js +++ b/tests/e2e/support.js @@ -1 +1,19 @@ 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'); + }); +}); diff --git a/tests/e2e/utils.js b/tests/e2e/utils.js index a269518..02ed5c1 100644 --- a/tests/e2e/utils.js +++ b/tests/e2e/utils.js @@ -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', +}; From 1847df85f92c163e3a417e0ea310bc317ddf74f8 Mon Sep 17 00:00:00 2001 From: Fraz Arshad Date: Tue, 11 Jun 2024 17:19:49 +0500 Subject: [PATCH 2/2] chore: formatter run on file --- tests/e2e/support.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/e2e/support.js b/tests/e2e/support.js index 86122a8..d9eb65e 100644 --- a/tests/e2e/support.js +++ b/tests/e2e/support.js @@ -1,19 +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'); - }); -}); +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'); + }); + } +);