From c5a8ffc3f155445a929cadaf9eb59ffe451498c1 Mon Sep 17 00:00:00 2001 From: rabi-siddique Date: Wed, 28 Aug 2024 16:02:22 +0500 Subject: [PATCH] ci: resolve localhost with cypress e2e tests --- Dockerfile | 10 +- test/e2e/specs/test.spec.js | 284 +++++++++++++++++------------------ test/e2e/synpress.config.cjs | 2 + 3 files changed, 149 insertions(+), 147 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3e1ffa9..cb40d62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,11 +3,11 @@ FROM ghcr.io/agoric/agoric-sdk:latest # Add the Agoric CLI to the PATH so that 'agops' can be accessed from anywhere in the command line. ENV PATH="/usr/src/agoric-sdk/packages/agoric-cli/bin:${PATH}" -# # Recent e2e test failures for all dApps were due to inconsistent network configurations in the CI setup. -# # GitHub Actions infrastructure can resolve localhost inconsistently (IPv4 or IPv6). -# # To address this, we set NODE_OPTIONS=--dns-result-order=ipv4first to prioritize IPv4 DNS resolution. -# # For more details, see: https://github.com/cypress-io/cypress/issues/27962 -# ENV NODE_OPTIONS=--dns-result-order=ipv4first +# Recent e2e test failures for all dApps were due to inconsistent network configurations in the CI setup. +# GitHub Actions infrastructure can resolve localhost inconsistently (IPv4 or IPv6). +# To address this, we set NODE_OPTIONS=--dns-result-order=ipv4first to prioritize IPv4 DNS resolution. +# For more details, see: https://github.com/cypress-io/cypress/issues/27962 +ENV NODE_OPTIONS=--dns-result-order=ipv4first # Install necessary dependencies RUN apt-get update \ diff --git a/test/e2e/specs/test.spec.js b/test/e2e/specs/test.spec.js index 2fd2f0e..e2eb2ce 100644 --- a/test/e2e/specs/test.spec.js +++ b/test/e2e/specs/test.spec.js @@ -27,7 +27,7 @@ describe('Wallet App Test Cases', { execTimeout: DEFAULT_EXEC_TIMEOUT }, () => { }); it('should setup web wallet successfully', () => { - cy.visit('http://localhost:3000/wallet/'); + cy.visit('/wallet/'); cy.get('input[type="checkbox"]').check(); cy.contains('Proceed').click(); @@ -60,146 +60,146 @@ describe('Wallet App Test Cases', { execTimeout: DEFAULT_EXEC_TIMEOUT }, () => { .should('exist'); }); - // it('should succeed in provisioning a new wallet ', () => { - // cy.skipWhen(AGORIC_NET === 'local'); - // cy.setupWallet({ - // createNewWallet: true, - // walletName: 'newWallet', - // selectedChains: ['Agoric'], - // }); - - // cy.getWalletAddress('Agoric').then((address) => { - // // provision BLD - // cy.provisionFromFaucet(address, 'delegate'); - // // provision IST - // cy.provisionFromFaucet(address, 'client'); - // }); - - // cy.visit('/wallet/'); - // cy.get('span').contains('ATOM').should('exist'); - // cy.get('span').contains('BLD').should('exist'); - // }); - - // it('should switch to "My Wallet" successfully', () => { - // cy.skipWhen(AGORIC_NET === 'local'); - // cy.switchWallet('My Wallet').then((taskCompleted) => { - // expect(taskCompleted).to.be.true; - // }); - // }); - // it('should add keys using agd from the CLI successfully', () => { - // cy.addKeys({ - // keyName: userConfig.userKeyName, - // mnemonic: userConfig.userWalletMnemonic, - // expectedAddress: userConfig.userWalletAddress, - // }); - // }); - - // it('should create a vault minting 400 ISTs and giving 80 ATOMs as collateral', () => { - // cy.skipWhen(AGORIC_NET !== 'local'); - // cy.createVault({ - // wantMinted: 400, - // giveCollateral: 80, - // userKey: userConfig.userKeyName, - // }); - // }); - - // it( - // 'should place a bid by discount from the CLI successfully and verify IST balance', - // { - // taskTimeout: DEFAULT_TASK_TIMEOUT, - // }, - // () => { - // cy.addNewTokensFound(); - // cy.getTokenAmount('IST').then((initialTokenValue) => { - // cy.placeBidByDiscount({ - // fromAddress: userConfig.userWalletAddress, - // giveAmount: '2IST', - // discount: 5, - // }).then(() => { - // cy.getTokenAmount('IST').then((tokenValue) => { - // expect(tokenValue).to.lessThan(initialTokenValue); - // }); - // }); - // }); - // cy.wait(5000); - // }, - // ); - - // it('should view the bid from CLI', () => { - // cy.listBids(userConfig.userWalletAddress); - // }); - - // it('should see an offer placed in the previous test case', () => { - // cy.visit('/wallet/'); - - // cy.contains('Offer').should('be.visible'); - // cy.contains('Give Bid').should('be.visible'); - // cy.contains('2.00 IST').should('be.visible'); - // cy.contains('from IST').should('be.visible'); - // cy.contains('Arguments').should('be.visible'); - // }); - - // it('should cancel the bid by discount and verify IST balance', () => { - // cy.getTokenAmount('IST').then((initialTokenValue) => { - // cy.visit('/wallet/'); - // cy.contains('Exit').click(); - // cy.acceptAccess().then((taskCompleted) => { - // expect(taskCompleted).to.be.true; - // }); - // cy.contains('Accepted', { timeout: DEFAULT_TIMEOUT }).should('exist'); - // cy.getTokenAmount('IST').then((tokenValue) => { - // expect(tokenValue).to.greaterThan(initialTokenValue); - // }); - // }); - // }); - - // it( - // 'should place a bid by price from the CLI successfully and verify IST balance', - // { - // taskTimeout: DEFAULT_TASK_TIMEOUT, - // }, - // () => { - // cy.getTokenAmount('IST').then((initialTokenValue) => { - // cy.placeBidByPrice({ - // fromAddress: userConfig.userWalletAddress, - // giveAmount: '1IST', - // price: 8.55, - // }).then(() => { - // cy.getTokenAmount('IST').then((tokenValue) => { - // expect(tokenValue).to.lessThan(initialTokenValue); - // }); - // }); - // }); - // }, - // ); - - // it('should see an offer placed in the previous test case', () => { - // cy.visit('/wallet/'); - // cy.contains('Offer').should('be.visible'); - // cy.contains('Give Bid').should('be.visible'); - // cy.contains('1.00 IST').should('be.visible'); - // cy.contains('from IST').should('be.visible'); - // cy.contains('Arguments').should('be.visible'); - // }); - - // it('should cancel the bid by price and verify IST balance', () => { - // cy.getTokenAmount('IST').then((initialTokenValue) => { - // cy.visit('/wallet/'); - // cy.contains('Exit').click(); - // cy.acceptAccess().then((taskCompleted) => { - // expect(taskCompleted).to.be.true; - // }); - // cy.contains('Accepted', { timeout: DEFAULT_TIMEOUT }).should('exist'); - // cy.getTokenAmount('IST').then((tokenValue) => { - // expect(tokenValue).to.greaterThan(initialTokenValue); - // }); - // }); - // }); - - // it('should check the auction status and ensure required fields are present', () => { - // cy.checkAuctionStatus().then((success) => { - // expect(success).to.be.true; - // }); - // }); + it('should succeed in provisioning a new wallet ', () => { + cy.skipWhen(AGORIC_NET === 'local'); + cy.setupWallet({ + createNewWallet: true, + walletName: 'newWallet', + selectedChains: ['Agoric'], + }); + + cy.getWalletAddress('Agoric').then((address) => { + // provision BLD + cy.provisionFromFaucet(address, 'delegate'); + // provision IST + cy.provisionFromFaucet(address, 'client'); + }); + + cy.visit('/wallet/'); + cy.get('span').contains('ATOM').should('exist'); + cy.get('span').contains('BLD').should('exist'); + }); + + it('should switch to "My Wallet" successfully', () => { + cy.skipWhen(AGORIC_NET === 'local'); + cy.switchWallet('My Wallet').then((taskCompleted) => { + expect(taskCompleted).to.be.true; + }); + }); + it('should add keys using agd from the CLI successfully', () => { + cy.addKeys({ + keyName: userConfig.userKeyName, + mnemonic: userConfig.userWalletMnemonic, + expectedAddress: userConfig.userWalletAddress, + }); + }); + + it('should create a vault minting 400 ISTs and giving 80 ATOMs as collateral', () => { + cy.skipWhen(AGORIC_NET !== 'local'); + cy.createVault({ + wantMinted: 400, + giveCollateral: 80, + userKey: userConfig.userKeyName, + }); + }); + + it( + 'should place a bid by discount from the CLI successfully and verify IST balance', + { + taskTimeout: DEFAULT_TASK_TIMEOUT, + }, + () => { + cy.addNewTokensFound(); + cy.getTokenAmount('IST').then((initialTokenValue) => { + cy.placeBidByDiscount({ + fromAddress: userConfig.userWalletAddress, + giveAmount: '2IST', + discount: 5, + }).then(() => { + cy.getTokenAmount('IST').then((tokenValue) => { + expect(tokenValue).to.lessThan(initialTokenValue); + }); + }); + }); + cy.wait(5000); + }, + ); + + it('should view the bid from CLI', () => { + cy.listBids(userConfig.userWalletAddress); + }); + + it('should see an offer placed in the previous test case', () => { + cy.visit('/wallet/'); + + cy.contains('Offer').should('be.visible'); + cy.contains('Give Bid').should('be.visible'); + cy.contains('2.00 IST').should('be.visible'); + cy.contains('from IST').should('be.visible'); + cy.contains('Arguments').should('be.visible'); + }); + + it('should cancel the bid by discount and verify IST balance', () => { + cy.getTokenAmount('IST').then((initialTokenValue) => { + cy.visit('/wallet/'); + cy.contains('Exit').click(); + cy.acceptAccess().then((taskCompleted) => { + expect(taskCompleted).to.be.true; + }); + cy.contains('Accepted', { timeout: DEFAULT_TIMEOUT }).should('exist'); + cy.getTokenAmount('IST').then((tokenValue) => { + expect(tokenValue).to.greaterThan(initialTokenValue); + }); + }); + }); + + it( + 'should place a bid by price from the CLI successfully and verify IST balance', + { + taskTimeout: DEFAULT_TASK_TIMEOUT, + }, + () => { + cy.getTokenAmount('IST').then((initialTokenValue) => { + cy.placeBidByPrice({ + fromAddress: userConfig.userWalletAddress, + giveAmount: '1IST', + price: 8.55, + }).then(() => { + cy.getTokenAmount('IST').then((tokenValue) => { + expect(tokenValue).to.lessThan(initialTokenValue); + }); + }); + }); + }, + ); + + it('should see an offer placed in the previous test case', () => { + cy.visit('/wallet/'); + cy.contains('Offer').should('be.visible'); + cy.contains('Give Bid').should('be.visible'); + cy.contains('1.00 IST').should('be.visible'); + cy.contains('from IST').should('be.visible'); + cy.contains('Arguments').should('be.visible'); + }); + + it('should cancel the bid by price and verify IST balance', () => { + cy.getTokenAmount('IST').then((initialTokenValue) => { + cy.visit('/wallet/'); + cy.contains('Exit').click(); + cy.acceptAccess().then((taskCompleted) => { + expect(taskCompleted).to.be.true; + }); + cy.contains('Accepted', { timeout: DEFAULT_TIMEOUT }).should('exist'); + cy.getTokenAmount('IST').then((tokenValue) => { + expect(tokenValue).to.greaterThan(initialTokenValue); + }); + }); + }); + + it('should check the auction status and ensure required fields are present', () => { + cy.checkAuctionStatus().then((success) => { + expect(success).to.be.true; + }); + }); }); }); diff --git a/test/e2e/synpress.config.cjs b/test/e2e/synpress.config.cjs index 298f447..6e2c138 100644 --- a/test/e2e/synpress.config.cjs +++ b/test/e2e/synpress.config.cjs @@ -11,4 +11,6 @@ module.exports = defineConfig({ screenshotsFolder: 'test/e2e/screenshots', videosFolder: 'test/e2e/videos', }, + // See https://github.com/cypress-io/cypress/issues/18881 + hosts: { localhost: '127.0.0.1' }, });