Skip to content

Commit

Permalink
[Upgrade Assistant] Set fix_logs step as incomplete if log collection…
Browse files Browse the repository at this point in the history
… is not enabled (elastic#111827)

* set step as incomplete if toggle is disabled

* Fix test names

* Remove unnecessary mocks
  • Loading branch information
sabarasaba committed Oct 20, 2021
1 parent f695412 commit c4e32b9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,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 @@ -68,20 +64,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 () => {
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';

0 comments on commit c4e32b9

Please sign in to comment.