mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
* Fix a type error from the default to named conversion add tests that would have caught it. * address code review comments
This commit is contained in:
parent
d6501e85b1
commit
b994f600e5
4 changed files with 80 additions and 39 deletions
|
@ -87,6 +87,7 @@
|
|||
ng-model="conf.unsavedValue"
|
||||
type="checkbox"
|
||||
class="kuiCheckBox"
|
||||
data-test-subj="advancedSetting-{{conf.name}}-checkbox"
|
||||
>
|
||||
|
||||
<select
|
||||
|
|
|
@ -15,7 +15,7 @@ import { Notifier } from 'ui/notify/notifier';
|
|||
|
||||
import {
|
||||
createStateHash,
|
||||
hashedItemStoreSingleton,
|
||||
HashedItemStoreSingleton,
|
||||
isStateHash,
|
||||
} from './state_storage';
|
||||
|
||||
|
@ -26,7 +26,7 @@ export function StateProvider(Private, $rootScope, $location, config, kbnUrl) {
|
|||
function State(
|
||||
urlParam,
|
||||
defaults,
|
||||
hashedItemStore = hashedItemStoreSingleton,
|
||||
hashedItemStore = HashedItemStoreSingleton,
|
||||
notifier = new Notifier()
|
||||
) {
|
||||
State.Super.call(this);
|
||||
|
|
|
@ -2,26 +2,17 @@ import expect from 'expect.js';
|
|||
|
||||
export default function ({ getService, getPageObjects }) {
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
const log = getService('log');
|
||||
const screenshots = getService('screenshots');
|
||||
const PageObjects = getPageObjects(['settings', 'common']);
|
||||
const remote = getService('remote');
|
||||
const PageObjects = getPageObjects(['settings', 'common', 'dashboard', 'header']);
|
||||
|
||||
describe('creating and deleting default index', function describeIndexTests() {
|
||||
before(function () {
|
||||
before(async function () {
|
||||
// delete .kibana index and then wait for Kibana to re-create it
|
||||
return kibanaServer.uiSettings.replace({})
|
||||
.then(function () {
|
||||
return PageObjects.settings.navigateTo();
|
||||
})
|
||||
.then(function () {
|
||||
return PageObjects.settings.clickKibanaIndices();
|
||||
})
|
||||
.then(function () {
|
||||
return PageObjects.settings.createIndexPattern();
|
||||
})
|
||||
.then(function () {
|
||||
return PageObjects.settings.navigateTo();
|
||||
});
|
||||
await kibanaServer.uiSettings.replace({});
|
||||
await PageObjects.settings.navigateTo();
|
||||
await PageObjects.settings.clickKibanaIndices();
|
||||
await PageObjects.settings.createIndexPattern();
|
||||
await PageObjects.settings.navigateTo();
|
||||
});
|
||||
|
||||
after(async function afterAll() {
|
||||
|
@ -30,29 +21,68 @@ export default function ({ getService, getPageObjects }) {
|
|||
await PageObjects.settings.removeIndexPattern();
|
||||
});
|
||||
|
||||
it('should allow setting advanced settings', function () {
|
||||
return PageObjects.settings.clickKibanaSettings()
|
||||
.then(function TestCallSetAdvancedSettingsForTimezone() {
|
||||
screenshots.take('Settings-advanced-tab');
|
||||
log.debug('calling setAdvancedSetting');
|
||||
return PageObjects.settings.setAdvancedSettings('dateFormat:tz', 'America/Phoenix');
|
||||
})
|
||||
.then(function GetAdvancedSetting() {
|
||||
screenshots.take('Settings-set-timezone');
|
||||
return PageObjects.settings.getAdvancedSettings('dateFormat:tz');
|
||||
})
|
||||
.then(function (advancedSetting) {
|
||||
expect(advancedSetting).to.be('America/Phoenix');
|
||||
it('should allow setting advanced settings', async function () {
|
||||
await PageObjects.settings.clickKibanaSettings();
|
||||
await PageObjects.settings.setAdvancedSettings('dateFormat:tz', 'America/Phoenix');
|
||||
const advancedSetting = await PageObjects.settings.getAdvancedSettings('dateFormat:tz');
|
||||
expect(advancedSetting).to.be('America/Phoenix');
|
||||
});
|
||||
|
||||
describe('state:storeInSessionStorage', () => {
|
||||
it ('defaults to false', async () => {
|
||||
await PageObjects.settings.clickKibanaSettings();
|
||||
const storeInSessionStorage = await PageObjects.settings.getAdvancedSettings('state:storeInSessionStorage');
|
||||
expect(storeInSessionStorage).to.be('false');
|
||||
});
|
||||
|
||||
it('when false, dashboard state is unhashed', async function () {
|
||||
await PageObjects.common.navigateToApp('dashboard');
|
||||
await PageObjects.dashboard.clickNewDashboard();
|
||||
await PageObjects.header.setAbsoluteRange('2015-09-19 06:31:44.000', '2015-09-23 18:31:44.000');
|
||||
const currentUrl = await remote.getCurrentUrl();
|
||||
const urlPieces = currentUrl.match(/(.*)?_g=(.*)&_a=(.*)/);
|
||||
const globalState = urlPieces[2];
|
||||
const appState = urlPieces[3];
|
||||
|
||||
// We don't have to be exact, just need to ensure it's greater than when the hashed variation is being used,
|
||||
// which is less than 20 characters.
|
||||
expect(globalState.length).to.be.greaterThan(20);
|
||||
expect(appState.length).to.be.greaterThan(20);
|
||||
});
|
||||
|
||||
it('setting to true change is preserved', async function () {
|
||||
await PageObjects.settings.navigateTo();
|
||||
await PageObjects.settings.clickKibanaSettings();
|
||||
await PageObjects.settings.toggleAdvancedSettingCheckbox('state:storeInSessionStorage');
|
||||
const storeInSessionStorage = await PageObjects.settings.getAdvancedSettings('state:storeInSessionStorage');
|
||||
expect(storeInSessionStorage).to.be('true');
|
||||
});
|
||||
|
||||
it('when true, dashboard state is hashed', async function () {
|
||||
await PageObjects.common.navigateToApp('dashboard');
|
||||
await PageObjects.dashboard.clickNewDashboard();
|
||||
await PageObjects.header.setAbsoluteRange('2015-09-19 06:31:44.000', '2015-09-23 18:31:44.000');
|
||||
const currentUrl = await remote.getCurrentUrl();
|
||||
const urlPieces = currentUrl.match(/(.*)?_g=(.*)&_a=(.*)/);
|
||||
const globalState = urlPieces[2];
|
||||
const appState = urlPieces[3];
|
||||
|
||||
// We don't have to be exact, just need to ensure it's less than the unhashed version, which will be
|
||||
// greater than 20 characters with the default state plus a time.
|
||||
expect(globalState.length).to.be.lessThan(20);
|
||||
expect(appState.length).to.be.lessThan(20);
|
||||
});
|
||||
|
||||
after('navigate to settings page and turn state:storeInSessionStorage back to false', async () => {
|
||||
await PageObjects.settings.navigateTo();
|
||||
await PageObjects.settings.clickKibanaSettings();
|
||||
await PageObjects.settings.toggleAdvancedSettingCheckbox('state:storeInSessionStorage');
|
||||
});
|
||||
});
|
||||
|
||||
after(function () {
|
||||
return PageObjects.settings.clickKibanaSettings()
|
||||
.then(function TestCallSetAdvancedSettingsForTimezone() {
|
||||
screenshots.take('Settings-advanced-tab');
|
||||
log.debug('calling setAdvancedSetting');
|
||||
return PageObjects.settings.setAdvancedSettings('dateFormat:tz', 'UTC');
|
||||
});
|
||||
after(async function () {
|
||||
await PageObjects.settings.clickKibanaSettings();
|
||||
await PageObjects.settings.setAdvancedSettings('dateFormat:tz', 'UTC');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -48,6 +48,16 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
|
|||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
}
|
||||
|
||||
async toggleAdvancedSettingCheckbox(propertyName) {
|
||||
await testSubjects.click(`advancedSetting-${propertyName}-editButton`);
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
const checkbox = await testSubjects.find(`advancedSetting-${propertyName}-checkbox`);
|
||||
await checkbox.click();
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
await testSubjects.click(`advancedSetting-${propertyName}-saveButton`);
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
}
|
||||
|
||||
async navigateTo() {
|
||||
await PageObjects.common.navigateToApp('settings');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue