Skip to content

Commit

Permalink
Added requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cmerloglb committed Jun 21, 2022
1 parent 3e8bcbf commit b8d350f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 38 deletions.
22 changes: 18 additions & 4 deletions packages/yoroi-extension/features/connector-get-collateral.feature
Expand Up @@ -46,12 +46,26 @@ Feature: dApp connector get collateral
Then The popup window should be closed
And The access request should succeed
And The wallet shelley-simple-15-2 is connected to the website localhost
Then The dApp should see collateral: {"utxo_id":"3677e75c7ba699bfdc6cd57d42f246f86f63aefd76025006ac78313fad2bba211","tx_hash":"3677e75c7ba699bfdc6cd57d42f246f86f63aefd76025006ac78313fad2bba21","tx_index":1,"receiver":"addr1qyv7qlaucathxkwkc503ujw0rv9lfj2rkj96feyst2rs9ey4tr5knj4fu4adelzqhxg8adu5xca4jra0gtllfrpcawyqzajfkn","amount":"5500000","assets":[]} for 490000
Then I ask to get Collateral for 4900000 Utxos
Then I ask to get Collateral for 200000 Utxos
Then I should see the connector popup to Add Collateral
And I should see the collateral fee data:
And I should see the transaction amount data:
| fee |
| 0.194453 |
And I should see the collateral addresses info:
| fromAddress | fromAddressAmount | toAddress | toAddressAmount |
| addr_...xy8em | -500 | addr1...x8evw | 3 |
| addr_...xy8em | -500 | addr1...x8evw | 3 |

@dApp-1024
Scenario: dApp, authorized wallet, get collateral, connector popup
Given There is a Shelley wallet stored named shelley-simple-15
Then Revamp. I switch to revamp version
Then I open the mock dApp tab
And I request access to Yoroi
Then I should see the connector popup for connection
And I select the only wallet named shelley-simple-15 with 5.5 balance
Then I enter the spending password asdfasdfasdf and click confirm
Then The popup window should be closed
And The access request should succeed
And The wallet shelley-simple-15 is connected to the website localhost
Then I ask to get Collateral for 2000000 Utxos
Then I should see the connector popup to Add Collateral
Expand Up @@ -6,27 +6,3 @@ export const addCollateralTitle: LocatorObject = {
locator: '//h5[contains(text(), "Add Collateral")]',
method: 'xpath',
};

export const transactionFeeTitle: LocatorObject = {
locator: '//p[contains(text(), "Transaction Fee")]',
method: 'xpath',
};

export const totalAmountTitle: LocatorObject = {
locator: '//p[contains(text(), "Total Amount")]',
method: 'xpath',
};

export const getCollateralFee = async (customWorld: Object): Promise<string> => {
const titleElement = await customWorld.findElement(transactionFeeTitle);
const parentElement = await titleElement.findElement(By.xpath('./..'));
const amountFieldElement = (await parentElement.findElements(By.xpath('./p')))[1];
return (await amountFieldElement.getText()).split(' ')[0];
};

export const getCollateralTotalAmount = async (customWorld: Object): Promise<string> => {
const titleElement = await customWorld.findElement(totalAmountTitle);
const parentElement = await titleElement.findElement(By.xpath('./..'));
const amountFieldElement = await parentElement.findElements(By.xpath('./h3'));
return (await amountFieldElement.getText()).split(' ')[0];
};
Expand Up @@ -344,16 +344,6 @@ Then(/^I should see the connector popup to Add Collateral$/, async function () {
await this.waitForElement(addCollateralTitle);
});

Then(/^I should see the collateral fee data:$/, async function (table) {
await this.waitForElement(overviewTabButton);
const fields = table.hashes()[0];
const realFee = await getCollateralFee(this);
const expectedFee = `-${fields.fee}`;
const realFullAmount = await getCollateralTotalAmount(this);
expect(realFee, 'Fee is different').to.equal(expectedFee);
expect(realFullAmount, 'Total amount is different').to.equal(expectedFee);
});

Then(/^I should see the collateral addresses info:$/, async function (table) {
await this.waitForElement(overviewTabButton);
const tableHashes = table.hashes();
Expand Down

0 comments on commit b8d350f

Please sign in to comment.