Skip to content

Commit

Permalink
Add functional tests for plugins to x-pack
Browse files Browse the repository at this point in the history
  • Loading branch information
oatkiller committed Dec 5, 2019
1 parent b592417 commit 285b1d6
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 1 deletion.
1 change: 1 addition & 0 deletions x-pack/scripts/functional_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require('@kbn/test').runTestsCli([
require.resolve('../test/alerting_api_integration/spaces_only/config.ts'),
require.resolve('../test/alerting_api_integration/security_and_spaces/config.ts'),
require.resolve('../test/plugin_api_integration/config.js'),
require.resolve('../test/plugin_functional/config.js'),
require.resolve('../test/kerberos_api_integration/config'),
require.resolve('../test/kerberos_api_integration/anonymous_access.config'),
require.resolve('../test/saml_api_integration/config'),
Expand Down
72 changes: 72 additions & 0 deletions x-pack/test/plugin_functional/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { resolve } from 'path';
import fs from 'fs';
import { FtrConfigProviderContext } from '@kbn/test/types/ftr';
import { services } from './services';
import { pageObjects } from './page_objects';

// the default export of config files must be a config provider
// that returns an object with the projects config values

/* eslint-disable import/no-default-export */
export default async function({ readConfigFile }: FtrConfigProviderContext) {
const xpackFunctionalConfig = await readConfigFile(require.resolve('../functional/config.js'));

// Find all folders in ./plugins since we treat all them as plugin folder
const allFiles = fs.readdirSync(resolve(__dirname, 'plugins'));
const plugins = allFiles.filter(file =>
fs.statSync(resolve(__dirname, 'plugins', file)).isDirectory()
);

return {
// list paths to the files that contain your plugins tests
testFiles: [resolve(__dirname, './test_suites/resolver')],

services,
pageObjects,

servers: xpackFunctionalConfig.get('servers'),

esTestCluster: xpackFunctionalConfig.get('esTestCluster'),

kbnTestServer: {
...xpackFunctionalConfig.get('kbnTestServer'),
serverArgs: [
...xpackFunctionalConfig.get('kbnTestServer.serverArgs'),
...plugins.map(pluginDir => `--plugin-path=${resolve(__dirname, 'plugins', pluginDir)}`),
// Required to load new platform plugins via `--plugin-path` flag.
'--env.name=development',
'--xpack.endpoint.enabled=true',
],
},
uiSettings: xpackFunctionalConfig.get('uiSettings'),
// the apps section defines the urls that
// `PageObjects.common.navigateTo(appKey)` will use.
// Merge urls for your plugin with the urls defined in
// Kibana's config in order to use this helper
apps: {
...xpackFunctionalConfig.get('apps'),
resolverTest: {
pathname: '/app/resolver_test',
},
},

// choose where esArchiver should load archives from
esArchiver: {
directory: resolve(__dirname, 'es_archives'),
},

// choose where screenshots should be saved
screenshots: {
directory: resolve(__dirname, 'screenshots'),
},

junit: {
reportName: 'Chrome X-Pack UI Plugin Functional Tests',
},
};
}
11 changes: 11 additions & 0 deletions x-pack/test/plugin_functional/ftr_provider_context.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { GenericFtrProviderContext } from '@kbn/test/types/ftr';
import { services } from './services';
import { pageObjects } from './page_objects';

export type FtrProviderContext = GenericFtrProviderContext<typeof services, typeof pageObjects>;
6 changes: 6 additions & 0 deletions x-pack/test/plugin_functional/page_objects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
export { pageObjects } from '../functional/page_objects';
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ const AppRoot: React.FC<{
}
}, [embeddable, renderTarget]);

return <div ref={setRenderTarget} />;
return <div data-test-subj="resolverEmbeddableContainer" ref={setRenderTarget} />;
});
7 changes: 7 additions & 0 deletions x-pack/test/plugin_functional/services.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export { services } from '../functional/services';
27 changes: 27 additions & 0 deletions x-pack/test/plugin_functional/test_suites/resolver/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function({ getPageObjects, getService }: FtrProviderContext) {
const pageObjects = getPageObjects(['common']);
const testSubjects = getService('testSubjects');

describe('Resolver embeddable test app', function() {
this.tags('ciGroup7');

beforeEach(async function() {
await pageObjects.common.navigateToApp('resolverTest');
});

it('renders a container div for the embeddable', async function() {
await testSubjects.existOrFail('resolverEmbeddableContainer');
});
it('renders resolver', async function() {
await testSubjects.existOrFail('resolverEmbeddable');
});
});
}

0 comments on commit 285b1d6

Please sign in to comment.