Commit f0e1ee5f authored by Tim Zallmann's avatar Tim Zallmann

Fixes for Tests on file.js and tabs tests

parent 1814fc3f
...@@ -48,29 +48,26 @@ export const setFileActive = ({ commit, state, getters, dispatch }, path) => { ...@@ -48,29 +48,26 @@ export const setFileActive = ({ commit, state, getters, dispatch }, path) => {
export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive = true }) => { export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive = true }) => {
const file = state.entries[path]; const file = state.entries[path];
return new Promise((resolve, reject) => { commit(types.TOGGLE_LOADING, { entry: file });
commit(types.TOGGLE_LOADING, { entry: file }); return service
service .getFileData(file.url)
.getFileData(file.url) .then(res => {
.then(res => { const pageTitle = decodeURI(normalizeHeaders(res.headers)['PAGE-TITLE']);
const pageTitle = decodeURI(normalizeHeaders(res.headers)['PAGE-TITLE']);
setPageTitle(pageTitle);
setPageTitle(pageTitle);
return res.json();
return res.json(); })
}) .then(data => {
.then(data => { commit(types.SET_FILE_DATA, { data, file });
commit(types.SET_FILE_DATA, { data, file }); commit(types.TOGGLE_FILE_OPEN, path);
commit(types.TOGGLE_FILE_OPEN, path); if (makeFileActive) dispatch('setFileActive', file.path);
if (makeFileActive) dispatch('setFileActive', file.path); commit(types.TOGGLE_LOADING, { entry: file });
commit(types.TOGGLE_LOADING, { entry: file }); })
}) .catch(() => {
.catch(err => { commit(types.TOGGLE_LOADING, { entry: file });
commit(types.TOGGLE_LOADING, { entry: file }); flash('Error loading file data. Please try again.', 'alert', document, null, false, true);
flash('Error loading file data. Please try again.', 'alert', document, null, false, true); });
reject(err);
});
});
}; };
export const setFileMrChange = ({ state, commit }, { file, mrChange }) => { export const setFileMrChange = ({ state, commit }, { file, mrChange }) => {
......
...@@ -17,6 +17,7 @@ describe('RepoTabs', () => { ...@@ -17,6 +17,7 @@ describe('RepoTabs', () => {
files: openedFiles, files: openedFiles,
viewer: 'editor', viewer: 'editor',
hasChanges: false, hasChanges: false,
hasMergeRequest: false,
}); });
openedFiles[0].active = true; openedFiles[0].active = true;
......
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