tokenbridge/ui/e2e-script/User.js
Przemyslaw Rzad 40fef06503
Update bridge-ui (#39)
* Renamed bridge-ui to ui, removed submodule

* Re-added submodules. Pointing at 2.2.0

* Updated workspace name.

* Removed package-lock.json.

* Updated ui contracts to 2.3.0-rc0, installed node modules.

* Added linting to ui

* Integrated UI lint, test and build into CI.

* Added readme for merging.

* Consistent eslint module

* Included plugins in dev dependencies.

* Changed eslint version.

* Add yarn.lock

* Update deprecated node api.

* Remove travis badge and config in ui

* Update link to oracle in ui dependencies.

* Remove duplicated gitter.

* Remove unimplemented coverage and dependencies badges.

* Update links in step 5 and 6 in UI

* Cosmetic.
2019-05-15 14:23:29 +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
};