Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matt Raible
committed
May 2, 2018
1 parent
dce3b9d
commit 7042249
Showing
3 changed files
with
107 additions
and
0 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,30 @@ | ||
import { $, by, element } from 'protractor'; | ||
import { Page } from './app.po'; | ||
|
||
export class AddHoldingPage extends Page { | ||
cryptoCode = element.all(by.css('input[type=text]')).first(); | ||
displayCurrency = element.all(by.css('input[type=text]')).get(1); | ||
amountHolding = element.all(by.css('input[type=number]')); | ||
addHoldingButton = element(by.buttonText('Add Holding')); | ||
pageTitle = $('ion-title'); | ||
|
||
setCryptoCode(code) { | ||
this.cryptoCode.sendKeys(code); | ||
} | ||
|
||
setCurrency(currency) { | ||
this.displayCurrency.sendKeys(currency); | ||
} | ||
|
||
setAmount(amount) { | ||
this.amountHolding.sendKeys(amount); | ||
} | ||
|
||
clickAddHoldingButton() { | ||
this.addHoldingButton.click(); | ||
} | ||
|
||
getPageTitle() { | ||
return this.pageTitle; | ||
} | ||
} |
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,11 @@ | ||
import { by, element } from 'protractor'; | ||
import { Page } from './app.po'; | ||
|
||
export class HomePage extends Page { | ||
addCoinsButton = element(by.buttonText('Add Coins')); | ||
deleteButton = element.all(by.css('button[color=danger]')).last(); | ||
|
||
clickAddCoinsButton() { | ||
this.addCoinsButton.click(); | ||
} | ||
} |
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,66 @@ | ||
import { browser, element, by, protractor, ExpectedConditions as ec, $ } from 'protractor'; | ||
import { LoginPage } from '../pages/login.po'; | ||
import { AddHoldingPage } from '../pages/add-holding.po'; | ||
import { HomePage } from '../pages/home.po'; | ||
|
||
describe('Manage Holdings', () => { | ||
|
||
let loginPage, homePage, addHoldingPage; | ||
|
||
beforeAll(() => { | ||
loginPage = new LoginPage(); | ||
homePage = new HomePage(); | ||
addHoldingPage = new AddHoldingPage(); | ||
loginPage.navigateTo('/'); | ||
browser.waitForAngular(); | ||
}); | ||
|
||
beforeEach(() => { | ||
loginPage.clickLoginButton(); | ||
loginPage.login(process.env.E2E_USERNAME, process.env.E2E_PASSWORD); | ||
loginPage.oktaLoginButton.click(); | ||
|
||
browser.wait(ec.urlContains('home'), 5000); | ||
}); | ||
|
||
afterEach(() => { | ||
loginPage.logout(); | ||
}); | ||
|
||
it('should add and remove a holding', () => { | ||
homePage.clickAddCoinsButton(); | ||
|
||
browser.wait(ec.urlContains('add-holding'), 1000); | ||
|
||
addHoldingPage.setCryptoCode('BTC'); | ||
addHoldingPage.setCurrency('USD'); | ||
addHoldingPage.setAmount(3); | ||
addHoldingPage.clickAddHoldingButton(); | ||
|
||
// wait for everything to happen | ||
browser.wait(ec.urlContains('home'), 5000); | ||
|
||
// verify message is removed and holding shows up | ||
element.all(by.css('.message')).then((message) => { | ||
expect(message.length).toBe(0); | ||
}); | ||
|
||
// wait for holding to show up | ||
const addedHolding = element.all(by.css('ion-item')).last(); | ||
browser.wait(ec.presenceOf(addedHolding), 5000).then(() => { | ||
|
||
// delete the holding - https://forum.ionicframework.com/t/move-ion-item-sliding-by-protractor/106918 | ||
browser.actions().mouseDown(addedHolding) | ||
.mouseMove({x: -50, y: 0}) | ||
.mouseMove({x: -50, y: 0}) | ||
.mouseMove({x: -50, y: 0}) | ||
.mouseUp() | ||
.perform(); | ||
|
||
homePage.deleteButton.click(); | ||
element.all(by.css('.message')).then((message) => { | ||
expect(message.length).toBe(1); | ||
}); | ||
}); | ||
}); | ||
}); |