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 {
}
}
},
handleClickPopoverButton(button) {
handleStepContentButton(button) {
const { showExitTourContent, redirectPath, nextPart, dismissPopover } = button;
const helpContentItems = this.stepContent
? this.stepContent.getHelpContent({ projectName: this.projectName })
......@@ -248,7 +248,7 @@ export default {
:initial-show="initialShowPopover"
:dismiss-popover="dismissPopover"
:golden-tanuki-svg-path="goldenTanukiSvgPath"
@clickPopoverButton="handleClickPopoverButton"
@clickStepContentButton="handleStepContentButton"
@clickExitTourButton="handleExitTourButton"
@clickFeedbackButton="handleFeedbackButton"
@restartStep="handleRestartStep"
......
......@@ -35,8 +35,8 @@ export default {
},
},
methods: {
callButtonAction(button) {
this.$emit('clickActionButton', button);
callStepContentButton(button) {
this.$emit('clickStepContentButton', button);
},
callExitTour() {
this.$emit('clickExitTourButton');
......@@ -66,7 +66,7 @@ export default {
:key="index"
:class="button.btnClass"
class="btn btn-sm mr-2"
@click="callButtonAction(button)"
@click="callStepContentButton(button)"
>
{{ button.text }}
</gl-button>
......
......@@ -135,8 +135,8 @@ export default {
showFeedbackContent() {
this.$emit('showFeedbackContent', true);
},
callButtonAction(button) {
this.$emit('clickPopoverButton', button);
callStepContentButton(button) {
this.$emit('clickStepContentButton', button);
},
callExitTour() {
this.$emit('clickExitTourButton');
......@@ -163,7 +163,7 @@ export default {
:target="helpContentTrigger"
:show="showPopover"
:disabled="popoverDismissed"
@clickActionButton="callButtonAction"
@clickStepContentButton="callStepContentButton"
@clickExitTourButton="callExitTour"
@clickFeedbackButton="submitFeedback"
/>
......
......@@ -216,7 +216,7 @@ describe('User onboarding helper app', () => {
});
});
describe('handleClickPopoverButton', () => {
describe('handleStepContentButton', () => {
it('shows the exitTour content', () => {
spyOn(vm, 'showExitTourContent');
......@@ -224,7 +224,7 @@ describe('User onboarding helper app', () => {
showExitTourContent: true,
};
vm.handleClickPopoverButton(button);
vm.handleStepContentButton(button);
expect(vm.showExitTourContent).toHaveBeenCalledWith(true);
});
......@@ -234,13 +234,13 @@ describe('User onboarding helper app', () => {
dismissPopover: true,
};
vm.handleClickPopoverButton(button);
vm.handleStepContentButton(button);
expect(vm.dismissPopover).toBe(true);
button = {};
vm.handleClickPopoverButton(button);
vm.handleStepContentButton(button);
expect(vm.dismissPopover).toBe(true);
});
......@@ -250,7 +250,7 @@ describe('User onboarding helper app', () => {
dismissPopover: false,
};
vm.handleClickPopoverButton(button);
vm.handleStepContentButton(button);
expect(vm.dismissPopover).toBe(false);
});
......@@ -261,7 +261,7 @@ describe('User onboarding helper app', () => {
redirectPath: 'my-redirect/path',
};
vm.handleClickPopoverButton(button);
vm.handleStepContentButton(button);
expect(redirectSpy).toHaveBeenCalledWith(button.redirectPath);
});
......@@ -275,7 +275,7 @@ describe('User onboarding helper app', () => {
nextPart,
};
vm.handleClickPopoverButton(button);
vm.handleStepContentButton(button);
expect(vm.$store.dispatch).toHaveBeenCalledWith('switchTourPart', nextPart);
expect(vm.initActionPopover).toHaveBeenCalled();
......@@ -289,7 +289,7 @@ describe('User onboarding helper app', () => {
vm.$store.state.url = 'http://gitlab-org/gitlab-test/foo';
vm.$store.state.lastStepIndex = 0;
vm.handleClickPopoverButton(button);
vm.handleStepContentButton(button);
expect(vm.$store.dispatch).toHaveBeenCalledWith('setHelpContentIndex', 1);
});
......
......@@ -49,14 +49,14 @@ describe('User onboarding help content popover', () => {
});
describe('methods', () => {
describe('callButtonAction', () => {
it('emits clickActionButton when called', () => {
describe('callStepContentButton', () => {
it('emits clickStepContentButton when called', () => {
createComponent(defaultProps);
wrapper.find('.btn-primary').vm.$emit('click');
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', () => {
});
});
describe('callButtonAction', () => {
it('emits the "clickPopoverButton" event when a popover button is clicked', () => {
describe('callStepContentButton', () => {
it('emits the "clickStepContentButton" event when a popover button is clicked', () => {
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