mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[share] Fix url redirect in custom space (#122787)
This commit is contained in:
parent
faa2afb59c
commit
00bb22a8d7
5 changed files with 97 additions and 31 deletions
|
@ -86,7 +86,7 @@ export class SharePlugin implements Plugin<SharePluginSetup, SharePluginStart> {
|
|||
const { basePath } = http;
|
||||
|
||||
this.url = new UrlService({
|
||||
baseUrl: basePath.publicBaseUrl || basePath.serverBasePath,
|
||||
baseUrl: basePath.get(),
|
||||
version: this.initializerContext.env.packageInfo.version,
|
||||
navigate: async ({ app, path, state }, { replace = false } = {}) => {
|
||||
const [start] = await core.getStartServices();
|
||||
|
|
|
@ -117,8 +117,9 @@ export function SearchSessionsMgmtTable({
|
|||
{...props}
|
||||
id={SEARCH_SESSIONS_TABLE_ID}
|
||||
data-test-subj={SEARCH_SESSIONS_TABLE_ID}
|
||||
rowProps={() => ({
|
||||
'data-test-subj': 'searchSessionsRow',
|
||||
rowProps={(searchSession: UISession) => ({
|
||||
'data-test-subj': `searchSessionsRow`,
|
||||
'data-test-search-session-id': `id-${searchSession.id}`,
|
||||
})}
|
||||
columns={getColumns(core, plugins, api, config, timezone, onActionComplete, kibanaVersion)}
|
||||
items={tableData}
|
||||
|
|
|
@ -32,7 +32,9 @@ export function SearchSessionsPageProvider({ getService, getPageObjects }: FtrPr
|
|||
const $ = await row.parseDomContent();
|
||||
const viewCell = await row.findByTestSubject('sessionManagementNameCol');
|
||||
const actionsCell = await row.findByTestSubject('sessionManagementActionsCol');
|
||||
|
||||
return {
|
||||
id: (await row.getAttribute('data-test-search-session-id')).split('id-')[1],
|
||||
name: $.findTestSubject('sessionManagementNameCol').text().trim(),
|
||||
status: $.findTestSubject('sessionManagementStatusLabel').attr('data-test-status'),
|
||||
mainUrl: $.findTestSubject('sessionManagementNameCol').text(),
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { FtrProviderContext } from '../../../../ftr_provider_context';
|
||||
|
||||
export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||
|
@ -18,17 +19,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
'visChart',
|
||||
'security',
|
||||
'timePicker',
|
||||
'searchSessionsManagement',
|
||||
]);
|
||||
const dashboardPanelActions = getService('dashboardPanelActions');
|
||||
const browser = getService('browser');
|
||||
const searchSessions = getService('searchSessions');
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
const toasts = getService('toasts');
|
||||
|
||||
// Failing: See https://github.com/elastic/kibana/issues/112732
|
||||
describe.skip('dashboard in space', () => {
|
||||
describe('dashboard in space', () => {
|
||||
describe('Storing search sessions in space', () => {
|
||||
before(async () => {
|
||||
await esArchiver.load('x-pack/test/functional/es_archives/dashboard/session_in_space');
|
||||
|
||||
await kibanaServer.uiSettings.replace(
|
||||
{
|
||||
'timepicker:timeDefaults':
|
||||
'{ "from": "2015-09-01T00:00:00.000Z", "to": "2015-10-01T00:00:00.000Z"}',
|
||||
defaultIndex: 'd1bd6c84-d9d0-56fb-8a72-63fe60020920',
|
||||
},
|
||||
{ space: 'another-space' }
|
||||
);
|
||||
|
||||
await security.role.create('data_analyst', {
|
||||
elasticsearch: {
|
||||
indices: [{ names: ['logstash-*'], privileges: ['all'] }],
|
||||
|
@ -63,6 +75,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await security.role.delete('data_analyst');
|
||||
await security.user.delete('analyst');
|
||||
|
||||
await kibanaServer.uiSettings.unset('timepicker:timeDefaults', { space: 'another-space' });
|
||||
await kibanaServer.uiSettings.unset('defaultIndex', { space: 'another-space' });
|
||||
await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/session_in_space');
|
||||
});
|
||||
|
||||
|
@ -70,11 +84,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await PageObjects.common.navigateToApp('dashboard', { basePath: 's/another-space' });
|
||||
await PageObjects.dashboard.loadSavedDashboard('A Dashboard in another space');
|
||||
|
||||
await PageObjects.timePicker.setAbsoluteRange(
|
||||
'Sep 1, 2015 @ 00:00:00.000',
|
||||
'Oct 1, 2015 @ 00:00:00.000'
|
||||
);
|
||||
|
||||
await PageObjects.dashboard.waitForRenderComplete();
|
||||
|
||||
await searchSessions.expectState('completed');
|
||||
|
@ -84,16 +93,30 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
'A Pie in another space'
|
||||
);
|
||||
|
||||
// load URL to restore a saved session
|
||||
const url = await browser.getCurrentUrl();
|
||||
const savedSessionURL = `${url}&searchSessionId=${savedSessionId}`;
|
||||
await browser.get(savedSessionURL);
|
||||
await searchSessions.openPopover();
|
||||
await searchSessions.viewSearchSessions();
|
||||
|
||||
// purge client side search cache
|
||||
// https://github.com/elastic/kibana/issues/106074#issuecomment-920462094
|
||||
await browser.refresh();
|
||||
|
||||
const searchSessionList = await PageObjects.searchSessionsManagement.getList();
|
||||
const searchSessionItem = searchSessionList.find(
|
||||
(session) => session.id === savedSessionId
|
||||
);
|
||||
|
||||
if (!searchSessionItem) throw new Error(`Can\'t find session with id = ${savedSessionId}`);
|
||||
|
||||
// navigate to discover
|
||||
await searchSessionItem.view();
|
||||
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
await PageObjects.dashboard.waitForRenderComplete();
|
||||
|
||||
// Check that session is restored
|
||||
await searchSessions.expectState('restored');
|
||||
await testSubjects.missingOrFail('embeddableErrorLabel');
|
||||
expect(await toasts.getToastCount()).to.be(0); // no session restoration related warnings
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -101,6 +124,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
before(async () => {
|
||||
await esArchiver.load('x-pack/test/functional/es_archives/dashboard/session_in_space');
|
||||
|
||||
await kibanaServer.uiSettings.replace(
|
||||
{
|
||||
'timepicker:timeDefaults':
|
||||
'{ "from": "2015-09-01T00:00:00.000Z", "to": "2015-10-01T00:00:00.000Z"}',
|
||||
defaultIndex: 'd1bd6c84-d9d0-56fb-8a72-63fe60020920',
|
||||
},
|
||||
{ space: 'another-space' }
|
||||
);
|
||||
|
||||
await security.role.create('data_analyst', {
|
||||
elasticsearch: {
|
||||
indices: [{ names: ['logstash-*'], privileges: ['all'] }],
|
||||
|
@ -135,6 +167,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await security.role.delete('data_analyst');
|
||||
await security.user.delete('analyst');
|
||||
|
||||
await kibanaServer.uiSettings.unset('timepicker:timeDefaults', { space: 'another-space' });
|
||||
await kibanaServer.uiSettings.unset('defaultIndex', { space: 'another-space' });
|
||||
await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/session_in_space');
|
||||
});
|
||||
|
||||
|
@ -142,11 +176,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await PageObjects.common.navigateToApp('dashboard', { basePath: 's/another-space' });
|
||||
await PageObjects.dashboard.loadSavedDashboard('A Dashboard in another space');
|
||||
|
||||
await PageObjects.timePicker.setAbsoluteRange(
|
||||
'Sep 1, 2015 @ 00:00:00.000',
|
||||
'Oct 1, 2015 @ 00:00:00.000'
|
||||
);
|
||||
|
||||
await PageObjects.dashboard.waitForRenderComplete();
|
||||
|
||||
await searchSessions.expectState('completed');
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { FtrProviderContext } from '../../../ftr_provider_context';
|
||||
|
||||
export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||
|
@ -19,16 +20,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
'visChart',
|
||||
'security',
|
||||
'timePicker',
|
||||
'searchSessionsManagement',
|
||||
]);
|
||||
const browser = getService('browser');
|
||||
const searchSessions = getService('searchSessions');
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
const toasts = getService('toasts');
|
||||
|
||||
// FLAKY https://github.com/elastic/kibana/issues/112913
|
||||
describe.skip('discover in space', () => {
|
||||
describe('discover in space', () => {
|
||||
describe('Storing search sessions in space', () => {
|
||||
before(async () => {
|
||||
await esArchiver.load('x-pack/test/functional/es_archives/dashboard/session_in_space');
|
||||
|
||||
await kibanaServer.uiSettings.replace(
|
||||
{
|
||||
'timepicker:timeDefaults':
|
||||
'{ "from": "2015-09-01T00:00:00.000Z", "to": "2015-10-01T00:00:00.000Z"}',
|
||||
defaultIndex: 'd1bd6c84-d9d0-56fb-8a72-63fe60020920',
|
||||
},
|
||||
{ space: 'another-space' }
|
||||
);
|
||||
|
||||
await security.role.create('data_analyst', {
|
||||
elasticsearch: {
|
||||
indices: [{ names: ['logstash-*'], privileges: ['all'] }],
|
||||
|
@ -63,6 +75,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await security.role.delete('data_analyst');
|
||||
await security.user.delete('analyst');
|
||||
|
||||
await kibanaServer.uiSettings.unset('timepicker:timeDefaults', { space: 'another-space' });
|
||||
await kibanaServer.uiSettings.unset('defaultIndex', { space: 'another-space' });
|
||||
await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/session_in_space');
|
||||
});
|
||||
|
||||
|
@ -71,11 +85,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
|
||||
await PageObjects.discover.selectIndexPattern('logstash-*');
|
||||
|
||||
await PageObjects.timePicker.setAbsoluteRange(
|
||||
'Sep 1, 2015 @ 00:00:00.000',
|
||||
'Oct 1, 2015 @ 00:00:00.000'
|
||||
);
|
||||
|
||||
await PageObjects.discover.waitForDocTableLoadingComplete();
|
||||
|
||||
await searchSessions.expectState('completed');
|
||||
|
@ -88,22 +97,45 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
).getAttribute('data-search-session-id');
|
||||
await inspector.close();
|
||||
|
||||
// load URL to restore a saved session
|
||||
const url = await browser.getCurrentUrl();
|
||||
const savedSessionURL = `${url}&searchSessionId=${savedSessionId}`;
|
||||
await browser.get(savedSessionURL);
|
||||
await searchSessions.openPopover();
|
||||
await searchSessions.viewSearchSessions();
|
||||
|
||||
// purge client side search cache
|
||||
// https://github.com/elastic/kibana/issues/106074#issuecomment-920462094
|
||||
await browser.refresh();
|
||||
|
||||
const searchSessionList = await PageObjects.searchSessionsManagement.getList();
|
||||
const searchSessionItem = searchSessionList.find(
|
||||
(session) => session.id === savedSessionId
|
||||
);
|
||||
|
||||
if (!searchSessionItem) throw new Error(`Can\'t find session with id = ${savedSessionId}`);
|
||||
|
||||
// navigate to discover
|
||||
await searchSessionItem.view();
|
||||
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
await PageObjects.discover.waitForDocTableLoadingComplete();
|
||||
|
||||
// Check that session is restored
|
||||
await searchSessions.expectState('restored');
|
||||
await testSubjects.missingOrFail('discoverNoResultsError'); // expect error because of fake searchSessionId
|
||||
await testSubjects.missingOrFail('discoverNoResultsError');
|
||||
expect(await toasts.getToastCount()).to.be(0); // no session restoration related warnings
|
||||
});
|
||||
});
|
||||
describe('Disabled storing search sessions in space', () => {
|
||||
before(async () => {
|
||||
await esArchiver.load('x-pack/test/functional/es_archives/dashboard/session_in_space');
|
||||
|
||||
await kibanaServer.uiSettings.replace(
|
||||
{
|
||||
'timepicker:timeDefaults':
|
||||
'{ "from": "2015-09-01T00:00:00.000Z", "to": "2015-10-01T00:00:00.000Z"}',
|
||||
defaultIndex: 'd1bd6c84-d9d0-56fb-8a72-63fe60020920',
|
||||
},
|
||||
{ space: 'another-space' }
|
||||
);
|
||||
|
||||
await security.role.create('data_analyst', {
|
||||
elasticsearch: {
|
||||
indices: [{ names: ['logstash-*'], privileges: ['all'] }],
|
||||
|
@ -138,6 +170,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await security.role.delete('data_analyst');
|
||||
await security.user.delete('analyst');
|
||||
|
||||
await kibanaServer.uiSettings.unset('timepicker:timeDefaults', { space: 'another-space' });
|
||||
await kibanaServer.uiSettings.unset('defaultIndex', { space: 'another-space' });
|
||||
await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/session_in_space');
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue