Skip to content

Commit

Permalink
[QA][fix failing test] Refactor to ui settings for timepicker
Browse files Browse the repository at this point in the history
6 tests passing
  • Loading branch information
wayneseymour committed Oct 6, 2021
1 parent 1eceef4 commit b8a8c08
Showing 1 changed file with 26 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,80 +12,62 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const config = getService('config');
const spacesService = getService('spaces');
const PageObjects = getPageObjects([
'common',
'error',
'discover',
'timePicker',
'security',
'spaceSelector',
]);
const PageObjects = getPageObjects(['common', 'error', 'discover']);
const testSubjects = getService('testSubjects');
const appsMenu = getService('appsMenu');
const kibanaServer = getService('kibanaServer');

async function setDiscoverTimeRange() {
await PageObjects.timePicker.setDefaultAbsoluteRange();
}
const space = 'custom_space';

// Failing: See https://github.com/elastic/kibana/issues/113067
describe.skip('spaces', () => {
describe('spaces', () => {
const basePath = `/s/${space}`;
const time = (range: { from: string; to: string }) => async () =>
await kibanaServer.uiSettings.replace({ 'timepicker:timeDefaults': JSON.stringify(range) }, { space });
const september2015 = time({ from: '2015-09-19T06:31:44.000Z', to: '2015-09-23T18:31:44.000Z' });
before(async () => {
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional');
});

// FLAKY: https://github.com/elastic/kibana/issues/60559
describe.skip('space with no features disabled', () => {
describe('space with no features disabled', async () => {
before(async () => {
// we need to load the following in every situation as deleting
// a space deletes all of the associated saved objects
await kibanaServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/discover/feature_controls/spaces'
);
await kibanaServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/discover/feature_controls/custom_space',
{ space: 'custom_space' }
{ space }
);
await spacesService.create({
id: 'custom_space',
name: 'custom_space',
disabledFeatures: [],
});
await spacesService.create({ id: space, name: space, disabledFeatures: [] });
await september2015();
});

after(async () => {
await spacesService.delete('custom_space');
await kibanaServer.importExport.unload(
'x-pack/test/functional/fixtures/kbn_archiver/discover/feature_controls/custom_space',
{ space: 'custom_space' }
{ space }
);
await kibanaServer.importExport.unload(
'x-pack/test/functional/fixtures/kbn_archiver/discover/feature_controls/spaces'
);
await kibanaServer.uiSettings.unset('timepicker:timeDefaults', { space });
await spacesService.delete(space);
});

it('shows discover navlink', async () => {
await PageObjects.common.navigateToApp('home', {
basePath: '/s/custom_space',
});
await PageObjects.common.navigateToApp('home', { basePath });
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Discover');
});

it('shows save button', async () => {
await PageObjects.common.navigateToApp('discover', {
basePath: '/s/custom_space',
});
await PageObjects.common.navigateToApp('discover', { basePath });
await testSubjects.existOrFail('discoverSaveButton', {
timeout: config.get('timeouts.waitFor'),
});
});

it('shows "visualize" field button', async () => {
await PageObjects.common.navigateToApp('discover', {
basePath: '/s/custom_space',
});
await setDiscoverTimeRange();
await PageObjects.common.navigateToApp('discover', { basePath });
await PageObjects.discover.clickFieldListItem('bytes');
await PageObjects.discover.expectFieldListItemVisualize('bytes');
});
Expand All @@ -99,30 +81,28 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
'x-pack/test/functional/fixtures/kbn_archiver/discover/feature_controls/spaces'
);
await spacesService.create({
id: 'custom_space',
name: 'custom_space',
id: space,
name: space,
disabledFeatures: ['discover'],
});
});

after(async () => {
await spacesService.delete('custom_space');
await spacesService.delete(space);
await kibanaServer.importExport.unload(
'x-pack/test/functional/fixtures/kbn_archiver/discover/feature_controls/spaces'
);
});

it(`doesn't show discover navlink`, async () => {
await PageObjects.common.navigateToApp('home', {
basePath: '/s/custom_space',
});
await PageObjects.common.navigateToApp('home', { basePath });
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).not.to.contain('Discover');
});

it(`shows 404`, async () => {
await PageObjects.common.navigateToUrl('discover', '', {
basePath: '/s/custom_space',
basePath,
shouldLoginIfPrompted: false,
ensureCurrentUrl: false,
useActualUrl: true,
Expand All @@ -136,52 +116,20 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
// we need to load the following in every situation as deleting
// a space deletes all of the associated saved objects
await esArchiver.load('x-pack/test/functional/es_archives/spaces/disabled_features');
await spacesService.create({
id: 'custom_space',
name: 'custom_space',
disabledFeatures: ['visualize'],
});
await spacesService.create({ id: space, name: space, disabledFeatures: ['visualize'] });
await september2015();
});

after(async () => {
await spacesService.delete('custom_space');
await spacesService.delete(space);
await esArchiver.unload('x-pack/test/functional/es_archives/spaces/disabled_features');
});

it('Does not show the "visualize" field button', async () => {
await PageObjects.common.navigateToApp('discover', {
basePath: '/s/custom_space',
});
await setDiscoverTimeRange();
await PageObjects.common.navigateToApp('discover', { basePath });
await PageObjects.discover.clickFieldListItem('bytes');
await PageObjects.discover.expectMissingFieldListItemVisualize('bytes');
});
});

describe('space with index pattern management disabled', function () {
// unskipped because of flakiness in cloud, caused be ingest management tests
// should be unskipped when https://github.com/elastic/kibana/issues/74353 was resolved
this.tags(['skipCloud']);
before(async () => {
await spacesService.create({
id: 'custom_space_no_index_patterns',
name: 'custom_space_no_index_patterns',
disabledFeatures: ['indexPatterns'],
});
});

after(async () => {
await spacesService.delete('custom_space_no_index_patterns');
});

it('Navigates to Kibana home rather than index pattern management when no index patterns exist', async () => {
await PageObjects.common.navigateToUrl('discover', '', {
basePath: '/s/custom_space_no_index_patterns',
ensureCurrentUrl: false,
shouldUseHashForSubUrl: false,
});
await testSubjects.existOrFail('homeApp', { timeout: config.get('timeouts.waitFor') });
});
});
});
}

0 comments on commit b8a8c08

Please sign in to comment.