added feature spec
This commit is contained in:
parent
4c186f99f2
commit
4699cf77b6
5 changed files with 107 additions and 4 deletions
|
@ -98,8 +98,8 @@ const RepoHelper = {
|
|||
.then((response) => {
|
||||
const data = response.data;
|
||||
if (response.headers && response.headers['page-title']) data.pageTitle = decodeURI(response.headers['page-title']);
|
||||
if (response.headers && response.headers['is-root'] && !Store.isInitialRoot) {
|
||||
Store.isRoot = convertPermissionToBoolean(response.headers['is-root']);
|
||||
if (data.path && !Store.isInitialRoot) {
|
||||
Store.isRoot = data.path === '/';
|
||||
Store.isInitialRoot = Store.isRoot;
|
||||
}
|
||||
|
||||
|
@ -140,6 +140,10 @@ const RepoHelper = {
|
|||
|
||||
addToDirectory(file, data) {
|
||||
const tree = file || Store;
|
||||
|
||||
// TODO: Figure out why `popstate` is being trigger in the specs
|
||||
if (!tree.files) return;
|
||||
|
||||
const files = tree.files.concat(this.dataToListOfFiles(data, file ? file.level + 1 : 0));
|
||||
|
||||
tree.files = files;
|
||||
|
@ -236,7 +240,8 @@ const RepoHelper = {
|
|||
return Store.openedFiles.find(file => file.url === path);
|
||||
},
|
||||
|
||||
loadingError() {
|
||||
loadingError(e) {
|
||||
console.log(e);
|
||||
Flash('Unable to load this content at this time.');
|
||||
},
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ class Projects::TreeController < Projects::ApplicationController
|
|||
|
||||
format.json do
|
||||
page_title @path.presence || _("Files"), @ref, @project.name_with_namespace
|
||||
response.header['is-root'] = @path.empty?
|
||||
|
||||
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/38261
|
||||
Gitlab::GitalyClient.allow_n_plus_1_calls do
|
||||
|
|
43
spec/features/projects/tree/create_directory_spec.rb
Normal file
43
spec/features/projects/tree/create_directory_spec.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'Multi-file editor new directory', :js do
|
||||
include WaitForRequests
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:project) { create(:project, :repository) }
|
||||
|
||||
before do
|
||||
project.add_master(user)
|
||||
sign_in(user)
|
||||
|
||||
page.driver.set_cookie('new_repo', 'true')
|
||||
|
||||
visit project_tree_path(project, :master)
|
||||
|
||||
wait_for_requests
|
||||
end
|
||||
|
||||
it 'creates directory in current directory' do
|
||||
find('.add-to-tree').click
|
||||
|
||||
click_link('New directory')
|
||||
|
||||
page.within('.popup-dialog') do
|
||||
find('.form-control').set('foldername')
|
||||
|
||||
click_button('Create directory')
|
||||
end
|
||||
|
||||
fill_in('commit-message', with: 'commit message')
|
||||
|
||||
click_button('Commit 1 file')
|
||||
|
||||
expect(page).to have_content('Your changes have been committed')
|
||||
expect(page).to have_selector('td', text: 'commit message')
|
||||
|
||||
click_link('foldername')
|
||||
|
||||
expect(page).to have_selector('td', text: 'commit message', count: 2)
|
||||
expect(page).to have_selector('td', text: '.gitkeep')
|
||||
end
|
||||
end
|
40
spec/features/projects/tree/create_file_spec.rb
Normal file
40
spec/features/projects/tree/create_file_spec.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'Multi-file editor new file', :js do
|
||||
include WaitForRequests
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:project) { create(:project, :repository) }
|
||||
|
||||
before do
|
||||
project.add_master(user)
|
||||
sign_in(user)
|
||||
|
||||
page.driver.set_cookie('new_repo', 'true')
|
||||
|
||||
visit project_tree_path(project, :master)
|
||||
|
||||
wait_for_requests
|
||||
end
|
||||
|
||||
it 'creates file in current directory' do
|
||||
find('.add-to-tree').click
|
||||
|
||||
click_link('New file')
|
||||
|
||||
page.within('.popup-dialog') do
|
||||
find('.form-control').set('filename')
|
||||
|
||||
click_button('Create file')
|
||||
end
|
||||
|
||||
find('.inputarea').send_keys('file content')
|
||||
|
||||
fill_in('commit-message', with: 'commit message')
|
||||
|
||||
click_button('Commit 1 file')
|
||||
|
||||
expect(page).to have_content('Your changes have been committed')
|
||||
expect(page).to have_selector('td', text: 'commit message')
|
||||
end
|
||||
end
|
|
@ -71,6 +71,22 @@ describe('new file modal component', () => {
|
|||
|
||||
expect(RepoStore.openedFiles.length).toBe(1);
|
||||
});
|
||||
|
||||
it(`creates ${type} in the current stores path`, () => {
|
||||
RepoStore.path = 'testing';
|
||||
vm.entryName = 'testing/app';
|
||||
|
||||
vm.$el.querySelector('.btn-success').click();
|
||||
|
||||
expect(RepoStore.files[0].path).toBe('testing/app');
|
||||
expect(RepoStore.files[0].name).toBe('app');
|
||||
|
||||
if (type === 'tree') {
|
||||
expect(RepoStore.files[0].files.length).toBe(1);
|
||||
}
|
||||
|
||||
RepoStore.path = '';
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue