Skip to content

Commit

Permalink
New test functions working
Browse files Browse the repository at this point in the history
  • Loading branch information
mistergone committed Aug 10, 2016
1 parent e39a45c commit b2b5d20
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 17 deletions.
2 changes: 1 addition & 1 deletion paying_for_college/templates/worksheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<span class="u-visually-hidden">Menu</span></a>
{% endblock %}
{% block content %}
<main data-context="{{url_root}}">
<main id="main" data-context="{{url_root}}">
<div class="understanding-financial-aid-offer">
<section class="content_hero hero hero__intro">
<div class="hero_wrapper wrapper">
Expand Down
1 change: 1 addition & 0 deletions src/disclosures/js/views/financial-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var financialView = {
this.resetPrivateLoanView();
this.continueStep2Listener();
this.termToggleListener();
$( 'main' ).data( 'getFinancial', getFinancial );
},

/**
Expand Down
102 changes: 86 additions & 16 deletions test/functional/dd-functional-settlement-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@

var SettlementPage = require( './settlementAidOfferPage.js' );

function getFinancial( prop ) {
var script = "$( 'main' ).attr( 'data-test', $( 'main' ).data().getFinancial.values()." +
prop + " );";
browser.executeScript( script );
return $( '#main' ).getAttribute( 'data-test').then( function( attr) {
return attr;
} );
}

function cleanNumber( string ) {
return string.replace( /[^0-9\.]+/g, '' );
}

function waitForNumbers( page ) {
return browser.wait(
function() {
return page.totalCostOfAttendance.getText().then(
function( text ) {
return text !== 'Updating...' && text !== '0';
} );
}
)
}

fdescribe( 'A dynamic financial aid disclosure that\'s required by settlement', function() {
var page;
var EC = protractor.ExpectedConditions;
Expand Down Expand Up @@ -94,35 +118,81 @@ fdescribe( 'A dynamic financial aid disclosure that\'s required by settlement',
// Remaining cost (before loans): $14,026
// Remaining cost (after loans): -$474

// it( 'should display the correct name for the college', function() {
// page.confirmVerification();
// expect( page.schoolName.getText() ).toEqual( 'Brown Mackie College-Fort Wayne' );
// } );

it( 'should display the correct name for the college', function() {
page.confirmVerification();
expect( page.schoolName.getText() ).toEqual( 'Brown Mackie College-Fort Wayne' );
getFinancial( 'school' ).then( function( attr ) {
expect( page.schoolName.getText() ).toEqual( attr );
} );
} );

it( 'should let a student edit the tuition and fees', function() {
page.confirmVerification();
expect( page.tuitionFeesCosts.isEnabled() ).toEqual( true );
} );

// it( 'should show correct totals on load', function() {
// page.confirmVerification();
// expect( page.totalCostOfAttendance.getText() ).toEqual( '43,626' );
// expect( page.studentTotalCost.getText() ).toEqual( '32,026' );
// expect( page.remainingCostFinal.getText() ).toEqual( '2,526' );
// } );

it( 'should show correct totals on load', function() {
page.confirmVerification();
expect( page.totalCostOfAttendance.getText() ).toEqual( '43,626' );
expect( page.studentTotalCost.getText() ).toEqual( '32,026' );
expect( page.remainingCostFinal.getText() ).toEqual( '2,526' );
waitForNumbers( page )
.then(
function() {
page.totalCostOfAttendance.getText().then( function( attr ) {
attr = cleanNumber( attr );
expect( getFinancial( 'costOfAttendance' ) ).toEqual( attr );
} );
page.studentTotalCost.getText().then( function( attr ) {
attr = cleanNumber( attr );
expect( getFinancial( 'firstYearNetCost' ) ).toEqual( attr );
} );
page.remainingCostFinal.getText().then( function( attr ) {
attr = cleanNumber( attr );
expect( getFinancial( 'gap' ) ).toEqual( attr );
} );
}
);
} );

it( 'should properly update when the tuition and fees are modified', function() {
page.confirmVerification();
browser.wait(
page.setTuitionFeesCosts( 48976 ).then(
function() {
browser.sleep(500);
expect( page.totalCostOfAttendance.getText() ).toEqual( '53,626' );
expect( page.studentTotalCost.getText() ).toEqual( '42,026' );
expect( page.remainingCostFinal.getText() ).toEqual( '12,526' );
}
), 10000
);
fit( 'should properly update when the tuition and fees are modified', function() {
page.confirmVerification();

waitForNumbers( page )
.then(
function() {
page.totalCostOfAttendance.getText().then( function( attr ) {
attr = cleanNumber( attr );
expect( getFinancial( 'costOfAttendance' ) ).toEqual( attr );
} );
page.studentTotalCost.getText().then( function( attr ) {
attr = cleanNumber( attr );
expect( getFinancial( 'firstYearNetCost' ) ).toEqual( attr );
} );
page.remainingCostFinal.getText().then( function( attr ) {
attr = cleanNumber( attr );
expect( getFinancial( 'gap' ) ).toEqual( attr );
} );
} );

// browser.wait(
// page.setTuitionFeesCosts( 48976 ).then(
// function() {
// browser.sleep(500);
// expect( page.totalCostOfAttendance.getText() ).toEqual( '53,626' );
// expect( page.studentTotalCost.getText() ).toEqual( '42,026' );
// expect( page.remainingCostFinal.getText() ).toEqual( '12,526' );
// }
// ), 10000
// );
} );

it( 'should properly update when the housing and meals are modified', function() {
Expand Down

0 comments on commit b2b5d20

Please sign in to comment.