diff --git a/app/cdash/tests/CMakeLists.txt b/app/cdash/tests/CMakeLists.txt index 018378334c..2c1d82441a 100644 --- a/app/cdash/tests/CMakeLists.txt +++ b/app/cdash/tests/CMakeLists.txt @@ -115,7 +115,7 @@ add_php_test(committerinfo) add_php_test(edituser) add_php_test(image) add_php_test(displayimage) -add_php_test(managebanner) +add_cypress_test(banner) add_php_test(manageprojectroles) add_php_test(manageusers) add_php_test(projectindb) diff --git a/app/cdash/tests/test_managebanner.php b/app/cdash/tests/test_managebanner.php deleted file mode 100644 index 1aa7aaa3c6..0000000000 --- a/app/cdash/tests/test_managebanner.php +++ /dev/null @@ -1,58 +0,0 @@ -expectsPageRequiresLogin('/manageBanner.php')) { - return 1; - } - - //make sure we can visit the page while logged in - $this->login(); - $content = $this->get($this->url . '/manageBanner.php'); - if (strpos($content, 'Banner Message') === false) { - $this->fail("'Banner Message' not found when expected"); - return 1; - } - - //change the banner - if (!$this->SetFieldByName('message', 'this is a new banner')) { - $this->fail('SetFieldByName on banner message returned false'); - return 1; - } - $this->clickSubmitByName('updateMessage'); - - //make sure the banner changed - $content = $this->get($this->url . '/api/v1/index.php?project=InsightExample'); - if (strpos($content, 'this is a new banner') === false) { - $this->fail('New banner message not found on dashboard'); - return 1; - } - - //change it back - $content = $this->get($this->url . '/manageBanner.php'); - $this->SetFieldByName('message', ''); - $this->clickSubmitByName('updateMessage'); - - //make sure it changed back - $content = $this->connect($this->url . '/api/v1/index.php'); - if (strpos($content, 'this is a new banner') !== false) { - $this->fail('New banner message still on dashboard after it should have been removed'); - return 1; - } - - $this->pass('Passed'); - return 0; - } -} diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6ece99928a..c777216d9d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -24931,21 +24931,6 @@ parameters: count: 1 path: app/cdash/tests/test_lotsofsubprojects.php - - - message: "#^Call to deprecated method pass\\(\\) of class SimpleTestCase\\.$#" - count: 1 - path: app/cdash/tests/test_managebanner.php - - - - message: "#^Call to method WebTestCase\\:\\:setFieldByName\\(\\) with incorrect case\\: SetFieldByName$#" - count: 2 - path: app/cdash/tests/test_managebanner.php - - - - message: "#^Method ManageBannerTestCase\\:\\:testManageBannerTest\\(\\) has no return type specified\\.$#" - count: 1 - path: app/cdash/tests/test_managebanner.php - - message: """ #^Call to deprecated method getPdo\\(\\) of class CDash\\\\Database\\: diff --git a/tests/cypress/e2e/banner.cy.js b/tests/cypress/e2e/banner.cy.js new file mode 100644 index 0000000000..286b71ee45 --- /dev/null +++ b/tests/cypress/e2e/banner.cy.js @@ -0,0 +1,26 @@ +describe('User profile page', () => { + it('is protected by login', () => { + cy.visit('/manageBanner.php'); + cy.url().should('eq', `${Cypress.config().baseUrl}/login`); + }); + + it('Can change banner', () => { + cy.visit('/index.php?project=InsightExample'); + cy.get('[name=banner]').should('not.exist'); + + cy.login(); + cy.visit('/manageBanner.php'); + cy.get('[name=message]').clear().type('this is a new banner'); + cy.get('[name=updateMessage]').click(); + + cy.visit('/index.php?project=InsightExample'); + cy.get('[name=banner]').should('contain.text', 'this is a new banner'); + + cy.visit('/manageBanner.php'); + cy.get('[name=message]').clear(); + cy.get('[name=updateMessage]').click(); + + cy.visit('/index.php?project=InsightExample'); + cy.get('[name=banner]').should('not.exist'); + }); +});