Test dashboards in spaces & interpreter socket. (#29459)
This commit is contained in:
parent
c70aeec6fd
commit
402b8cfa8a
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { getInterpreter } from './interpreter';
|
||||
|
||||
import { createSocket } from '@kbn/interpreter/public';
|
||||
import { functionsRegistry } from './functions_registry';
|
||||
|
||||
jest.mock('@kbn/interpreter/public', () => ({
|
||||
createSocket: jest.fn(),
|
||||
initializeInterpreter: jest.fn(() => Promise.resolve()),
|
||||
loadBrowserRegistries: jest.fn(() => Promise.resolve())
|
||||
}));
|
||||
|
||||
jest.mock('ui/chrome', () => ({
|
||||
getBasePath: jest.fn(() => '/abc/s/123'),
|
||||
getInjected: jest.fn(config => { // eslint-disable-line no-unused-vars
|
||||
return config === 'serverBasePath' ? '/abc' : '/123';
|
||||
}),
|
||||
}));
|
||||
|
||||
jest.mock('./functions', () => ({
|
||||
functions: [jest.fn()]
|
||||
}));
|
||||
|
||||
jest.mock('./render_functions_registry', () => ({
|
||||
renderFunctionsRegistry: {
|
||||
register: jest.fn()
|
||||
}
|
||||
}));
|
||||
|
||||
jest.mock('./renderers/visualization', () => ({
|
||||
visualization: jest.fn()
|
||||
}));
|
||||
|
||||
jest.mock('./functions_registry', () => ({
|
||||
functionsRegistry: {
|
||||
register: jest.fn()
|
||||
}
|
||||
}));
|
||||
|
||||
jest.mock('./types_registry', () => ({
|
||||
typesRegistry: jest.fn()
|
||||
}));
|
||||
|
||||
describe('Core Interpreter', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
});
|
||||
|
||||
describe('getInterpreter', () => {
|
||||
|
||||
it('calls createSocket with the correct arguments', async () => {
|
||||
await getInterpreter();
|
||||
expect(createSocket).toHaveBeenCalledTimes(1);
|
||||
expect(createSocket).toHaveBeenCalledWith('/abc', functionsRegistry);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
|
@ -90,9 +90,17 @@ export function CommonPageProvider({ getService, getPageObjects }) {
|
|||
}
|
||||
|
||||
|
||||
navigateToApp(appName) {
|
||||
/**
|
||||
* @param {string} appName - name of the app
|
||||
* @param {object} [opts] - optional options object
|
||||
* @param {object} [opts.appConfig] - overrides for appConfig, e.g. { pathname, hash }
|
||||
*/
|
||||
navigateToApp(appName, opts = { appConfig: {} }) {
|
||||
const self = this;
|
||||
const appUrl = getUrl.noAuth(config.get('servers.kibana'), config.get(['apps', appName]));
|
||||
const appUrl = getUrl.noAuth(config.get('servers.kibana'), {
|
||||
...config.get(['apps', appName]),
|
||||
...opts.appConfig,
|
||||
});
|
||||
log.debug('navigating to ' + appName + ' url: ' + appUrl);
|
||||
|
||||
function navigateTo(url) {
|
||||
|
|
|
@ -7,8 +7,16 @@ import { TestInvoker } from './lib/types';
|
|||
|
||||
// tslint:disable:no-default-export
|
||||
export default function spaceSelectorFunctonalTests({ getService, getPageObjects }: TestInvoker) {
|
||||
const config = getService('config');
|
||||
const esArchiver = getService('esArchiver');
|
||||
const PageObjects = getPageObjects(['security', 'spaceSelector', 'home']);
|
||||
const PageObjects = getPageObjects([
|
||||
'common',
|
||||
'dashboard',
|
||||
'header',
|
||||
'home',
|
||||
'security',
|
||||
'spaceSelector',
|
||||
]);
|
||||
|
||||
describe('Spaces', () => {
|
||||
describe('Space Selector', () => {
|
||||
|
@ -39,5 +47,74 @@ export default function spaceSelectorFunctonalTests({ getService, getPageObjects
|
|||
await PageObjects.spaceSelector.expectHomePage('default');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Spaces Data', () => {
|
||||
const spaceId = 'another-space';
|
||||
const dashboardPath = config.get(['apps', 'dashboard']).pathname;
|
||||
const homePath = config.get(['apps', 'home']).pathname;
|
||||
const sampleDataHash = '/home/tutorial_directory/sampleData';
|
||||
|
||||
const expectDashboardRenders = async (dashName: string) => {
|
||||
await PageObjects.dashboard.searchForDashboardWithName(dashName);
|
||||
await PageObjects.dashboard.selectDashboard(dashName);
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
await PageObjects.dashboard.waitForRenderComplete(); // throws if all items are not rendered
|
||||
};
|
||||
|
||||
before(async () => {
|
||||
await esArchiver.load('spaces');
|
||||
await PageObjects.security.login(null, null, {
|
||||
expectSpaceSelector: true,
|
||||
});
|
||||
await PageObjects.spaceSelector.clickSpaceCard('default');
|
||||
await PageObjects.common.navigateToApp('home', {
|
||||
appConfig: {
|
||||
hash: sampleDataHash,
|
||||
},
|
||||
});
|
||||
await PageObjects.home.addSampleDataSet('logs');
|
||||
await PageObjects.common.navigateToApp('home', {
|
||||
appConfig: {
|
||||
hash: sampleDataHash,
|
||||
pathname: `/s/${spaceId}${homePath}`,
|
||||
},
|
||||
});
|
||||
await PageObjects.home.addSampleDataSet('flights');
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await PageObjects.common.navigateToApp('home', {
|
||||
appConfig: {
|
||||
hash: sampleDataHash,
|
||||
},
|
||||
});
|
||||
await PageObjects.home.removeSampleDataSet('logs');
|
||||
await PageObjects.common.navigateToApp('home', {
|
||||
appConfig: {
|
||||
hash: sampleDataHash,
|
||||
pathname: `/s/${spaceId}${homePath}`,
|
||||
},
|
||||
});
|
||||
await PageObjects.home.removeSampleDataSet('flights');
|
||||
await PageObjects.security.logout();
|
||||
await esArchiver.unload('spaces');
|
||||
});
|
||||
|
||||
describe('displays separate data for each space', async () => {
|
||||
it('in the default space', async () => {
|
||||
await PageObjects.common.navigateToApp('dashboard');
|
||||
await expectDashboardRenders('[Logs] Web Traffic');
|
||||
});
|
||||
|
||||
it('in a custom space', async () => {
|
||||
await PageObjects.common.navigateToApp('dashboard', {
|
||||
appConfig: {
|
||||
pathname: `/s/${spaceId}${dashboardPath}`,
|
||||
},
|
||||
});
|
||||
await expectDashboardRenders('[Flights] Global Flight Dashboard');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ export function SpaceSelectorPageProvider({ getService, getPageObjects }) {
|
|||
const testSubjects = getService('testSubjects');
|
||||
const browser = getService('browser');
|
||||
const find = getService('find');
|
||||
const PageObjects = getPageObjects(['common', 'home', 'security']);
|
||||
const PageObjects = getPageObjects(['common', 'header', 'security']);
|
||||
|
||||
class SpaceSelectorPage {
|
||||
async initTests() {
|
||||
|
|
Loading…
Reference in a new issue