Commit 70a9bd19 authored by Sarah Groff Hennigh-Palermo's avatar Sarah Groff Hennigh-Palermo

Merge branch 'auto-scroll-pipeline-editor-on-commit' into 'master'

Auto-scroll to top of page upon committing in pipeline editor

See merge request gitlab-org/gitlab!54657
parents cfe336ab c5c20891
...@@ -186,11 +186,13 @@ export default { ...@@ -186,11 +186,13 @@ export default {
this.showSuccessAlert = false; this.showSuccessAlert = false;
}, },
reportFailure(type, reasons = []) { reportFailure(type, reasons = []) {
window.scrollTo({ top: 0, behavior: 'smooth' });
this.showFailureAlert = true; this.showFailureAlert = true;
this.failureType = type; this.failureType = type;
this.failureReasons = reasons; this.failureReasons = reasons;
}, },
reportSuccess(type) { reportSuccess(type) {
window.scrollTo({ top: 0, behavior: 'smooth' });
this.showSuccessAlert = true; this.showSuccessAlert = true;
this.successType = type; this.successType = type;
}, },
......
---
title: Auto-scroll to top of page upon committing in pipeline editor
merge_request: 54657
author:
type: changed
...@@ -193,6 +193,7 @@ describe('Pipeline editor app component', () => { ...@@ -193,6 +193,7 @@ describe('Pipeline editor app component', () => {
describe('and the commit mutation succeeds', () => { describe('and the commit mutation succeeds', () => {
beforeEach(() => { beforeEach(() => {
window.scrollTo = jest.fn();
createComponent(); createComponent();
findEditorHome().vm.$emit('commit', { type: COMMIT_SUCCESS }); findEditorHome().vm.$emit('commit', { type: COMMIT_SUCCESS });
...@@ -201,11 +202,16 @@ describe('Pipeline editor app component', () => { ...@@ -201,11 +202,16 @@ describe('Pipeline editor app component', () => {
it('shows a confirmation message', () => { it('shows a confirmation message', () => {
expect(findAlert().text()).toBe(wrapper.vm.$options.successTexts[COMMIT_SUCCESS]); expect(findAlert().text()).toBe(wrapper.vm.$options.successTexts[COMMIT_SUCCESS]);
}); });
it('scrolls to the top of the page to bring attention to the confirmation message', () => {
expect(window.scrollTo).toHaveBeenCalledWith({ top: 0, behavior: 'smooth' });
});
}); });
describe('and the commit mutation fails', () => { describe('and the commit mutation fails', () => {
const commitFailedReasons = ['Commit failed']; const commitFailedReasons = ['Commit failed'];
beforeEach(() => { beforeEach(() => {
window.scrollTo = jest.fn();
createComponent(); createComponent();
findEditorHome().vm.$emit('showError', { findEditorHome().vm.$emit('showError', {
...@@ -219,11 +225,17 @@ describe('Pipeline editor app component', () => { ...@@ -219,11 +225,17 @@ describe('Pipeline editor app component', () => {
`${updateFailureMessage} ${commitFailedReasons[0]}`, `${updateFailureMessage} ${commitFailedReasons[0]}`,
); );
}); });
it('scrolls to the top of the page to bring attention to the error message', () => {
expect(window.scrollTo).toHaveBeenCalledWith({ top: 0, behavior: 'smooth' });
});
}); });
describe('when an unknown error occurs', () => { describe('when an unknown error occurs', () => {
const unknownReasons = ['Commit failed']; const unknownReasons = ['Commit failed'];
beforeEach(() => { beforeEach(() => {
window.scrollTo = jest.fn();
createComponent(); createComponent();
findEditorHome().vm.$emit('showError', { findEditorHome().vm.$emit('showError', {
...@@ -237,6 +249,10 @@ describe('Pipeline editor app component', () => { ...@@ -237,6 +249,10 @@ describe('Pipeline editor app component', () => {
`${updateFailureMessage} ${unknownReasons[0]}`, `${updateFailureMessage} ${unknownReasons[0]}`,
); );
}); });
it('scrolls to the top of the page to bring attention to the error message', () => {
expect(window.scrollTo).toHaveBeenCalledWith({ top: 0, behavior: 'smooth' });
});
}); });
}); });
}); });
......
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