Commit e9034e2b authored by Paul Slaughter's avatar Paul Slaughter

Fix Web IDE deleting newly added files

*How?*
It does this by removing from stagedFiles as
well as changedFiles. This is not ideal and should
be addressed in [this issue][1].

[1]: https://gitlab.com/gitlab-org/create-stage/-/issues/12669
parent 83d05863
......@@ -216,7 +216,12 @@ export default {
if (entry.type === 'blob') {
if (tempFile) {
// Since we only support one list of file changes, it's safe to just remove from both
// changed and staged. Otherwise, we'd need to somehow evaluate the difference between
// changed and HEAD.
// https://gitlab.com/gitlab-org/create-stage/-/issues/12669
state.changedFiles = state.changedFiles.filter(f => f.path !== path);
state.stagedFiles = state.stagedFiles.filter(f => f.path !== path);
} else {
state.changedFiles = state.changedFiles.concat(entry);
}
......
---
title: Fix Web IDE handling of deleting newly added files
merge_request: 29783
author:
type: fixed
......@@ -30,4 +30,14 @@ describe 'IDE user commits changes', :js do
expect(project.repository.blob_at('master', 'foo/bar/.gitkeep')).to be_nil
expect(project.repository.blob_at('master', 'foo/bar/lorem_ipsum.md').data).to eql(content)
end
it 'user adds then deletes new file' do
ide_create_new_file('foo/bar/lorem_ipsum.md')
expect(page).to have_selector(ide_commit_tab_selector)
ide_delete_file('foo/bar/lorem_ipsum.md')
expect(page).not_to have_selector(ide_commit_tab_selector)
end
end
......@@ -273,7 +273,7 @@ describe('Multi-file store mutations', () => {
expect(localState.changedFiles).toEqual([]);
});
it('removes tempFile from changedFiles when deleted', () => {
it('removes tempFile from changedFiles and stagedFiles when deleted', () => {
localState.entries.filePath = {
path: 'filePath',
deleted: false,
......@@ -282,10 +282,12 @@ describe('Multi-file store mutations', () => {
};
localState.changedFiles.push({ ...localState.entries.filePath });
localState.stagedFiles.push({ ...localState.entries.filePath });
mutations.DELETE_ENTRY(localState, 'filePath');
expect(localState.changedFiles).toEqual([]);
expect(localState.stagedFiles).toEqual([]);
});
it('bursts unused seal', () => {
......
......@@ -32,6 +32,10 @@ module WebIdeSpecHelpers
page.find('.ide-tree-actions')
end
def ide_tab_selector(mode)
".js-ide-#{mode}-mode"
end
def ide_file_row_open?(row)
row.matches_css?('.is-open')
end
......@@ -106,16 +110,16 @@ module WebIdeSpecHelpers
evaluate_script("monaco.editor.getModel('#{uri}').getValue()")
end
def ide_commit_tab_selector
ide_tab_selector('commit')
end
def ide_commit
ide_switch_mode('commit')
find(ide_commit_tab_selector).click
commit_to_current_branch
end
def ide_switch_mode(mode)
find(".js-ide-#{mode}-mode").click
end
private
def file_row_container(row)
......
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