Commit 6a6bd2e8 authored by Denys Mishunov's avatar Denys Mishunov

Fixed redirection when deleting a project snippet

parent 911c4841
......@@ -127,7 +127,7 @@ export default {
},
methods: {
redirectToSnippets() {
window.location.pathname = 'dashboard/snippets';
window.location.pathname = this.snippet.project?.fullPath || 'dashboard/snippets';
},
closeDeleteModal() {
this.$refs.deleteModal.hide();
......
---
title: Fixed redirection when deleting a project snippet
merge_request: 31709
author:
type: fixed
......@@ -172,14 +172,34 @@ describe('Snippet header component', () => {
});
});
it('closes modal and redirects to snippets listing in case of successful mutation', () => {
createComponent();
describe('in case of successful mutation, closes modal and redirects to correct listing', () => {
const createDeleteSnippet = (snippetProps = {}) => {
createComponent({
snippetProps,
});
wrapper.vm.closeDeleteModal = jest.fn();
wrapper.vm.deleteSnippet();
return wrapper.vm.$nextTick().then(() => {
return wrapper.vm.$nextTick();
};
it('redirects to dashboard/snippets for personal snippet', () => {
return createDeleteSnippet().then(() => {
expect(wrapper.vm.closeDeleteModal).toHaveBeenCalled();
expect(window.location.pathname).toEqual('dashboard/snippets');
expect(window.location.pathname).toBe('dashboard/snippets');
});
});
it('redirects to project snippets for project snippet', () => {
const fullPath = 'foo/bar';
return createDeleteSnippet({
project: {
fullPath,
},
}).then(() => {
expect(wrapper.vm.closeDeleteModal).toHaveBeenCalled();
expect(window.location.pathname).toBe(fullPath);
});
});
});
});
......
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