Last active
July 20, 2016 17:39
-
-
Save rossPatton/ba89379c6f729e471d427d248afca095 to your computer and use it in GitHub Desktop.
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
'use strict' | |
/** | |
* api docs: http://webdriver.io/api.html | |
* config: wdio.conf.js | |
*/ | |
/** | |
* @description run mocha unit tests against a multi program report | |
* in review mode, so we can check codeMirror, QA links, etc | |
* RUN ON PROD=true gulp | |
*/ | |
describe('\n./test/ui/unit/faxMultiProgram', function() { | |
this.timeout(0) | |
// for convenience | |
const b = browser | |
// set up browser for current run of tests | |
before(function *() { | |
yield b.url('http://localhost:3000/report/k5tL17kkjb/doctor-view?reportWeek=10&type=fax&name=tester&birthDate=03211987') | |
yield b.setViewportSize({ | |
width: 1400, | |
height: 960, | |
}) | |
}) | |
it('fax header should have patient name and dob (fmp)', function *() { | |
yield b.waitForVisible('//*[@id="fax"]/div/div/div[2]', 10000) | |
const faxHdr = '//*[@id="fax"]/div/div/div[2]' | |
yield b.getText(faxHdr) | |
.should.eventually.equal('Patient name: tester\nDate of birth: 02-06-1970') | |
}) | |
it('validate doctor notes (fmp)', function *() { | |
const minimal = '//*[@id="fax"]/div/div/section[1]/div[1]/ul/li[1]' | |
yield b.getText(minimal) | |
.should.eventually.include('Minimal symptoms (currently)') | |
}) | |
it('validate annotations (fmp)', function *() { | |
const anno = '//*[@id="fax"]/div/div/section[1]/div[2]/ul[1]/li' | |
const state = '//*[@id="fax"]/div/div/section[1]/div[2]/ul[1]/li/div[1]' | |
const med = '//*[@id="fax"]/div/div/section[1]/div[2]/ul[1]/li/div[2]' | |
const dose = '//*[@id="fax"]/div/div/section[1]/div[2]/ul[1]/li/div[3]' | |
// first anno should say started | |
yield b.getText(state) | |
.should.eventually.equal('Restarted Tracking') | |
yield b.getText(med) | |
.should.eventually.equal('Escitalopram') | |
yield b.getText(dose) | |
.should.eventually.equal('10mg once a day') | |
}) | |
it('validate scores (fmp)', function *() { | |
const scores = '//*[@id="fax"]/div/div/section[1]/div[2]/ul[2]' | |
const score1 = '//*[@id="fax"]/div/div/section[1]/div[2]/ul[2]/li[2]/span' | |
const score2 = '//*[@id="fax"]/div/div/section[1]/div[2]/ul[2]/li[4]/span' | |
const score3 = '//*[@id="fax"]/div/div/section[1]/div[2]/ul[2]/li[6]/span' | |
const score4 = '//*[@id="fax"]/div/div/section[1]/div[2]/ul[2]/li[8]/span' | |
// we only show past 2 months on doctor view | |
yield b.execute(function () { | |
return document | |
.getElementsByClassName('chart-scores')[0] | |
.childElementCount | |
}) | |
.then(val => val.value) | |
.should.eventually.equal(10) | |
yield b.getText(score1).should.eventually.equal('8') | |
yield b.getText(score2).should.eventually.equal('7') | |
yield b.getText(score3).should.eventually.equal('6') | |
yield b.getText(score4).should.eventually.equal('3') | |
const color = yield b.getCssProperty(score1, 'color') | |
color.parsed.hex.should.equal('#000000') | |
}) | |
it('validate current medication (fmp)', function *() { | |
const med = '//*[@id="fax"]/div/div/section[2]/p' | |
yield b.getText(med) | |
.should.eventually.equal('Escitalopram 10 mg once a day') | |
}) | |
it('validate adherence and worth (fmp)', function *() { | |
const date1 = '//*[@id="fax"]/div/div/section[3]/ul/li[1]/div[1]' | |
const date3 = '//*[@id="fax"]/div/div/section[3]/ul/li[3]/div[1]' | |
const adherent1 = '//*[@id="fax"]/div/div/section[3]/ul/li[1]/div[2]/span' | |
const worth1 = '//*[@id="fax"]/div/div/section[3]/ul/li[1]/div[3]/span' | |
const adherent3 = '//*[@id="fax"]/div/div/section[3]/ul/li[3]/div[2]/span' | |
const worth3 = '//*[@id="fax"]/div/div/section[3]/ul/li[3]/div[3]/span' | |
yield b.getText(date1) | |
.should.eventually.equal('Feb 5-Feb 19') | |
const color1 = yield b.getCssProperty(date1, 'color') | |
color1.parsed.hex.should.equal('#000000') | |
yield b.getText(date3) | |
.should.eventually.equal('Mar 4-Mar 18') | |
yield b.getText(adherent1) | |
.should.eventually.equal('Adherent') | |
const color2 = yield b.getCssProperty(adherent1, 'color') | |
color2.parsed.hex.should.equal('#000000') | |
yield b.getText(adherent3) | |
.should.eventually.equal('Adherent') | |
yield b.getText(worth1) | |
.should.eventually.equal('Satisfied') | |
const color3 = yield b.getCssProperty(worth1, 'color') | |
color3.parsed.hex.should.equal('#000000') | |
yield b.getText(worth3) | |
.should.eventually.equal('Satisfied') | |
}) | |
it('validate issues (fmp)', function *() { | |
const recentIssue = '//*[@id="fax"]/div/div/section[4]/ul/li[2]' | |
yield b.getText(recentIssue) | |
.should.eventually.equal('Finding motivation to do things') | |
const color = yield b.getCssProperty(recentIssue, 'color') | |
color.parsed.hex.should.equal('#000000') | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment