mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Rendering imported dashboards in import saved objects between version tests and refactor of multi-space imports test (#129065) (#129346)
(cherry picked from commit e2e8dbb08f
)
Co-authored-by: Bhavya RM <bhavya@elastic.co>
This commit is contained in:
parent
5a28d0fa50
commit
ef6507bfc7
4 changed files with 102 additions and 74 deletions
|
@ -668,6 +668,11 @@ export class DashboardPageObject extends FtrService {
|
|||
await this.renderable.waitForRender(parseInt(count));
|
||||
}
|
||||
|
||||
public async verifyNoRenderErrors() {
|
||||
const errorEmbeddables = await this.testSubjects.findAll('embeddableStackError');
|
||||
expect(errorEmbeddables.length).to.be(0);
|
||||
}
|
||||
|
||||
public async getSharedContainerData() {
|
||||
this.log.debug('getSharedContainerData');
|
||||
const sharedContainer = await this.find.byCssSelector('[data-shared-items-container]');
|
||||
|
|
|
@ -32,6 +32,40 @@ export class SavedObjectsPageObject extends FtrService {
|
|||
return await searchBox.getAttribute('value');
|
||||
}
|
||||
|
||||
async getExportCount() {
|
||||
return await this.retry.tryForTime(10000, async () => {
|
||||
const exportText = await this.testSubjects.getVisibleText('exportAllObjects');
|
||||
const parts = exportText.trim().split(' ');
|
||||
if (parts.length !== 3) {
|
||||
throw new Error('text not loaded yet');
|
||||
}
|
||||
const count = Number.parseInt(parts[1], 10);
|
||||
if (count === 0) {
|
||||
throw new Error('text not loaded yet');
|
||||
}
|
||||
return count;
|
||||
});
|
||||
}
|
||||
|
||||
getSpacePrefix(spaceId: string) {
|
||||
return spaceId && spaceId !== 'default' ? `/s/${spaceId}` : ``;
|
||||
}
|
||||
|
||||
async importIntoSpace(path: string, spaceId = 'default') {
|
||||
await this.common.navigateToUrl('settings', 'kibana/objects', {
|
||||
basePath: this.getSpacePrefix(spaceId),
|
||||
shouldUseHashForSubUrl: false,
|
||||
});
|
||||
await this.waitTableIsLoaded();
|
||||
|
||||
await this.importFile(path);
|
||||
|
||||
await this.checkImportSucceeded();
|
||||
await this.clickImportDone();
|
||||
await this.waitTableIsLoaded();
|
||||
return await this.getExportCount();
|
||||
}
|
||||
|
||||
async importFile(path: string, overwriteAll = true) {
|
||||
this.log.debug(`importFile(${path})`);
|
||||
|
||||
|
|
|
@ -16,66 +16,77 @@ import { FtrProviderContext } from '../../ftr_provider_context';
|
|||
export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
const esArchiver = getService('esArchiver');
|
||||
const PageObjects = getPageObjects(['common', 'settings', 'header', 'savedObjects']);
|
||||
const testSubjects = getService('testSubjects');
|
||||
const retry = getService('retry');
|
||||
|
||||
const getExportCount = async () => {
|
||||
return await retry.tryForTime(10000, async () => {
|
||||
const exportText = await testSubjects.getVisibleText('exportAllObjects');
|
||||
const parts = exportText.trim().split(' ');
|
||||
if (parts.length !== 3) {
|
||||
throw new Error('text not loaded yet');
|
||||
}
|
||||
const count = Number.parseInt(parts[1], 10);
|
||||
if (count === 0) {
|
||||
throw new Error('text not loaded yet');
|
||||
}
|
||||
return count;
|
||||
});
|
||||
};
|
||||
const PageObjects = getPageObjects([
|
||||
'common',
|
||||
'settings',
|
||||
'savedObjects',
|
||||
'dashboard',
|
||||
'timePicker',
|
||||
]);
|
||||
const renderService = getService('renderable');
|
||||
|
||||
describe('Export import saved objects between versions', function () {
|
||||
before(async function () {
|
||||
await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana');
|
||||
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional');
|
||||
await esArchiver.loadIfNeeded(
|
||||
'test/functional/fixtures/es_archiver/getting_started/shakespeare'
|
||||
);
|
||||
await kibanaServer.uiSettings.replace({});
|
||||
await PageObjects.settings.navigateTo();
|
||||
await PageObjects.settings.clickKibanaSavedObjects();
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
await PageObjects.settings.navigateTo();
|
||||
await PageObjects.settings.clickKibanaSavedObjects();
|
||||
await PageObjects.savedObjects.waitTableIsLoaded();
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional');
|
||||
await esArchiver.unload('test/functional/fixtures/es_archiver/getting_started/shakespeare');
|
||||
await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana');
|
||||
});
|
||||
|
||||
it('should be able to import 7.13 saved objects into 8.0.0', async function () {
|
||||
const initialObjectCount = await getExportCount();
|
||||
|
||||
it('should be able to import 7.13 saved objects into 8.0.0 and verfiy the rendering of two dashboards', async function () {
|
||||
const initialObjectCount = await PageObjects.savedObjects.getExportCount();
|
||||
await PageObjects.savedObjects.importFile(
|
||||
path.join(__dirname, 'exports', '_7.13_import_saved_objects.ndjson')
|
||||
);
|
||||
await PageObjects.savedObjects.checkImportSucceeded();
|
||||
await PageObjects.savedObjects.clickImportDone();
|
||||
await PageObjects.savedObjects.waitTableIsLoaded();
|
||||
|
||||
const newObjectCount = await getExportCount();
|
||||
const newObjectCount = await PageObjects.savedObjects.getExportCount();
|
||||
expect(newObjectCount - initialObjectCount).to.eql(86);
|
||||
|
||||
// logstash by reference dashboard with drilldowns
|
||||
await PageObjects.common.navigateToApp('dashboard');
|
||||
await PageObjects.dashboard.loadSavedDashboard('by_reference_drilldown');
|
||||
// dashboard should load properly
|
||||
await PageObjects.dashboard.expectOnDashboard('by_reference_drilldown');
|
||||
await PageObjects.timePicker.setDefaultAbsoluteRange();
|
||||
// count of panels rendered completely
|
||||
await renderService.waitForRender(4);
|
||||
// There should be 0 error embeddables on the dashboard
|
||||
await PageObjects.dashboard.verifyNoRenderErrors();
|
||||
|
||||
// combined shakespeare and logstash dashboard
|
||||
await PageObjects.dashboard.loadSavedDashboard('lens_combined_dashboard');
|
||||
await PageObjects.dashboard.expectOnDashboard('lens_combined_dashboard');
|
||||
// count of panels rendered completely
|
||||
await renderService.waitForRender(2);
|
||||
// There should be 0 error embeddables on the dashboard
|
||||
await PageObjects.dashboard.verifyNoRenderErrors();
|
||||
});
|
||||
|
||||
it('should be able to import alerts and actions saved objects from 7.14 into 8.0.0', async function () {
|
||||
const initialObjectCount = await getExportCount();
|
||||
|
||||
const initialObjectCount = await PageObjects.savedObjects.getExportCount();
|
||||
await PageObjects.savedObjects.importFile(
|
||||
path.join(__dirname, 'exports', '_7.14_import_alerts_actions.ndjson')
|
||||
);
|
||||
await PageObjects.savedObjects.checkImportSucceeded();
|
||||
await PageObjects.savedObjects.clickImportDone();
|
||||
await PageObjects.savedObjects.waitTableIsLoaded();
|
||||
|
||||
const newObjectCount = await getExportCount();
|
||||
const newObjectCount = await PageObjects.savedObjects.getExportCount();
|
||||
expect(newObjectCount - initialObjectCount).to.eql(23);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -24,50 +24,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
'dashboard',
|
||||
]);
|
||||
const testSubjects = getService('testSubjects');
|
||||
const retry = getService('retry');
|
||||
const spacesService = getService('spaces');
|
||||
const renderService = getService('renderable');
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
|
||||
const getExportCount = async () => {
|
||||
return await retry.tryForTime(10000, async () => {
|
||||
const exportText = await testSubjects.getVisibleText('exportAllObjects');
|
||||
const parts = exportText.trim().split(' ');
|
||||
if (parts.length !== 3) {
|
||||
throw new Error('text not loaded yet');
|
||||
}
|
||||
const count = Number.parseInt(parts[1], 10);
|
||||
if (count === 0) {
|
||||
throw new Error('text not loaded yet');
|
||||
}
|
||||
return count;
|
||||
});
|
||||
};
|
||||
|
||||
const getSpacePrefix = (spaceId: string) => {
|
||||
return spaceId && spaceId !== 'default' ? `/s/${spaceId}` : ``;
|
||||
};
|
||||
|
||||
const importIntoSpace = async (spaceId: string) => {
|
||||
await PageObjects.common.navigateToUrl('settings', 'kibana/objects', {
|
||||
basePath: getSpacePrefix(spaceId),
|
||||
shouldUseHashForSubUrl: false,
|
||||
});
|
||||
await PageObjects.savedObjects.waitTableIsLoaded();
|
||||
const initialObjectCount = await getExportCount();
|
||||
|
||||
await PageObjects.savedObjects.importFile(
|
||||
path.join(__dirname, 'exports', '_8.0.0_multispace_import.ndjson')
|
||||
);
|
||||
await PageObjects.savedObjects.checkImportSucceeded();
|
||||
await PageObjects.savedObjects.clickImportDone();
|
||||
await PageObjects.savedObjects.waitTableIsLoaded();
|
||||
|
||||
const newObjectCount = await getExportCount();
|
||||
|
||||
expect(newObjectCount - initialObjectCount).to.eql(6);
|
||||
};
|
||||
|
||||
const checkIfDashboardRendered = async (spaceId: string) => {
|
||||
await PageObjects.common.navigateToUrl('dashboard', undefined, {
|
||||
basePath: getSpacePrefix(spaceId),
|
||||
|
@ -76,13 +39,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await PageObjects.dashboard.loadSavedDashboard('multi_space_import_8.0.0_export');
|
||||
// dashboard should load properly
|
||||
await PageObjects.dashboard.expectOnDashboard('multi_space_import_8.0.0_export');
|
||||
|
||||
// count of panels rendered completely
|
||||
await renderService.waitForRender(8);
|
||||
|
||||
// There should be 0 error embeddables on the dashboard
|
||||
const errorEmbeddables = await testSubjects.findAll('embeddableStackError');
|
||||
expect(errorEmbeddables.length).to.be(0);
|
||||
await PageObjects.dashboard.verifyNoRenderErrors();
|
||||
};
|
||||
|
||||
describe('should be able to handle multi-space imports correctly', function () {
|
||||
|
@ -109,14 +69,34 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
it('imported dashboard into default space should render correctly', async () => {
|
||||
await PageObjects.settings.navigateTo();
|
||||
await PageObjects.settings.clickKibanaSavedObjects();
|
||||
const initialObjectCount = await PageObjects.savedObjects.getExportCount();
|
||||
const spaceId = 'default';
|
||||
await importIntoSpace(spaceId);
|
||||
const importFileName = '_8.0.0_multispace_import.ndjson';
|
||||
const importFilePath = path.join(__dirname, 'exports', importFileName);
|
||||
const newObjectCount = await PageObjects.savedObjects.importIntoSpace(
|
||||
importFilePath,
|
||||
spaceId
|
||||
);
|
||||
expect(newObjectCount - initialObjectCount).to.eql(6);
|
||||
await checkIfDashboardRendered(spaceId);
|
||||
});
|
||||
|
||||
it('imported dashboard into another space should render correctly', async () => {
|
||||
const spaceId = 'another_space';
|
||||
await importIntoSpace(spaceId);
|
||||
await PageObjects.common.navigateToUrl('settings', 'kibana/objects', {
|
||||
basePath: getSpacePrefix(spaceId),
|
||||
shouldUseHashForSubUrl: false,
|
||||
});
|
||||
const initialObjectCount = await PageObjects.savedObjects.getExportCount();
|
||||
const importFileName = '_8.0.0_multispace_import.ndjson';
|
||||
const importFilePath = path.join(__dirname, 'exports', importFileName);
|
||||
const newObjectCount = await PageObjects.savedObjects.importIntoSpace(
|
||||
importFilePath,
|
||||
spaceId
|
||||
);
|
||||
expect(newObjectCount - initialObjectCount).to.eql(6);
|
||||
await checkIfDashboardRendered(spaceId);
|
||||
});
|
||||
|
||||
|
@ -140,9 +120,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
// Wait for successful copy
|
||||
await testSubjects.waitForDeleted(`cts-summary-indicator-loading-${destinationSpaceId}`);
|
||||
await testSubjects.existOrFail(`cts-summary-indicator-success-${destinationSpaceId}`);
|
||||
|
||||
const summaryCounts = await PageObjects.copySavedObjectsToSpace.getSummaryCounts();
|
||||
|
||||
expect(summaryCounts).to.eql({
|
||||
success: 6,
|
||||
pending: 0,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue