From 42dbb9d36551e99b6e667c5ccd5094f1ecc42410 Mon Sep 17 00:00:00 2001 From: Shelly Belsky <71195502+sbelsk@users.noreply.github.com> Date: Wed, 28 Feb 2024 09:01:59 -0500 Subject: [PATCH] Add a new e2e test for the build configure page (#2015) This PR adds a new Cypress end-to-end test for the `builds//configure` page, as part of our efforts to increase the test coverage. The changes also include a fix to a typo in the pluralization rerouting logic (introduced in https://github.com/Kitware/CDash/pull/1900) that broke all existing references to the url: `build//configure`. --- tests/cypress/e2e/CMakeLists.txt | 1 + tests/cypress/e2e/build-configure.cy.js | 53 +++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/cypress/e2e/build-configure.cy.js diff --git a/tests/cypress/e2e/CMakeLists.txt b/tests/cypress/e2e/CMakeLists.txt index 98b8fb1c62..acbabc03a9 100644 --- a/tests/cypress/e2e/CMakeLists.txt +++ b/tests/cypress/e2e/CMakeLists.txt @@ -21,3 +21,4 @@ add_cypress_e2e_test(build-notes) add_cypress_e2e_test(sites) add_cypress_e2e_test(view-coverage) add_cypress_e2e_test(tests) +add_cypress_e2e_test(build-configure) diff --git a/tests/cypress/e2e/build-configure.cy.js b/tests/cypress/e2e/build-configure.cy.js new file mode 100644 index 0000000000..c5da8caad4 --- /dev/null +++ b/tests/cypress/e2e/build-configure.cy.js @@ -0,0 +1,53 @@ +describe('The Build Configure Page', () => { + it('can be reached from the index page', () => { + cy.visit('index.php?project=InsightExample'); + + cy.get('table#project_5_15').find('tbody').find('tr').first().as('build_row'); + cy.get('@build_row').find('td').each((table_entry, col) => { + if (col === 2 || col === 3) { + // check urls in both columns under the 'Configure' header + cy.wrap(table_entry).find('a').as(`configure_url_${col}`).should('have.attr', 'href').and('match', /builds?\/[0-9]+\/configure/); + } + }); + cy.get('@configure_url_2').click(); + cy.get('#subheadername').should('contain', 'InsightExample').and('contain', 'Configure'); + }); + + + it('can be reached from the build summary page', () => { + cy.visit('index.php?project=InsightExample'); + + // click on one of the builds in the index page table + cy.get('table#project_5_15').find('tbody').contains('a', 'CDash-CTest-simple').click(); + cy.url().then(build_url => { + const buildid = build_url.match(/builds?\/([0-9]+)/)[1]; + expect(buildid).to.not.be.null; + + cy.get('a#configure_link').as('configure_link') + .should('have.attr', 'href').and('match', /builds?\/[0-9]+\/configure/); + cy.get('@configure_link').click(); + cy.get('#subheadername').should('contain', 'InsightExample').and('contain', 'Configure'); + }); + }); + + + it('loads the right configure data', () => { + cy.visit('index.php?project=InsightExample'); + cy.get('table#project_5_15').contains('a', 'CDash-CTest-simple2').invoke('attr', 'href').then(build_url => { + const buildid = build_url.match(/builds?\/([0-9]+)/)[1]; + cy.visit(`builds/${buildid}/configure`); + + cy.contains('a', 'CDash-CTest-simple2').invoke('attr', 'href') + .should('match', new RegExp (`builds?\\/${buildid}`)); + + const configure_cmd = '"/usr/bin/cmake" "-GUnix Makefiles" "/cdash/app/cdash/tests/ctest/simple2"'; + cy.contains('b', 'Configure Command:').siblings('pre').should('contain', configure_cmd); + + const configure_rc = '0'; + cy.contains('b', 'Configure Return Value:').siblings('pre').should('contain', configure_rc); + + const configure_output_line = '-- Build files have been written to: /cdash/_build/tests/ctest/simple2'; + cy.contains('b', 'Configure Output:').siblings('pre').should('contain', configure_output_line); + }); + }); +});