This repository has been archived by the owner on Sep 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TEST] Test for Gateways functionality (RT-1906)
- Loading branch information
1 parent
036b064
commit 196a9d5
Showing
7 changed files
with
361 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
'use strict'; | ||
|
||
// Chai is a BDD / TDD assertion library | ||
var chai = require('chai'); | ||
var chaiAsPromised = require('chai-as-promised'); | ||
var config = require('./protractor.conf.js').config; | ||
|
||
var helperForms = require('./utils/forms'); | ||
var helperBrowser = require('./utils/browser'); | ||
var TrustPage = require('./pages/trustPage.js'); | ||
var AdvancedPage = require('./pages/advancedPage.js'); | ||
|
||
|
||
chai.use(chaiAsPromised); | ||
var expect = chai.expect; | ||
|
||
// For some weird reason config ignores allScriptsTimeout | ||
browser.manage().timeouts().setScriptTimeout(60000); | ||
|
||
describe('gateway advanced', function() { | ||
|
||
var page; | ||
var advancedPage; | ||
|
||
before(function(){ | ||
helperForms.login(config.user.username,config.user.password); | ||
page = new TrustPage(); | ||
advancedPage = new AdvancedPage(); | ||
advancedPage.goTo(); | ||
}); | ||
|
||
it('should show advanced settings page', function(done) { | ||
helperBrowser.waitForElementToDisplay(advancedPage.editAdvancedSettingsButton).then(function() { done(); }); | ||
}); | ||
|
||
it('should show trust line advanced settings edit control', function(done) { | ||
advancedPage.editAdvancedSettingsButton.click(). | ||
then(helperBrowser.waitForElementToDisplay.bind(this, advancedPage.showAdvancedOptionsInput)). | ||
then(function() { done(); }); | ||
}); | ||
|
||
it('should save trust line advanced settings show on', function(done) { | ||
advancedPage.showAdvancedOptionsInput.click(). | ||
then(advancedPage.saveAdvancedSettingsButton.click). | ||
then(helperBrowser.waitForElementToDisplay.bind(this, advancedPage.advancedSettingsShowHolder)). | ||
then(function() { done(); }); | ||
}); | ||
|
||
it('should show gateways page', function(done) { | ||
page.goTo(); | ||
|
||
helperBrowser.waitForElementToDisplay(page.connectGatewayButton).then(function() { done(); }); | ||
}); | ||
|
||
it('should show add gateway user controls', function(done) { | ||
page.connectGatewayButton.click(); | ||
|
||
expect(page.gatewayAddressInput.isDisplayed()) | ||
.to.eventually.be.true | ||
.and.notify(done); | ||
}); | ||
|
||
it('should show trust amount input field', function(done) { | ||
expect(page.gatewayTrustAmountInput.isDisplayed()) | ||
.to.eventually.be.true | ||
.and.notify(done); | ||
}); | ||
|
||
it('should connect a gateway using Ripple address', function(done) { | ||
var self = this; | ||
page.putAddressAdvanced(config.gateway.address, 'USD', "1000"). | ||
then(page.connectGatewaySubmit.bind(page, config.user.password)). | ||
then(function() { done(); }); | ||
}); | ||
|
||
it('should show gateway', function(done) { | ||
expect(page.usdGatewayTitle).to.eventually.equal('USD - US Dollar') | ||
.and.notify(done); | ||
}); | ||
|
||
it('should show edit limit input', function(done) { | ||
page.usdGatewayEditButton.click(). | ||
then(helperBrowser.waitForElementToDisplay.bind(this, page.editLimitInput)). | ||
then(function() { done(); }); | ||
}); | ||
|
||
it('should show new limit', function(done) { | ||
page.editLimitInput.clear(). | ||
then(page.editLimitInput.sendKeys.bind(this, '200')). | ||
then(function() { | ||
protractor.getInstance().ignoreSynchronization = true; | ||
return page.usdGatewaySaveButton.click(); | ||
}).then(helperBrowser.waitForElement.bind(this, page.changesSavedHolder)). | ||
then(function() { | ||
expect(page.usdGatewayLimitHolder.getText()).to.eventually.equal('200.00') | ||
.and.notify(done); | ||
}); | ||
}); | ||
|
||
it('should remove a gateway', function(done) { | ||
page.usdGatewayEditButton.click(). | ||
then(page.usdGatewayAdvancedDeleteButton.click). | ||
then(helperBrowser.waitForElement.bind(this, page.gatewayRemovedHolder)). | ||
then(function() { | ||
advancedPage.goTo(); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should show advanced settings page 2', function(done) { | ||
helperBrowser.waitForElementToDisplay(advancedPage.editAdvancedSettingsButton).then(function() { done(); }); | ||
}); | ||
|
||
it('should show trust line advanced settings edit control 2', function(done) { | ||
advancedPage.editAdvancedSettingsButton.click(). | ||
then(helperBrowser.waitForElementToDisplay.bind(this, advancedPage.showAdvancedOptionsInput)). | ||
then(function() { done(); }); | ||
}); | ||
|
||
it('should save trust line advanced settings show off', function(done) { | ||
advancedPage.showAdvancedOptionsInput.click(). | ||
then(advancedPage.saveAdvancedSettingsButton.click). | ||
then(helperBrowser.waitForElementToDisplay.bind(this, advancedPage.advancedSettingsHideHolder)). | ||
then(function() { done(); }); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
'use strict'; | ||
|
||
// Chai is a BDD / TDD assertion library | ||
var chai = require('chai'); | ||
var chaiAsPromised = require('chai-as-promised'); | ||
var config = require('./protractor.conf.js').config; | ||
|
||
var helperForms = require('./utils/forms'); | ||
var helperBrowser = require('./utils/browser'); | ||
var TrustPage = require('./pages/trustPage.js'); | ||
|
||
|
||
chai.use(chaiAsPromised); | ||
var expect = chai.expect; | ||
|
||
// For some weird reason config ignores allScriptsTimeout | ||
browser.manage().timeouts().setScriptTimeout(60000); | ||
|
||
describe('gateway simple', function() { | ||
|
||
var page; | ||
|
||
before(function(){ | ||
helperForms.login(config.user.username,config.user.password); | ||
page = new TrustPage(); | ||
page.goTo(); | ||
}); | ||
|
||
it('should show gateways page', function(done) { | ||
helperBrowser.waitForElementToDisplay(page.connectGatewayButton).then(function() { done(); }); | ||
// hack. check if trust line advanced settings is on - than gatewayAdvanced | ||
// $('#trust_counterparty').evaluate('advanced_feature_switch').then(function(on) { | ||
// if (on) { | ||
// $('#trust_counterparty').evaluate('advanced_feature_switch = true;'); | ||
// } | ||
// }); | ||
}); | ||
|
||
it('should show add gateway user controls', function(done) { | ||
page.connectGatewayButton.click(); | ||
|
||
// $('#trust_counterparty').evaluate('advanced_feature_switch').then(function(r) { }); | ||
expect(page.gatewayAddressInput.isDisplayed()) | ||
.to.eventually.be.true | ||
.and.notify(done); | ||
}); | ||
|
||
it('should connect a gateway using Ripple address', function(done) { | ||
page.connectGateway(config.gateway.address, 'USD', config.user.password).then(function() { done(); }); | ||
}); | ||
|
||
it('should show gateway', function(done) { | ||
// protractor.getInstance().ignoreSynchronization = false; | ||
expect(page.usdGatewayTitle).to.eventually.equal('USD - US Dollar') | ||
.and.notify(done); | ||
}); | ||
|
||
it('should remove a gateway', function(done) { | ||
page.removeGateway('USD').then(function() { done(); }); | ||
}); | ||
|
||
it('should show add gateway user controls (by name)', function(done) { | ||
page.connectGatewayButton.click(); | ||
|
||
expect(page.gatewayAddressInput.isDisplayed()) | ||
.to.eventually.be.true | ||
.and.notify(done); | ||
}); | ||
|
||
it('should connect a gateway using Ripple name', function(done) { | ||
page.connectGateway(config.gateway.name, 'USD', config.user.password).then(function() { done(); }); | ||
}); | ||
|
||
it('should show USD gateway', function(done) { | ||
expect(page.usdGatewayTitle).to.eventually.equal('USD - US Dollar') | ||
.and.notify(done); | ||
}); | ||
|
||
it('should remove a USD gateway', function(done) { | ||
page.removeGateway('USD').then(function() { done(); }); | ||
}); | ||
|
||
it('should show add gateway user controls (fake currency)', function(done) { | ||
page.connectGatewayButton.click().then(function() { | ||
expect(page.gatewayAddressInput.isDisplayed()) | ||
.to.eventually.be.true | ||
.and.notify(done); | ||
}); | ||
}); | ||
|
||
it('should connect a gateway with fake currency', function(done) { | ||
page.connectGateway(config.gateway.address, config.gateway.fakeCurrency, config.user.password).then(function() { done(); }); | ||
}); | ||
|
||
it('should show gateway with fake currency', function(done) { | ||
expect(page.gatewayTitle(config.gateway.fakeCurrency)).to.eventually.equal(config.gateway.fakeCurrency) | ||
.and.notify(done); | ||
}); | ||
|
||
it('should remove a fake currency gateway', function(done) { | ||
page.removeGateway(config.gateway.fakeCurrency).then(function() { done(); }); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
var AdvancedPage = function () { | ||
}; | ||
|
||
AdvancedPage.prototype = Object.create({}, { | ||
goTo: { value: function () { browser.get('#/advanced'); }}, | ||
|
||
editAdvancedSettingsButton: { get: function () { return $('form[name="accountsAdvForm"] div[ng-hide="editAcctOptions"] a.btn-cancel'); }}, | ||
showAdvancedOptionsInput: { get: function () { return $('input[name="acct_adv"]'); }}, | ||
saveAdvancedSettingsButton: { get: function () { return $('form[name="accountsAdvForm"] #save'); }}, | ||
advancedSettingsShowHolder: { get: function () { return $('form[name="accountsAdvForm"] div[ng-show="advanced_feature_switch"]'); }}, | ||
advancedSettingsHideHolder: { get: function () { return $('form[name="accountsAdvForm"] div[ng-hide="advanced_feature_switch"]'); }}, | ||
}); | ||
|
||
module.exports = AdvancedPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
'use strict'; | ||
|
||
var helperBrowser = require('../utils/browser'); | ||
|
||
var TrustPage = function () { | ||
}; | ||
|
||
TrustPage.prototype = Object.create({}, { | ||
goTo: { value: function () { browser.get('#/trust'); }}, | ||
|
||
connectGatewayButton: { get: function () { return $('.btn-add-trust a'); }}, | ||
gatewayAddressInput: { get: function () { return $('#trust_counterparty'); }}, | ||
trustFormSubmitButton: { get: function () { return $("form[name='trustForm'] a.btn.btn-primary.submit"); }}, | ||
currencyInput: { get: function () { return $('form[name="trustForm"] div[ng-hide="advanced_feature_switch"] #trust_amount_currency'); }}, | ||
confirmGatewayButton: { get: function () { return $("div.modal-dialog button.btn-default.btn-success"); }}, | ||
unlockPasswordInput: { get: function () { return $("div.modal-dialog #popup_unlock_password"); }}, | ||
unlockPasswordButton: { get: function () { return $("div.modal-dialog div.unlock-btns-wrapper button.modal-submit-btn"); }}, | ||
gatewayAddedHolder: { get: function () { return $('group.result-success h2'); }}, | ||
usdGatewayTitle: { get: function () { return $('div.currency-usd span.currency').getText(); }}, | ||
usdGatewayEditButton: { get: function () { return $('div.currency-usd div.lines a[ng-click="edit_account()"]'); }}, | ||
usdGatewayDeleteButton: { get: function () { return $('div.currency-usd div.lines span[ng-show="editing && !advanced_feature_switch"] button[ng-click="delete_account()"]'); }}, | ||
gatewayRemovedHolder: { get: function () { return $('group[on="notif"] group.result-success[ng-switch-when="gateway_removed"]'); }}, | ||
|
||
gatewayTitle: { value: function (currency) { | ||
return $('div.currency-' + currency.toLowerCase() + ' span.currency').getText(); | ||
}}, | ||
|
||
putAddress: { value: function (address, currency) { | ||
return this.gatewayAddressInput.sendKeys(address). | ||
then(this.currencyInput.clear). | ||
then(this.currencyInput.sendKeys.bind(this, currency)); | ||
}}, | ||
|
||
connectGateway: { value: function (addressOrName, currency, password) { | ||
return this.putAddress(addressOrName, currency).then(this.connectGatewaySubmit.bind(this, password)); | ||
}}, | ||
|
||
connectGatewaySubmit: { value: function (password) { | ||
var self = this; | ||
|
||
return helperBrowser.waitForElementToBecameAvailable(this.trustFormSubmitButton). | ||
then(this.trustFormSubmitButton.click). | ||
then(helperBrowser.waitForElementToDisplay.bind(self, this.confirmGatewayButton)). | ||
then(this.confirmGatewayButton.click). | ||
then(browser.sleep.bind(self, 1000)). | ||
then(this.unlockPasswordInput.isPresent). | ||
then(function(isUnlockDisplayed) { | ||
/// it should show password input | ||
if (isUnlockDisplayed) { | ||
return self.unlockPasswordInput.sendKeys(password).then(function() { | ||
protractor.getInstance().ignoreSynchronization = true; | ||
return self.unlockPasswordButton.click(); | ||
}); | ||
} else { | ||
return protractor.promise.fulfilled(true); | ||
} | ||
}). | ||
then(helperBrowser.waitForElementToDisplay.bind(self, this.gatewayAddedHolder)); | ||
}}, | ||
|
||
removeGateway: { value: function (currency) { | ||
return $('div.currency-' + currency.toLowerCase() + ' div.lines a[ng-click="edit_account()"]').click(). | ||
then($('div.currency-' + currency.toLowerCase() + ' div.lines span[ng-show="editing && !advanced_feature_switch"] button[ng-click="delete_account()"]').click). | ||
then(helperBrowser.waitForElement.bind(this, this.gatewayRemovedHolder)). | ||
then(browser.sleep.bind(this, 1000)); | ||
}}, | ||
|
||
|
||
// for gateway advanced test | ||
gatewayTrustAmountInput: { get: function () { return $('#trust_amount'); }}, | ||
advancedCurrencyInput: { get: function () { return $('form[name="trustForm"] div[ng-show="advanced_feature_switch"] #trust_amount_currency'); }}, | ||
// editLimitInput: { get: function () { return element(by.model('trust.limit')); }}, | ||
editLimitInput: { get: function () { return $('div.currency-usd input[name="limit"]'); }}, | ||
usdGatewaySaveButton: { get: function () { return $('div.currency-usd div.lines div[ng-show="editing && advanced_feature_switch"] #save'); }}, | ||
changesSavedHolder: { get: function () { return $('group[on="notif"] group.result-success[ng-switch-when="success"]'); }}, | ||
// exactBinding not working - protractor is too old :( | ||
// usdGatewayLimitHolder: { get: function () { return element(by.css('div.currency-usd div.lines ')).element(by.exactBinding('component.limit')); }}, | ||
usdGatewayLimitHolder: { get: function () { return $('div.currency-usd div.lines div[ng-show="advanced_feature_switch"] div.ng-binding'); }}, | ||
usdGatewayAdvancedDeleteButton: { get: function () { return $('div.currency-usd div.lines div[ng-show="editing && advanced_feature_switch"] button[ng-click="delete_account()"]'); }}, | ||
|
||
|
||
putAddressAdvanced: { value: function (address, currency, amount) { | ||
var self = this; | ||
return this.gatewayAddressInput.sendKeys(address). | ||
then(this.advancedCurrencyInput.clear). | ||
then(this.advancedCurrencyInput.sendKeys.bind(this, currency)). | ||
then(this.gatewayTrustAmountInput.clear). | ||
then(this.gatewayTrustAmountInput.sendKeys.bind(this, amount)); | ||
}}, | ||
|
||
}); | ||
|
||
module.exports = TrustPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
exports.waitForNavigation = function (part) { | ||
browser.wait(function () { | ||
return browser.wait(function () { | ||
return browser.driver.getCurrentUrl().then(function (url) { | ||
return !!url.match(part); | ||
}); | ||
}); | ||
}; | ||
|
||
exports.waitForElement = function (part) { | ||
browser.wait(function () { | ||
return part.isPresent().then(function (isPresent) { | ||
return isPresent; | ||
return browser.wait(part.isPresent); | ||
}; | ||
|
||
exports.waitForElementToDisplay = function (part) { | ||
return browser.wait(part.isDisplayed); | ||
}; | ||
|
||
exports.waitForElementToBecameAvailable = function (part) { | ||
return browser.wait(function () { | ||
return part.getAttribute('disabled').then(function (isDisabled) { | ||
return !isDisabled; | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
var protractor = require('protractor'); | ||
var helpers = require('./browser'); | ||
|
||
/* | ||
|