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

[Upgrade Assistant] Set fix_logs step as incomplete if log collection is not enabled #111827

Merged
merged 3 commits into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ describe('Overview - Fix deprecation logs step', () => {

describe('Step status', () => {
test(`It's complete when there are no deprecation logs since last checkpoint`, async () => {
httpRequestsMockHelpers.setUpdateDeprecationLoggingResponse(getLoggingResponse(true));

httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({
count: 0,
});
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({ count: 0 });

await act(async () => {
testBed = await setupOverviewPage();
Expand All @@ -67,20 +63,36 @@ describe('Overview - Fix deprecation logs step', () => {
});

test(`It's incomplete when there are deprecation logs since last checkpoint`, async () => {
httpRequestsMockHelpers.setUpdateDeprecationLoggingResponse(getLoggingResponse(true));
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({ count: 5 });

httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({
count: 5,
await act(async () => {
testBed = await setupOverviewPage();
});

const { exists, component } = testBed;

component.update();

expect(exists(`fixLogsStep-incomplete`)).toBe(true);
});

test(`It's incomplete when log collection is disabled `, async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I smile every time I open a PR like this and the first thing I see are the new tests that we added! 😃

httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({ count: 0 });

await act(async () => {
testBed = await setupOverviewPage();
});

const { exists, component } = testBed;
const { actions, exists, component } = testBed;

component.update();

expect(exists(`fixLogsStep-complete`)).toBe(true);

httpRequestsMockHelpers.setUpdateDeprecationLoggingResponse(getLoggingResponse(false));

await actions.clickDeprecationToggle();

expect(exists(`fixLogsStep-incomplete`)).toBe(true);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ const FixLogsStep: FunctionComponent<Props> = ({ setIsComplete }) => {
saveLogsCheckpoint(checkpoint);
}, [checkpoint]);

useEffect(() => {
if (!state.isDeprecationLogIndexingEnabled) {
setIsComplete(false);
}

// Depending upon setIsComplete would create an infinite loop.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state.isDeprecationLogIndexingEnabled]);

return (
<>
<EuiText>
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/upgrade_assistant/public/shared_imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ export {

export { Storage } from '../../../../src/plugins/kibana_utils/public';

export { KibanaContextProvider } from '../../../../src/plugins/kibana_react/public';

export { DataPublicPluginStart } from '../../../../src/plugins/data/public';

export { APP_WRAPPER_CLASS } from '../../../../src/core/public';