mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [Improves cleanup in spaces data functional test (#198921)](https://github.com/elastic/kibana/pull/198921) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Jeramy Soucy","email":"jeramy.soucy@elastic.co"},"sourceCommit":{"committedDate":"2024-11-05T16:31:25Z","message":"Improves cleanup in spaces data functional test (#198921)\n\nCloses #52714\r\n\r\n## Summary\r\n\r\nUses the sample data FTR service to remove the sample data via API\r\nduring cleanup. Previously, the after block only removed the sample data\r\nfrom one space and attempted to rely on an esArchiver call to clean up\r\nremaining data later on. As the scope of the test does not use the\r\nesArchiver any longer, it seems more appropriate to remove the sample\r\ndata more deterministically.\r\n\r\n### Flaky test runner\r\n\r\n-\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7335","sha":"b5c8ed7b5c8883993a534626384fe92b728e850c","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Security","release_note:skip","v9.0.0","backport:all-open","FTR"],"title":"Improves cleanup in spaces data functional test","number":198921,"url":"https://github.com/elastic/kibana/pull/198921","mergeCommit":{"message":"Improves cleanup in spaces data functional test (#198921)\n\nCloses #52714\r\n\r\n## Summary\r\n\r\nUses the sample data FTR service to remove the sample data via API\r\nduring cleanup. Previously, the after block only removed the sample data\r\nfrom one space and attempted to rely on an esArchiver call to clean up\r\nremaining data later on. As the scope of the test does not use the\r\nesArchiver any longer, it seems more appropriate to remove the sample\r\ndata more deterministically.\r\n\r\n### Flaky test runner\r\n\r\n-\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7335","sha":"b5c8ed7b5c8883993a534626384fe92b728e850c"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198921","number":198921,"mergeCommit":{"message":"Improves cleanup in spaces data functional test (#198921)\n\nCloses #52714\r\n\r\n## Summary\r\n\r\nUses the sample data FTR service to remove the sample data via API\r\nduring cleanup. Previously, the after block only removed the sample data\r\nfrom one space and attempted to rely on an esArchiver call to clean up\r\nremaining data later on. As the scope of the test does not use the\r\nesArchiver any longer, it seems more appropriate to remove the sample\r\ndata more deterministically.\r\n\r\n### Flaky test runner\r\n\r\n-\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7335","sha":"b5c8ed7b5c8883993a534626384fe92b728e850c"}}]}] BACKPORT--> Co-authored-by: Jeramy Soucy <jeramy.soucy@elastic.co>
181 lines
6.4 KiB
TypeScript
181 lines
6.4 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
* 2.0.
|
|
*/
|
|
|
|
import { FtrProviderContext } from '../../ftr_provider_context';
|
|
|
|
export default function spaceSelectorFunctionalTests({
|
|
getService,
|
|
getPageObjects,
|
|
}: FtrProviderContext) {
|
|
const listingTable = getService('listingTable');
|
|
const PageObjects = getPageObjects([
|
|
'common',
|
|
'dashboard',
|
|
'header',
|
|
'home',
|
|
'security',
|
|
'spaceSelector',
|
|
]);
|
|
const spacesService = getService('spaces');
|
|
const sampleData = getService('sampleData');
|
|
|
|
describe('Spaces', function () {
|
|
const testSpacesIds = ['another-space', ...Array.from('123456789', (idx) => `space-${idx}`)];
|
|
before(async () => {
|
|
for (const testSpaceId of testSpacesIds) {
|
|
await spacesService.create({ id: testSpaceId, name: `${testSpaceId} name` });
|
|
}
|
|
});
|
|
after(async () => {
|
|
for (const testSpaceId of testSpacesIds) {
|
|
await spacesService.delete(testSpaceId);
|
|
}
|
|
});
|
|
|
|
// FLAKY: https://github.com/elastic/kibana/issues/157760 (amongst others)
|
|
// Skipping only Firefox, as the flaky failures are caused by slow CI execution with new version of Firefox
|
|
// See also https://github.com/elastic/kibana/pull/158545
|
|
// Can un-comment line below when issue is resolved
|
|
// this.tags('includeFirefox');
|
|
describe('Login Space Selector', () => {
|
|
before(async () => {
|
|
await PageObjects.security.forceLogout();
|
|
});
|
|
|
|
after(async () => {
|
|
// NOTE: Logout needs to happen before anything else to avoid flaky behavior
|
|
await PageObjects.security.forceLogout();
|
|
});
|
|
|
|
it('allows user to select initial space', async () => {
|
|
const spaceId = 'another-space';
|
|
|
|
await PageObjects.security.login(undefined, undefined, {
|
|
expectSpaceSelector: true,
|
|
});
|
|
|
|
// select space with card after login
|
|
await PageObjects.spaceSelector.clickSpaceCard(spaceId);
|
|
await PageObjects.spaceSelector.expectHomePage(spaceId);
|
|
});
|
|
});
|
|
|
|
describe('Space Navigation Menu', () => {
|
|
before(async () => {
|
|
await PageObjects.security.forceLogout();
|
|
await PageObjects.security.login(undefined, undefined, {
|
|
expectSpaceSelector: true,
|
|
});
|
|
});
|
|
|
|
after(async () => {
|
|
await PageObjects.security.forceLogout();
|
|
});
|
|
|
|
it('allows user to navigate to different spaces', async () => {
|
|
const anotherSpaceId = 'another-space';
|
|
const defaultSpaceId = 'default';
|
|
const space5Id = 'space-5';
|
|
|
|
await PageObjects.spaceSelector.clickSpaceCard(defaultSpaceId);
|
|
await PageObjects.spaceSelector.expectHomePage(defaultSpaceId);
|
|
|
|
// change spaces with nav menu
|
|
await PageObjects.spaceSelector.openSpacesNav();
|
|
await PageObjects.spaceSelector.goToSpecificSpace(space5Id);
|
|
await PageObjects.spaceSelector.expectHomePage(space5Id);
|
|
|
|
await PageObjects.spaceSelector.openSpacesNav();
|
|
await PageObjects.spaceSelector.goToSpecificSpace(anotherSpaceId);
|
|
await PageObjects.spaceSelector.expectHomePage(anotherSpaceId);
|
|
|
|
await PageObjects.spaceSelector.openSpacesNav();
|
|
await PageObjects.spaceSelector.goToSpecificSpace(defaultSpaceId);
|
|
await PageObjects.spaceSelector.expectHomePage(defaultSpaceId);
|
|
});
|
|
});
|
|
|
|
describe('Search spaces in popover', function () {
|
|
const spaceId = 'default';
|
|
before(async () => {
|
|
await PageObjects.security.forceLogout();
|
|
await PageObjects.security.login(undefined, undefined, {
|
|
expectSpaceSelector: true,
|
|
});
|
|
});
|
|
|
|
after(async () => {
|
|
await PageObjects.security.forceLogout();
|
|
});
|
|
|
|
it('allows user to search for spaces', async () => {
|
|
await PageObjects.spaceSelector.clickSpaceCard(spaceId);
|
|
await PageObjects.spaceSelector.expectHomePage(spaceId);
|
|
await PageObjects.spaceSelector.openSpacesNav();
|
|
await PageObjects.spaceSelector.expectSearchBoxInSpacesSelector();
|
|
});
|
|
|
|
it('search for "ce-1 name" and find one space', async () => {
|
|
await PageObjects.spaceSelector.setSearchBoxInSpacesSelector('ce-1 name');
|
|
await PageObjects.spaceSelector.expectToFindThatManySpace(1);
|
|
});
|
|
|
|
it('search for "dog" and find NO space', async () => {
|
|
await PageObjects.spaceSelector.setSearchBoxInSpacesSelector('dog');
|
|
await PageObjects.spaceSelector.expectToFindThatManySpace(0);
|
|
await PageObjects.spaceSelector.expectNoSpacesFound();
|
|
});
|
|
});
|
|
|
|
describe('Spaces Data', function () {
|
|
const spaceId = 'another-space';
|
|
const sampleDataHash = '/tutorial_directory/sampleData';
|
|
|
|
const expectDashboardRenders = async (dashName: string) => {
|
|
await listingTable.searchForItemWithName(dashName);
|
|
await listingTable.clickItemLink('dashboard', dashName);
|
|
await PageObjects.header.waitUntilLoadingHasFinished();
|
|
await PageObjects.dashboard.waitForRenderComplete(); // throws if all items are not rendered
|
|
};
|
|
|
|
before(async () => {
|
|
await PageObjects.security.login(undefined, undefined, {
|
|
expectSpaceSelector: true,
|
|
});
|
|
await PageObjects.spaceSelector.clickSpaceCard('default');
|
|
await PageObjects.common.navigateToApp('home', {
|
|
hash: sampleDataHash,
|
|
});
|
|
await PageObjects.home.addSampleDataSet('logs');
|
|
await PageObjects.common.navigateToApp('home', {
|
|
hash: sampleDataHash,
|
|
basePath: `/s/${spaceId}`,
|
|
});
|
|
await PageObjects.home.addSampleDataSet('logs');
|
|
});
|
|
|
|
after(async () => {
|
|
await sampleData.testResources.removeKibanaSampleData('logs');
|
|
await PageObjects.security.forceLogout();
|
|
});
|
|
|
|
describe('displays separate data for each space', () => {
|
|
it('in the default space', async () => {
|
|
await PageObjects.dashboard.navigateToApp();
|
|
await expectDashboardRenders('[Logs] Web Traffic');
|
|
});
|
|
|
|
it('in a custom space', async () => {
|
|
await PageObjects.common.navigateToApp('dashboard', {
|
|
basePath: `/s/${spaceId}`,
|
|
});
|
|
await expectDashboardRenders('[Logs] Web Traffic');
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|