Skip to content

Commit

Permalink
chore: update tests and round values when comparing
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi-siddique committed Oct 11, 2024
1 parent 99e28ee commit 2383e3a
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 17 deletions.
53 changes: 45 additions & 8 deletions test/e2e/specs/liquidation-reconstitution.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
webWalletURL,
webWalletSelectors,
tokens,
extractNumber,
} from '../test.utils';

describe('Wallet App Test Cases', () => {
Expand Down Expand Up @@ -483,9 +484,15 @@ describe('Wallet App Test Cases', () => {
);
});
} else {
const propertyName = 'book0.startPrice';
const propertyName = 'startPrice';
const expectedValue = '9.99 IST/ATOM';
cy.verifyAuctionData(propertyName, expectedValue);
cy.task('info', `Expected Value: ${expectedValue}`);
cy.getAuctionParam(propertyName).then(value => {
const actualValue = extractNumber(value);
const expectedValueRounded = extractNumber(expectedValue);

expect(actualValue).to.eq(expectedValueRounded);
});
}
});

Expand All @@ -505,9 +512,21 @@ describe('Wallet App Test Cases', () => {
);
});
} else {
const propertyName = 'book0.startProceedsGoal';
const propertyName = 'startProceedsGoal';
const expectedValue = '309.54 IST';
cy.verifyAuctionData(propertyName, expectedValue);
cy.task('info', `Expected Value: ${expectedValue}`);
cy.getAuctionParam(propertyName).then(value => {
cy.task(
'info',
'Comparing actual and expected values rounded to one decimal place.',
);

const actualValue = Math.round(extractNumber(value) * 10) / 10;
const expectedValueRounded =
Math.round(extractNumber(expectedValue) * 10) / 10;

expect(actualValue).to.eq(expectedValueRounded);
});
}
});

Expand All @@ -527,9 +546,15 @@ describe('Wallet App Test Cases', () => {
);
});
} else {
const propertyName = 'book0.startCollateral';
const propertyName = 'startCollateral';
const expectedValue = '45 ATOM';
cy.verifyAuctionData(propertyName, expectedValue);
cy.task('info', `Expected Value: ${expectedValue}`);
cy.getAuctionParam(propertyName).then(value => {
const actualValue = extractNumber(value);
const expectedValueRounded = extractNumber(expectedValue);

expect(actualValue).to.eq(expectedValueRounded);
});
}
});
});
Expand Down Expand Up @@ -576,9 +601,21 @@ describe('Wallet App Test Cases', () => {
);
});
} else {
const propertyName = 'book0.collateralAvailable';
const propertyName = 'collateralAvailable';
const expectedValue = '31.414987 ATOM';
cy.verifyAuctionData(propertyName, expectedValue); // eslint-disable-line cypress/no-unnecessary-waiting
cy.task('info', `Expected Value: ${expectedValue}`);
cy.getAuctionParam(propertyName).then(value => {
cy.task(
'info',
'Comparing actual and expected values rounded to one decimal place.',
);

const actualValue = Math.round(extractNumber(value) * 10) / 10;
const expectedValueRounded =
Math.round(extractNumber(expectedValue) * 10) / 10;

expect(actualValue).to.eq(expectedValueRounded);
});
}
});
},
Expand Down
53 changes: 45 additions & 8 deletions test/e2e/specs/liquidation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
QUICK_WAIT,
THIRTY_SECONDS,
tokens,
extractNumber,
} from '../test.utils';

describe('Wallet App Test Cases', () => {
Expand Down Expand Up @@ -485,9 +486,15 @@ describe('Wallet App Test Cases', () => {
);
});
} else {
const propertyName = 'book0.startPrice';
const propertyName = 'startPrice';
const expectedValue = '9.99 IST/ATOM';
cy.verifyAuctionData(propertyName, expectedValue);
cy.task('info', `Expected Value: ${expectedValue}`);
cy.getAuctionParam(propertyName).then(value => {
const actualValue = extractNumber(value);
const expectedValueRounded = extractNumber(expectedValue);

expect(actualValue).to.eq(expectedValueRounded);
});
}
});

Expand All @@ -507,9 +514,21 @@ describe('Wallet App Test Cases', () => {
);
});
} else {
const propertyName = 'book0.startProceedsGoal';
const propertyName = 'startProceedsGoal';
const expectedValue = '309.54 IST';
cy.verifyAuctionData(propertyName, expectedValue);
cy.task('info', `Expected Value: ${expectedValue}`);
cy.getAuctionParam(propertyName).then(value => {
cy.task(
'info',
'Comparing actual and expected values rounded to one decimal place.',
);

const actualValue = Math.round(extractNumber(value) * 10) / 10;
const expectedValueRounded =
Math.round(extractNumber(expectedValue) * 10) / 10;

expect(actualValue).to.eq(expectedValueRounded);
});
}
});

Expand All @@ -529,9 +548,15 @@ describe('Wallet App Test Cases', () => {
);
});
} else {
const propertyName = 'book0.startCollateral';
const propertyName = 'startCollateral';
const expectedValue = '45 ATOM';
cy.verifyAuctionData(propertyName, expectedValue);
cy.task('info', `Expected Value: ${expectedValue}`);
cy.getAuctionParam(propertyName).then(value => {
const actualValue = extractNumber(value);
const expectedValueRounded = extractNumber(expectedValue);

expect(actualValue).to.eq(expectedValueRounded);
});
}
});
});
Expand Down Expand Up @@ -571,9 +596,21 @@ describe('Wallet App Test Cases', () => {
);
});
} else {
const propertyName = 'book0.collateralAvailable';
const propertyName = 'collateralAvailable';
const expectedValue = '9.659301 ATOM';
cy.verifyAuctionData(propertyName, expectedValue); // eslint-disable-line cypress/no-unnecessary-waiting
cy.task('info', `Expected Value: ${expectedValue}`);
cy.getAuctionParam(propertyName).then(value => {
cy.task(
'info',
'Comparing actual and expected values rounded to one decimal place.',
);

const actualValue = Math.round(extractNumber(value) * 10) / 10;
const expectedValueRounded =
Math.round(extractNumber(expectedValue) * 10) / 10;

expect(actualValue).to.eq(expectedValueRounded);
});
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const balanceUrl =
: 'http://localhost:1317/cosmos/bank/v1beta1/balances/';
const COMMAND_TIMEOUT = configMap[network].COMMAND_TIMEOUT;

const agops = 'agops';
const agops = '/usr/src/agoric-sdk/packages/agoric-cli/bin/agops';

Cypress.Commands.add('addKeys', params => {
const { keyName, mnemonic, expectedAddress } = params;
Expand Down

0 comments on commit 2383e3a

Please sign in to comment.