Skip to content

Commit

Permalink
ci: resolve localhost with cypress e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi-siddique committed Aug 28, 2024
1 parent f34e5f7 commit c5a8ffc
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 147 deletions.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
284 changes: 142 additions & 142 deletions test/e2e/specs/test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
});
});
});
});
2 changes: 2 additions & 0 deletions test/e2e/synpress.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
});

0 comments on commit c5a8ffc

Please sign in to comment.