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

Fixes rendering service config keys test #167937

Merged
37 changes: 30 additions & 7 deletions test/plugin_functional/test_suites/core_plugins/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
const deployment = getService('deployment');
const find = getService('find');
const testSubjects = getService('testSubjects');
const retry = getService('retry');

const navigateTo = async (path: string) =>
await browser.navigateTo(`${deployment.getHostPort()}${path}`);
Expand All @@ -47,7 +48,16 @@ export default function ({ getService }: PluginFunctionalProviderContext) {

const getInjectedMetadata = () =>
browser.execute(() => {
return JSON.parse(document.querySelector('kbn-injected-metadata')!.getAttribute('data')!);
const injectedMetadata = document.querySelector('kbn-injected-metadata');
// null/hasAttribute check and explicit error for better future troublehsooting
// (see https://github.com/elastic/kibana/issues/167142)
// The 'kbn-injected-metadata' tag that we're relying on here gets removed
// some time after navigation (e.g. to /render/core). It appears that
// occasionally this test fails to read the tag before it is removed.
if (!injectedMetadata?.hasAttribute('data')) {
throw new Error(`'kbn-injected-metadata.data' not found.`);
}
return JSON.parse(injectedMetadata.getAttribute('data')!);
});
const getUserSettings = () =>
browser.execute(() => {
Expand All @@ -61,11 +71,17 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
return window.__RENDERING_SESSION__;
});

// Failing: See https://github.com/elastic/kibana/issues/167142
describe.skip('rendering service', () => {
describe('rendering service', () => {
it('exposes plugin config settings to authenticated users', async () => {
await navigateTo('/render/core');
const injectedMetadata = await getInjectedMetadata();
// This retry loop to get the injectedMetadata is to overcome flakiness
// (see comment in getInjectedMetadata)
let injectedMetadata: Partial<{ uiPlugins: any }> = { uiPlugins: undefined };
await retry.waitFor('injectedMetadata', async () => {
await navigateTo('/render/core');
injectedMetadata = await getInjectedMetadata();
return !!injectedMetadata;
});

expect(injectedMetadata).to.not.be.empty();
expect(injectedMetadata.uiPlugins).to.not.be.empty();

Expand Down Expand Up @@ -317,12 +333,19 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
// abundantly clear when the test fails that (A) Kibana is exposing a new key, or (B) Kibana is no longer exposing a key.
const extra = _.difference(actualExposedConfigKeys, expectedExposedConfigKeys).sort();
const missing = _.difference(expectedExposedConfigKeys, actualExposedConfigKeys).sort();

expect({ extra, missing }).to.eql({ extra: [], missing: [] }, EXPOSED_CONFIG_SETTINGS_ERROR);
});

it('exposes plugin config settings to unauthenticated users', async () => {
await navigateTo('/render/core?isAnonymousPage=true');
const injectedMetadata = await getInjectedMetadata();
// This retry loop to get the injectedMetadata is to overcome flakiness
// (see comment in getInjectedMetadata)
let injectedMetadata: Partial<{ uiPlugins: any }> = { uiPlugins: undefined };
await retry.waitFor('injectedMetadata', async () => {
await navigateTo('/render/core?isAnonymousPage=true');
injectedMetadata = await getInjectedMetadata();
return !!injectedMetadata;
});
expect(injectedMetadata).to.not.be.empty();
expect(injectedMetadata.uiPlugins).to.not.be.empty();

Expand Down