Commit 89da618d authored by Paul Slaughter's avatar Paul Slaughter

Merge branch 'revert-2ac0ed75' into 'master'

Fix regression in renaming files in Web IDE

See merge request gitlab-org/gitlab!32166
parents b1a75c7d edbbf705
......@@ -52,7 +52,7 @@ export default {
...mapActions(['createTempEntry', 'renameEntry']),
submitForm() {
if (this.modalType === modalTypes.rename) {
if (!this.entries[this.entryName]?.deleted) {
if (this.entries[this.entryName] && !this.entries[this.entryName].deleted) {
flash(
sprintf(s__('The name "%{name}" is already taken in this directory.'), {
name: this.entryName,
......
......@@ -121,8 +121,10 @@ describe('new file modal component', () => {
});
describe('submitForm', () => {
it('throws an error when target entry exists', () => {
const store = createStore();
let store;
beforeEach(() => {
store = createStore();
store.state.entries = {
'test-path/test': {
name: 'test',
......@@ -131,6 +133,9 @@ describe('new file modal component', () => {
};
vm = createComponentWithStore(Component, store).$mount();
});
it('throws an error when target entry exists', () => {
vm.open('rename', 'test-path/test');
expect(createFlash).not.toHaveBeenCalled();
......@@ -146,5 +151,15 @@ describe('new file modal component', () => {
true,
);
});
it('does not throw error when target entry does not exist', () => {
jest.spyOn(vm, 'renameEntry').mockImplementation();
vm.open('rename', 'test-path/test');
vm.entryName = 'test-path/test2';
vm.submitForm();
expect(createFlash).not.toHaveBeenCalled();
});
});
});
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