Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix path for github action running tauri-wallet-tests #884

Merged
merged 2 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tauri-wallet/webdriver/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this should be an empty config?

Also, be careful only using prettier because the root of the project has eslint (and no prettier). They will end up flip-flopping unless configured to work together. Look at https://prettier.io/docs/en/integrating-with-linters.html and use https://github.com/prettier/eslint-plugin-prettier to drive prettier.

I'm wondering if we should maybe do that work in another PR? Because it will likely mean a lot of formatting changes to the wallet JS/TS code.

73 changes: 40 additions & 33 deletions tauri-wallet/webdriver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,75 +5,82 @@ SPDX-License-Identifier: Apache-2.0

# Nym Wallet Webdriverio testsuite

A webdriverio test suite implementation using tauri driver
A webdriverio test suite implementation using tauri driver
with a page object model design. This is to provide quick iterative feedback
on the UI of the nym wallet. Currently, tauri-driver is available to run on Windows and Linux machines.

## Installation prerequisites
* `Yarn`
* `NodeJS >= v16.8.0`
* `Rust & cargo >= v1.51`
* `tauri-driver`
* `That you have an existing mnemonic and you can login to the app`
* `Have the details listed below to provide the user-data.json file`
## Installation prerequisites

- `Yarn`
- `NodeJS >= v16.8.0`
- `Rust & cargo >= v1.56.1`
- `tauri-driver`
- `That you have an existing mnemonic and you can login to the app`
- `Have the details listed below to provide the user-data.json file`

## Key Information
* Please read the instructions on the `nym/tauri-wallet/README.md` in the root of the project on how to build the application
* Please ensure you have the relevant Webdriver kits installed on your machine -

- Please read the instructions on the `nym/tauri-wallet/README.md` in the root of the project on how to build the application
- Please ensure you have the relevant Webdriver kits installed on your machine -

```
linux:
sudo apt-get install -y webkit2gtk-driver
```
```
windows:
sudo apt-get install -y webkit2gtk-driver
```

```
windows:
download msedgedriver.exe from https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
```

please visit [Tauri Studio](https://tauri.studio/en/docs/usage/guides/webdriver/introduction), this will specify the additional drivers you need
* The path to run the application is set in the `wdio.conf.js` which lives in the root directory
* Before running the suite you need to build the application and check that the application has
built successfully, if so, you will have an executable sitting in the target directory in `tauri-wallet/target/*/nym_wallet` (refer to point 1)
* The suite will not be able to detect elements on screen if you select a release build, however you can run tests against a release target

- The path to run the application is set in the `wdio.conf.js` which lives in the root directory
- Before running the suite you need to build the application and check that the application has
built successfully, if so, you will have an executable sitting in the target directory in `tauri-wallet/target/*/nym_wallet` (refer to point 1)
- The suite will not be able to detect elements on screen if you select a release build, however you can run tests against a release target

## Installation & usage
* `test excution happens inside /webdriver directory`
* `test data needs to be provided inside the user-data.json`
* `check the wdio.conf.cjs to see the test execution along with the path location of the binary`

- `test excution happens inside /webdriver directory`
- `test data needs to be provided inside the user-data.json`
- `check the wdio.conf.cjs to see the test execution along with the path location of the binary`

```
example:
example:
//mnemonic is a base64 enconded value, which is your 24 character passphrase, these values are for illustration purposes
{
"mnemonic" : "dGhpcyBpcyBhIHBhc3NwaHJhc2UK",
"punk_address" : "punk1f3dzkhmunma5ze5q952daxca6371989189",
"receiver_address" : "punk1p0ce82jxxglpmutvhq4mdwgcwf4avm5n1821982",
{
"mnemonic" : "dGhpcyBpcyBhIHBhc3NwaHJhc2UK",
"punk_address" : "punk1f3dzkhmunma5ze5q952daxca6371989189",
"receiver_address" : "punk1p0ce82jxxglpmutvhq4mdwgcwf4avm5n1821982",
"amount_to_send" : "1",
"identity_key_to_delegate_mix_node": "value",
"identity_key_to_delegate_gateway" : "value",
"delegate_amount" : "1"
}
```
* `yarn test:runall` - the first test run will take some time to spin up be patient
* You can run tests individually by passing through the script situated in the package.json for example `yarn test:newuser`

- `yarn test:runall` - the first test run will take some time to spin up be patient
- You can run tests individually by passing through the script situated in the package.json for example `yarn test:newuser`

Tests are categorised and run by their pages, they follow a sequential flow, if one test case fails before the next execution it may derail the next test.

//todo improve in near future

## Test reporting

Currently the tests use allure reporting, the configuration can be altered in the `wdio.conf.cjs`. At present it takes snapshots of any failing tests, the test output run can be seen in the allure-results directory
Tests ouput:
* <guid-testuite.xml>
* <guid-attachment.png>

- <guid-testuite.xml>
- <guid-attachment.png>

If any tests fail in their test run it will produce the stack trace error along with the test in question

## TODO

*Disclaimer*: Still WIP

_Disclaimer_: Still WIP

Implement error handling/ beforeTest() - validating json file exists with data for test execution


Currently this is dev'd against a Linux based OS, not tested against windows yet.
22 changes: 11 additions & 11 deletions tauri-wallet/webdriver/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module.exports = {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "14"
}
}
]
]
}
presets: [
[
"@babel/preset-env",
{
targets: {
node: "14",
},
},
],
],
};
52 changes: 27 additions & 25 deletions tauri-wallet/webdriver/common/constants/text-constants.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
module.exports = {
//receivePage
"recievePageInformation" : "You can receive tokens by providing this address to the sender",
"receivePageHeaderText": "Receive Nym",

//sendPage
"sendPunk" : "Send PUNK",
//receivePage
recievePageInformation:
"You can receive tokens by providing this address to the sender",
receivePageHeaderText: "Receive Nym",

//homePage
"homePageErrorMnemonic": "Error parsing bip39 mnemonic",
"homePageSignIn" : "Sign in",
"createOne" : "Create one",
"walletSuccess" : "Please store your mnemonic in a safe place. You'll need it to access your wallet",

//bondPage // unbondPage
"bondAlreadyNoded" : "Looks like you already have a mixnode bonded.",
"bondNodeHeaderText": "Bond a node or gateway",
"unbondNodeHeaderText" : "Unbond a mixnode or gateway",
"unbondMixNodeText": "Looks like you already have a mixnode bonded.",
"unbondMixNode": "UNBOND",
//sendPage
sendPunk: "Send PUNK",

//delegatePage // undelegatePage
"delegateHeaderText" : "Delegate\nDelegate to mixnode or gateway",
"nodeIdentityValidationText" : "identity is a required field",
"amountValidationText": "amount is a required field",
"undelegateHeaderText" : "Undelegate from a mixnode or gateway",
"delegationComplete" : "Delegation complete"
}
//homePage
homePageErrorMnemonic: "Error parsing bip39 mnemonic",
homePageSignIn: "Sign in",
createOne: "Create one",
walletSuccess:
"Please store your mnemonic in a safe place. You'll need it to access your wallet",

//bondPage // unbondPage
bondAlreadyNoded: "Looks like you already have a mixnode bonded.",
bondNodeHeaderText: "Bond a node or gateway",
unbondNodeHeaderText: "Unbond a mixnode or gateway",
unbondMixNodeText: "Looks like you already have a mixnode bonded.",
unbondMixNode: "UNBOND",

//delegatePage // undelegatePage
delegateHeaderText: "Delegate\nDelegate to mixnode",
nodeIdentityValidationText: "identity is a required field",
amountValidationText: "amount is a required field",
undelegateHeaderText: "Undelegate from a mixnode or gateway",
delegationComplete: "Delegation complete",
};
16 changes: 8 additions & 8 deletions tauri-wallet/webdriver/common/data/user-data.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"mnemonic": "value",
"punk_address": "",
"receiver_address": "",
"amount_to_send": "",
"identity_key_to_delegate_mix_node": "",
"identity_key_to_delegate_gateway" : "",
"delegate_amount": ""
}
"mnemonic": "value",
"punk_address": "",
"receiver_address": "",
"amount_to_send": "",
"identity_key_to_delegate_mix_node": "",
"identity_key_to_delegate_gateway": "",
"delegate_amount": ""
}
74 changes: 36 additions & 38 deletions tauri-wallet/webdriver/common/helpers/helper.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
class Helpers {

//helper to decode mnemonic so plain 24 character passphrase isn't in sight albeit it is presented when ruunning the scripts
//maybe a show passphrase toggle button?
decodeBase = async (input) => {
var m = Buffer.from(input, 'base64').toString()
return m
}

navigateAndClick = async (element) => {
await element.click()
}

scrollIntoView = async (element) => {
await element.scrollIntoView()
//helper to decode mnemonic so plain 24 character passphrase isn't in sight albeit it is presented when ruunning the scripts
//maybe a show passphrase toggle button?
decodeBase = async (input) => {
var m = Buffer.from(input, "base64").toString();
return m;
};

navigateAndClick = async (element) => {
await element.click();
};

scrollIntoView = async (element) => {
await element.scrollIntoView();
};

currentBalance = async (value) => {
return parseFloat(value.split(/\s+/)[0].toString()).toFixed(5);
};

//todo need to improve calculation - WIP
calculateFees = async (beforeBalance, transactionFee, amount, isSend) => {
let fee;

if (isSend) {
//send transaction
fee = transactionFee.split(/\s+/)[0];
} else {
//delegate transaction
fee = transactionFee.split(/\s+/)[3];
}

const currentBalance = beforeBalance.split(/\s+/)[0];

currentBalance = async (value) => {
return parseFloat(value.split(/\s+/)[0].toString()).toFixed(5)
}
const castCurrentBalance = parseFloat(currentBalance).toFixed(5);
const transCost = +parseFloat(amount) + +parseFloat(fee).toFixed(5);

//todo need to improve calculation - WIP
calculateFees = async (beforeBalance, transactionFee, amount, isSend) => {
let fee

if (isSend) {
//send transaction
fee = transactionFee.split(/\s+/)[0]
} else {
//delegate transaction
fee = transactionFee.split(/\s+/)[3]
}

const currentBalance = beforeBalance.split(/\s+/)[0]

const castCurrentBalance = parseFloat(currentBalance).toFixed(5)
const transCost = +parseFloat(amount) + +parseFloat(fee).toFixed(5)

let sum = parseFloat(castCurrentBalance) - parseFloat(transCost)
return sum.toFixed(5)
}
let sum = parseFloat(castCurrentBalance) - parseFloat(transCost);
return sum.toFixed(5);
};
}

module.exports = new Helpers()
module.exports = new Helpers();
6 changes: 4 additions & 2 deletions tauri-wallet/webdriver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"test:home": "wdio run wdio.conf.cjs --suite home",
"test:bond": "wdio run wdio.conf.cjs --suite bond",
"test:delegate": "wdio run wdio.conf.cjs --suite delegate",
"test:newuser": "wdio run wdio.conf.cjs --suite newuser"
"test:newuser": "wdio run wdio.conf.cjs --suite newuser",
"run:prettier": "prettier --write ."
},
"dependencies": {
"@types/node": "^16.11.0",
Expand All @@ -20,6 +21,7 @@
"devDependencies": {
"@wdio/local-runner": "^7.14.1",
"@wdio/mocha-framework": "^7.14.1",
"@wdio/spec-reporter": "^7.14.1"
"@wdio/spec-reporter": "^7.14.1",
"prettier": "2.4.1"
}
}
62 changes: 45 additions & 17 deletions tauri-wallet/webdriver/tests/pages/wallet.bond.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,48 @@
class WalletBond {

get header() { return $("#root > div > div:nth-child(2) > div:nth-child(2) > div > div > div > div.MuiCardHeader-root > div > span.MuiTypography-root.MuiCardHeader-subheader.MuiTypography-subtitle1.MuiTypography-colorTextSecondary.MuiTypography-displayBlock") }
get identityKey() { return $("#identityKey") }
get sphinxKey() { return $("#sphinxKey") }
get amountToBond() { return $("#amount") }
get hostInput() { return $("#host") }
get versionInput() { return $("version") }
get selectAdvancedOptions() { return $("[type='checkbox']") }
get mixPort() { return $("#mixPort") }
get verlocPort() { return $("#verlocPort") }
get httpApiPort() { return $("#httpApiPort") }
get bondButton() { return $("[data-testid='bond-button']") }
get unBondButton() { return $("[data-testid='un-bond']") }
get unBond() { return $("[data-testid='bond-noded']") }
get unBondWarning() {return $("div.MuiAlert-message")}

get header() {
return $(
"#root > div > div:nth-child(2) > div:nth-child(2) > div > div > div > div.MuiCardHeader-root > div > span.MuiTypography-root.MuiCardHeader-subheader.MuiTypography-subtitle1.MuiTypography-colorTextSecondary.MuiTypography-displayBlock"
);
}
get identityKey() {
return $("#identityKey");
}
get sphinxKey() {
return $("#sphinxKey");
}
get amountToBond() {
return $("#amount");
}
get hostInput() {
return $("#host");
}
get versionInput() {
return $("version");
}
get selectAdvancedOptions() {
return $("[type='checkbox']");
}
get mixPort() {
return $("#mixPort");
}
get verlocPort() {
return $("#verlocPort");
}
get httpApiPort() {
return $("#httpApiPort");
}
get bondButton() {
return $("[data-testid='bond-button']");
}
get unBondButton() {
return $("[data-testid='un-bond']");
}
get unBond() {
return $("[data-testid='bond-noded']");
}
get unBondWarning() {
return $("div.MuiAlert-message");
}
}

module.exports = new WalletBond()
module.exports = new WalletBond();
Loading