This commit is contained in:
Benedetta
2022-08-04 15:37:05 +02:00
parent 2637924e9c
commit 02da10e222
27 changed files with 933 additions and 647 deletions
Generated
+518 -472
View File
File diff suppressed because it is too large Load Diff
@@ -56,7 +56,7 @@ export const ConfirmationModal = ({
const ConfirmButton =
typeof confirmButton === 'string' ? (
<Button onClick={onConfirm} variant="contained" fullWidth disabled={disabled} sx={{ py: 1.6 }}>
<Typography variant="button" fontSize="large">
<Typography variant="button" fontSize="large" data-testid={confirmButton}>
{confirmButton}
</Typography>
</Button>
@@ -62,7 +62,7 @@ export const SimpleModal: React.FC<{
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2, mt: 2 }}>
{onBack && <StyledBackButton onBack={onBack} />}
<Button variant="contained" fullWidth size="large" onClick={onOk} disabled={okDisabled}>
<Button variant="contained" fullWidth size="large" onClick={onOk} disabled={okDisabled} data-testid={okLabel}>
{okLabel}
</Button>
</Box>
@@ -60,6 +60,9 @@ export const SendInputModal = ({
fullWidth
onChange={(e) => onAddressChange(e.target.value)}
value={toAddress}
inputProps={{
"data-testid": "recipientAddress",
}}
/>
<CurrencyFormField
placeholder="Amount"
@@ -70,7 +73,7 @@ export const SendInputModal = ({
}}
initialValue={amount?.amount}
/>
<Typography fontSize="smaller" sx={{ color: 'error.main' }}>
<Typography fontSize="smaller" sx={{ color: 'error.main' }} >
{error}
</Typography>
</Stack>
@@ -32,7 +32,7 @@ export const SendSuccessModal = ({
{txDetails && (
<>
<Typography variant="h5">{txDetails.amount}</Typography>
<Link href={txDetails.txUrl} target="_blank" sx={{ ml: 1 }} text="View on blockchain" />
<Link href={txDetails.txUrl} target="_blank" sx={{ ml: 1 }} text="View on blockchain" data-testid="viewOnBlockchain"/>
</>
)}
</Stack>
@@ -6,7 +6,7 @@ export const Title = ({ title }: { title: string }) => (
);
export const Subtitle = ({ subtitle }: { subtitle: string }) => (
<Typography sx={{ color: 'common.white', textAlign: 'center', maxWidth: 450 }}>{subtitle}</Typography>
<Typography data-testid={subtitle} sx={{ color: 'common.white', textAlign: 'center', maxWidth: 450 }}>{subtitle}</Typography>
);
export const SubtitleSlick = ({ subtitle }: { subtitle: string }) => (
+4 -2
View File
@@ -5,8 +5,10 @@ import { AppContext } from '../../context/main';
const SendReviewField = ({ title, subtitle, info }: { title: string; subtitle?: string; info?: boolean }) => (
<>
<Typography sx={{ color: info ? 'nym.fee' : '' }}>{title}</Typography>
<Typography data-testid={title} sx={{ color: info ? 'nym.fee' : '', wordBreak: 'break-all' }}>
<Typography sx={{ color: info ? 'nym.fee' : '' }} data-testid={title}>
{title}
</Typography>
<Typography sx={{ color: info ? 'nym.fee' : '', wordBreak: 'break-all' }} data-testid={subtitle}>
{subtitle}
</Typography>
</>
+73 -5
View File
@@ -1,18 +1,86 @@
import Balance from '../tests/pageobjects/balanceScreen'
import Auth from '../tests/pageobjects/authScreens'
const userData = require("../common/user-data.json");
const deleteScript = require("../scripts/deletesavedwallet")
const savedWalletScript = require("../scripts/savedwalletexists")
class Helpers {
// clear wallet data, login, and navigate to QA network
freshMnemonicLoginQaNetwork = async () => {
await deleteScript
await savedWalletScript
await Auth.loginWithMnemonic(userData.mnemonic)
await Balance.selectQa()
}
loginMnemonic = async () => {
await Auth.loginWithMnemonic(userData.mnemonic)
}
//helper to decode mnemonic so plain 24 character passphrase isn't in sight albeit it is presented when ruunning the scripts
// TO-DO figure out what's going on with the decoding bit
decodeBase = async (input) => {
var m = Buffer.from(input, "base64").toString();
return m;
};
}
navigateAndClick = async (element) => {
await element.waitForClickable({ timeout: 6000 })
await element.click();
};
}
elementVisible = async (element) => {
await element.waitForDisplayed({ timeout: 6000 })
}
elementClickable = async (element) => {
await element.toBeClickable({ timeout: 8000 })
}
addValueToTextField = async (element, value) => {
await element.addValue(value)
}
verifyStrictText = async (element, expectedText) => {
let error = await element.getText()
expect(error).toStrictEqual(expectedText)
}
verifyPartialText = async (element, expectedText) => {
let error = await element.getText()
expect(error).toContain(expectedText)
}
currentBalance = async (value) => {
return parseFloat(value.split(/\s+/)[0].toString()).toFixed(5)
}
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]
console.log("currenttttt 2 ............. = " + currentBalance)
const castCurrentBalance = parseFloat(currentBalance).toFixed(5)
console.log("castttt ............. " + castCurrentBalance)
const transCost = +parseFloat(amount) + +parseFloat(fee).toFixed(5)
console.log("trans ............." + transCost)
let sum = +castCurrentBalance - transCost
return sum.toFixed(5)
}
scrollIntoView = async (element) => {
await element.scrollIntoView();
};
}
module.exports = new Helpers();
@@ -10,15 +10,30 @@ module.exports = {
signInWithoutPassword: "A password must be provided",
failedToFindWalletFile: "The wallet file is not found",
//headers
mnemonicSignIn: "Enter a mnemonic to sign in",
passwordSignIn: "Enter a password to sign in",
//homePage
qaNetwork: "QA",
sandboxNetwork: "Testnet Sandbox",
mainnetNetwork: "Nym Mainnet",
noNym: "0 NYM",
//send
invalidRecipientAddress: "123",
recipientAddress: "n17tj0a0w6v7r2dc54rnkzfza6s8hxs87rj273a5",
amountToSend: "1",
negativeAmount: "-1",
inferiorAmount: "0.0000001",
confirmedAmount: "1 NYM",
sendDetails: "Send details",
// bond
host: "1.1.1.1",
version: "1.2.1",
// user incorrect data
incorrectMnemonic: "giraffe note order sun cradle bottom crime humble able antique rural donkey guess parent potato tongue truly way disagree exile zebra someone else heat",
randomString:"thisrandomstring",
@@ -1,9 +1,9 @@
{
"mnemonic": "giraffe note order sun cradle bottom crime humble able antique rural donkey guess parent potato tongue truly way disagree exile zebra someone else typical",
"punk_address": "",
"receiver_address": "",
"amount_to_send": "",
"identity_key_to_delegate_mix_node": "",
"qa_address": "n1qqct7gs79yrjncpkumljxeqjsnwvn42j2g3fw4",
"receiver_address": "n167rupnmpput2alw62sz43eelks03zek4fwvjk0",
"amount_to_send": "1",
"identity_key_to_delegate_mix_node": "HqW2HStFHtAZ3PxRaiSCh7xJK6B7swoR1gSmJzH2iV9g",
"identity_key_to_delegate_gateway": "",
"delegate_amount": ""
"delegate_amount": "10"
}
+3 -1
View File
@@ -7,7 +7,9 @@
"test:signup": "wdio run wdio.conf.ts --suite signup",
"test:login": "wdio run wdio.conf.ts --suite login",
"test:balance": "wdio run wdio.conf.ts --suite balance",
"test:nav": "wdio run wdio.conf.ts --suite nav"
"test:nav": "wdio run wdio.conf.ts --suite nav",
"test:send": "wdio run wdio.conf.ts --suite send",
"test:delegation": "wdio run wdio.conf.ts --suite delegation"
},
"author": "",
@@ -1,4 +1,14 @@
const { exec } = require("child_process")
const doesFileExist = exec("test -f /home/benedetta/.local/share/nym-wallet/saved-wallet.json" && "echo '$FILE exists.'" || "echo 'file doesn't exist'")
// scriptExist ? expect(getErrorWarning).toStrictEqual(textConstants.invalidPasswordOnSignIn) : expect(getErrorWarning).toStrictEqual(textConstants.failedToFindWalletFile)
// const doesFileExist = exec("test -f /home/benedetta/.local/share/nym-wallet/saved-wallet.json" && "echo '$FILE exists.'" || "echo 'file doesn't exist'")
// scriptExist ? expect(getErrorWarning).toStrictEqual(textConstants.invalidPasswordOnSignIn) : expect(getErrorWarning).toStrictEqual(textConstants.failedToFindWalletFile)
const doesFileExist = exec("test -f /home/benedetta/.local/share/nym-wallet/saved-wallet.json", (err, stdout, stderr) => {
if (err) {
console.error(`${err.message}`)
return
} else
console.log("File: " + stdout)
})
@@ -12,6 +12,7 @@ class Auth {
get forgotPassword() { return $("[data-testid='forgotPassword']") }
// Sign in with mnemonic page
get mnemonicLoginScreenHeader() { return $("[data-testid='Enter a mnemonic to sign in']") }
get mnemonicInput() { return $("[data-testid='mnemonicInput']") }
get signIn() { return $("[data-testid='signInSubmitButton']") }
get backToSignInOptions() { return $("[data-testid='backToSignInOptions']") }
@@ -44,6 +45,7 @@ class Auth {
get skipPasswordAndSignInWithMnemonic() { return $("[data-testid='skipPasswordAndSignInWithMnemonic']") }
// Enter password to sign in
get passwordLoginScreenHeader() { return $("[data-testid='Enter a password to sign in']") }
get enterPassword() { return $("[data-testid='Enter password']") }
get signInPasswordButton() { return $("[data-testid='signInPasswordButton']") }
get backToSignInOptionsFromPassword() { return $("[data-testid='backToSignInOptionsFromPassword']") }
@@ -64,7 +66,7 @@ class Auth {
await this.mnemonicInput.waitForDisplayed()
await this.mnemonicInput.addValue(mnemonic);
await this.signIn.click();
await Balance.nymBalance.isExisting({timeout:4000});
await Balance.nymBalance.isExisting({ timeout: 4000 });
};
}
@@ -4,14 +4,20 @@ class Balance {
get checkBalance() { return $("[data-testid='check-balance']") }
get nymBalance() { return $("[data-testid='nym-balance']") }
get copyAccountId() { return $("[data-testid='copyIcon']")}
get copyAccountId() { return $("[data-testid='copyIcon']") }
get accountNumber() { return $("[data-testid='accountNumber']")}
get accountNumber() { return $("[data-testid='accountNumber']") }
get networkDropdown() { return $("[data-testid='ArrowDropDownIcon']") }
get networkEnv() { return $("[data-testid='networkEnv']") }
get networkSelectQa() { return $("[data-testid='QA']") }
selectQa = async () => {
await this.networkDropdown.waitForDisplayed({ timeout: 4000 })
await this.networkDropdown.click()
await this.networkSelectQa.waitForClickable({ timeout: 4000 })
await this.networkSelectQa.click()
await this.networkEnv.waitForClickable({ timeout: 2000 })
}
}
export default new Balance()
@@ -1,6 +1,8 @@
class Delegation {
get delegationTitle() { return $("[data-testid='Delegation']") }
get delegateStakeButton() { return $("[data-testid='Delegate stake']") }
get delegateModalHeader() { return $("[data-testid='Delegate']") }
}
@@ -1,5 +1,28 @@
class Send {
// send nym form
get sendHeader() { return $("[data-testid='Send']") }
get recipientAddress() { return $("[data-testid='recipientAddress']") }
// get sendAmount() { return $("[data-testid='Amount']") }
get sendAmount() { return $("#mui-5") } // TO-DO fix this selector, using #mui-5 isn't a good solution
get next() { return $("[data-testid='Next']") }
// confirm transaction modal
get sendDetailsHeader() { return $("[data-testid='Send details']") }
get from() { return $("/html/body/div[2]/div[3]/div[2]/div[1]/div[1]") }
get to() { return $("/html/body/div[2]/div[3]/div[2]/div[2]") }
get amount() { return $("/html/body/div[2]/div[3]/div[2]/div[3]") }
get fee() { return $("/html/body/div[2]/div[3]/div[2]/div[4]") }
get confirm() { return $("[data-testid='Confirm']") }
// transaction sent
get viewOnBlockchain() { return $("[data-testid='viewOnBlockchain']") }
get done() { return $("[data-testid='Done']") }
}
export default new Send()
@@ -2,34 +2,31 @@ import Balance from '../../pageobjects/balanceScreen'
import Auth from '../../pageobjects/authScreens'
const textConstants = require("../../../common/text-constants");
const userData = require("../../../common/user-data.json");
const Helper = require('../../../common/helper');
describe('Balance screen displays correctly', () => {
it('selecting qa network', async () => {
//log in
await Auth.loginWithMnemonic(userData.mnemonic)
await Helper.loginMnemonic()
// select QA network
await (await Balance.networkDropdown).waitForDisplayed({ timeout: 4000 })
await (await Balance.networkDropdown).click()
await (await Balance.networkSelectQa).waitForDisplayed({ timeout: 2500 })
await (await Balance.networkSelectQa).click()
await Helper.navigateAndClick(Balance.networkDropdown)
await Helper.navigateAndClick(Balance.networkSelectQa)
// verifty QA network has been selected properly
let network = await (await Balance.networkEnv).getText()
expect(network).toStrictEqual(textConstants.qaNetwork)
await Helper.verifyStrictText(Balance.networkEnv, textConstants.qaNetwork)
})
it('copy the account id', async () => {
// ensure the account number contains *something*
await (await Balance.accountNumber).waitForDisplayed({ timeout: 1500 })
let accountnumber = await (await Balance.accountNumber).getText()
expect(accountnumber[1]).toStrictEqual('1')
await (await Balance.copyAccountId).waitForClickable({ timeout: 1500 })
await (await Balance.copyAccountId).click()
await Helper.elementVisible(Balance.accountNumber)
await Helper.verifyPartialText(Balance.accountNumber[1],'1')
await Helper.navigateAndClick(Balance.copyAccountId)
// TO-DO is there a way to verify that the copy worked, aka pasting it somewhere maybe?
})
})
@@ -0,0 +1,21 @@
import Balance from '../../pageobjects/balanceScreen'
import Auth from '../../pageobjects/authScreens'
import Nav from '../../pageobjects/appNavConstants'
import Delegation from '../../pageobjects/delegationScreen'
import Send from '../../pageobjects/sendScreen'
const Helper = require('../../../common/helper');
const textConstants = require("../../../common/text-constants");
const userData = require("../../../common/user-data.json");
describe('Delegate to a mixnode', () => {
it('entering an invalid node identity key', async () => {
//login and navigate to the screen
await Helper.freshMnemonicLoginQaNetwork()
await Helper.navigateAndClick(Nav.delegation)
await Helper.elementVisible(Delegation.delegationTitle)
// TO-DO enter an invalid node
})
})
@@ -1,9 +1,10 @@
import Auth from '../../pageobjects/authScreens'
import Balance from '../../pageobjects/balanceScreen'
import ValidatorClient from '@nymproject/nym-validator-client';
const deleteScript = require("../../../scripts/deletesavedwallet")
const textConstants = require("../../../common/text-constants");
const userData = require("../../../common/user-data.json");
const { exec } = require("child_process")
const Helper = require('../../../common/helper');
describe('Create password for existing account and use it to sign in', () => {
@@ -11,27 +12,25 @@ describe('Create password for existing account and use it to sign in', () => {
it('enter incorrect mnemonic', async () => {
//click through sign in
await (await Auth.signInButton).click()
await (await Auth.signInMnemonic).click()
await Helper.navigateAndClick(Auth.signInButton)
await Helper.navigateAndClick(Auth.signInMnemonic)
//instead of entering mnemonic, click on create a password
await (await Auth.createPassword).click()
await Helper.navigateAndClick(Auth.createPassword)
//enter incorrect mnemonic
await (await Auth.mnemonicInput).addValue(textConstants.incorrectMnemonic)
await (await Auth.nextToPasswordCreation).click()
// assert error message is correct
let getErrorWarning = await (await Auth.error).getText()
expect(getErrorWarning).toStrictEqual(textConstants.incorrectMnemonicPasswordCreation)
await Helper.addValueToTextField(Auth.mnemonicInput, textConstants.incorrectMnemonic)
await Helper.navigateAndClick(Auth.nextToPasswordCreation)
// assert error message is correct
await Helper.verifyStrictText(Auth.error, textConstants.incorrectMnemonicPasswordCreation)
})
it('enter random string', async () => {
// enter random string as mnemonic
await (await Auth.mnemonicInput).addValue(textConstants.randomString)
await (await Auth.nextToPasswordCreation).click()
await Helper.addValueToTextField(Auth.mnemonicInput, textConstants.randomString)
await Helper.navigateAndClick(Auth.nextToPasswordCreation)
// assert error is correct
let getErrorWarning = await (await Auth.error).getText()
expect(getErrorWarning).toStrictEqual(textConstants.incorrectMnemonicPasswordCreation)
await Helper.verifyStrictText(Auth.error, textConstants.incorrectMnemonicPasswordCreation)
})
@@ -40,20 +39,21 @@ describe('Create password for existing account and use it to sign in', () => {
// generate random mnemonic in the backend
const randomMnemonic = ValidatorClient.randomMnemonic();
deleteScript
// use it to continue with password creation flow
await (await Auth.backToMnemonicSignIn).click()
await (await Auth.createPassword).click()
await (await Auth.mnemonicInput).addValue(randomMnemonic)
await (await Auth.nextToPasswordCreation).click()
await (await Auth.password).waitForDisplayed({ timeout: 2500 })
await Helper.navigateAndClick(Auth.backToMnemonicSignIn)
await Helper.navigateAndClick(Auth.createPassword)
await Helper.addValueToTextField(Auth.mnemonicInput, randomMnemonic)
await Helper.navigateAndClick(Auth.nextToPasswordCreation)
await Helper.elementVisible(Auth.password)
})
it('create an invalid password', async () => {
// type an invalid password in both fields
await (await Auth.password).addValue(textConstants.incorrectPassword)
await (await Auth.confirmPassword).click({timeout: 1500})
await (await Auth.confirmPassword).addValue(textConstants.incorrectPassword)
await Helper.addValueToTextField(Auth.password, textConstants.incorrectPassword)
await Helper.navigateAndClick(Auth.confirmPassword)
await Helper.addValueToTextField(Auth.confirmPassword, textConstants.incorrectPassword)
// ensure the button to proceed is still disabled
const nextButton = await Auth.createPasswordButton
const isNextDisabled = await nextButton.getAttribute('disabled')
@@ -61,37 +61,39 @@ describe('Create password for existing account and use it to sign in', () => {
})
it('create a valid password', async () =>{
await (await Auth.password).click({timeout: 1500})
await (await Auth.password).addValue(textConstants.password)
await (await Auth.confirmPassword).click({timeout: 1500})
await (await Auth.confirmPassword).addValue(textConstants.password)
await (await Auth.createPasswordButton).click()
it('create a valid password', async () => {
// type a valid password in both fields
await Helper.navigateAndClick(Auth.password)
await Helper.addValueToTextField(Auth.password, textConstants.password)
await Helper.navigateAndClick(Auth.confirmPassword)
await Helper.addValueToTextField(Auth.confirmPassword, textConstants.password)
// verify the password is created and the next screen is visible
await Helper.navigateAndClick(Auth.createPasswordButton)
await Helper.verifyStrictText(Auth.passwordLoginScreenHeader, textConstants.passwordSignIn)
})
it('sign in with no password throws error', async () => {
//click sign without entering a password
await (await Auth.signInPasswordButton).click()
await Helper.navigateAndClick(Auth.signInPasswordButton)
// wait for error
await (await Auth.error).waitForDisplayed({ timeout: 1500 })
let getErrorWarning = await (await Auth.error).getText()
await Helper.elementVisible(Auth.error)
// verify error has the correct message
expect(getErrorWarning).toStrictEqual(textConstants.signInWithoutPassword)
await Helper.verifyStrictText(Auth.error, textConstants.signInWithoutPassword)
})
it('sign in with invalid password throws error', async () => {
// enter invalid password
await (await Auth.enterPassword).addValue(textConstants.incorrectPassword)
await (await Auth.signInPasswordButton).click()
await Helper.addValueToTextField(Auth.enterPassword, textConstants.incorrectPassword)
await Helper.navigateAndClick(Auth.signInPasswordButton)
// wait for error
await (await Auth.error).waitForDisplayed({ timeout: 1500 })
let getErrorWarning = await (await Auth.error).getText()
expect(getErrorWarning).toStrictEqual(textConstants.invalidPasswordOnSignIn)
await Helper.elementVisible(Auth.error)
await Helper.verifyStrictText(Auth.error, textConstants.invalidPasswordOnSignIn)
})
})
@@ -1,68 +1,67 @@
import Auth from '../../pageobjects/authScreens'
import Balance from '../../pageobjects/balanceScreen'
import ValidatorClient from '@nymproject/nym-validator-client';
import { text } from 'stream/consumers';
const textConstants = require("../../../common/text-constants");
const userData = require("../../../common/user-data.json");
const Helper = require('../../../common/helper');
describe('Wallet sign in functionality with mnemonic', () => {
it('get to the sign in with mnemonic screen', async () => {
// click through to reach the mnemonic sign in
await Helper.navigateAndClick(Auth.signInButton)
await Helper.navigateAndClick(Auth.signInMnemonic)
// verify you are on the right screen by confirming the header
await Helper.verifyStrictText(Auth.mnemonicLoginScreenHeader, textConstants.mnemonicSignIn)
})
it('sign in with no mnemonic throws error', async () => {
//click through sign without entering a mnemonic
await (await Auth.signInButton).click()
await (await Auth.signInMnemonic).click()
await (await Auth.signIn).click()
// // wait for error
// await (await Auth.error).waitForDisplayed({ timeout: 1500 })
// let getErrorWarning = await (await Auth.error).getText()
await Helper.navigateAndClick(Auth.signIn)
// wait for error
await Helper.elementVisible(Auth.error)
// verify error has the correct message
expect(Auth.getErrorMessage).toStrictEqual(textConstants.signInWithoutMnemonic)
await Helper.verifyStrictText(Auth.error, textConstants.signInWithoutMnemonic)
})
it('sign in with incorrect mnemonic throws error', async () => {
// enter an incorrect mnemonic string
await (await Auth.mnemonicInput).addValue(textConstants.incorrectMnemonic)
await (await Auth.signIn).click()
await Helper.addValueToTextField(Auth.mnemonicInput, textConstants.incorrectMnemonic)
await Helper.navigateAndClick(Auth.signIn)
// verifty error message is correct
let getErrorWarning = await (await Auth.error).getText()
expect(getErrorWarning).toContain(textConstants.signInIncorrectMnemonic)
await Helper.verifyPartialText(Auth.error, textConstants.signInIncorrectMnemonic)
})
it('sign in with random string throws error', async () => {
// enter a random string not in mnemonic "format"
await (await Auth.mnemonicInput).addValue(textConstants.randomString)
await (await Auth.signIn).click()
await Helper.addValueToTextField(Auth.mnemonicInput, textConstants.randomString)
await Helper.navigateAndClick(Auth.signIn)
// verifty error message is correct
let getErrorWarning = await (await Auth.error).getText()
expect(getErrorWarning).toContain(textConstants.signInRandomString)
await Helper.verifyPartialText(Auth.error, textConstants.signInRandomString)
})
it('should sign in with valid credentials', async () => {
// go back to create account option
await (await Auth.backToSignInOptions).click()
await (await Auth.backToWelcomePage).click()
// create new mnemonic
await (await Auth.createAccount).click()
let mnemonic = await (await Auth.mnemonicPhrase).getText()
await (await Auth.backToWelcomePageFromCreate).click()
// back on login page then enter the mnemonic
await (await Auth.signInButton).click()
await (await Auth.signInMnemonic).click()
await (await Auth.mnemonicInput).waitForDisplayed()
await (await Auth.mnemonicInput).addValue(mnemonic)
await (await Auth.signIn).click()
const randomMnemonic = ValidatorClient.randomMnemonic();
// enter mnemonic
await Helper.addValueToTextField(Auth.mnemonicInput, randomMnemonic)
await Helper.navigateAndClick(Auth.signIn)
// verify successful login, balance is visible
await (await Balance.balance).waitForDisplayed({ timeout: 5000 })
let balance = await (await Balance.nymBalance).getText()
await Helper.elementVisible(Balance.balance)
//new accounts will always default to mainnet, so 0 balance
expect(balance).toStrictEqual(textConstants.noNym)
// TO-DO this value sometimes returns " " instead of "0"
await Helper.verifyStrictText(Balance.nymBalance, textConstants.noNym)
})
})
@@ -4,23 +4,25 @@ const textConstants = require("../../../common/text-constants");
const userData = require("../../../common/user-data.json");
const deleteWallet = require("../../../scripts/deletesavedwallet");
const walletExists = require("../../../scripts/savedwalletexists")
const { exec } = require("child_process")
const Helper = require('../../../common/helper');
describe('Wallet sign in functionality without creating password', () => {
it('sign in with invalid password and no saved wallet.json file throws error', async () => {
//click through sign without entering a password
await (await Auth.signInButton).click()
await (await Auth.signInPassword).click()
// delete existing saved wallet file
deleteWallet
//click through sign without entering a password
await Helper.navigateAndClick(Auth.signInButton)
await Helper.navigateAndClick(Auth.signInPassword)
// enter invalid password
await (await Auth.enterPassword).addValue(textConstants.incorrectPassword)
await (await Auth.signInPasswordButton).click()
await Helper.addValueToTextField(Auth.enterPassword,textConstants.incorrectPassword)
await Helper.navigateAndClick(Auth.signInPasswordButton)
// wait for error
await (await Auth.error).waitForDisplayed({ timeout: 1500 })
let getErrorWarning = await (await Auth.error).getText()
expect(getErrorWarning).toStrictEqual(textConstants.failedToFindWalletFile)
await Helper.elementVisible(Auth.error)
// verify error has the correct message
await Helper.verifyStrictText(Auth.error, textConstants.failedToFindWalletFile)
})
@@ -7,29 +7,29 @@ import Bond from '../../pageobjects/bondScreen'
import Unbond from '../../pageobjects/unbondScreen'
import Delegation from '../../pageobjects/delegationScreen'
const userData = require("../../../common/user-data.json");
const Helper = require('../../../common/helper');
describe('Nav Items behave correctly', () => {
it('switch from light to dark mode and back', async () => {
//log in
await Auth.loginWithMnemonic(userData.mnemonic)
await Helper.freshMnemonicLoginQaNetwork()
// click on different modes
await (await Nav.lightMode).waitForDisplayed({ timeout: 6000 })
await (await Nav.lightMode).click()
await (await Nav.darkMode).click()
await (await Nav.lightMode).waitForDisplayed({ timeout: 2500 })
await Helper.navigateAndClick(Nav.lightMode)
await Helper.navigateAndClick(Nav.darkMode)
await Helper.elementVisible(Nav.lightMode)
})
it('clicking terminal opens the modal', async () => {
// ensure the terminal button opens the terminal
await (await Nav.terminalIcon).waitForDisplayed({ timeout: 1500 })
await (await Nav.terminalIcon).click()
await (await Nav.terminalTitle).waitForDisplayed({ timeout: 2000 })
let terminalTitle = await (await Nav.terminalTitle).getText()
expect(terminalTitle).toContain('Terminal')
await Helper.elementVisible(Nav.terminalIcon)
await Helper.navigateAndClick(Nav.terminalIcon)
await Helper.elementVisible(Nav.terminalTitle)
await Helper.verifyPartialText(Nav.terminalTitle, 'Terminal')
})
@@ -37,41 +37,37 @@ describe('Nav Items behave correctly', () => {
describe('Menu items lead to correct screen', () => {
//TO-DO none of this works
//check each menu item opens the right screen/modal
it('check Balance link works', async () => {
await (await Nav.balance).click()
let balanceTitle = await (await Balance.balance).getText()
expect(balanceTitle).toContain('Balance')
await Helper.navigateAndClick(Nav.balance)
await Helper.verifyPartialText(Balance.balance, 'Balance')
})
it('check Send link works', async () => {
await (await Nav.send).click()
let sendTitle = await (await Send.sendHeader).getText()
expect(sendTitle).toContain('Send')
await (await Nav.closeIcon).click()
await Helper.navigateAndClick(Nav.send)
await Helper.verifyPartialText(Send.sendHeader, 'Send')
await Helper.navigateAndClick(Nav.closeIcon)
})
it('check Receive link works', async () => {
await (await Nav.receive).click()
let receiveNymTitle = await (await Receive.receiveNymTitle).getText()
expect(receiveNymTitle).toContain('Receive NYM')
await Helper.navigateAndClick(Nav.receive)
await Helper.verifyPartialText(Receive.receiveNymTitle, 'Receive NYM')
})
it('check Bond link works', async () => {
await (await Nav.bond).click()
let bondTitle = await (await Bond.bondTitle).getText()
expect(bondTitle).toContain('Bond')
await Helper.navigateAndClick(Nav.bond)
await Helper.verifyPartialText(Bond.bondTitle, 'Bond')
})
it('check Unbond link works', async () => {
await (await Nav.unbond).click()
let unbondTitle = await (await Unbond.unbondTitle).getText()
expect(unbondTitle).toContain('Unbond')
await Helper.navigateAndClick(Nav.unbond)
await Helper.verifyPartialText(Unbond.unbondTitle, 'Unbond')
})
it('check Delegation link works', async () => {
await (await Nav.delegation).click()
let delegationTitle = await (await Delegation.delegationTitle).getText()
expect(delegationTitle).toContain('Delegation')
await Helper.navigateAndClick(Nav.delegation)
await Helper.verifyPartialText(Delegation.delegationTitle, 'Delegation')
})
})
@@ -2,20 +2,25 @@ import Auth from '../../pageobjects/authScreens'
import Balance from '../../pageobjects/balanceScreen'
const textConstants = require("../../../common/text-constants");
const userData = require("../../../common/user-data.json");
const deleteScript = require("../../../scripts/deletesavedwallet")
const Helper = require('../../../common/helper');
describe('Create a new account and verify it exists', () => {
it('generate new mnemonic and verify mnemonic words', async () => {
await (await Auth.createAccount).click()
await (await Auth.mnemonicPhrase).waitForDisplayed({ timeout: 2500 })
// delete any existing saved-wallet.json
deleteScript
// click through create account flow
await Helper.navigateAndClick(Auth.createAccount)
await Helper.elementVisible(Auth.mnemonicPhrase)
// save mnemonic phrase
let mnemonic = await (await Auth.mnemonicPhrase).getText()
let arrayMnemonic = mnemonic.split(" ")
await (await Auth.copyMnemonic).click()
await (await expect(Auth.iSavedMnemonic).toBeClickable())
await (await Auth.iSavedMnemonic).click()
await Helper.navigateAndClick(Auth.copyMnemonic)
await Helper.navigateAndClick(Auth.iSavedMnemonic)
// verify the mnemonic words in the correct order
let mnemonicWordTiles = await (await Auth.mnemonicWordTile)
let wordTileIndex = await (await Auth.wordIndex)
@@ -34,7 +39,7 @@ describe('Create a new account and verify it exists', () => {
await match.word.click()
}
}
// ensure that once the task above is complete, the 'next' button is enabled
const nextButton = await Auth.nextToStep3
const isNextDisabled = await nextButton.getAttribute('disabled')
expect(isNextDisabled).toBe(null)
@@ -42,17 +47,24 @@ describe('Create a new account and verify it exists', () => {
})
it('click skip password', async () => {
await (await Auth.nextToStep3).click()
await (await Auth.skipPasswordAndSignInWithMnemonic).click()
await (await Auth.mnemonicInput).waitForDisplayed({ timeout: 1500 })
await (await Auth.backToSignInOptions).click()
// click on skip password creation
await Helper.navigateAndClick(Auth.nextToStep3)
await Helper.navigateAndClick(Auth.skipPasswordAndSignInWithMnemonic)
// can see mnemonic login page
await Helper.elementVisible(Auth.mnemonicInput)
await Helper.navigateAndClick(Auth.backToSignInOptions)
})
it('set up invalid password for new account', async () => {
await (await Auth.password).click()
await (await Auth.password).addValue(textConstants.incorrectPassword)
await (await Auth.confirmPassword).click()
await (await Auth.confirmPassword).addValue(textConstants.incorrectPassword)
// enter invalid password in both fields
await Helper.navigateAndClick(Auth.password)
await Helper.addValueToTextField(Auth.password, textConstants.incorrectPassword)
await Helper.navigateAndClick(Auth.confirmPassword)
await Helper.addValueToTextField(Auth.confirmPassword, textConstants.incorrectPassword)
// verify that the 'next' button is still disabled
const nextButton = await Auth.nextStorePassword
const isNextDisabled = await nextButton.getAttribute('disabled')
expect(isNextDisabled).toBe("true")
@@ -60,24 +72,30 @@ describe('Create a new account and verify it exists', () => {
})
it('set up valid password for new account', async () => {
await (await Auth.password).click()
await (await Auth.password).addValue(textConstants.password)
await (await Auth.confirmPassword).click()
await (await Auth.confirmPassword).addValue(textConstants.password)
// enter a valid password in both fields
await Helper.navigateAndClick(Auth.password)
await Helper.addValueToTextField(Auth.password, textConstants.password)
await Helper.navigateAndClick(Auth.confirmPassword)
await Helper.addValueToTextField(Auth.confirmPassword, textConstants.password)
// verify that the 'next' button is clickable
const nextButton = await Auth.nextStorePassword
const isNextDisabled = await nextButton.getAttribute('disabled')
expect(isNextDisabled).toBe(null)
})
it('proceed to login with newly created password', async () => {
await (await Auth.nextStorePassword).click()
await (await Auth.enterPassword).waitForDisplayed({ timeout: 1500 })
await (await Auth.enterPassword).addValue(textConstants.password)
await (await Auth.signInPasswordButton).click()
await (await Balance.balance).waitForDisplayed({ timeout: 4000 })
let balance = await (await Balance.nymBalance).getText()
// login with a password
await Helper.navigateAndClick(Auth.nextStorePassword)
await Helper.navigateAndClick(Auth.enterPassword)
await Helper.addValueToTextField(Auth.enterPassword, textConstants.password)
await Helper.navigateAndClick(Auth.signInPasswordButton)
// TO-DO for some reason this is failing due to failed to decrypt the wallet etc error
await Helper.elementVisible(Balance.balance)
//new accounts will always default to mainnet, so 0 balance
expect(balance).toStrictEqual(textConstants.noNym)
await Helper.verifyStrictText(Balance.nymBalance, textConstants.noNym)
})
})
@@ -0,0 +1,62 @@
import Balance from '../../pageobjects/balanceScreen'
import Auth from '../../pageobjects/authScreens'
import Nav from '../../pageobjects/appNavConstants'
import Send from '../../pageobjects/sendScreen'
const Helper = require('../../../common/helper');
const textConstants = require("../../../common/text-constants");
const userData = require("../../../common/user-data.json");
describe.skip('Send modal functions correctly', () => {
it('entering an invalid recipient address shows error', async () => {
// sign in with mnemonic and select QA
await Helper.freshMnemonicLoginQaNetwork()
// click on send and check modal appears
await Helper.navigateAndClick(Nav.send)
await Helper.elementVisible(Send.sendHeader)
// add an invalid recipient address
await Helper.addValueToTextField(Send.recipientAddress, textConstants.invalidRecipientAddress)
// TO-DO -- question: should there not be an error message before clicking on Next to warn that the address is invalid?
})
it('entering an valid recipient address with negative amount value shows error', async () => {
await Helper.navigateAndClick(Send.recipientAddress)
// TO-DO figure out how to clear a text field before adding new value
await (Send.recipientAddress).clearValue()
await Helper.addValueToTextField(Send.recipientAddress, userData.receiver_address)
await Helper.navigateAndClick(Send.sendAmount)
await Helper.addValueToTextField(Send.sendAmount, textConstants.negativeAmount)
//next button is still disabled and error message appears
const nextButton = await Send.next
const isNextDisabled = await nextButton.getAttribute('disabled')
expect(isNextDisabled).toBe("true")
})
it('enter a valid recipient and value', async () => {
// enter valid data
await Helper.addValueToTextField(Send.recipientAddress, userData.receiver_address)
const getCurrentBalance = await (await Balance.nymBalance).getText()
await Helper.addValueToTextField(Send.sendAmount, textConstants.amountToSend)
// click on next and verify details
await Helper.navigateAndClick(Send.next)
const fee = await (await Send.fee).getText()
await Helper.verifyPartialText(Send.sendDetailsHeader, textConstants.sendDetails)
await Helper.verifyPartialText(Send.amount, textConstants.confirmedAmount)
await Helper.navigateAndClick(Send.confirm)
await Helper.elementVisible(Send.viewOnBlockchain)
await Helper.elementClickable(Send.done)
// calculate the transaction and verify it has been correctly executed
let sumCost = await Helper.calculateFees(getCurrentBalance, fee, textConstants.amountToSend, true)
const getNewBalance = await Balance.nymBalance.getText()
await Helper.navigateAndClick(Send.done)
// TO-DO the following fails with "TypeError: elem[prop] is not a function"
expect(getNewBalance).toEqual(sumCost)
})
})
+2 -1
View File
@@ -4,7 +4,8 @@
"node",
"webdriverio/async",
"@wdio/mocha-framework",
"expect-webdriverio"
"expect-webdriverio",
"./wdio.conf.ts"
],
"target": "ES5"
},
+6
View File
@@ -29,6 +29,12 @@ exports.config = {
nav: [
'./tests/specs/navbaritems/*.ts',
],
send: [
'./tests/specs/send/*.ts',
],
delegation: [
'./tests/specs/delegation/*.ts',
],
},
// Patterns to exclude.
exclude: [
@@ -72,6 +72,9 @@ export const IdentityKeyFormField: React.FC<{
return (
<TextField
fullWidth={fullWidth}
inputProps={{
"data-testid": placeholder
}}
InputProps={{
readOnly,
required,