From 33d053c9f57c9e0638ff76d3a17c42445384e86a Mon Sep 17 00:00:00 2001 From: LeeDr Date: Fri, 30 Oct 2015 16:08:35 -0500 Subject: [PATCH 01/18] Trying BDD testing. --- test/fixtures/__tests__/scenarioManager.js | 2 +- .../apps/settings/_initial_state.js | 41 ++ test/functional/apps/settings/testSettings.js | 75 +++ test/functional/status.js | 21 - test/functional/testSettings.js | 590 ------------------ test/intern.js | 3 +- 6 files changed, 118 insertions(+), 614 deletions(-) create mode 100644 test/functional/apps/settings/_initial_state.js create mode 100644 test/functional/apps/settings/testSettings.js delete mode 100644 test/functional/status.js delete mode 100644 test/functional/testSettings.js diff --git a/test/fixtures/__tests__/scenarioManager.js b/test/fixtures/__tests__/scenarioManager.js index 8d93d9d650176..3c8d261c4c854 100644 --- a/test/fixtures/__tests__/scenarioManager.js +++ b/test/fixtures/__tests__/scenarioManager.js @@ -84,7 +84,7 @@ describe('scenario manager', function () { }); - it('should load if the index is empty', function () { + it('should not load if the index is not empty', function () { var load = sinon.stub(manager, 'load', Promise.resolve); var returnOne = sinon.stub(manager.client, 'count', function () { return Promise.resolve({ diff --git a/test/functional/apps/settings/_initial_state.js b/test/functional/apps/settings/_initial_state.js new file mode 100644 index 0000000000000..d8a8815e9e852 --- /dev/null +++ b/test/functional/apps/settings/_initial_state.js @@ -0,0 +1,41 @@ +define(function () { + return function (bdd, expect, common, settingsPage) { + console.log(arguments); + return function () { + bdd.it('something', function () { + var testSubName = 'testSettingsInitialState'; + common.log('we have common stuff'); + return settingsPage.getTimeBasedEventsCheckbox().isSelected() + .then(function (selected) { + expect(selected).to.be.ok(); + }) + .then(function () { + return settingsPage.getNameIsPatternCheckbox().isSelected() + .then(function (nameIsPatternSelected) { + expect(nameIsPatternSelected).to.not.be.ok(); + }); + }) + .then(function () { + return settingsPage.getIndexPatternField() + .then(function (patternField) { + return patternField.getProperty('value') + .then(function (pattern) { + common.log('patternField value = ' + pattern); + expect(pattern).to.be('logstash-*'); + }); + }); + }) + .then(function () { + return settingsPage.getTimeFieldNameField().isSelected() + .then(function (timeFieldIsSelected) { + common.log('timeField isSelected = ' + timeFieldIsSelected); + expect(timeFieldIsSelected).to.not.be.ok(); + }); + }) + .catch(function screenshotError(reason) { + return common.screenshotError(testSubName, reason); + }); + }); + }; + }; +}); diff --git a/test/functional/apps/settings/testSettings.js b/test/functional/apps/settings/testSettings.js new file mode 100644 index 0000000000000..d119226336435 --- /dev/null +++ b/test/functional/apps/settings/testSettings.js @@ -0,0 +1,75 @@ +define(function (require) { + var bdd = require('intern!bdd'); + var expect = require('intern/dojo/node!expect.js'); + var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenarioManager'); + var pollUntil = require('intern/dojo/node!leadfoot/helpers/pollUntil'); + var Common = require('../../../support/pages/Common'); + var SettingsPage = require('../../../support/pages/SettingsPage'); + var HeaderPage = require('../../../support/pages/HeaderPage'); + var config = require('intern').config; + var url = require('intern/dojo/node!url'); + var _ = require('intern/dojo/node!lodash'); + var initialStateTest = require('./_initial_state'); + + bdd.describe('settings app', function () { + var common; + var settingsPage; + var headerPage; + var scenarioManager; + var remote; + + var expectedAlertText = 'Are you sure you want to remove this index pattern?'; + // on setup, we create an settingsPage instance + // that we will use for all the tests + bdd.before(function () { + common = new Common(this.remote); + settingsPage = new SettingsPage(this.remote); + common.log('running bdd.before'); + headerPage = new HeaderPage(this.remote); + scenarioManager = new ScenarioManager(url.format(config.elasticsearch)); + remote = this.remote; + console.log('common = ', common); + }); + + bdd.beforeEach(function () { + + // start each test with an empty kibana index + return scenarioManager.reload('emptyKibana') + // and load a minimal set of makelogs data + .then(function loadIfEmptyMakelogs() { + return scenarioManager.loadIfEmpty('makelogs'); + }) + .then(function () { + return common.sleep(2500); + }) + .then(function () { + return common.tryForTime(25000, function () { + return remote.get(url.format(_.assign(config.kibana, { + pathname: '' + }))) + .then(function () { + return common.sleep(2000); + }) + .then(function () { + return remote.getCurrentUrl() + .then(function (currentUrl) { + expect(currentUrl).to.contain('settings'); + }); + }); + }); + }); + }); + + bdd.after(function unloadMakelogs() { + return scenarioManager.unload('makelogs'); + }); + + /* + ** Test the default state of checboxes and the 2 text input fields + */ + bdd.describe('initial state', function () { + initialStateTest(bdd, expect, common, settingsPage); + }); + + }); +}); diff --git a/test/functional/status.js b/test/functional/status.js deleted file mode 100644 index 2ab69ecc144c5..0000000000000 --- a/test/functional/status.js +++ /dev/null @@ -1,21 +0,0 @@ -define(function (require) { - var registerSuite = require('intern!object'); - var expect = require('intern/dojo/node!expect.js'); - var config = require('intern').config; - var getUrl = require('intern/dojo/node!../utils/getUrl'); - - registerSuite(function () { - return { - status: function () { - return this.remote - .get(getUrl(config.kibana, 'status')) - .setFindTimeout(60000) - .findByCssSelector('.plugin_status_breakdown') - .getVisibleText() - .then(function (text) { - expect(text.indexOf('plugin:kibana Ready')).to.be.above(-1); - }); - } - }; - }); -}); diff --git a/test/functional/testSettings.js b/test/functional/testSettings.js deleted file mode 100644 index 4b809a869c79b..0000000000000 --- a/test/functional/testSettings.js +++ /dev/null @@ -1,590 +0,0 @@ -define(function (require) { - - var registerSuite = require('intern!object'); - var expect = require('intern/dojo/node!expect.js'); - var ScenarioManager = require('intern/dojo/node!../fixtures/scenarioManager'); - var pollUntil = require('intern/dojo/node!leadfoot/helpers/pollUntil'); - var Common = require('../support/pages/Common'); - var SettingsPage = require('../support/pages/SettingsPage'); - var HeaderPage = require('../support/pages/HeaderPage'); - var config = require('intern').config; - var url = require('intern/dojo/node!url'); - var _ = require('intern/dojo/node!lodash'); - - - registerSuite(function () { - var common; - var settingsPage; - var headerPage; - var scenarioManager; - var remote; - - var expectedAlertText = 'Are you sure you want to remove this index pattern?'; - return { - // on setup, we create an settingsPage instance - // that we will use for all the tests - setup: function () { - common = new Common(this.remote); - settingsPage = new SettingsPage(this.remote); - headerPage = new HeaderPage(this.remote); - scenarioManager = new ScenarioManager(url.format(config.elasticsearch)); - remote = this.remote; - }, - - beforeEach: function () { - - // start each test with an empty kibana index - return scenarioManager.reload('emptyKibana') - // and load a minimal set of makelogs data - .then(function loadIfEmptyMakelogs() { - return scenarioManager.loadIfEmpty('makelogs'); - }) - .then(function () { - return common.sleep(2500); - }) - .then(function () { - return common.tryForTime(25000, function () { - return remote.get(url.format(_.assign(config.kibana, { - pathname: '' - }))) - .then(function () { - return common.sleep(2000); - }) - .then(function () { - return remote.getCurrentUrl() - .then(function (currentUrl) { - expect(currentUrl).to.contain('settings'); - }); - }); - }); - }); - }, - - teardown: function unloadMakelogs() { - return scenarioManager.unload('makelogs'); - }, - - /* - ** Test the default state of checboxes and the 2 text input fields - */ - testSettingsInitialState: function () { - var testSubName = 'testSettingsInitialState'; - - return settingsPage.getTimeBasedEventsCheckbox().isSelected() - .then(function (selected) { - expect(selected).to.be.ok(); - }) - .then(function () { - return settingsPage.getNameIsPatternCheckbox().isSelected() - .then(function (nameIsPatternSelected) { - expect(nameIsPatternSelected).to.not.be.ok(); - }); - }) - .then(function () { - return settingsPage.getIndexPatternField() - .then(function (patternField) { - return patternField.getProperty('value') - .then(function (pattern) { - common.log('patternField value = ' + pattern); - expect(pattern).to.be('logstash-*'); - }); - }); - }) - .then(function () { - return settingsPage.getTimeFieldNameField().isSelected() - .then(function (timeFieldIsSelected) { - common.log('timeField isSelected = ' + timeFieldIsSelected); - expect(timeFieldIsSelected).to.not.be.ok(); - }); - }) - .catch(function screenshotError(reason) { - return common.screenshotError(testSubName, reason); - }); - }, - - /* - ** Ensure Create button is disabled until you select a time field - */ - testCreateButtonDisabledUntilTimeFieldSelected: function () { - var testSubName = 'testCreateButtonDisabledUntilTimeFieldSelected'; - - return settingsPage.getCreateButton().isEnabled() - .then(function (enabled) { - expect(enabled).to.not.be.ok(); - }) - .then(function () { - // select a time field and check that Create button is enabled - return settingsPage - .selectTimeFieldOption('@timestamp'); - }) - .then(function () { - return settingsPage.getCreateButton().isEnabled() - .then(function (enabled) { - expect(enabled).to.be.ok(); - }); - }) - .catch(function screenshotError(reason) { - return common.screenshotError(testSubName, reason); - }); - }, - - - /* - ** Test that unchecking the Time-based Events checkbox hides the Name is pattern checkbox - */ - testSettingsCheckboxHide: function () { - var testSubName = 'testSettingsCheckboxHide'; - - return settingsPage.getTimeBasedEventsCheckbox() - .then(function (selected) { - // uncheck the 'time-based events' checkbox - return selected.click(); - }) - // try to find the name is pattern checkbox (shouldn't find it) - .then(function () { - return settingsPage.getNameIsPatternCheckbox(); - }) - .then(function (selected1) { - expect( - true, false, 'Did not expect to find the Name is Pattern checkbox when the TimeBasedEvents checkbox is unchecked' - ); - }) - .catch(function (reason) { - // it's OK. We expected not to find the getNameIsPatternCheckbox. - return; - }); - }, - // Index pattern field list - - testCreateRemoveIndexPattern: function () { - var testSubName = 'testCreateRemoveIndexPattern'; - - // select a time field and then Create button - return settingsPage.selectTimeFieldOption('@timestamp') - .then(function () { - return settingsPage.getCreateButton().click(); - }) - .then(function () { - return settingsPage.getIndexPageHeading() - .then(function (getIndexPageHeading) { - common.log(getIndexPageHeading.getVisibleText()); - }) - .then(function () { - // delete the index pattern - return common.tryForTime(3000, function () { - return settingsPage.clickDeletePattern(); - }); - }) - .then(function () { - return common.tryForTime(3000, function () { - return remote.getAlertText(); - }); - }) - .then(function () { - return remote.acceptAlert(); - }) - // getting the current URL which shows 'logstash-*' pattern - .then(function () { - return remote.getCurrentUrl() - .then(function (currentUrl) { - common.log('currentUrl = ' + currentUrl); - }); - }) - // pollUntil we find the Create button - .then(pollUntil(function (value) { - var element = document.getElementsByClassName('btn-success')[0]; - return element ? element : null; - }, ['Configure an index pattern'], 8000)) - .then(function () { - common.log('success'); - }) - // getting the current URL which no longer includes 'logstash-*' - .then(function () { - return remote.getCurrentUrl() - .then(function (currentUrl) { - common.log('currentUrl = ' + currentUrl); - }); - }); - }) - .catch(function screenshotError(reason) { - return common.screenshotError(testSubName, reason); - }); - }, - - testIndexPatternResultsHeader: function () { - var testSubName = 'testIndexPatternResultsHeader'; - - return settingsPage.selectTimeFieldOption('@timestamp') - .then(function () { - return settingsPage.getCreateButton().click(); - }) - .then(function () { - return settingsPage.getIndexPageHeading() - .then(function (getIndexPageHeading) { - return getIndexPageHeading.getVisibleText() - .then(function (pageText) { - expect(pageText).to.be('logstash-*'); - }); - }); - }) - .then(function () { - return settingsPage.getTableHeader() - .then(function (header) { - common.log('header.length = ' + header.length); // 6 name type format analyzed indexed controls - expect(header.length).to.be(6); - return header[0].getVisibleText() - .then(function (text) { - common.log('header[0] = ' + text); // name - expect(text).to.be('name'); - return header; - }); - }) - .then(function (header) { - return header[1].getVisibleText() - .then(function (text) { - common.log('header[1] = ' + text); - expect(text).to.be('type'); - return header; - }); - }) - .then(function (header) { - return header[2].getVisibleText() - .then(function (text) { - common.log('header[2] = ' + text); - expect(text).to.be('format'); - return header; - }); - }) - .then(function (header) { - return header[3].getVisibleText() - .then(function (text) { - common.log('header[3] = ' + text); - expect(text).to.be('analyzed'); - return header; - }); - }) - .then(function (header) { - return header[4].getVisibleText() - .then(function (text) { - common.log('header[4] = ' + text); - expect(text).to.be('indexed'); - return header; - }); - }) - .then(function (header) { - return header[5].getVisibleText() - .then(function (text) { - common.log('header[5] = ' + text); - expect(text).to.be('controls'); - return header; - }); - }) - .then(function () { - return common.tryForTime(3000, function () { - // delete the index pattern -X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X - return settingsPage.clickDeletePattern(); - }); - }) - .then(function () { - return common.tryForTime(3000, function () { - return remote.getAlertText(); - }); - }) - .then(function () { - return remote.getAlertText() - .then(function (alertText) { - common.log('alertText = ' + alertText); - expect(alertText).to.be(expectedAlertText); - }); - }) - .then(function () { - return remote.acceptAlert(); - }); - }) - .catch(function screenshotError(reason) { - return common.screenshotError(testSubName, reason); - }); - }, - - - testIndexPatternResultsSort: function () { - var testSubName = 'testIndexPatternResultsSort'; - - return settingsPage.selectTimeFieldOption('@timestamp') - .then(function () { - return settingsPage.getCreateButton().click(); - }) - // check the page header to make sure we see logstash-* - .then(function () { - return settingsPage.getIndexPageHeading() - .then(function (getIndexPageHeading) { - return getIndexPageHeading.getVisibleText() - .then(function (pageText) { - expect(pageText).to.be('logstash-*'); - // return - }); - }); - }) - // Sort by Name - .then(function sortByName() { - return settingsPage.sortBy('name'); - }) - // check name sort - .then(function sortAgain() { - return settingsPage.getTableRow(0, 0) - .then(function (row) { - return row.getVisibleText() - .then(function (rowText) { - //common.log('After name-sort first row first column = ' + rowText); - expect(rowText).to.be('@message'); - }); - }); - }) - // Sort by Name again - .then(function sortByName2() { - return settingsPage.sortBy('name'); - }) - // check name sort - .then(function sortAgain2() { - return settingsPage.getTableRow(0, 0) - .then(function (row) { - return row.getVisibleText() - .then(function (rowText) { - //common.log('After name-sort first row first column = ' + rowText); - expect(rowText).to.be('xss.raw'); - }); - }); - }) - // Sort by type - .then(function sortByType() { - return settingsPage.sortBy('type'); - }) - // check type sort - .then(function checksort() { - return settingsPage.getTableRow(0, 1) - .then(function (row) { - return row.getVisibleText() - .then(function (rowText) { - //common.log('After type-sort first row first column = ' + rowText); - expect(rowText).to.be('_source'); - }); - }); - }) - // Sort by type again - .then(function sortByType2() { - return settingsPage.sortBy('type'); - }) - // check type sort - .then(function checksort2() { - return settingsPage.getTableRow(0, 1) - .then(function (row) { - return row.getVisibleText() - .then(function (rowText) { - common.log('After type-sort first row first column = ' + rowText); - expect(rowText).to.be('string'); - }); - }); - }) - // Sort by type again (this time it "unsorts it") - .then(function sortByType2() { - return settingsPage.sortBy('type'); - }) - // check pagination - .then(function getFieldsTabCount() { - return settingsPage.getFieldsTabCount() - .then(function (tabCount) { - common.log('fields item count = ' + tabCount); - expect(tabCount).to.be('85'); - }); - }) - // verify the page size is 25 - .then(function checkPageSize() { - return settingsPage.getPageSize() - .then(function (pageSize) { - expect(pageSize).to.be('25'); - }); - }) - // we know with 25 fields per page and 85 fields there should be 4 pages. - // the first page should have 25 items on it. - .then(function getPageFieldCount() { - return settingsPage.getPageFieldCount() - .then(function (pageCount) { - common.log('Page 1 count = ' + pageCount.length); - expect(pageCount.length).to.be(25); - }); - }) - //page 2 should also have 25 items - .then(function goPage2() { - return settingsPage.goToPage(2); - }) - .then(function getPageFieldCount() { - return settingsPage.getPageFieldCount() - .then(function (pageCount) { - common.log('Page 2 count = ' + pageCount.length); - expect(pageCount.length).to.be(25); - }); - }) - //page 3 should also have 25 items - .then(function goPage3() { - return settingsPage.goToPage(3); - }) - .then(function getPageFieldCount() { - return settingsPage.getPageFieldCount() - .then(function (pageCount) { - common.log('Page 3 count = ' + pageCount.length); - expect(pageCount.length).to.be(25); - }); - }) - //page 4 should also have 10 items - .then(function goPage4() { - return settingsPage.goToPage(4); - }) - .then(function getPageFieldCount() { - return settingsPage.getPageFieldCount() - .then(function (pageCount) { - common.log('Page 4 count = ' + pageCount.length); - expect(pageCount.length).to.be(10); - }); - }) - .then(function () { - return common.tryForTime(3000, function () { - // delete the index pattern -X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X - return settingsPage.clickDeletePattern(); - }); - }) - .then(function () { - return common.tryForTime(3000, function () { - return remote.getAlertText(); - }); - }) - .then(function () { - return remote.getAlertText() - .then(function (alertText) { - common.log('alertText = ' + alertText); - expect(alertText).to.be(expectedAlertText); - }); - }) - .then(function () { - return remote.acceptAlert(); - }) - .catch(function screenshotError(reason) { - return common.screenshotError(testSubName, reason); - }); - }, - - - testIndexPatternPopularity: function () { - var testSubName = 'testIndexPatternPopularity'; - - return settingsPage.selectTimeFieldOption('@timestamp') - .then(function () { - return settingsPage.getCreateButton().click(); - }) - // check the page header to make sure we see logstash-* - .then(function () { - return settingsPage.getIndexPageHeading() - .then(function (getIndexPageHeading) { - return getIndexPageHeading.getVisibleText() - .then(function (pageText) { - expect(pageText).to.be('logstash-*'); - // return - }); - }); - }) - .then(function () { - return settingsPage.setPageSize('All'); - }) - // increase Popularity - .then(function openControlsByName() { - common.log('Starting openControlsByName "geo.coordinates"'); - return settingsPage.openControlsByName('geo.coordinates'); - }) - .then(function increasePopularity() { - common.log('increasePopularity'); - return settingsPage.increasePopularity(); - }) - .then(function getPopularity() { - common.log('getPopularity'); - return settingsPage.getPopularity() - .then(function (popularity) { - common.log('popularity = ' + popularity); - expect(popularity).to.be('1'); - }); - }) - // Cancel saving the popularity change - .then(function controlChangeCancel() { - return settingsPage.controlChangeCancel(); - }) - // set the page size to All again, https://github.com/elastic/kibana/issues/5030 - .then(function () { - return settingsPage.setPageSize('All'); - }) - .then(function openControlsByName() { - return settingsPage.openControlsByName('geo.coordinates'); - }) - // check that its 0 (previous increase was cancelled) - .then(function getPopularity() { - return settingsPage.getPopularity() - .then(function (popularity) { - common.log('popularity = ' + popularity); - expect(popularity).to.be('0'); - }); - }) - .then(function increasePopularity() { - return settingsPage.increasePopularity(); - }) - // Saving the popularity change - .then(function controlChangeSave() { - return settingsPage.controlChangeSave(); - }) - // set the page size to All again, https://github.com/elastic/kibana/issues/5030 - .then(function () { - return settingsPage.setPageSize('All'); - }) - // open it again to see that it saved - .then(function openControlsByName() { - return settingsPage.openControlsByName('geo.coordinates'); - }) - // check that its 0 (previous increase was cancelled) - .then(function getPopularity() { - return settingsPage.getPopularity() - .then(function (popularity) { - common.log('popularity = ' + popularity); - expect(popularity).to.be('1'); - }); - }) - // Cancel saving the popularity change (we didn't make a change in this case, just checking the value) - .then(function controlChangeCancel() { - return settingsPage.controlChangeCancel(); - }) - // should this test go to discover page and verify the Popular field? - .then(function () { - return common.tryForTime(3000, function () { - // delete the index pattern - return settingsPage.clickDeletePattern(); - }); - }) - .then(function () { - return common.tryForTime(3000, function () { - return remote.getAlertText(); - }); - }) - .then(function () { - return remote.getAlertText() - .then(function (alertText) { - common.log('alertText = ' + alertText); - expect(alertText).to.be(expectedAlertText); - }); - }) - .then(function () { - return remote.acceptAlert(); - }) - .catch(function screenshotError(reason) { - return common.screenshotError(testSubName, reason); - }); - } - - - }; - }); -}); diff --git a/test/intern.js b/test/intern.js index bd9fdf26035c5..76aba2141902b 100644 --- a/test/intern.js +++ b/test/intern.js @@ -12,8 +12,7 @@ define(function (require) { }], tunnelOptions: serverConfig.webdriver, functionalSuites: [ - 'test/functional/status.js', - 'test/functional/testSettings' + 'test/functional/apps/settings/testSettings' ], excludeInstrumentation: /(fixtures|node_modules)\//, loaderOptions: { From 6a18a112b56c5f5db38b102f1c6494a98355fe4a Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Fri, 30 Oct 2015 16:15:58 -0700 Subject: [PATCH 02/18] make the bdd style tests run --- .../apps/settings/_initial_state.js | 78 +++++++++++-------- test/functional/apps/settings/testSettings.js | 25 ++---- 2 files changed, 52 insertions(+), 51 deletions(-) diff --git a/test/functional/apps/settings/_initial_state.js b/test/functional/apps/settings/_initial_state.js index d8a8815e9e852..b1590dc968a13 100644 --- a/test/functional/apps/settings/_initial_state.js +++ b/test/functional/apps/settings/_initial_state.js @@ -1,41 +1,55 @@ -define(function () { - return function (bdd, expect, common, settingsPage) { - console.log(arguments); - return function () { - bdd.it('something', function () { - var testSubName = 'testSettingsInitialState'; - common.log('we have common stuff'); +define(function (require) { + var Common = require('../../../support/pages/Common'); + var SettingsPage = require('../../../support/pages/SettingsPage'); + var expect = require('intern/dojo/node!expect.js'); + + return function (bdd) { + bdd.describe('initial state', function () { + var common; + var settingsPage; + + bdd.before(function () { + common = new Common(this.remote); + settingsPage = new SettingsPage(this.remote); + }); + + bdd.it('should load with time pattern checked', function () { + console.log(Object.keys(this)); + return settingsPage.getTimeBasedEventsCheckbox().isSelected() .then(function (selected) { expect(selected).to.be.ok(); }) - .then(function () { - return settingsPage.getNameIsPatternCheckbox().isSelected() - .then(function (nameIsPatternSelected) { - expect(nameIsPatternSelected).to.not.be.ok(); - }); - }) - .then(function () { - return settingsPage.getIndexPatternField() - .then(function (patternField) { - return patternField.getProperty('value') - .then(function (pattern) { - common.log('patternField value = ' + pattern); - expect(pattern).to.be('logstash-*'); - }); - }); - }) - .then(function () { - return settingsPage.getTimeFieldNameField().isSelected() - .then(function (timeFieldIsSelected) { - common.log('timeField isSelected = ' + timeFieldIsSelected); - expect(timeFieldIsSelected).to.not.be.ok(); - }); + }); + + bdd.it('should load with name pattern unchecked', function () { + return settingsPage.getNameIsPatternCheckbox().isSelected() + .then(function (selected) { + expect(selected).to.not.be.ok(); + }); + }); + + bdd.it('should contain default index pattern', function () { + var defaultPattern = 'logstash-*'; + + return settingsPage.getIndexPatternField().getProperty('value') + .then(function (pattern) { + expect(pattern).to.be(defaultPattern); }) - .catch(function screenshotError(reason) { - return common.screenshotError(testSubName, reason); + }); + + bdd.it('should not select the time field', function () { + return settingsPage.getTimeFieldNameField().isSelected() + .then(function (timeFieldIsSelected) { + common.log('timeField isSelected = ' + timeFieldIsSelected); + expect(timeFieldIsSelected).to.not.be.ok(); }); }); - }; + + // var testSubName = 'testSettingsInitialState'; + // function screenshotError(reason) { + // return common.screenshotError(testSubName, reason); + // } + }); }; }); diff --git a/test/functional/apps/settings/testSettings.js b/test/functional/apps/settings/testSettings.js index d119226336435..08793b288d6de 100644 --- a/test/functional/apps/settings/testSettings.js +++ b/test/functional/apps/settings/testSettings.js @@ -1,20 +1,17 @@ define(function (require) { var bdd = require('intern!bdd'); var expect = require('intern/dojo/node!expect.js'); - var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenarioManager'); - var pollUntil = require('intern/dojo/node!leadfoot/helpers/pollUntil'); - var Common = require('../../../support/pages/Common'); - var SettingsPage = require('../../../support/pages/SettingsPage'); - var HeaderPage = require('../../../support/pages/HeaderPage'); var config = require('intern').config; var url = require('intern/dojo/node!url'); var _ = require('intern/dojo/node!lodash'); - var initialStateTest = require('./_initial_state'); + + var Common = require('../../../support/pages/Common'); + var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenarioManager'); + // var HeaderPage = require('../../../support/pages/HeaderPage'); + // var pollUntil = require('intern/dojo/node!leadfoot/helpers/pollUntil'); bdd.describe('settings app', function () { var common; - var settingsPage; - var headerPage; var scenarioManager; var remote; @@ -23,16 +20,11 @@ define(function (require) { // that we will use for all the tests bdd.before(function () { common = new Common(this.remote); - settingsPage = new SettingsPage(this.remote); - common.log('running bdd.before'); - headerPage = new HeaderPage(this.remote); scenarioManager = new ScenarioManager(url.format(config.elasticsearch)); remote = this.remote; - console.log('common = ', common); }); bdd.beforeEach(function () { - // start each test with an empty kibana index return scenarioManager.reload('emptyKibana') // and load a minimal set of makelogs data @@ -64,12 +56,7 @@ define(function (require) { return scenarioManager.unload('makelogs'); }); - /* - ** Test the default state of checboxes and the 2 text input fields - */ - bdd.describe('initial state', function () { - initialStateTest(bdd, expect, common, settingsPage); - }); + require('./_initial_state')(bdd); }); }); From 33372cd7ac4ab678480c20ae3d2f5594d64faabd Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Fri, 30 Oct 2015 16:37:47 -0700 Subject: [PATCH 03/18] cleanup, tweak URL wait time --- test/fixtures/scenarioManager.js | 1 - test/functional/apps/settings/_initial_state.js | 2 -- test/functional/apps/settings/testSettings.js | 3 ++- test/support/pages/Common.js | 2 -- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/test/fixtures/scenarioManager.js b/test/fixtures/scenarioManager.js index d033341c2b425..acc350e6ac90c 100644 --- a/test/fixtures/scenarioManager.js +++ b/test/fixtures/scenarioManager.js @@ -37,7 +37,6 @@ ScenarioManager.prototype.load = function (id) { body: require(path.join(scenario.baseDir, bulk.source)), }); }); - })); }; diff --git a/test/functional/apps/settings/_initial_state.js b/test/functional/apps/settings/_initial_state.js index b1590dc968a13..abd07359c9b9d 100644 --- a/test/functional/apps/settings/_initial_state.js +++ b/test/functional/apps/settings/_initial_state.js @@ -14,8 +14,6 @@ define(function (require) { }); bdd.it('should load with time pattern checked', function () { - console.log(Object.keys(this)); - return settingsPage.getTimeBasedEventsCheckbox().isSelected() .then(function (selected) { expect(selected).to.be.ok(); diff --git a/test/functional/apps/settings/testSettings.js b/test/functional/apps/settings/testSettings.js index 08793b288d6de..3f0a3f87a55ee 100644 --- a/test/functional/apps/settings/testSettings.js +++ b/test/functional/apps/settings/testSettings.js @@ -32,7 +32,7 @@ define(function (require) { return scenarioManager.loadIfEmpty('makelogs'); }) .then(function () { - return common.sleep(2500); + return common.sleep(3000); }) .then(function () { return common.tryForTime(25000, function () { @@ -40,6 +40,7 @@ define(function (require) { pathname: '' }))) .then(function () { + // give angular enough time to update the URL return common.sleep(2000); }) .then(function () { diff --git a/test/support/pages/Common.js b/test/support/pages/Common.js index 169cd827e4c18..c785f5cfc2c66 100644 --- a/test/support/pages/Common.js +++ b/test/support/pages/Common.js @@ -12,8 +12,6 @@ define(function (require) { this.remote = remote; } - var defaultTimeout = 5000; - Common.prototype = { constructor: Common, From db5e279f5f2e31b434c963f90abf837c8fec505e Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Fri, 30 Oct 2015 16:39:24 -0700 Subject: [PATCH 04/18] move scenarios config under its own property --- test/fixtures/config.js | 38 +++++++++++++++++--------------- test/fixtures/scenarioManager.js | 2 +- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/test/fixtures/config.js b/test/fixtures/config.js index b232047511c99..8c1d3f1117e1e 100644 --- a/test/fixtures/config.js +++ b/test/fixtures/config.js @@ -2,23 +2,25 @@ var path = require('path'); var rootDir = path.join(__dirname, 'scenarios'); module.exports = { - makelogs: { - baseDir: path.join(rootDir, 'makelogs'), - bulk: [{ - indexDefinition: 'makelogsIndexDefinition.js', - indexName: 'logstash-2015.09.17', - source: 'logstash-2015.09.17.js' - }, { - indexDefinition: 'makelogsIndexDefinition.js', - indexName: 'logstash-2015.09.18', - source: 'logstash-2015.09.18.js' - }] - }, - emptyKibana: { - baseDir: path.join(rootDir, 'emptyKibana'), - bulk: [{ - indexName: '.kibana', - source: 'kibana.js' - }] + scenarios: { + makelogs: { + baseDir: path.join(rootDir, 'makelogs'), + bulk: [{ + indexDefinition: 'makelogsIndexDefinition.js', + indexName: 'logstash-2015.09.17', + source: 'logstash-2015.09.17.js' + }, { + indexDefinition: 'makelogsIndexDefinition.js', + indexName: 'logstash-2015.09.18', + source: 'logstash-2015.09.18.js' + }] + }, + emptyKibana: { + baseDir: path.join(rootDir, 'emptyKibana'), + bulk: [{ + indexName: '.kibana', + source: 'kibana.js' + }] + } } }; diff --git a/test/fixtures/scenarioManager.js b/test/fixtures/scenarioManager.js index acc350e6ac90c..6e178167351f6 100644 --- a/test/fixtures/scenarioManager.js +++ b/test/fixtures/scenarioManager.js @@ -1,5 +1,5 @@ var path = require('path'); -var config = require('./config'); +var config = require('./config').scenarios; var elasticsearch = require('elasticsearch'); function ScenarioManager(server) { From 45bce9db2be04035efa9db8378f44b5c1d7b761e Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Fri, 30 Oct 2015 16:39:54 -0700 Subject: [PATCH 05/18] use bluebird delay for sleep method --- test/support/pages/Common.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/test/support/pages/Common.js b/test/support/pages/Common.js index c785f5cfc2c66..d307fca61ff39 100644 --- a/test/support/pages/Common.js +++ b/test/support/pages/Common.js @@ -48,16 +48,11 @@ define(function (require) { }, sleep: function sleep(sleepMilliseconds) { - var self = this; - self.log('... sleep(' + sleepMilliseconds + ') start'); + var log = this.log; + log('... sleep(' + sleepMilliseconds + ') start'); - var promise = new Promise(function (resolve, reject) { - setTimeout(function () { - self.log('... sleep(' + sleepMilliseconds + ') end'); - resolve({}); - }, sleepMilliseconds); - }); - return promise; + return Promise.resolve().delay(sleepMilliseconds) + .then(function () { log('... sleep(' + sleepMilliseconds + ') end'); }) }, screenshotError: function screenshotError(testSubName, reason) { From 22671d7a417cbdc4dc2ac63c6c109ec3905de77a Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Fri, 30 Oct 2015 17:32:16 -0700 Subject: [PATCH 06/18] change how screenshot are captured --- .../apps/settings/_initial_state.js | 13 +++++----- test/support/pages/Common.js | 24 ++++++++++++++----- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/test/functional/apps/settings/_initial_state.js b/test/functional/apps/settings/_initial_state.js index abd07359c9b9d..97a7e82320c3e 100644 --- a/test/functional/apps/settings/_initial_state.js +++ b/test/functional/apps/settings/_initial_state.js @@ -18,13 +18,15 @@ define(function (require) { .then(function (selected) { expect(selected).to.be.ok(); }) + .catch(common.handleError(this)); }); bdd.it('should load with name pattern unchecked', function () { return settingsPage.getNameIsPatternCheckbox().isSelected() .then(function (selected) { expect(selected).to.not.be.ok(); - }); + }) + .catch(common.handleError(this)); }); bdd.it('should contain default index pattern', function () { @@ -34,6 +36,7 @@ define(function (require) { .then(function (pattern) { expect(pattern).to.be(defaultPattern); }) + .catch(common.handleError(this)); }); bdd.it('should not select the time field', function () { @@ -41,13 +44,9 @@ define(function (require) { .then(function (timeFieldIsSelected) { common.log('timeField isSelected = ' + timeFieldIsSelected); expect(timeFieldIsSelected).to.not.be.ok(); - }); + }) + .catch(common.handleError(this)); }); - - // var testSubName = 'testSettingsInitialState'; - // function screenshotError(reason) { - // return common.screenshotError(testSubName, reason); - // } }); }; }); diff --git a/test/support/pages/Common.js b/test/support/pages/Common.js index d307fca61ff39..b471406922587 100644 --- a/test/support/pages/Common.js +++ b/test/support/pages/Common.js @@ -55,15 +55,27 @@ define(function (require) { .then(function () { log('... sleep(' + sleepMilliseconds + ') end'); }) }, - screenshotError: function screenshotError(testSubName, reason) { + handleError: function (testObj) { var self = this; - var now = Date.now(); - var filename = path.resolve('./screenshot-' + testSubName + '-ERROR-' + now + '.png'); - self.log('Test Failed, taking screenshot "' + filename + '"'); - return self.remote.takeScreenshot() + testName = (testObj.parent) ? [testObj.parent.name, testObj.name].join('_') : testObj.name; + + return function (reason) { + var now = Date.now(); + var filename = path.resolve(['./screenshot', now, testName, '.png'].join('_')); + + return self.saveScreenshot(filename) + .then(function () { + throw new Error(reason); + }) + }; + }, + + saveScreenshot: function saveScreenshot(filename) { + this.log('Test Failed, taking screenshot "' + filename + '"'); + + return this.remote.takeScreenshot() .then(function writeScreenshot(data) { fs.writeFileSync(filename, data); - throw new Error(reason); }); } }; From 5176ce08195df68d884183144ad878c36b3b27b0 Mon Sep 17 00:00:00 2001 From: LeeDr Date: Mon, 2 Nov 2015 15:54:53 -0600 Subject: [PATCH 07/18] Changed more testSettings tests to BDD. --- .../apps/settings/_create_button.js | 37 ++++++ .../settings/_index_pattern_create_delete.js | 124 ++++++++++++++++++ .../apps/settings/_name_pattern_checkbox.js | 41 ++++++ test/functional/apps/settings/testSettings.js | 16 ++- test/support/pages/Common.js | 6 +- 5 files changed, 218 insertions(+), 6 deletions(-) create mode 100644 test/functional/apps/settings/_create_button.js create mode 100644 test/functional/apps/settings/_index_pattern_create_delete.js create mode 100644 test/functional/apps/settings/_name_pattern_checkbox.js diff --git a/test/functional/apps/settings/_create_button.js b/test/functional/apps/settings/_create_button.js new file mode 100644 index 0000000000000..1f56ebf13c70f --- /dev/null +++ b/test/functional/apps/settings/_create_button.js @@ -0,0 +1,37 @@ +define(function (require) { + var Common = require('../../../support/pages/Common'); + var SettingsPage = require('../../../support/pages/SettingsPage'); + var expect = require('intern/dojo/node!expect.js'); + + return function (bdd) { + bdd.describe('create button states', function () { + var common; + var settingsPage; + + bdd.before(function () { + common = new Common(this.remote); + settingsPage = new SettingsPage(this.remote); + }); + + bdd.it('should not be initially enabled', function () { + return settingsPage.getCreateButton().isEnabled() + .then(function (enabled) { + expect(enabled).to.not.be.ok(); + }) + .catch(common.handleError(this)); + }); + + bdd.it('should be enabled after selecting time field option', function () { + // select a time field and check that Create button is enabled + return settingsPage.selectTimeFieldOption('@timestamp') + .then(function () { + return settingsPage.getCreateButton().isEnabled() + .then(function (enabled) { + expect(enabled).to.be.ok(); + }); + }) + .catch(common.handleError(this)); + }); + }); + }; +}); diff --git a/test/functional/apps/settings/_index_pattern_create_delete.js b/test/functional/apps/settings/_index_pattern_create_delete.js new file mode 100644 index 0000000000000..d68fb5cf0a9f8 --- /dev/null +++ b/test/functional/apps/settings/_index_pattern_create_delete.js @@ -0,0 +1,124 @@ +define(function (require) { + var Common = require('../../../support/pages/Common'); + var SettingsPage = require('../../../support/pages/SettingsPage'); + var expect = require('intern/dojo/node!expect.js'); + var Promise = require('bluebird'); + + return function (bdd) { + bdd.describe('creating and deleting default index', function describeIndexTests() { + var common; + var settingsPage; + var remote; + var expectedAlertText = 'Are you sure you want to remove this index pattern?'; + + bdd.before(function () { + common = new Common(this.remote); + settingsPage = new SettingsPage(this.remote); + remote = this.remote; + }); + + + function createIndex() { + return settingsPage.selectTimeFieldOption('@timestamp') + .then(function () { + return settingsPage.getCreateButton().click(); + }); + } + + function removeIndex() { + return common.tryForTime(3000, function () { + // delete the index pattern -X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X + return settingsPage.clickDeletePattern(); + }) + .then(function () { + return common.tryForTime(3000, function () { + return remote.getAlertText() + .then(function (alertText) { + expect(alertText).to.be(expectedAlertText); + }); + }); + }) + .then(function () { + return remote.acceptAlert(); + }); + } + + bdd.describe('index pattern creation', function indexPatternCreation() { + bdd.beforeEach(function be() { + return createIndex(); + }); + + bdd.afterEach(function ae() { + return removeIndex(); + }); + + bdd.it('should have index pattern in page header', function pageHeader() { + return settingsPage.getIndexPageHeading().getVisibleText() + .then(function (patternName) { + expect(patternName).to.be('logstash-*'); + }) + .catch(common.handleError(this)); + }); + + bdd.it('should have index pattern in url', function url() { + return common.tryForTime(5000, function () { + return remote.getCurrentUrl() + .then(function (currentUrl) { + expect(currentUrl).to.contain('logstash-*'); + }); + }) + .catch(common.handleError(this)); + }); + + bdd.it('should have expected table headers', function checkingHeader() { + return settingsPage.getTableHeader() + .then(function (headers) { + common.log('header.length = ' + headers.length); + var expectedHeaders = [ + 'name', + 'type', + 'format', + 'analyzed', + 'indexed', + 'controls' + ]; + + // 6 name type format analyzed indexed controls + expect(headers.length).to.be(expectedHeaders.length); + + var comparedHeaders = headers.map(function compareHead(header, i) { + return header.getVisibleText() + .then(function (text) { + expect(text).to.be(expectedHeaders[i]); + }); + }); + + return Promise.all(comparedHeaders); + }) + .catch(common.handleError(this)); + }); + }); + + bdd.describe('index pattern deletion', function indexDelete() { + bdd.it('should return to index pattern creation page', function returnToPage() { + return common.tryForTime(5000, function () { + return settingsPage.getCreateButton(); + }) + .catch(common.handleError(this)); + }); + + bdd.it('should remove index pattern from url', function indexNotInUrl() { + return common.tryForTime(3000, function () { + return remote.getCurrentUrl() + .then(function (currentUrl) { + common.log('currentUrl = ' + currentUrl); + expect(currentUrl).to.not.contain('logstash-*'); + }); + }) + .catch(common.handleError(this)); + }); + }); + + }); + }; +}); diff --git a/test/functional/apps/settings/_name_pattern_checkbox.js b/test/functional/apps/settings/_name_pattern_checkbox.js new file mode 100644 index 0000000000000..2e6f93b30117e --- /dev/null +++ b/test/functional/apps/settings/_name_pattern_checkbox.js @@ -0,0 +1,41 @@ +define(function (require) { + var Common = require('../../../support/pages/Common'); + var SettingsPage = require('../../../support/pages/SettingsPage'); + var expect = require('intern/dojo/node!expect.js'); + + return function (bdd) { + bdd.describe('name is pattern checkbox', function () { + var common; + var settingsPage; + + bdd.before(function () { + common = new Common(this.remote); + settingsPage = new SettingsPage(this.remote); + }); + + bdd.it('should be hidden with time based unchecked', function () { + var self = this; + return settingsPage.getTimeBasedEventsCheckbox() + .then(function (selected) { + // uncheck the 'time-based events' checkbox + return selected.click(); + }) + // try to find the name is pattern checkbox (shouldn't find it) + .then(function () { + return settingsPage.getNameIsPatternCheckbox(); + }) + .then(function () { + // we expect the promise above to fail + var handler = common.handleError(self); + handler( + 'Did not expect to find the Name is Pattern checkbox when the TimeBasedEvents checkbox is unchecked' + ); + }) + .catch(function () { + // we expect this failure since the 'name is pattern' checkbox should be hidden + return; + }); + }); + }); + }; +}); diff --git a/test/functional/apps/settings/testSettings.js b/test/functional/apps/settings/testSettings.js index 3f0a3f87a55ee..efc39e2848331 100644 --- a/test/functional/apps/settings/testSettings.js +++ b/test/functional/apps/settings/testSettings.js @@ -4,18 +4,22 @@ define(function (require) { var config = require('intern').config; var url = require('intern/dojo/node!url'); var _ = require('intern/dojo/node!lodash'); - var Common = require('../../../support/pages/Common'); var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenarioManager'); // var HeaderPage = require('../../../support/pages/HeaderPage'); // var pollUntil = require('intern/dojo/node!leadfoot/helpers/pollUntil'); + var initialStateTest = require('./_initial_state'); + var createButtonTest = require('./_create_button'); + var namePatternCheckboxTest = require('./_name_pattern_checkbox'); + var indexPatternCreateDeleteTest = require('./_index_pattern_create_delete'); + // var indexPatternResultsSortTest = require('./_index_pattern_results_sort'); + // var indexPatternPopularityTest = require('./_index_pattern_popularity'); bdd.describe('settings app', function () { var common; var scenarioManager; var remote; - var expectedAlertText = 'Are you sure you want to remove this index pattern?'; // on setup, we create an settingsPage instance // that we will use for all the tests bdd.before(function () { @@ -25,6 +29,7 @@ define(function (require) { }); bdd.beforeEach(function () { + common.log('running bdd.beforeEach'); // start each test with an empty kibana index return scenarioManager.reload('emptyKibana') // and load a minimal set of makelogs data @@ -57,7 +62,12 @@ define(function (require) { return scenarioManager.unload('makelogs'); }); - require('./_initial_state')(bdd); + initialStateTest(bdd); + + createButtonTest(bdd); + + namePatternCheckboxTest(bdd); + indexPatternCreateDeleteTest(bdd); }); }); diff --git a/test/support/pages/Common.js b/test/support/pages/Common.js index b471406922587..8a1450542ecda 100644 --- a/test/support/pages/Common.js +++ b/test/support/pages/Common.js @@ -52,12 +52,12 @@ define(function (require) { log('... sleep(' + sleepMilliseconds + ') start'); return Promise.resolve().delay(sleepMilliseconds) - .then(function () { log('... sleep(' + sleepMilliseconds + ') end'); }) + .then(function () { log('... sleep(' + sleepMilliseconds + ') end'); }); }, handleError: function (testObj) { var self = this; - testName = (testObj.parent) ? [testObj.parent.name, testObj.name].join('_') : testObj.name; + var testName = (testObj.parent) ? [testObj.parent.name, testObj.name].join('_') : testObj.name; return function (reason) { var now = Date.now(); @@ -66,7 +66,7 @@ define(function (require) { return self.saveScreenshot(filename) .then(function () { throw new Error(reason); - }) + }); }; }, From 47da19d9c0b8a490c3c8ffeac960d56afa19e877 Mon Sep 17 00:00:00 2001 From: LeeDr Date: Mon, 2 Nov 2015 18:29:18 -0600 Subject: [PATCH 08/18] Added _index_pattern_results_sort. --- .../settings/_index_pattern_create_delete.js | 43 ++---- .../settings/_index_pattern_results_sort.js | 136 ++++++++++++++++++ test/functional/apps/settings/testSettings.js | 16 ++- test/support/pages/SettingsPage.js | 52 ++++++- 4 files changed, 205 insertions(+), 42 deletions(-) create mode 100644 test/functional/apps/settings/_index_pattern_results_sort.js diff --git a/test/functional/apps/settings/_index_pattern_create_delete.js b/test/functional/apps/settings/_index_pattern_create_delete.js index d68fb5cf0a9f8..87c5936c3b55a 100644 --- a/test/functional/apps/settings/_index_pattern_create_delete.js +++ b/test/functional/apps/settings/_index_pattern_create_delete.js @@ -9,7 +9,6 @@ define(function (require) { var common; var settingsPage; var remote; - var expectedAlertText = 'Are you sure you want to remove this index pattern?'; bdd.before(function () { common = new Common(this.remote); @@ -18,38 +17,17 @@ define(function (require) { }); - function createIndex() { - return settingsPage.selectTimeFieldOption('@timestamp') - .then(function () { - return settingsPage.getCreateButton().click(); - }); - } - - function removeIndex() { - return common.tryForTime(3000, function () { - // delete the index pattern -X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X - return settingsPage.clickDeletePattern(); - }) - .then(function () { - return common.tryForTime(3000, function () { - return remote.getAlertText() - .then(function (alertText) { - expect(alertText).to.be(expectedAlertText); - }); - }); - }) - .then(function () { - return remote.acceptAlert(); - }); - } - bdd.describe('index pattern creation', function indexPatternCreation() { bdd.beforeEach(function be() { - return createIndex(); + return settingsPage.createIndex(); }); bdd.afterEach(function ae() { - return removeIndex(); + var expectedAlertText = 'Are you sure you want to remove this index pattern?'; + return settingsPage.removeIndex() + .then(function (alertText) { + expect(alertText).to.be(expectedAlertText); + }); }); bdd.it('should have index pattern in page header', function pageHeader() { @@ -99,7 +77,16 @@ define(function (require) { }); }); + bdd.describe('index pattern deletion', function indexDelete() { + + bdd.beforeEach(function be() { + return settingsPage.createIndex() + .then(function () { + return settingsPage.removeIndex(); + }); + }); + bdd.it('should return to index pattern creation page', function returnToPage() { return common.tryForTime(5000, function () { return settingsPage.getCreateButton(); diff --git a/test/functional/apps/settings/_index_pattern_results_sort.js b/test/functional/apps/settings/_index_pattern_results_sort.js new file mode 100644 index 0000000000000..1311f12d8ac09 --- /dev/null +++ b/test/functional/apps/settings/_index_pattern_results_sort.js @@ -0,0 +1,136 @@ +define(function (require) { + var Common = require('../../../support/pages/Common'); + var SettingsPage = require('../../../support/pages/SettingsPage'); + var expect = require('intern/dojo/node!expect.js'); + var Promise = require('bluebird'); + + return function (bdd) { + bdd.describe('index result field sort', function describeIndexTests() { + var common; + var settingsPage; + var remote; + + bdd.before(function () { + common = new Common(this.remote); + settingsPage = new SettingsPage(this.remote); + remote = this.remote; + }); + + bdd.beforeEach(function be() { + return settingsPage.createIndex(); + }); + + bdd.afterEach(function ae() { + return settingsPage.removeIndex(); + }); + + + bdd.describe('sort by name', function indexPatternCreation() { + + bdd.it('should sort ascending', function pageHeader() { + return settingsPage.sortBy('name') + .then(function getText() { + return settingsPage.getTableRow(0, 0).getVisibleText(); + }) + .then(function (rowText) { + expect(rowText).to.be('@message'); + }) + .catch(common.handleError(this)); + }); + + bdd.it('should sort descending', function pageHeader() { + return settingsPage.sortBy('name') + .then(function sortAgain() { + return settingsPage.sortBy('name'); + }) + .then(function getText() { + return settingsPage.getTableRow(0, 0).getVisibleText(); + }) + .then(function (rowText) { + expect(rowText).to.be('xss.raw'); + }) + .catch(common.handleError(this)); + }); + }); + + bdd.describe('sort by type', function indexPatternCreation() { + + bdd.it('should sort ascending', function pageHeader() { + return settingsPage.sortBy('type') + .then(function getText() { + return settingsPage.getTableRow(0, 1).getVisibleText(); + }) + .then(function (rowText) { + expect(rowText).to.be('_source'); + }) + .catch(common.handleError(this)); + }); + + bdd.it('should sort descending', function pageHeader() { + return settingsPage.sortBy('type') + .then(function sortAgain() { + return settingsPage.sortBy('type'); + }) + .then(function getText() { + return settingsPage.getTableRow(0, 1).getVisibleText(); + }) + .then(function (rowText) { + expect(rowText).to.be('string'); + }) + .catch(common.handleError(this)); + }); + }); + + bdd.describe('pagination', function () { + var expectedDefaultPageSize = 25; + var expectedFieldCount = 85; + var expectedLastPageCount = 10; + var pages = [1, 2, 3, 4]; + + bdd.it('makelogs data should have expected number of fields', function () { + return common.sleep(1000) + .then(function () { + return common.tryForTime(5000, function () { + return settingsPage.getFieldsTabCount() + .then(function (tabCount) { + expect(tabCount).to.be('' + expectedFieldCount); + }); + }); + }) + .catch(common.handleError(this)); + }); + + bdd.it('should have correct default page size selected', function () { + return settingsPage.getPageSize() + .then(function (pageSize) { + expect(pageSize).to.be('' + expectedDefaultPageSize); + }) + .catch(common.handleError(this)); + }); + + bdd.it('should have the correct number of rows per page', function () { + var pageCount = Math.ceil(expectedFieldCount / expectedDefaultPageSize); + var chain = pages.reduce(function (chain, val) { + return chain.then(function () { + return settingsPage.goToPage(val) + .then(function () { + return common.sleep(1000); + }) + .then(function () { + return settingsPage.getPageFieldCount(); + }) + .then(function (pageCount) { + var expectedSize = (val < 4) ? expectedDefaultPageSize : expectedLastPageCount; + expect(pageCount.length).to.be(expectedSize); + }); + }); + }, Promise.resolve()); + + return chain.catch(common.handleError(this)); + }); + + }); // end describe pagination + + }); // end index result field sort + }; +}); diff --git a/test/functional/apps/settings/testSettings.js b/test/functional/apps/settings/testSettings.js index efc39e2848331..181d3083729dc 100644 --- a/test/functional/apps/settings/testSettings.js +++ b/test/functional/apps/settings/testSettings.js @@ -12,7 +12,7 @@ define(function (require) { var createButtonTest = require('./_create_button'); var namePatternCheckboxTest = require('./_name_pattern_checkbox'); var indexPatternCreateDeleteTest = require('./_index_pattern_create_delete'); - // var indexPatternResultsSortTest = require('./_index_pattern_results_sort'); + var indexPatternResultsSortTest = require('./_index_pattern_results_sort'); // var indexPatternPopularityTest = require('./_index_pattern_popularity'); bdd.describe('settings app', function () { @@ -62,12 +62,14 @@ define(function (require) { return scenarioManager.unload('makelogs'); }); - initialStateTest(bdd); + // initialStateTest(bdd); + // + // createButtonTest(bdd); + // + // namePatternCheckboxTest(bdd); + // + // indexPatternCreateDeleteTest(bdd); - createButtonTest(bdd); - - namePatternCheckboxTest(bdd); - - indexPatternCreateDeleteTest(bdd); + indexPatternResultsSortTest(bdd); }); }); diff --git a/test/support/pages/SettingsPage.js b/test/support/pages/SettingsPage.js index 59f75b4258f93..820adda774e2b 100644 --- a/test/support/pages/SettingsPage.js +++ b/test/support/pages/SettingsPage.js @@ -119,13 +119,10 @@ define(function (require) { getFieldsTabCount: function getFieldsTabCount() { return this.remote.setFindTimeout(defaultTimeout) // passing in zero-based index, but adding 1 for css 1-based indexes - .findByCssSelector('li.kbn-settings-tab.ng-scope.active a.ng-binding small.ng-binding') - .then(function (tabData) { - return tabData.getVisibleText() - .then(function (theText) { - // the value has () around it, remove them - return theText.replace(/\((.*)\)/, '$1'); - }); + .findByCssSelector('li.kbn-settings-tab.ng-scope.active a.ng-binding small.ng-binding').getVisibleText() + .then(function (theText) { + // the value has () around it, remove them + return theText.replace(/\((.*)\)/, '$1'); }); }, @@ -227,6 +224,47 @@ define(function (require) { .then(function (button) { return button.click(); }); + }, + + createIndex: function createIndex() { + var self = this; + return this.selectTimeFieldOption('@timestamp') + .then(function () { + return self.getCreateButton().click(); + }) + .then(function () { + return common.tryForTime(3000, function () { + return self.remote.getCurrentUrl() + .then(function (currentUrl) { + if (!currentUrl.match(/indices\/.+\?/)) { + throw new Error('Index pattern not created'); + } + }); + }); + }); + }, + + removeIndex: function removeIndex() { + var self = this; + var alertText; + return common.tryForTime(3000, function () { + // delete the index pattern -X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X + return self.clickDeletePattern(); + }) + .then(function () { + return common.tryForTime(3000, function () { + return self.remote.getAlertText() + .then(function (text) { + alertText = text; + }); + }); + }) + .then(function () { + return self.remote.acceptAlert(); + }) + .then(function () { + return alertText; + }); } }; From 43c91ffbc28356fa225d260a4e06efffef1995eb Mon Sep 17 00:00:00 2001 From: LeeDr Date: Mon, 2 Nov 2015 18:30:48 -0600 Subject: [PATCH 09/18] Ignore screenshot-*.png. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1e7c58a50a2ef..86993eef3f7a3 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ target .idea *.iml *.log +screenshot-*.png /esvm .htpasswd .eslintcache From 93501a45900cd6618453964140b997f4233c2e0d Mon Sep 17 00:00:00 2001 From: LeeDr Date: Tue, 3 Nov 2015 09:33:40 -0600 Subject: [PATCH 10/18] Added _index_pattern_popularity tests. --- .../settings/_index_pattern_popularity.js | 115 ++++++++++++++++++ test/functional/apps/settings/testSettings.js | 18 +-- 2 files changed, 125 insertions(+), 8 deletions(-) create mode 100644 test/functional/apps/settings/_index_pattern_popularity.js diff --git a/test/functional/apps/settings/_index_pattern_popularity.js b/test/functional/apps/settings/_index_pattern_popularity.js new file mode 100644 index 0000000000000..417f95e9a8228 --- /dev/null +++ b/test/functional/apps/settings/_index_pattern_popularity.js @@ -0,0 +1,115 @@ +define(function (require) { + var Common = require('../../../support/pages/Common'); + var SettingsPage = require('../../../support/pages/SettingsPage'); + var expect = require('intern/dojo/node!expect.js'); + //var Promise = require('bluebird'); + + return function (bdd) { + bdd.describe('index result popularity', function describeIndexTests() { + var common; + var settingsPage; + var remote; + + bdd.before(function () { + common = new Common(this.remote); + settingsPage = new SettingsPage(this.remote); + remote = this.remote; + }); + + bdd.beforeEach(function be() { + return settingsPage.createIndex(); + }); + + bdd.afterEach(function ae() { + return settingsPage.removeIndex(); + }); + + + bdd.describe('change popularity', function indexPatternCreation() { + + bdd.it('can be cancelled', function pageHeader() { + return settingsPage.setPageSize('All') + // increase Popularity + .then(function openControlsByName() { + common.log('Starting openControlsByName "geo.coordinates"'); + return settingsPage.openControlsByName('geo.coordinates'); + }) + .then(function increasePopularity() { + common.log('increasePopularity'); + return settingsPage.increasePopularity(); + }) + .then(function getPopularity() { + return settingsPage.getPopularity(); + }) + .then(function (popularity) { + common.log('popularity = ' + popularity); + expect(popularity).to.be('1'); + }) + // Cancel saving the popularity change + .then(function controlChangeCancel() { + return settingsPage.controlChangeCancel(); + }) + // set the page size to All again, https://github.com/elastic/kibana/issues/5030 + .then(function () { + return settingsPage.setPageSize('All'); + }) + .then(function openControlsByName() { + return settingsPage.openControlsByName('geo.coordinates'); + }) + // check that its 0 (previous increase was cancelled) + .then(function getPopularity() { + return settingsPage.getPopularity() + .then(function (popularity) { + common.log('popularity = ' + popularity); + expect(popularity).to.be('0'); + }) + // Cancel saving the popularity change (we were just checking) + .then(function controlChangeCancel() { + return settingsPage.controlChangeCancel(); + }) + .catch(common.handleError(this)); + }); + }); + + bdd.it('can be saved', function pageHeader() { + return settingsPage.setPageSize('All') + // increase Popularity + .then(function openControlsByName() { + common.log('Starting openControlsByName "geo.coordinates"'); + return settingsPage.openControlsByName('geo.coordinates'); + }) + .then(function increasePopularity() { + return settingsPage.increasePopularity(); + }) + // Saving the popularity change + .then(function controlChangeSave() { + return settingsPage.controlChangeSave(); + }) + // set the page size to All again, https://github.com/elastic/kibana/issues/5030 + .then(function () { + return settingsPage.setPageSize('All'); + }) + // open it again to see that it saved + .then(function openControlsByName() { + return settingsPage.openControlsByName('geo.coordinates'); + }) + // check that its 0 (previous increase was cancelled) + .then(function getPopularity() { + return settingsPage.getPopularity(); + }) + .then(function (popularity) { + common.log('popularity = ' + popularity); + expect(popularity).to.be('1'); + }) + // Cancel saving the popularity change (we didn't make a change in this case, just checking the value) + .then(function controlChangeCancel() { + return settingsPage.controlChangeCancel(); + }) + .catch(common.handleError(this)); + }); + + }); // end 'change popularity' + + }); // end index result popularity + }; +}); diff --git a/test/functional/apps/settings/testSettings.js b/test/functional/apps/settings/testSettings.js index 181d3083729dc..524d5c1cd3a2f 100644 --- a/test/functional/apps/settings/testSettings.js +++ b/test/functional/apps/settings/testSettings.js @@ -13,7 +13,7 @@ define(function (require) { var namePatternCheckboxTest = require('./_name_pattern_checkbox'); var indexPatternCreateDeleteTest = require('./_index_pattern_create_delete'); var indexPatternResultsSortTest = require('./_index_pattern_results_sort'); - // var indexPatternPopularityTest = require('./_index_pattern_popularity'); + var indexPatternPopularityTest = require('./_index_pattern_popularity'); bdd.describe('settings app', function () { var common; @@ -62,14 +62,16 @@ define(function (require) { return scenarioManager.unload('makelogs'); }); - // initialStateTest(bdd); - // - // createButtonTest(bdd); - // - // namePatternCheckboxTest(bdd); - // - // indexPatternCreateDeleteTest(bdd); + initialStateTest(bdd); + + createButtonTest(bdd); + + namePatternCheckboxTest(bdd); + + indexPatternCreateDeleteTest(bdd); indexPatternResultsSortTest(bdd); + + indexPatternPopularityTest(bdd); }); }); From 33d2484d9386c65a8c4b68c17d5ac96ca66459fb Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 3 Nov 2015 13:55:18 -0700 Subject: [PATCH 11/18] remove delay after createing makelogs data --- test/functional/apps/settings/testSettings.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/functional/apps/settings/testSettings.js b/test/functional/apps/settings/testSettings.js index 524d5c1cd3a2f..732d406ccdf47 100644 --- a/test/functional/apps/settings/testSettings.js +++ b/test/functional/apps/settings/testSettings.js @@ -36,9 +36,6 @@ define(function (require) { .then(function loadIfEmptyMakelogs() { return scenarioManager.loadIfEmpty('makelogs'); }) - .then(function () { - return common.sleep(3000); - }) .then(function () { return common.tryForTime(25000, function () { return remote.get(url.format(_.assign(config.kibana, { From a5748f27af8e5bd9b01f04bc2a34560e584dd807 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 3 Nov 2015 15:35:33 -0700 Subject: [PATCH 12/18] break down the popularity tests a little --- .../settings/_index_pattern_popularity.js | 82 +++++++++---------- test/functional/apps/settings/testSettings.js | 3 +- 2 files changed, 39 insertions(+), 46 deletions(-) diff --git a/test/functional/apps/settings/_index_pattern_popularity.js b/test/functional/apps/settings/_index_pattern_popularity.js index 417f95e9a8228..e9b2faa19401d 100644 --- a/test/functional/apps/settings/_index_pattern_popularity.js +++ b/test/functional/apps/settings/_index_pattern_popularity.js @@ -24,87 +24,81 @@ define(function (require) { return settingsPage.removeIndex(); }); - bdd.describe('change popularity', function indexPatternCreation() { + var fieldName = 'geo.coordinates'; + + // set the page size to All again, https://github.com/elastic/kibana/issues/5030 + // TODO: remove this after #5030 is closed + function fix5030() { + return settingsPage.setPageSize('All') + .then(function () { + return common.sleep(1000); + }); + } - bdd.it('can be cancelled', function pageHeader() { + bdd.beforeEach(function () { + // increase Popularity of geo.coordinates return settingsPage.setPageSize('All') - // increase Popularity + .then(function () { + return common.sleep(1000); + }) .then(function openControlsByName() { - common.log('Starting openControlsByName "geo.coordinates"'); - return settingsPage.openControlsByName('geo.coordinates'); + return settingsPage.openControlsByName(fieldName); }) .then(function increasePopularity() { - common.log('increasePopularity'); return settingsPage.increasePopularity(); - }) - .then(function getPopularity() { - return settingsPage.getPopularity(); - }) + }); + }); + + bdd.afterEach(function () { + // Cancel saving the popularity change (we didn't make a change in this case, just checking the value) + return settingsPage.controlChangeCancel(); + }); + + bdd.it('should update the popularity input', function () { + return settingsPage.getPopularity() .then(function (popularity) { - common.log('popularity = ' + popularity); expect(popularity).to.be('1'); }) + .catch(common.handleError(this)); + }); + + bdd.it('should be reset on cancel', function pageHeader() { // Cancel saving the popularity change - .then(function controlChangeCancel() { - return settingsPage.controlChangeCancel(); - }) - // set the page size to All again, https://github.com/elastic/kibana/issues/5030 + + return settingsPage.controlChangeCancel() .then(function () { - return settingsPage.setPageSize('All'); + return fix5030(); }) .then(function openControlsByName() { - return settingsPage.openControlsByName('geo.coordinates'); + return settingsPage.openControlsByName(fieldName); }) // check that its 0 (previous increase was cancelled) .then(function getPopularity() { return settingsPage.getPopularity() + }) .then(function (popularity) { - common.log('popularity = ' + popularity); expect(popularity).to.be('0'); }) - // Cancel saving the popularity change (we were just checking) - .then(function controlChangeCancel() { - return settingsPage.controlChangeCancel(); - }) .catch(common.handleError(this)); - }); }); bdd.it('can be saved', function pageHeader() { - return settingsPage.setPageSize('All') - // increase Popularity - .then(function openControlsByName() { - common.log('Starting openControlsByName "geo.coordinates"'); - return settingsPage.openControlsByName('geo.coordinates'); - }) - .then(function increasePopularity() { - return settingsPage.increasePopularity(); - }) // Saving the popularity change - .then(function controlChangeSave() { - return settingsPage.controlChangeSave(); - }) - // set the page size to All again, https://github.com/elastic/kibana/issues/5030 + return settingsPage.controlChangeSave() .then(function () { - return settingsPage.setPageSize('All'); + return fix5030(); }) - // open it again to see that it saved .then(function openControlsByName() { - return settingsPage.openControlsByName('geo.coordinates'); + return settingsPage.openControlsByName(fieldName); }) // check that its 0 (previous increase was cancelled) .then(function getPopularity() { return settingsPage.getPopularity(); }) .then(function (popularity) { - common.log('popularity = ' + popularity); expect(popularity).to.be('1'); }) - // Cancel saving the popularity change (we didn't make a change in this case, just checking the value) - .then(function controlChangeCancel() { - return settingsPage.controlChangeCancel(); - }) .catch(common.handleError(this)); }); diff --git a/test/functional/apps/settings/testSettings.js b/test/functional/apps/settings/testSettings.js index 732d406ccdf47..75333104928f4 100644 --- a/test/functional/apps/settings/testSettings.js +++ b/test/functional/apps/settings/testSettings.js @@ -6,8 +6,7 @@ define(function (require) { var _ = require('intern/dojo/node!lodash'); var Common = require('../../../support/pages/Common'); var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenarioManager'); - // var HeaderPage = require('../../../support/pages/HeaderPage'); - // var pollUntil = require('intern/dojo/node!leadfoot/helpers/pollUntil'); + var initialStateTest = require('./_initial_state'); var createButtonTest = require('./_create_button'); var namePatternCheckboxTest = require('./_name_pattern_checkbox'); From 1ee196f2920f13700b6e8c9714d2fdc2cb09a9c0 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 3 Nov 2015 15:37:21 -0700 Subject: [PATCH 13/18] only reset kibana index before each test no need to reset the makelogs data --- test/functional/apps/settings/testSettings.js | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/test/functional/apps/settings/testSettings.js b/test/functional/apps/settings/testSettings.js index 75333104928f4..453c40fdcb495 100644 --- a/test/functional/apps/settings/testSettings.js +++ b/test/functional/apps/settings/testSettings.js @@ -19,43 +19,46 @@ define(function (require) { var scenarioManager; var remote; + function checkForSettingsUrl() { + return common.tryForTime(25000, function () { + return remote.get(url.format(_.assign(config.kibana, { + pathname: '' + }))) + .then(function () { + // give angular enough time to update the URL + return common.sleep(2000); + }) + .then(function () { + return remote.getCurrentUrl() + .then(function (currentUrl) { + expect(currentUrl).to.contain('settings'); + }); + }); + }); + } + // on setup, we create an settingsPage instance // that we will use for all the tests bdd.before(function () { common = new Common(this.remote); scenarioManager = new ScenarioManager(url.format(config.elasticsearch)); remote = this.remote; + + return scenarioManager.loadIfEmpty('makelogs'); }); bdd.beforeEach(function () { - common.log('running bdd.beforeEach'); - // start each test with an empty kibana index return scenarioManager.reload('emptyKibana') - // and load a minimal set of makelogs data - .then(function loadIfEmptyMakelogs() { - return scenarioManager.loadIfEmpty('makelogs'); - }) .then(function () { - return common.tryForTime(25000, function () { - return remote.get(url.format(_.assign(config.kibana, { - pathname: '' - }))) - .then(function () { - // give angular enough time to update the URL - return common.sleep(2000); - }) - .then(function () { - return remote.getCurrentUrl() - .then(function (currentUrl) { - expect(currentUrl).to.contain('settings'); - }); - }); - }); + return checkForSettingsUrl(); }); }); - bdd.after(function unloadMakelogs() { - return scenarioManager.unload('makelogs'); + bdd.after(function () { + return scenarioManager.unload('makelogs') + .then(function () { + scenarioManager.unload('emptyKibana'); + }); }); initialStateTest(bdd); From 6419590b0be0f9541c764d77ea355446f48b5a6e Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 3 Nov 2015 15:53:41 -0700 Subject: [PATCH 14/18] fix screenshot ignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 86993eef3f7a3..7cf7e97724231 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ target .idea *.iml *.log -screenshot-*.png +screenshot*.png /esvm .htpasswd .eslintcache From f6c442ba7076a179a9f03697fc441102c3f11ca1 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 3 Nov 2015 15:53:57 -0700 Subject: [PATCH 15/18] add back the status tests in bdd form this time --- test/functional/status_page/index.js | 34 ++++++++++++++++++++++++++++ test/intern.js | 1 + 2 files changed, 35 insertions(+) create mode 100644 test/functional/status_page/index.js diff --git a/test/functional/status_page/index.js b/test/functional/status_page/index.js new file mode 100644 index 0000000000000..d1eb86212ab7c --- /dev/null +++ b/test/functional/status_page/index.js @@ -0,0 +1,34 @@ +define(function (require) { + var bdd = require('intern!bdd'); + var expect = require('intern/dojo/node!expect.js'); + var config = require('intern').config; + var getUrl = require('intern/dojo/node!../../utils/getUrl'); + var Common = require('../../support/pages/Common'); + + bdd.describe('status page', function () { + var common; + + bdd.before(function () { + common = new Common(this.remote); + }); + + bdd.beforeEach(function () { + // load the status page + return this.remote.get(getUrl(config.kibana, 'status')); + }); + + bdd.it('should show the kibana plugin as ready', function () { + var self = this; + + return common.tryForTime(6000, function () { + return self.remote + .findByCssSelector('.plugin_status_breakdown') + .getVisibleText() + .then(function (text) { + expect(text.indexOf('plugin:kibana Ready')).to.be.above(-1); + }) + }) + .catch(common.handleError(self)); + }); + }); +}); \ No newline at end of file diff --git a/test/intern.js b/test/intern.js index 76aba2141902b..10f2dc1666fd2 100644 --- a/test/intern.js +++ b/test/intern.js @@ -12,6 +12,7 @@ define(function (require) { }], tunnelOptions: serverConfig.webdriver, functionalSuites: [ + 'test/functional/status_page/index' 'test/functional/apps/settings/testSettings' ], excludeInstrumentation: /(fixtures|node_modules)\//, From ea54f199329a5103e703a888d9411d9d28d75c31 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 3 Nov 2015 15:54:40 -0700 Subject: [PATCH 16/18] rename entry file for settings tests --- test/functional/apps/settings/{testSettings.js => index.js} | 0 test/intern.js | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename test/functional/apps/settings/{testSettings.js => index.js} (100%) diff --git a/test/functional/apps/settings/testSettings.js b/test/functional/apps/settings/index.js similarity index 100% rename from test/functional/apps/settings/testSettings.js rename to test/functional/apps/settings/index.js diff --git a/test/intern.js b/test/intern.js index 10f2dc1666fd2..d4585ea96e81a 100644 --- a/test/intern.js +++ b/test/intern.js @@ -12,8 +12,8 @@ define(function (require) { }], tunnelOptions: serverConfig.webdriver, functionalSuites: [ - 'test/functional/status_page/index' - 'test/functional/apps/settings/testSettings' + 'test/functional/status_page/index', + 'test/functional/apps/settings/index' ], excludeInstrumentation: /(fixtures|node_modules)\//, loaderOptions: { From cbcc34ee80c40863315d6b6375eadcbb8a45cf7c Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 3 Nov 2015 16:19:04 -0700 Subject: [PATCH 17/18] clean up stray common.logs, unused deps --- test/functional/apps/settings/_index_pattern_create_delete.js | 2 -- test/functional/apps/settings/_initial_state.js | 1 - test/support/pages/Common.js | 3 --- 3 files changed, 6 deletions(-) diff --git a/test/functional/apps/settings/_index_pattern_create_delete.js b/test/functional/apps/settings/_index_pattern_create_delete.js index 87c5936c3b55a..d5cc55e8156d7 100644 --- a/test/functional/apps/settings/_index_pattern_create_delete.js +++ b/test/functional/apps/settings/_index_pattern_create_delete.js @@ -51,7 +51,6 @@ define(function (require) { bdd.it('should have expected table headers', function checkingHeader() { return settingsPage.getTableHeader() .then(function (headers) { - common.log('header.length = ' + headers.length); var expectedHeaders = [ 'name', 'type', @@ -98,7 +97,6 @@ define(function (require) { return common.tryForTime(3000, function () { return remote.getCurrentUrl() .then(function (currentUrl) { - common.log('currentUrl = ' + currentUrl); expect(currentUrl).to.not.contain('logstash-*'); }); }) diff --git a/test/functional/apps/settings/_initial_state.js b/test/functional/apps/settings/_initial_state.js index 97a7e82320c3e..948eb415d162c 100644 --- a/test/functional/apps/settings/_initial_state.js +++ b/test/functional/apps/settings/_initial_state.js @@ -42,7 +42,6 @@ define(function (require) { bdd.it('should not select the time field', function () { return settingsPage.getTimeFieldNameField().isSelected() .then(function (timeFieldIsSelected) { - common.log('timeField isSelected = ' + timeFieldIsSelected); expect(timeFieldIsSelected).to.not.be.ok(); }) .catch(common.handleError(this)); diff --git a/test/support/pages/Common.js b/test/support/pages/Common.js index 8a1450542ecda..b5aa3e4e8381f 100644 --- a/test/support/pages/Common.js +++ b/test/support/pages/Common.js @@ -1,8 +1,5 @@ // in test/support/pages/Common.js define(function (require) { - - var registerSuite = require('intern!object'); - var expect = require('intern/dojo/node!expect.js'); var Promise = require('bluebird'); var moment = require('moment'); var fs = require('intern/dojo/node!fs'); From d42f54b5d3144ddbebeaadb1de83fd05118f824e Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 3 Nov 2015 16:19:53 -0700 Subject: [PATCH 18/18] add debug method to common add debug setting to intern config, don't output debug messages by default --- test/intern.js | 1 + test/support/pages/Common.js | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/test/intern.js b/test/intern.js index d4585ea96e81a..a57e9385bce4c 100644 --- a/test/intern.js +++ b/test/intern.js @@ -3,6 +3,7 @@ define(function (require) { var _ = require('intern/dojo/node!lodash'); return _.assign({ + debug: false, capabilities: { 'selenium-version': '2.47.1', 'idle-timeout': 30 diff --git a/test/support/pages/Common.js b/test/support/pages/Common.js index b5aa3e4e8381f..6199a9c3403ad 100644 --- a/test/support/pages/Common.js +++ b/test/support/pages/Common.js @@ -1,5 +1,6 @@ // in test/support/pages/Common.js define(function (require) { + var config = require('intern').config; var Promise = require('bluebird'); var moment = require('moment'); var fs = require('intern/dojo/node!fs'); @@ -27,12 +28,12 @@ define(function (require) { return Promise .try(block) .then(function tryForTimeSuccess() { - self.log('tryForTime success in about ' + (lastTry - start) + ' milliseconds'); + self.debug('tryForTime success in about ' + (lastTry - start) + ' milliseconds'); return (lastTry - start); }) .catch(function tryForTimeCatch(err) { - self.log('failed with "' + err.message + '"'); - self.log('trying again in 1/2 second'); + self.debug('failed with "' + err.message + '"'); + self.debug('trying again in 1/2 second'); return Promise.delay(500).then(attempt); }); } @@ -44,12 +45,16 @@ define(function (require) { console.log(moment().format('HH:mm:ss.SSS') + ': ' + logString); }, + debug: function debug(logString) { + if (config.debug) this.log(logString); + }, + sleep: function sleep(sleepMilliseconds) { - var log = this.log; - log('... sleep(' + sleepMilliseconds + ') start'); + var debug = this.debug; + debug('... sleep(' + sleepMilliseconds + ') start'); return Promise.resolve().delay(sleepMilliseconds) - .then(function () { log('... sleep(' + sleepMilliseconds + ') end'); }); + .then(function () { debug('... sleep(' + sleepMilliseconds + ') end'); }); }, handleError: function (testObj) { @@ -68,7 +73,7 @@ define(function (require) { }, saveScreenshot: function saveScreenshot(filename) { - this.log('Test Failed, taking screenshot "' + filename + '"'); + this.debug('Test Failed, taking screenshot "' + filename + '"'); return this.remote.takeScreenshot() .then(function writeScreenshot(data) {