Skip to content

Commit

Permalink
fix(Tests): All e2e tests working in Firefox
Browse files Browse the repository at this point in the history
Notable changes:
* Add a conditional "reload if Firefox" method that will force page
  reloads in-between tests. FF apparently doesn't do this automatically,
  perhaps only/esp. on localhost.j
* Had to split the cancelFilter helper function into two, one for the 208
  tutorial and one for 103. For some reason each required a different
  selector to get the right button to click. This can be fixed later
* Updated Selenium version
* Reworked many click events to use a combo of mouseUp() and mouseDown().
  Firefox was not liking
* In FF the navbar header would overlay controls and intercept click
 events. An addition was made to the firefox check method that removes the
 header before testing begins.
  • Loading branch information
c0bra committed Jun 15, 2015
1 parent 6d364d4 commit b9cc39f
Show file tree
Hide file tree
Showing 16 changed files with 571 additions and 288 deletions.
13 changes: 9 additions & 4 deletions grunt/aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ module.exports = function (grunt, options) {
'test:ci-e2e': ['clean', 'build', 'connect:testserver', 'protractor:ci']
};

if (grunt.option('e2e') === false || grunt.option('fast') ){
baseTasks['dev'] = ['before-test', 'after-test', 'connect', 'autotest:unit', 'autotest:e2e', 'watch'];

if (grunt.option('e2e') === false || grunt.option('fast')) {
grunt.log.writeln("Skipping e2e testing...");
baseTasks['dev'] = ['before-test', 'after-test', 'connect', 'autotest:unit', 'watch'];
} else {
baseTasks['dev'] = ['before-test', 'after-test', 'connect', 'autotest:unit', 'autotest:e2e', 'watch'];
baseTasks['dev'].splice(baseTasks['dev'].indexOf('autotest:e2e', 1));
}

if (grunt.option('unit') === false) {
grunt.log.writeln("Skipping unit testing...");
baseTasks['dev'].splice(baseTasks['dev'].indexOf('autotest:unit', 1));
}

if (process.env.TRAVIS){
Expand Down
173 changes: 112 additions & 61 deletions misc/tutorial/102_sorting.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Multiple columns can be sorted by shift-clicking on the 2-n columns. To see it

When sorting using the menus, the sorts are additive. So if you have one column sorted and you pick another sort
from a column menu, it will add on to the existing sort rather than replacing it. You need to use the 'remove sort' option
on the existing column if you don't want to sort by it any more.
on the existing column if you don't want to sort by it any more.

When sorting using the headers, clicking on a header removes all other sorts unless you shift-click.

Expand All @@ -26,8 +26,8 @@ If you set a default sort, you can prevent the user from removing that sort by s
for that column. This will let the user change the direction of the sort, but take away the option to remove the sort.

The sort algorithm is chosen based on the column type. ui-grid will guess the type based on the data, although if you load data
asynchronously after the columns it will often decide all your columns are string. You can explicitly set the column type in the
column def using `type='number'`. Valid types are documented in {@link api/ui.grid.class:GridOptions.columnDef columnDef}, and
asynchronously after the columns it will often decide all your columns are string. You can explicitly set the column type in the
column def using `type='number'`. Valid types are documented in {@link api/ui.grid.class:GridOptions.columnDef columnDef}, and
include `string`, `number`, `numberStr` and `date`. If you use date be aware the code expects a javascript date object.

<example module="app">
Expand All @@ -46,7 +46,7 @@ include `string`, `number`, `numberStr` and `date`. If you use date be aware th
$scope.grid1Api = gridApi;
}
};

$scope.toggleGender = function() {
if( $scope.gridOptions1.data[64].gender === 'male' ) {
$scope.gridOptions1.data[64].gender = 'female';
Expand Down Expand Up @@ -124,8 +124,8 @@ include `string`, `number`, `numberStr` and `date`. If you use date be aware th
<div id="grid1" ui-grid="gridOptions1" class="grid"></div>

<br>
You can set an initial sort state for the grid by defining the `sort` property on your column definitions.
The `direction` sub-property says which way to sort, and the `priority` says what order to sort the columns
You can set an initial sort state for the grid by defining the `sort` property on your column definitions.
The `direction` sub-property says which way to sort, and the `priority` says what order to sort the columns
in (lower priority gets sorted first).
<br>
<br>
Expand All @@ -141,71 +141,100 @@ include `string`, `number`, `numberStr` and `date`. If you use date be aware th
</file>
<file name="scenario.js">
var gridTestUtils = require('../../test/e2e/gridTestUtils.spec.js');

describe('first grid on the page, no default sort', function() {
// Reload the page before each test if on Firefox. Chrome does it automatically.
gridTestUtils.firefoxReload();

it('grid should have three visible columns', function () {
gridTestUtils.expectHeaderColumnCount( 'grid1', 3 );
});

it('header values should be as expected', function () {
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 0, 'Name' );
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 1, 'Gender' );
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 2, 'Company' );
});

it('grid should be unsorted by default', function () {
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Ethel Price' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Claudine Neal' );
});

it('sort by name by clicking header', function () {
gridTestUtils.clickHeaderCell( 'grid1', 0 );
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Alexander Foley' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Alisha Myers' );
gridTestUtils.clickHeaderCell( 'grid1', 0 )
.then(function () {
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Alexander Foley' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Alisha Myers' );
});
});

it('reverse sort by name by clicking header', function () {
gridTestUtils.clickHeaderCell( 'grid1', 0 );
gridTestUtils.clickHeaderCell( 'grid1', 0 );
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Yvonne Parsons' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Woods Key' );
gridTestUtils.clickHeaderCell( 'grid1', 0 )
.then(function () {
return gridTestUtils.clickHeaderCell( 'grid1', 0 );
})
.then(function () {
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Yvonne Parsons' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Woods Key' );
});
});

it('return to original sort by name by clicking header', function () {
gridTestUtils.clickHeaderCell( 'grid1', 0 );
gridTestUtils.clickHeaderCell( 'grid1', 0 );
gridTestUtils.clickHeaderCell( 'grid1', 0 );
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Ethel Price' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Claudine Neal' );
gridTestUtils.clickHeaderCell( 'grid1', 0 )
.then(function () {
return gridTestUtils.clickHeaderCell( 'grid1', 0 );
})
.then(function () {
return gridTestUtils.clickHeaderCell( 'grid1', 0 );
})
.then(function () {
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Ethel Price' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Claudine Neal' );
});
});

it('sort asc by clicking menu', function() {
gridTestUtils.clickColumnMenuSortAsc( 'grid1', 0 );
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Alexander Foley' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Alisha Myers' );
gridTestUtils.clickColumnMenuSortAsc( 'grid1', 0 )
.then(function () {
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Alexander Foley' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Alisha Myers' );
});
});

it('sort desc by clicking menu, then remove sort', function() {
gridTestUtils.clickColumnMenuSortDesc( 'grid1', 0 );
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Yvonne Parsons' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Woods Key' );

gridTestUtils.clickColumnMenuRemoveSort( 'grid1', 0 );
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Ethel Price' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Claudine Neal' );
gridTestUtils.clickColumnMenuSortDesc( 'grid1', 0 )
.then(function () {
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Yvonne Parsons' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Woods Key' );
return true;
})
.then(function () {
return gridTestUtils.clickColumnMenuRemoveSort( 'grid1', 0 );
})
.then(function () {
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Ethel Price' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Claudine Neal' );
});
});

it('sort two columns, gender then name, by shift clicking', function() {
gridTestUtils.clickHeaderCell( 'grid1', 1 );
gridTestUtils.shiftClickHeaderCell( 'grid1', 0 );
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Alisha Myers' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Beryl Rice' );
gridTestUtils.clickHeaderCell( 'grid1', 1 )
.then(function () {
return gridTestUtils.shiftClickHeaderCell( 'grid1', 0 );
})
.then(function () {
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Alisha Myers' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Beryl Rice' );
});
});

it('sort disabled on last column', function() {
gridTestUtils.clickHeaderCell( 'grid1', 2 );
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Ethel Price' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Claudine Neal' );
gridTestUtils.clickHeaderCell( 'grid1', 2 )
.then(function () {
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Ethel Price' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Claudine Neal' );
});
});

it('click one menu, then click another menu, expect undisplay and redisplay on second click', function() {
Expand All @@ -215,14 +244,28 @@ include `string`, `number`, `numberStr` and `date`. If you use date be aware th

it('toggle gender, expect Alexander Foley to move around', function() {
// sort gender asc, then name
gridTestUtils.clickHeaderCell( 'grid1', 1 );
gridTestUtils.clickHeaderCell( 'grid1', 1 );
gridTestUtils.shiftClickHeaderCell( 'grid1', 0 );
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Alexander Foley' );
element(by.id('toggleGender')).click();
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Anthony Joyner' );
element(by.id('toggleGender')).click();
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Alexander Foley' );
gridTestUtils.clickHeaderCell( 'grid1', 1 )
.then(function () {
return gridTestUtils.clickHeaderCell( 'grid1', 1 );
})
.then(function () {
return gridTestUtils.shiftClickHeaderCell( 'grid1', 0 );
})
.then(function () {
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Alexander Foley' );
})
.then(function () {
return gridTestUtils.click(element(by.id('toggleGender')));
})
.then(function () {
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Anthony Joyner' );
})
.then(function () {
return gridTestUtils.click(element(by.id('toggleGender')));
})
.then(function () {
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Alexander Foley' );
});
});

});
Expand All @@ -232,29 +275,37 @@ include `string`, `number`, `numberStr` and `date`. If you use date be aware th
it('grid should have three visible columns', function () {
gridTestUtils.expectHeaderColumnCount( 'grid2', 3 );
});

it('header values should be as expected', function () {
gridTestUtils.expectHeaderCellValueMatch( 'grid2', 0, 'Name' );
gridTestUtils.expectHeaderCellValueMatch( 'grid2', 1, 'Gender' );
gridTestUtils.expectHeaderCellValueMatch( 'grid2', 2, 'Company' );
});

it('grid should be sorted by default', function () {
gridTestUtils.expectCellValueMatch( 'grid2', 0, 0, 'Yvonne Parsons' );
gridTestUtils.expectCellValueMatch( 'grid2', 1, 0, 'Velma Fry' );
});

it('sort on second column can\'t be removed when cycle through header clicks', function () {
gridTestUtils.clickHeaderCell( 'grid2', 0 );
gridTestUtils.expectCellValueMatch( 'grid2', 0, 0, 'Ethel Price' );

gridTestUtils.clickHeaderCell( 'grid2', 1 );
gridTestUtils.expectCellValueMatch( 'grid2', 0, 0, 'Wilder Gonzales' );

gridTestUtils.clickHeaderCell( 'grid2', 1 );
gridTestUtils.expectCellValueMatch( 'grid2', 0, 0, 'Ethel Price' );
gridTestUtils.clickHeaderCell( 'grid2', 0 )
.then(function () {
gridTestUtils.expectCellValueMatch( 'grid2', 0, 0, 'Ethel Price' );
})
.then(function () {
return gridTestUtils.clickHeaderCell( 'grid2', 1 );
})
.then(function () {
gridTestUtils.expectCellValueMatch( 'grid2', 0, 0, 'Wilder Gonzales' );
})
.then(function () {
return gridTestUtils.clickHeaderCell( 'grid2', 1 );
})
.then(function () {
gridTestUtils.expectCellValueMatch( 'grid2', 0, 0, 'Ethel Price' );
});
});
});

</file>
</file>
</example>
Loading

0 comments on commit b9cc39f

Please sign in to comment.