Skip to content

Commit

Permalink
Fix e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed Oct 5, 2020
1 parent 6d26685 commit 3386228
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 16 deletions.
1 change: 1 addition & 0 deletions x-pack/test/licensing_plugin/config.public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
KIBANA_ROOT,
'test/plugin_functional/plugins/core_provider_plugin'
)}`,
`--plugin-path=${path.resolve(__dirname, 'plugins/test_feature_usage')}`,
],
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "testFeatureUsage",
"version": "kibana",
"server": false,
"ui": true,
"requiredPlugins": ["licensing"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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 { TestFeatureUsagePlugin } from './plugin';

export const plugin = () => new TestFeatureUsagePlugin();
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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 { CoreSetup } from 'src/core/server';
import { LicensingPluginSetup } from '../../../../../plugins/licensing/public';

interface SetupPlugins {
licensing: LicensingPluginSetup;
}

export class TestFeatureUsagePlugin {
public setup(core: CoreSetup, plugins: SetupPlugins) {
plugins.licensing.featureUsage.register('test-client-A', 'gold');
plugins.licensing.featureUsage.register('test-client-B', 'enterprise');
}

public start() {}
public stop() {}
}
17 changes: 1 addition & 16 deletions x-pack/test/licensing_plugin/public/feature_usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@ export default function (ftrContext: FtrProviderContext) {
const browser = getService('browser');
const PageObjects = getPageObjects(['common', 'security']);

const registerFeature = async (featureName: string, licenseType: LicenseType) => {
await browser.executeAsync(
async (feature, type, cb) => {
const { setup } = window._coreProvider;
const licensing: LicensingPluginSetup = setup.plugins.licensing;
await licensing.featureUsage.register(feature, type);
cb();
},
featureName,
licenseType
);
};

const notifyFeatureUsage = async (featureName: string, lastUsed: number) => {
await browser.executeAsync(
async (feature, time, cb) => {
Expand All @@ -57,12 +44,10 @@ export default function (ftrContext: FtrProviderContext) {
});

it('allows to register features to the server', async () => {
await registerFeature('test-client-A', 'gold');
await registerFeature('test-client-B', 'enterprise');

const response = await supertest.get('/api/licensing/feature_usage').expect(200);
const features = response.body.features.map(({ name }: FeatureUsage) => name);

// These were registered by the plugin in ../plugins/test_feature_usage
expect(features).to.contain('test-client-A');
expect(features).to.contain('test-client-B');
});
Expand Down

0 comments on commit 3386228

Please sign in to comment.