tokenbridge/ui-e2e/User.js
Przemyslaw Rzad 6d1d4bce6b
Extracting UI E2E (#49)
* Commented out package-lock.json

* Moved over changes from https://github.com/poanetwork/bridge-ui/pull/217

* Brought back package-lock.json used in e2e.

* Edited postinstall to work for sub-repo npm install

* Using local oracle

* Moved ui/e2e-script to ui-e2e

* Introduced ui-e2e workspace.

* Updated paths,. removed bridge dockerfile.

* Updated e2e script after extracting.

* Introduced ui-e2e into CI

* Disabled ui-e2e

* Updated readme.
2019-05-21 09:41:52 +02:00

54 lines
1.5 KiB
JavaScript

const fs = require('fs-extra');
const MetaMask = require('./MetaMask.js').MetaMask;
const MainPage = require('./mainPage.js').MainPage;
class User {
constructor(driver, file) {
try {
this.driver = driver;
let obj = JSON.parse(fs.readFileSync(file, "utf8"));
this.account = obj.account;
this.privateKey = obj.privateKey;
this.networkID = obj.networkID;
this.accountOrderInMetamask = "undefined";//for MetaMaskPage usage only
this.name = file;
}
catch (err) {
console.log("instance User was not created");
console.log(err);
}
}
async transferTokens(amount) {
let mainPage = new MainPage(this.driver);
let metaMask = new MetaMask(this.driver);
return await mainPage.fillFieldAmount(amount) &&
await mainPage.clickButtonTransfer() &&
await mainPage.waitUntilShowUpButtonTransferConfirm() &&
await mainPage.clickButtonTransferConfirm() &&
await metaMask.signTransaction() &&
await mainPage.waitUntilTransactionDone() &&
await mainPage.waitUntilShowUpButtonOk() &&
await mainPage.clickButtonOk()
}
async setMetaMaskNetwork() {
let metaMask = new MetaMask(this.driver);
return await metaMask.switchToNextPage() &&
await metaMask.setNetwork(this.networkID) &&
await metaMask.switchToNextPage();
}
async setMetaMaskAccount() {
let metaMask = new MetaMask(this.driver);
if (this.accountOrderInMetamask === "undefined") {
return await metaMask.importAccount(this);
} else
return await metaMask.selectAccount(this);
}
}
module.exports = {
User: User
};