Commit 4b74033f authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '213341-project-snippet-delete-redirect' into 'master'

Resolve "Project Snippet deletion redirects to wrong path"

Closes #213341

See merge request gitlab-org/gitlab!31709
parents b58fff99 6a6bd2e8
...@@ -127,7 +127,7 @@ export default { ...@@ -127,7 +127,7 @@ export default {
}, },
methods: { methods: {
redirectToSnippets() { redirectToSnippets() {
window.location.pathname = 'dashboard/snippets'; window.location.pathname = this.snippet.project?.fullPath || 'dashboard/snippets';
}, },
closeDeleteModal() { closeDeleteModal() {
this.$refs.deleteModal.hide(); 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', () => { ...@@ -172,14 +172,34 @@ describe('Snippet header component', () => {
}); });
}); });
it('closes modal and redirects to snippets listing in case of successful mutation', () => { describe('in case of successful mutation, closes modal and redirects to correct listing', () => {
createComponent(); const createDeleteSnippet = (snippetProps = {}) => {
wrapper.vm.closeDeleteModal = jest.fn(); createComponent({
snippetProps,
});
wrapper.vm.closeDeleteModal = jest.fn();
wrapper.vm.deleteSnippet();
return wrapper.vm.$nextTick();
};
wrapper.vm.deleteSnippet(); it('redirects to dashboard/snippets for personal snippet', () => {
return wrapper.vm.$nextTick().then(() => { return createDeleteSnippet().then(() => {
expect(wrapper.vm.closeDeleteModal).toHaveBeenCalled(); 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