Skip to content

Commit

Permalink
✅ migrate wallet integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiklimenok committed Dec 5, 2018
1 parent ea8c6c0 commit e03d215
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/components/request/confirmRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ConfirmRequest extends React.Component {
<CopyToClipboard
value={link}
className={styles.copy}/>
<a className={styles.emailLink}
<a className={`${styles.emailLink} email-link`}
href={`mailto:?subject=Request ${amount} LSK to ${address}&body=Hey there, here is a link you can use to send me ${amount} LSK via your wallet: ${encodeURIComponent(link)}`}>
{t('Send request via E-mail')} <FontIcon value='arrow-right'/>
</a>
Expand All @@ -75,7 +75,7 @@ class ConfirmRequest extends React.Component {
<TertiaryButton
label={t("Okay, I'm done")}
onClick={() => finalCallback()}
className='finish-button'
className='okay-button'
/>
<div className='subTitle'></div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/request/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class Request extends React.Component {
<TransferTabs setTabSend={setTabSend} isActiveTabSend={false}/>
</div>
<div className={styles.body}>
<div className={`${styles.qrCode} ${styles.magnified} request-qr-code`}>
<div className={`${styles.qrCode} ${styles.magnified} qr-code`}>
<QRCode value={account.address} />
</div>
<CopyToClipboard
value={account.address}
className={styles.copy}/>
<a className={`${styles.emailLink} ${styles.paddingLeft}`}
<a className={`${styles.emailLink} ${styles.paddingLeft} email-link`}
href={`mailto:?subject=Requesting LSK to ${account.address}&body=Hey there, here is a link you can use to send me LSK via your wallet: ${encodeURIComponent(link)}`}>
{t('Send request via E-mail')} <FontIcon value='arrow-right'/>
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/components/resultBox/resultBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ResultBox extends React.Component {
<footer>
{this.props.success &&
this.props.recipientId && this.isNotYetFollowed(this.props.recipientId) ?
<Button className={`add-follwed-account-button ${styles.addFollowedAccountButton}`}
<Button className={`add-followed-account-button ${styles.addFollowedAccountButton}`}
onClick={() => {
this.props.nextStep({ address: this.props.recipientId });
}}>
Expand Down
10 changes: 10 additions & 0 deletions test/constants/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ const ss = {
app: '#app',
transactoinsTable: '.transaction-results',
transactionRow: '.transactions-row',
filterAll: '.filter-all',
filterOutgoing: '.filter-out',
filterIncoming: '.filter-in',
seeAllTxsBtn: '.seeAllLink',
txDetailsBackButton: '.transaction-details-back-button',
recipientInput: '.recipient input',
transferSendTab: '.send-tab',
transferRequestTab: '.request-tab',
requestSpecificAmountBtn: '.specify-request',
confirmRequestBtn: '.confirm-request',
qrCode: '.qr-code',
emailLink: '.email-link',
confirmRequestBlock: '.confirm-request-step',
accountInfoTab: '.account-info',
delegateStatisticsTab: '.delegate-statistics ',
votedAddress: '.votes .voter-address',
Expand Down
27 changes: 24 additions & 3 deletions test/cypress/e2e/activity.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ describe('Dashboard Activity', () => {
},
].forEach((testSet) => {
describe(testSet.name, () => {
beforeEach(() => {
cy.autologin(accounts.genesis.passphrase, networks.devnet.node);
});
/**
* Scrolling down triggers loading another portion of txs
* @expect more txs are present
*/
it('25 tx are shown, scrolling loads another 25', () => {
cy.autologin(accounts.genesis.passphrase, networks.devnet.node);
testSet.open();
cy.get(ss.transactionRow).should('have.length', 25);
cy.get(ss.transactoinsTable).scrollTo('bottom');
Expand All @@ -81,12 +79,35 @@ describe('Dashboard Activity', () => {
* @expect some specific to page element is present on it
*/
it('Click leads to tx details', () => {
cy.autologin(accounts.genesis.passphrase, networks.devnet.node);
testSet.open();
cy.get(ss.transactionRow).eq(0).click();
cy.url().should('contain', '?id=');
cy.get(ss.txDetailsBackButton);
});

/**
* Transaction filtering tabs show filtered transaction lists
* @expect incoming txs on Incoming tab
* @expect outgoing txs on Outgoing tab
* @expect all txs on All tab
*/
it('Filtering works', () => {
cy.autologin(accounts['second passphrase account'].passphrase, networks.devnet.node);
testSet.open();
cy.get(ss.transactionRow).should('have.length', 2);
cy.get(ss.filterIncoming).click();
cy.get(ss.transactionRow).should('have.length', 1);
cy.get(ss.transactionRow).eq(0)
.find(ss.transactionAddress).contains(accounts.genesis.address);
cy.get(ss.filterOutgoing).click();
cy.get(ss.transactionRow).should('have.length', 1);
cy.get(ss.transactionRow).eq(0)
.find(ss.transactionAddress).contains('Second passphrase registration');
cy.get(ss.filterAll).click();
cy.get(ss.transactionRow).should('have.length', 2);
});

describe('Account info tabs', () => {
beforeEach(() => {
cy.autologin(accounts.genesis.passphrase, networks.devnet.node);
Expand Down
66 changes: 66 additions & 0 deletions test/cypress/e2e/transfer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,70 @@ describe('Transfer', () => {
cy.get('@tx').find(ss.transactionAddress).should('have.text', accounts['without initialization'].address);
cy.get('@tx').find(ss.transactionReference).should('have.text', 'Account initialization');
});

/**
* Try to make a transfer if not enough funds
* @expect next button is disabled
* @expect error message shown
*/
it('It\'s not allowed to make a transfer if not enough funds', () => {
cy.autologin(accounts['empty account'].passphrase, networks.devnet.node);
cy.visit(urls.wallet);
cy.get(ss.recipientInput).type(randomAddress);
cy.get(ss.amountInput).click().type(randomAmount);
cy.get(ss.nextTransferBtn).should('be.disabled');
cy.get(ss.amountInput).parent().contains('Not enough LSK');
});

/**
* Make a transfer which will fail
* @expect status code and error message are shown
*/
it('Error message is shown if transfer tx fails', () => {
cy.server({ status: 409 });
cy.route('POST', '/api/transactions', { message: 'Test error' });
cy.autologin(accounts.genesis.passphrase, networks.devnet.node);
cy.visit(urls.wallet);
cy.get(ss.recipientInput).type(randomAddress);
cy.get(ss.amountInput).click().type(randomAmount);
cy.get(ss.nextTransferBtn).click();
cy.get(ss.sendBtn).click();
cy.get(ss.resultMessage).contains('Status 409 : Test error');
});

/**
* Click request transfer
* @expect qr code is there
* @expect mail link contains correct message
* @expect click on send tab button leads to send transfer tab
*/
it('Request transfer', () => {
cy.autologin(accounts.genesis.passphrase, networks.devnet.node);
cy.visit(urls.wallet);
cy.get(ss.transferRequestTab).click();
cy.get(ss.qrCode);
cy.get(ss.emailLink).should('have.prop', 'href').and('include', `mailto:?subject=Requesting%20LSK%20to%20${accounts.genesis.address}&body=Hey%20there,%20here%20is%20a%20link%20you%20can%20use%20to%20send%20me%20LSK%20via%20your%20wallet:%20lisk%3A%2F%2Fwallet%3Frecipient%3D${accounts.genesis.address}`);
cy.get(ss.transferSendTab).click();
cy.get(ss.recipientInput);
});

/**
* Request specific amount
* @expect protocol link contains correct parameters
* @expect email link contains correct message
* @expect okay button leads to send tab
*/
it('Request specific amount', () => {
cy.autologin(accounts.genesis.passphrase, networks.devnet.node);
cy.visit(urls.wallet);
cy.get(ss.transferRequestTab).click();
cy.get(ss.requestSpecificAmountBtn).click();
cy.get(ss.amountInput).type(randomAmount);
cy.get(ss.referenceInput).type(randomReference);
cy.get(ss.confirmRequestBtn).click();
cy.get(ss.confirmRequestBlock).contains(`lisk://wallet?recipient=${accounts.genesis.address}&amount=${randomAmount}&reference=${randomReference}`);
cy.get(ss.confirmRequestBlock).find(ss.emailLink).should('have.prop', 'href').and('include', `mailto:?subject=Request%20${randomAmount}%20LSK%20to%20${accounts.genesis.address}&body=Hey%20there,%20here%20is%20a%20link%20you%20can%20use%20to%20send%20me%20${randomAmount}%20LSK%20via%20your%20wallet:%20lisk%3A%2F%2Fwallet%3Frecipient%3D${accounts.genesis.address}%26amount%3D${randomAmount}%26reference%3D${randomReference}`);
cy.get(ss.okayBtn).click();
cy.get(ss.recipientInput);
});
});
1 change: 1 addition & 0 deletions test/integration/wallet.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO: delete file after coverage is fulfilled
import thunk from 'redux-thunk';
import { step } from 'mocha-steps';
import { expect } from 'chai';
Expand Down

0 comments on commit e03d215

Please sign in to comment.