Commit 9a5919f3 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'refactor-onboard-click-step-content-button' into 'master'

Refactor general use popover button to be for content only

Closes gitlab-org/growth/engineering#15

See merge request gitlab-org/gitlab!18348
parents a66494a3 d1ab3c87
...@@ -137,7 +137,7 @@ export default { ...@@ -137,7 +137,7 @@ export default {
} }
} }
}, },
handleClickPopoverButton(button) { handleStepContentButton(button) {
const { showExitTourContent, redirectPath, nextPart, dismissPopover } = button; const { showExitTourContent, redirectPath, nextPart, dismissPopover } = button;
const helpContentItems = this.stepContent const helpContentItems = this.stepContent
? this.stepContent.getHelpContent({ projectName: this.projectName }) ? this.stepContent.getHelpContent({ projectName: this.projectName })
...@@ -248,7 +248,7 @@ export default { ...@@ -248,7 +248,7 @@ export default {
:initial-show="initialShowPopover" :initial-show="initialShowPopover"
:dismiss-popover="dismissPopover" :dismiss-popover="dismissPopover"
:golden-tanuki-svg-path="goldenTanukiSvgPath" :golden-tanuki-svg-path="goldenTanukiSvgPath"
@clickPopoverButton="handleClickPopoverButton" @clickStepContentButton="handleStepContentButton"
@clickExitTourButton="handleExitTourButton" @clickExitTourButton="handleExitTourButton"
@clickFeedbackButton="handleFeedbackButton" @clickFeedbackButton="handleFeedbackButton"
@restartStep="handleRestartStep" @restartStep="handleRestartStep"
......
...@@ -35,8 +35,8 @@ export default { ...@@ -35,8 +35,8 @@ export default {
}, },
}, },
methods: { methods: {
callButtonAction(button) { callStepContentButton(button) {
this.$emit('clickActionButton', button); this.$emit('clickStepContentButton', button);
}, },
callExitTour() { callExitTour() {
this.$emit('clickExitTourButton'); this.$emit('clickExitTourButton');
...@@ -66,7 +66,7 @@ export default { ...@@ -66,7 +66,7 @@ export default {
:key="index" :key="index"
:class="button.btnClass" :class="button.btnClass"
class="btn btn-sm mr-2" class="btn btn-sm mr-2"
@click="callButtonAction(button)" @click="callStepContentButton(button)"
> >
{{ button.text }} {{ button.text }}
</gl-button> </gl-button>
......
...@@ -135,8 +135,8 @@ export default { ...@@ -135,8 +135,8 @@ export default {
showFeedbackContent() { showFeedbackContent() {
this.$emit('showFeedbackContent', true); this.$emit('showFeedbackContent', true);
}, },
callButtonAction(button) { callStepContentButton(button) {
this.$emit('clickPopoverButton', button); this.$emit('clickStepContentButton', button);
}, },
callExitTour() { callExitTour() {
this.$emit('clickExitTourButton'); this.$emit('clickExitTourButton');
...@@ -163,7 +163,7 @@ export default { ...@@ -163,7 +163,7 @@ export default {
:target="helpContentTrigger" :target="helpContentTrigger"
:show="showPopover" :show="showPopover"
:disabled="popoverDismissed" :disabled="popoverDismissed"
@clickActionButton="callButtonAction" @clickStepContentButton="callStepContentButton"
@clickExitTourButton="callExitTour" @clickExitTourButton="callExitTour"
@clickFeedbackButton="submitFeedback" @clickFeedbackButton="submitFeedback"
/> />
......
...@@ -216,7 +216,7 @@ describe('User onboarding helper app', () => { ...@@ -216,7 +216,7 @@ describe('User onboarding helper app', () => {
}); });
}); });
describe('handleClickPopoverButton', () => { describe('handleStepContentButton', () => {
it('shows the exitTour content', () => { it('shows the exitTour content', () => {
spyOn(vm, 'showExitTourContent'); spyOn(vm, 'showExitTourContent');
...@@ -224,7 +224,7 @@ describe('User onboarding helper app', () => { ...@@ -224,7 +224,7 @@ describe('User onboarding helper app', () => {
showExitTourContent: true, showExitTourContent: true,
}; };
vm.handleClickPopoverButton(button); vm.handleStepContentButton(button);
expect(vm.showExitTourContent).toHaveBeenCalledWith(true); expect(vm.showExitTourContent).toHaveBeenCalledWith(true);
}); });
...@@ -234,13 +234,13 @@ describe('User onboarding helper app', () => { ...@@ -234,13 +234,13 @@ describe('User onboarding helper app', () => {
dismissPopover: true, dismissPopover: true,
}; };
vm.handleClickPopoverButton(button); vm.handleStepContentButton(button);
expect(vm.dismissPopover).toBe(true); expect(vm.dismissPopover).toBe(true);
button = {}; button = {};
vm.handleClickPopoverButton(button); vm.handleStepContentButton(button);
expect(vm.dismissPopover).toBe(true); expect(vm.dismissPopover).toBe(true);
}); });
...@@ -250,7 +250,7 @@ describe('User onboarding helper app', () => { ...@@ -250,7 +250,7 @@ describe('User onboarding helper app', () => {
dismissPopover: false, dismissPopover: false,
}; };
vm.handleClickPopoverButton(button); vm.handleStepContentButton(button);
expect(vm.dismissPopover).toBe(false); expect(vm.dismissPopover).toBe(false);
}); });
...@@ -261,7 +261,7 @@ describe('User onboarding helper app', () => { ...@@ -261,7 +261,7 @@ describe('User onboarding helper app', () => {
redirectPath: 'my-redirect/path', redirectPath: 'my-redirect/path',
}; };
vm.handleClickPopoverButton(button); vm.handleStepContentButton(button);
expect(redirectSpy).toHaveBeenCalledWith(button.redirectPath); expect(redirectSpy).toHaveBeenCalledWith(button.redirectPath);
}); });
...@@ -275,7 +275,7 @@ describe('User onboarding helper app', () => { ...@@ -275,7 +275,7 @@ describe('User onboarding helper app', () => {
nextPart, nextPart,
}; };
vm.handleClickPopoverButton(button); vm.handleStepContentButton(button);
expect(vm.$store.dispatch).toHaveBeenCalledWith('switchTourPart', nextPart); expect(vm.$store.dispatch).toHaveBeenCalledWith('switchTourPart', nextPart);
expect(vm.initActionPopover).toHaveBeenCalled(); expect(vm.initActionPopover).toHaveBeenCalled();
...@@ -289,7 +289,7 @@ describe('User onboarding helper app', () => { ...@@ -289,7 +289,7 @@ describe('User onboarding helper app', () => {
vm.$store.state.url = 'http://gitlab-org/gitlab-test/foo'; vm.$store.state.url = 'http://gitlab-org/gitlab-test/foo';
vm.$store.state.lastStepIndex = 0; vm.$store.state.lastStepIndex = 0;
vm.handleClickPopoverButton(button); vm.handleStepContentButton(button);
expect(vm.$store.dispatch).toHaveBeenCalledWith('setHelpContentIndex', 1); expect(vm.$store.dispatch).toHaveBeenCalledWith('setHelpContentIndex', 1);
}); });
......
...@@ -49,14 +49,14 @@ describe('User onboarding help content popover', () => { ...@@ -49,14 +49,14 @@ describe('User onboarding help content popover', () => {
}); });
describe('methods', () => { describe('methods', () => {
describe('callButtonAction', () => { describe('callStepContentButton', () => {
it('emits clickActionButton when called', () => { it('emits clickStepContentButton when called', () => {
createComponent(defaultProps); createComponent(defaultProps);
wrapper.find('.btn-primary').vm.$emit('click'); wrapper.find('.btn-primary').vm.$emit('click');
expect(wrapper.emittedByOrder()).toEqual([ expect(wrapper.emittedByOrder()).toEqual([
{ name: 'clickActionButton', args: [defaultProps.helpContent.buttons[0]] }, { name: 'clickStepContentButton', args: [defaultProps.helpContent.buttons[0]] },
]); ]);
}); });
}); });
......
...@@ -230,13 +230,15 @@ describe('User onboarding tour parts list', () => { ...@@ -230,13 +230,15 @@ describe('User onboarding tour parts list', () => {
}); });
}); });
describe('callButtonAction', () => { describe('callStepContentButton', () => {
it('emits the "clickPopoverButton" event when a popover button is clicked', () => { it('emits the "clickStepContentButton" event when a popover button is clicked', () => {
const button = defaultProps.helpContent.buttons[0]; const button = defaultProps.helpContent.buttons[0];
wrapper.vm.callButtonAction(button); wrapper.vm.callStepContentButton(button);
expect(wrapper.emittedByOrder()).toEqual([{ name: 'clickPopoverButton', args: [button] }]); expect(wrapper.emittedByOrder()).toEqual([
{ name: 'clickStepContentButton', args: [button] },
]);
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment