Skip to content

Commit

Permalink
added tests for negative order
Browse files Browse the repository at this point in the history
  • Loading branch information
bkimminich committed Oct 30, 2014
1 parent 681d2d3 commit d2529a7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/views/Basket.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h3 class="page-header page-header-sm">Your Basket</h3>
</table>

<div class="container-fluid well">
<button type="submit" class="btn btn-default" ng-disabled="products.length < 1" ng-click="checkout()">Checkout</button>
<button type="submit" id="checkoutButton" class="btn btn-default" ng-disabled="products.length < 1" ng-click="checkout()">Checkout</button>
</div>
</div>
</div>
Expand Down
31 changes: 19 additions & 12 deletions test/e2e/basketSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,39 @@ describe('/#/basket', function () {

protractor.beforeEach.login({email: '[email protected]', password: 'admin123'});

describe('challenge "accessBasket"', function () {
describe('challenge "negativeOrder"', function () {

it('should access basket with id from cookie instead of the one associated to logged-in user', function () {
browser.executeScript('window.sessionStorage.bid = 2;');
it('should be possible to update a basket to a negative quantity via the Rest API', function () {
browser.ignoreSynchronization = true;
browser.executeScript('var $http = angular.injector([\'myApp\']).get(\'$http\'); $http.put(\'/api/BasketItems/1\', {quantity: -100});');
browser.driver.sleep(1000);

browser.get('/#/basket');
browser.ignoreSynchronization = false;

// TODO Verify functionally that it's not the basket of the admin
var productQuantities = element.all(by.repeater('product in products').column('basketItem.quantity'));
expect(productQuantities.first().getText()).toMatch(/-100/);
});

protractor.expect.challengeSolved({challenge: 'accessBasket'});
it('should be possible to place an order with a negative total amount', function () {
element(by.id('checkoutButton')).click();
});

protractor.expect.challengeSolved({challenge: 'negativeOrder'});

});

describe('challenge "negativeOrder"', function () {
describe('challenge "accessBasket"', function () {

xit('should be possible to put an item with negative price into the basket', function () {
});
it('should access basket with id from cookie instead of the one associated to logged-in user', function () {
browser.executeScript('window.sessionStorage.bid = 2;');

xit('should be possible to put an item with negative quantity into the basket', function () {
});
browser.get('/#/basket');

xit('should be possible to place an order with a negative total amount', function () {
// TODO Verify functionally that it's not the basket of the admin
});

//protractor.expect.challengeSolved({challenge: 'negativeOrder'});
protractor.expect.challengeSolved({challenge: 'accessBasket'});

});

Expand Down

0 comments on commit d2529a7

Please sign in to comment.