diff --git a/.eslintignore b/.eslintignore index 6ab37e773a..ba4edb4748 100644 --- a/.eslintignore +++ b/.eslintignore @@ -75,7 +75,6 @@ app/cdash/tests/js/pages/catchConsoleErrors.page.js app/cdash/tests/js/e2e_tests/viewTestPagination.js app/cdash/tests/js/e2e_tests/viewSubProjects.js app/cdash/tests/js/e2e_tests/subprojectGroupOrder.js -app/cdash/tests/js/e2e_tests/sort_index.js app/cdash/tests/js/e2e_tests/remove_build.js app/cdash/tests/js/e2e_tests/multiSort.js app/cdash/tests/js/e2e_tests/done_build.js diff --git a/app/cdash/tests/js/e2e_tests/CMakeLists.txt b/app/cdash/tests/js/e2e_tests/CMakeLists.txt index d2fa0c674e..3602747a87 100644 --- a/app/cdash/tests/js/e2e_tests/CMakeLists.txt +++ b/app/cdash/tests/js/e2e_tests/CMakeLists.txt @@ -23,7 +23,7 @@ add_cypress_e2e_test(manage-build-group) add_cypress_e2e_test(manage-sub-project) add_cypress_e2e_test(view-build-error) add_cypress_e2e_test(view-test) -add_protractor_test(sort_index) +add_cypress_e2e_test(sort-index) add_cypress_e2e_test(expected-build) add_protractor_test(remove_build) add_protractor_test(viewSubProjects) diff --git a/app/cdash/tests/js/e2e_tests/sort_index.js b/app/cdash/tests/js/e2e_tests/sort_index.js deleted file mode 100644 index f35f715c6c..0000000000 --- a/app/cdash/tests/js/e2e_tests/sort_index.js +++ /dev/null @@ -1,123 +0,0 @@ -require('../pages/catchConsoleErrors.page.js'); -describe("sort_index", function() { - - function sort_test(field, column_index, first_value, last_value) { - browser.get('index.php?project=InsightExample&date=2010-07-07'); - - // Mitigate default sorting by clicking on some other header first. - var different_index = 0; - if (column_index == 0) { - different_index = 1; - } - var different_header = element.all(by.className('table-heading')).all(by.tagName('th')).filter(function(elem) { return elem.isDisplayed(); }).get(different_index); - different_header.click(); - - // Make sure this is the header we think it is. - var header = element.all(by.className('table-heading')).all(by.tagName('th')).filter(function(elem) { return elem.isDisplayed(); }).get(column_index); - expect(header.getText()).toBe(field); - - // Click the header to sort by the specified field. - header.click(); - - // Make sure the sort indicator has the class we expect. - expect(header.element(by.tagName('span')).getAttribute('class')).toContain("glyphicon-chevron-down"); - - // Filter out the table cells that aren't currently displayed. - var visible_tds = element(by.repeater('build in buildgroup.pagination.filteredBuilds').row(0)).all(by.tagName('td')).filter(function(elem) { return elem.isDisplayed(); }); - - // Check that the expected value is at the top of the list. - expect(visible_tds.get(column_index).getText()).toBe(first_value); - - // Reverse order & check values again. - header.click(); - expect(header.element(by.tagName('span')).getAttribute('class')).toContain("glyphicon-chevron-up"); - expect(visible_tds.get(column_index).getText()).toBe(last_value); - - // Reload the page and make sure we get the same result. - // This tests that our cookies are set & read correctly. - browser.get('index.php?project=InsightExample&date=2010-07-07'); - expect(visible_tds.get(column_index).getText()).toBe(last_value); - - // Delete the cookie. - // browser.manage().deleteAllCookies(); - browser.manage().deleteCookie('cdash_InsightExample_indexNightly_sort'); - } - - it("sort by Site", function() { - sort_test('Site', 0, 'thurmite.kitware', 'dash13.kitware'); - }); - - it("sort by Build Name", function() { - sort_test('Build Name', 1, 'zApps-Win32-vs60', 'zApp-Win64-Vista-vs9-Release'); - }); - - it("sort by Updated Files", function() { - sort_test('Files', 2, '4', '0'); - }); - - it("sort by Configure Errors", function() { - sort_test('Error', 3, '2', '0'); - }); - - it("sort by Configure Warnings", function() { - sort_test('Warn', 4, '2', '0'); - }); - - it("sort by Build Errors", function() { - sort_test('Error', 5, '2', '0'); - }); - - it("sort by Build Warnings", function() { - sort_test('Warn', 6, '3', '0'); - }); - - it("sort by Test Not Run", function() { - sort_test('Not Run', 7, '3', '1'); - }); - - it("sort by Test Fail", function() { - sort_test('Fail', 8, '3', '1'); - }); - - it("sort by Test Pass", function() { - sort_test('Pass', 9, '3', '1'); - }); - - it("sort by Start Time", function() { - sort_test('Start Time', 10, 'Jul 07, 2010 - 12:26 UTC', 'Jul 07, 2010 - 12:22 UTC'); - }); - - it("sort by multiple columns", function() { - browser.get('index.php?project=InsightExample&date=2010-07-07'); - - // Clear default sorting by clicking on the Site header. - var site_header = element.all(by.className('table-heading')).all(by.tagName('th')).filter(function(elem) { return elem.isDisplayed(); }).get(0); - site_header.click(); - - // Click on the Build Time header. - var buildtime_header = element.all(by.className('table-heading')).all(by.tagName('th')).filter(function(elem) { return elem.isDisplayed(); }).get(10); - expect(buildtime_header.getText()).toBe('Start Time'); - buildtime_header.click(); - expect(buildtime_header.element(by.tagName('span')).getAttribute('class')).toContain("glyphicon-chevron-down"); - - // Then hold down shift and click on Test Pass header. - var pass_header = element.all(by.className('table-heading')).all(by.tagName('th')).filter(function(elem) { return elem.isDisplayed(); }).get(9); - - browser.actions().mouseMove(pass_header).keyDown(protractor.Key.SHIFT).click().perform(); - expect(pass_header.element(by.tagName('span')).getAttribute('class')).toContain("glyphicon-chevron-down"); - - // Filter out the table cells that aren't currently displayed. - var visible_tds = element(by.repeater('build in buildgroup.pagination.filteredBuilds').row(0)).all(by.tagName('td')).filter(function(elem) { return elem.isDisplayed(); }); - - // Check that the expected build is at the top of the list. - expect(visible_tds.get(0).getText()).toBe('dash13.kitware'); - - // Reverse order & check values again. - pass_header.click(); - //browser.actions().mouseMove(pass_header).keyDown(protractor.Key.SHIFT).click().perform(); - expect(pass_header.element(by.tagName('span')).getAttribute('class')).toContain("glyphicon-chevron-up"); - expect(visible_tds.get(0).getText()).toBe('thurmite.kitware'); - }); - - -}); diff --git a/tests/cypress/e2e/sort-index.cy.js b/tests/cypress/e2e/sort-index.cy.js new file mode 100644 index 0000000000..1ff071e963 --- /dev/null +++ b/tests/cypress/e2e/sort-index.cy.js @@ -0,0 +1,158 @@ +describe('sort_index', () => { + + // these two "verify_<>_cell" functions help getting the text from all + // child elements of the td, since it may contain links, formatting, etc. + function _verify_cell(position, td_alias, expected_value) { + cy.get(td_alias).invoke(position).invoke('text').then(td_text => { + cy.wrap(td_text.trim()).should('contain', expected_value); + }); + } + + function verify_first_cell(td_alias, expected_value) { + _verify_cell('first', td_alias, expected_value); + } + + function verify_last_cell(td_alias, expected_value) { + _verify_cell('last', td_alias, expected_value); + } + + function sort_test(field, column_index, first_value, last_value) { + // mitigate default sorting by clicking on some other header first + const different_index = column_index === 0 ? 1 : 0; + cy.get('tr.table-heading > th').eq(different_index).click(); + + // click the header to sort by the specified field + cy.get('tr.table-heading > th').eq(column_index).should('contain', field).as('header'); + cy.get('@header').click(); + + // make sure the right sort indicator is displayed + cy.get('@header').find('span').should('have.class', 'glyphicon-chevron-down'); + + // filter out the table cells from the targeted column + cy.get('tbody').find(`tr td:visible:nth-child(${column_index+1})`).as('column_tds'); + + // check that the expected value is at the top of the list + verify_first_cell('@column_tds', first_value); + verify_last_cell('@column_tds', last_value); + + // reverse order & check values again + cy.get('@header').click(); + cy.get('@header').find('span').should('have.class', 'glyphicon-chevron-up'); + cy.get('tbody').find(`tr td:visible:nth-child(${column_index+1})`).as('column_tds'); + verify_first_cell('@column_tds', last_value); + verify_last_cell('@column_tds', first_value); + + // reload the page and make sure we get the same result + // to test that our cookies are set & read correctly + cy.reload(); + verify_first_cell('@column_tds', last_value); + verify_last_cell('@column_tds', first_value); + } + + beforeEach(() => { + cy.clearCookies(); + cy.visit('index.php?project=InsightExample&date=2010-07-07'); + }); + + it('is sortable by Site', () => { + sort_test('Site', 0, 'thurmite.kitware', 'dash13.kitware'); + }); + + it('is sortable by Build Name', () => { + sort_test('Build Name', 1, 'zApps-Win32-vs60', 'zApp-Win64-Vista-vs9-Release'); + }); + + it('is sortable by Updated Files', () => { + sort_test('Files', 2, '4', '0'); + }); + + it('is sortable by Configure Errors', () => { + sort_test('Error', 3, '2', '0'); + }); + + it('is sortable by Configure Warnings', () => { + sort_test('Warn', 4, '2', '0'); + }); + + it('is sortable by Build Errors', () => { + sort_test('Error', 5, '2', '0'); + }); + + it('is sortable by Build Warnings', () => { + sort_test('Warn', 6, '3', '0'); + }); + + it('is sortable by Test Not Run', () => { + sort_test('Not Run', 7, '3', '1'); + }); + + it('is sortable by Test Fail', () => { + sort_test('Fail', 8, '3', '1'); + }); + + it('is sortable by Test Pass', () => { + sort_test('Pass', 9, '3', '1'); + }); + + it('is sortable by Start Time', () => { + sort_test('Start Time', 10, 'Jul 07, 2010 - 12:26 UTC', 'Jul 07, 2010 - 12:22 UTC'); + }); + + it('can be sorted by multiple columns', () => { + const site_col = 0; + const time_col = 10; + const files_col = 2; + + const time_first_value = 'Jul 07, 2010 - 12:26 UTC'; + const time_last_value = 'Jul 07, 2010 - 12:22 UTC'; + const files_first_value = '4'; + const files_last_value = '0'; + + // clear default sorting by clicking on the Site header + cy.get('tr.table-heading > th').eq(site_col).click(); + + // click the Build Time header + cy.get('tr.table-heading > th').eq(time_col).as('buildtime_header').click(); + cy.get('@buildtime_header').find('span').should('have.class', 'glyphicon-chevron-down'); + + // then hold down shift and click on Files header + cy.get('tr.table-heading > th').eq(files_col).as('files_header').click({ shiftKey: true }); + + // make sure sort indicators on both columns are displayed + cy.get('@buildtime_header').find('span').should('have.class', 'glyphicon-chevron-down'); + cy.get('@files_header').find('span').should('have.class', 'glyphicon-chevron-down'); + + // get cells from each of the two columns + cy.get('tbody').find(`tr td:visible:nth-child(${time_col+1})`).as('time_column_tds'); + cy.get('tbody').find(`tr td:visible:nth-child(${files_col+1})`).as('files_column_tds'); + + // check for the expected Build Time values + verify_first_cell('@time_column_tds', time_first_value); + verify_last_cell('@time_column_tds', time_last_value); + // do the same for the expected Files values + verify_first_cell('@files_column_tds', files_first_value); + verify_last_cell('@files_column_tds', files_last_value); + + // reverse order & check values again + cy.get('@buildtime_header').click(); + cy.get('@files_header').click({ shiftKey: true }).click({ shiftKey: true }); + // check both icons + cy.get('@buildtime_header').find('span').should('have.class', 'glyphicon-chevron-up'); + cy.get('@files_header').find('span').should('have.class', 'glyphicon-chevron-up'); + // verify values + cy.get('tbody').find(`tr td:visible:nth-child(${time_col+1})`).as('time_column_tds'); + cy.get('tbody').find(`tr td:visible:nth-child(${files_col+1})`).as('files_column_tds'); + verify_first_cell('@time_column_tds', time_last_value); + verify_last_cell('@time_column_tds', time_first_value); + verify_first_cell('@files_column_tds', files_last_value); + verify_last_cell('@files_column_tds', files_first_value); + + // reload the page and make sure sort order is preserved + cy.reload(); + verify_first_cell('@time_column_tds', time_last_value); + verify_last_cell('@time_column_tds', time_first_value); + verify_first_cell('@files_column_tds', files_last_value); + verify_last_cell('@files_column_tds', files_first_value); + }); + +});