diff --git a/app/cdash/tests/js/e2e_tests/CMakeLists.txt b/app/cdash/tests/js/e2e_tests/CMakeLists.txt index 292fda536f..31b1e85470 100644 --- a/app/cdash/tests/js/e2e_tests/CMakeLists.txt +++ b/app/cdash/tests/js/e2e_tests/CMakeLists.txt @@ -37,3 +37,4 @@ add_protractor_test(subprojectGroupOrder) add_cypress_e2e_test(calendar) add_cypress_e2e_test(colorblind) add_cypress_e2e_test(daterange) +add_cypress_e2e_test(build-notes) diff --git a/app/cdash/tests/selenium/CMakeLists.txt b/app/cdash/tests/selenium/CMakeLists.txt index 55db58448b..2127b3de63 100644 --- a/app/cdash/tests/selenium/CMakeLists.txt +++ b/app/cdash/tests/selenium/CMakeLists.txt @@ -24,8 +24,5 @@ endif() add_selenium_test(finduserproject) add_selenium_test(findusers) -## Not used with the new GUI -# add_selenium_test(buildnote) - add_selenium_test(editsite) add_selenium_test(emailsubscription) diff --git a/app/cdash/tests/selenium/test_buildnote.html b/app/cdash/tests/selenium/test_buildnote.html deleted file mode 100644 index bc230d33f0..0000000000 --- a/app/cdash/tests/selenium/test_buildnote.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - -test_buildnote - - - - - - - - - - - - - - - - - - - - - - -
test_buildnote
open/CDash/index.php?project=EmailProjectExample&date=2009-02-23
mouseOver//a[@id='buildnote_5']/img
clickAndWait//a[@id='buildnote_5']/img
- - diff --git a/app/cdash/tests/selenium/test_buildnote.php b/app/cdash/tests/selenium/test_buildnote.php deleted file mode 100644 index f911316b7f..0000000000 --- a/app/cdash/tests/selenium/test_buildnote.php +++ /dev/null @@ -1,22 +0,0 @@ -browserSetUp(); - } - - public function testBuildNote() - { - $this->open($this->webPath . '/index.php?project=EmailProjectExample&date=2009-02-23'); - $this->mouseOver("//a[@id='buildnote_4']/img"); - $this->click("//a[@id='buildnote_4']/img"); - $this->waitForPageToLoad('30000'); - } -} diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 46d93509a5..c27e728b55 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -20674,36 +20674,6 @@ parameters: count: 1 path: app/cdash/tests/sameImage.php - - - message: "#^Call to an undefined method Example\\:\\:click\\(\\)\\.$#" - count: 1 - path: app/cdash/tests/selenium/test_buildnote.php - - - - message: "#^Call to an undefined method Example\\:\\:mouseOver\\(\\)\\.$#" - count: 1 - path: app/cdash/tests/selenium/test_buildnote.php - - - - message: "#^Call to an undefined method Example\\:\\:open\\(\\)\\.$#" - count: 1 - path: app/cdash/tests/selenium/test_buildnote.php - - - - message: "#^Call to an undefined method Example\\:\\:waitForPageToLoad\\(\\)\\.$#" - count: 1 - path: app/cdash/tests/selenium/test_buildnote.php - - - - message: "#^Method Example\\:\\:setUp\\(\\) has no return type specified\\.$#" - count: 1 - path: app/cdash/tests/selenium/test_buildnote.php - - - - message: "#^Method Example\\:\\:testBuildNote\\(\\) has no return type specified\\.$#" - count: 1 - path: app/cdash/tests/selenium/test_buildnote.php - - message: "#^Call to an undefined method Example\\:\\:click\\(\\)\\.$#" count: 10 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a3fa761926..d704411b3e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -93,7 +93,6 @@ set_tests_properties(eslint PROPERTIES ) add_vue_test(Spec/build-configure) -add_vue_test(Spec/build-notes) add_vue_test(Spec/build-summary) add_vue_test(Spec/edit-project) add_vue_test(Spec/manage-measurements) diff --git a/tests/Spec/build-notes.spec.js b/tests/Spec/build-notes.spec.js deleted file mode 100644 index 52e5d6a7b1..0000000000 --- a/tests/Spec/build-notes.spec.js +++ /dev/null @@ -1,84 +0,0 @@ -import { mount, config } from '@vue/test-utils'; -import axios from 'axios'; -import AxiosMockAdapter from 'axios-mock-adapter'; -import expect from 'expect'; -import BuildNotes from '../../resources/js/components/BuildNotes.vue'; - -config.global.mocks['$baseURL'] = 'http://localhost'; -axios.defaults.baseURL = config.global.mocks['$baseURL']; - -import $ from 'jquery'; -$.plot = function() { - return null; -}; -global.$ = $; - -let apiResponse; -let axiosMockAdapter; - -beforeEach(() => { - axiosMockAdapter = new AxiosMockAdapter(axios); - config.global.mocks['$axios'] = axios; - apiResponse = { - build: { - buildid: 1, - buildname: 'my build', - siteid: 1, - site: 'mysite', - starttime: '5 minutes ago', - }, - notes: [ - { - name: 'a note', - text: 'note text', - time: 'yesterday', - }, - ], - user: { - id: 1, - }, - }; -}); - -afterEach(() => { - axiosMockAdapter.restore(); -}); - -test('BuildNote handles API response', async () => { - axiosMockAdapter.onGet('/api/v1/viewNotes.php?buildid=').reply(200, apiResponse); - const component = mount(BuildNotes); - await new Promise(process.nextTick); - expect(component.vm.loading).toBe(false); - expect(component.vm.cdash.notes.length).toBe(1); - - // Verify some expected content. - const html = component.html(); - expect(html).toContain('my build'); - expect(html).toContain('mysite'); - expect(html).toContain('5 minutes ago'); - - // Since we only have one note it should be displayed by default. - expect(component.find('#notetext0').isVisible()).toBe(true); -}); - -test('BuildNote can toggle notes', async () => { - apiResponse.notes.push({ - name: 'another note', - text: 'more note text', - time: 'later on', - }); - axiosMockAdapter.onGet('/api/v1/viewNotes.php?buildid=').reply(200, apiResponse); - const component = mount(BuildNotes); - await new Promise(process.nextTick); - - // Two notes, both hidden by default. - expect(component.vm.cdash.notes.length).toBe(2); - expect(component.find('#notetext0').isVisible()).toBe(false); - expect(component.find('#notetext1').isVisible()).toBe(false); - - // Toggle a note back on. - const note_button = component.find('#note0'); - note_button.trigger('click'); - await new Promise(process.nextTick); - expect(component.find('#notetext0').isVisible()).toBe(true); -}); diff --git a/tests/cypress/e2e/build-notes.cy.js b/tests/cypress/e2e/build-notes.cy.js new file mode 100644 index 0000000000..d3c02617e1 --- /dev/null +++ b/tests/cypress/e2e/build-notes.cy.js @@ -0,0 +1,36 @@ +describe('build notes', () => { + it('can be reached from the index page', () => { + cy.visit('index.php?project=EmailProjectExample'); + cy.get('tbody').find('tr').first().find('td').eq(1).find('a[name="notesLink"]').as('notes_link'); + cy.get('@notes_link').find('img').should('have.attr', 'src', 'img/document.png'); + cy.get('@notes_link').click(); + cy.url().should('match', /builds\/[0-9]+\/notes/); + }); + + it('displays contents of note', () => { + cy.visit('index.php?project=EmailProjectExample'); + cy.get('tbody').find('a[name="notesLink"]').click(); + + // verify content of note + cy.get('#note0').should('contain', '/cdash/_build/app/cdash/tests/ctest/ctestdriver-svnUpdates.ctest'); + // some expected code from the attached note + cy.get('#notetext0') + .should('contain', 'cmake_minimum_required') + .and('contain', 'submit.php?project=EmailProjectExample'); + + // toggle the note + cy.get('#note0').find('i').as('toggle_button'); + cy.get('@toggle_button').should('have.class', 'glyphicon-chevron-down'); + cy.get('@toggle_button').click(); + + // TODO: (sbelsk) perhaps the choice of icons for the + // collapsed and open modes should be revisited... + cy.get('@toggle_button').should('have.class', 'glyphicon-chevron-right'); + cy.get('#notetext0').should('not.be.visible'); + cy.get('@toggle_button').click(); + + // assert page is back to original state + cy.get('@toggle_button').should('have.class', 'glyphicon-chevron-down'); + cy.get('#notetext0').should('be.visible'); + }); +});