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

[Watcher] Fix flaky functional test #56393

Merged
merged 9 commits into from
Feb 11, 2020
8 changes: 6 additions & 2 deletions src/plugins/es_ui_shared/public/request/np_ready_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ export const useRequest = (

const response = await sendRequest(httpClient, requestBody);
const { data: serializedResponseData, error: responseError } = response;
const responseData = deserializer(serializedResponseData);

// If an outdated request has resolved, DON'T update state, but DO allow the processData handler
// to execute side effects like update telemetry.
Expand All @@ -129,7 +128,12 @@ export const useRequest = (
}

setError(responseError);
setData(responseData);

if (!responseError) {
const responseData = deserializer(serializedResponseData);
setData(responseData);
}

setIsLoading(false);
setIsInitialRequest(false);

Expand Down
5 changes: 1 addition & 4 deletions x-pack/plugins/watcher/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class WatcherUIPlugin implements Plugin<void, void, Dependencies, any> {
}),
icon: 'watchesApp',
path: '/app/kibana#/management/elasticsearch/watcher/watches',
showOnHomePage: true,
showOnHomePage: false,
};

home.featureCatalogue.register(watcherHome);
Expand All @@ -85,9 +85,6 @@ export class WatcherUIPlugin implements Plugin<void, void, Dependencies, any> {
if (valid) {
watcherESApp.enable();
watcherHome.showOnHomePage = true;
} else {
watcherESApp.disable();
watcherHome.showOnHomePage = false;
}
});
}
Expand Down
21 changes: 17 additions & 4 deletions x-pack/test/functional/apps/watcher/watcher_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,23 @@ export default function({ getService, getPageObjects }) {
}

await browser.setWindowSize(1600, 1000);
// TODO: Remove the retry.try wrapper once https://github.com/elastic/kibana/issues/55985 is resolved
retry.try(async () => {
await PageObjects.common.navigateToApp('watcher');
await testSubjects.find('createWatchButton');

// License values are emitted ES -> Kibana Server -> Kibana Public. The current implementation
// creates a situation where the Watcher plugin may not have received a minimum required license at setup time
// so the public app may not have registered in the UI.
//
// For functional testing this is a problem. The temporary solution is we wait for watcher
// to be visible.
//
// See this issue https://github.com/elastic/kibana/issues/55985.
await retry.waitFor('watcher to display in management UI', async () => {
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Jean-Louis. This is looking good so far. You can remove this extra try because retry.waitFor() is just a wrapper function around try. So you don't need the second one. Other than that, we I think we are looking good.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh. Gotcha. I reran the test and you are correct. LGTM.

await PageObjects.common.navigateToApp('watcher');
await testSubjects.find('createWatchButton');
} catch (e) {
return false;
}
return true;
});
});

Expand Down