Commit 459285fb authored by Mike Greiling's avatar Mike Greiling

Merge branch '27244-webide-discard-all-changes' into 'master'

Web IDE: Fix the console error that happens when discarding a newly added/uploaded file.

See merge request gitlab-org/gitlab!21537
parents 58d4f470 f721c8b8
...@@ -20,7 +20,7 @@ export const discardAllChanges = ({ state, commit, dispatch }) => { ...@@ -20,7 +20,7 @@ export const discardAllChanges = ({ state, commit, dispatch }) => {
commit(types.DISCARD_FILE_CHANGES, file.path); commit(types.DISCARD_FILE_CHANGES, file.path);
if (file.tempFile) { if (file.tempFile) {
dispatch('closeFile', file.path); dispatch('closeFile', file);
} }
}); });
......
---
title: "Web IDE: Fix the console error that happens when discarding a newly added/uploaded file."
merge_request: 21537
author:
type: fixed
...@@ -12,6 +12,7 @@ import actions, { ...@@ -12,6 +12,7 @@ import actions, {
renameEntry, renameEntry,
getBranchData, getBranchData,
createTempEntry, createTempEntry,
discardAllChanges,
} from '~/ide/stores/actions'; } from '~/ide/stores/actions';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { createStore } from '~/ide/stores'; import { createStore } from '~/ide/stores';
...@@ -60,8 +61,9 @@ describe('Multi-file store actions', () => { ...@@ -60,8 +61,9 @@ describe('Multi-file store actions', () => {
}); });
describe('discardAllChanges', () => { describe('discardAllChanges', () => {
let f;
beforeEach(() => { beforeEach(() => {
const f = file('discardAll'); f = file('discardAll');
f.changed = true; f.changed = true;
store.state.openFiles.push(f); store.state.openFiles.push(f);
...@@ -89,6 +91,27 @@ describe('Multi-file store actions', () => { ...@@ -89,6 +91,27 @@ describe('Multi-file store actions', () => {
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
}); });
it('closes the temp file if it was open', done => {
f.tempFile = true;
testAction(
discardAllChanges,
undefined,
store.state,
[
{ type: types.DISCARD_FILE_CHANGES, payload: 'discardAll' },
{ type: types.REMOVE_ALL_CHANGES_FILES },
],
[
{
type: 'closeFile',
payload: jasmine.objectContaining({ path: 'discardAll' }),
},
],
done,
);
});
}); });
describe('closeAllFiles', () => { describe('closeAllFiles', () => {
......
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