Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering imported dashboards in import saved objects between version tests and refactor of multi-space imports test #129065

Merged
merged 15 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions test/functional/page_objects/dashboard_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]');
Expand Down
34 changes: 34 additions & 0 deletions test/functional/page_objects/management/saved_objects_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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})`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,40 @@ 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')
Expand All @@ -61,12 +58,32 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
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')
Expand All @@ -75,7 +92,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.savedObjects.clickImportDone();
await PageObjects.savedObjects.waitTableIsLoaded();

const newObjectCount = await getExportCount();
const newObjectCount = await PageObjects.savedObjects.getExportCount();
expect(newObjectCount - initialObjectCount).to.eql(23);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,50 +24,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
'dashboard',
]);
const testSubjects = getService('testSubjects');
const retry = getService('retry');

bhavyarm marked this conversation as resolved.
Show resolved Hide resolved
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),
Expand All @@ -81,8 +46,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
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 () {
Expand All @@ -109,14 +73,43 @@ 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
bhavyarm marked this conversation as resolved.
Show resolved Hide resolved
);

expect(newObjectCount - initialObjectCount).to.eql(6);

bhavyarm marked this conversation as resolved.
Show resolved Hide resolved
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);
});

Expand All @@ -127,15 +120,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
basePath: getSpacePrefix(spaceId),
shouldUseHashForSubUrl: false,
});

await PageObjects.savedObjects.waitTableIsLoaded();

await PageObjects.copySavedObjectsToSpace.openCopyToSpaceFlyoutForObject(
'multi_space_import_8.0.0_export'
);

await PageObjects.copySavedObjectsToSpace.setupForm({
createNewCopies: true,
overwrite: false,
destinationSpaceId,
});

bhavyarm marked this conversation as resolved.
Show resolved Hide resolved
await PageObjects.copySavedObjectsToSpace.startCopy();
// Wait for successful copy
await testSubjects.waitForDeleted(`cts-summary-indicator-loading-${destinationSpaceId}`);
Expand Down