[Guided onboarding] Disable welcome screen on use case click

This commit is contained in:
Yulia Cech 2022-10-24 14:26:22 +02:00
parent cc12697404
commit abc347e741
2 changed files with 14 additions and 5 deletions

View file

@ -33,6 +33,7 @@ jest.mock('../../kibana_services', () => {
},
guidedOnboardingService: {
fetchAllGuidesState: jest.fn(),
activateGuide: jest.fn(),
},
}),
};
@ -54,11 +55,17 @@ describe('getting started', () => {
expect(component).toMatchSnapshot();
});
test('skip button should disable home welcome screen', async () => {
const component = mountWithIntl(<GettingStarted />);
const skipButton = findTestSubject(component, 'onboarding--skipUseCaseTourLink');
skipButton.simulate('click');
[
{ dataTestSubj: 'onboarding--skipUseCaseTourLink', buttonName: 'skip' },
{ dataTestSubj: 'onboarding--guideCard--view--search', buttonName: 'use case' },
].map(({ dataTestSubj, buttonName }) => {
test(`${buttonName} button should disable home welcome screen`, async () => {
localStorage.removeItem(KEY_ENABLE_WELCOME);
const component = mountWithIntl(<GettingStarted />);
const button = findTestSubject(component, dataTestSubj);
button.simulate('click');
expect(localStorage.getItem(KEY_ENABLE_WELCOME)).toBe('false');
expect(localStorage.getItem(KEY_ENABLE_WELCOME)).toBe('false');
});
});
});

View file

@ -89,6 +89,8 @@ export const GettingStarted = () => {
const isDarkTheme = uiSettings.get<boolean>('theme:darkMode');
const activateGuide = async (useCase: UseCase, guideState?: GuideState) => {
// disable welcome screen on the home page
localStorage.setItem(KEY_ENABLE_WELCOME, JSON.stringify(false));
await guidedOnboardingService?.activateGuide(useCase as GuideId, guideState);
// TODO error handling https://github.com/elastic/kibana/issues/139798
};