2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-12 04:11:01 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 14:08:28 -04:00
|
|
|
RSpec.describe 'Projects tree', :js do
|
2020-06-21 23:08:17 -04:00
|
|
|
include RepoHelpers
|
|
|
|
|
2017-12-12 04:11:01 -05:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :repository) }
|
2020-02-24 10:09:10 -05:00
|
|
|
let(:gravatar_enabled) { true }
|
2017-12-12 04:11:01 -05:00
|
|
|
|
2018-09-04 08:51:02 -04:00
|
|
|
# This commit has a known state on the master branch of gitlab-test
|
|
|
|
let(:test_sha) { '7975be0116940bf2ad4321f79d02a55c5f7779aa' }
|
|
|
|
|
2017-12-12 04:11:01 -05:00
|
|
|
before do
|
2020-02-24 10:09:10 -05:00
|
|
|
stub_application_setting(gravatar_enabled: gravatar_enabled)
|
|
|
|
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2017-12-12 04:11:01 -05:00
|
|
|
sign_in(user)
|
2018-08-02 12:17:20 -04:00
|
|
|
end
|
2017-12-12 04:11:01 -05:00
|
|
|
|
2018-08-02 12:17:20 -04:00
|
|
|
it 'renders tree table without errors' do
|
2018-09-04 08:51:02 -04:00
|
|
|
visit project_tree_path(project, test_sha)
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_selector('.tree-item')
|
|
|
|
expect(page).to have_content('add tests for .gitattributes custom highlighting')
|
|
|
|
expect(page).not_to have_selector('.flash-alert')
|
2020-05-26 17:07:45 -04:00
|
|
|
expect(page).not_to have_selector('[data-qa-selector="label-lfs"]', text: 'LFS')
|
2018-09-04 08:51:02 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders tree table for a subtree without errors' do
|
|
|
|
visit project_tree_path(project, File.join(test_sha, 'files'))
|
2018-08-02 12:17:20 -04:00
|
|
|
wait_for_requests
|
2017-12-12 04:11:01 -05:00
|
|
|
|
|
|
|
expect(page).to have_selector('.tree-item')
|
2018-09-04 08:51:02 -04:00
|
|
|
expect(page).to have_content('add spaces in whitespace file')
|
2020-05-26 17:07:45 -04:00
|
|
|
expect(page).not_to have_selector('[data-qa-selector="label-lfs"]', text: 'LFS')
|
2018-08-02 12:17:20 -04:00
|
|
|
expect(page).not_to have_selector('.flash-alert')
|
2017-12-12 04:11:01 -05:00
|
|
|
end
|
|
|
|
|
2020-02-26 10:08:56 -05:00
|
|
|
it 'renders tree table with non-ASCII filenames without errors' do
|
|
|
|
visit project_tree_path(project, File.join(test_sha, 'encoding'))
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_selector('.tree-item')
|
|
|
|
expect(page).to have_content('Files, encoding and much more')
|
|
|
|
expect(page).to have_content('テスト.txt')
|
|
|
|
expect(page).not_to have_selector('.flash-alert')
|
|
|
|
end
|
|
|
|
|
2020-06-26 17:08:51 -04:00
|
|
|
context "with a tree that contains pathspec characters" do
|
2020-06-21 23:08:17 -04:00
|
|
|
let(:path) { ':wq' }
|
|
|
|
let(:filename) { File.join(path, 'test.txt') }
|
|
|
|
let(:newrev) { project.repository.commit('master').sha }
|
2020-06-26 17:08:51 -04:00
|
|
|
let(:short_newrev) { project.repository.commit('master').short_id }
|
2020-06-21 23:08:17 -04:00
|
|
|
let(:message) { 'Glob characters'}
|
|
|
|
|
|
|
|
before do
|
|
|
|
create_file_in_repo(project, 'master', 'master', filename, 'Test file', commit_message: message)
|
|
|
|
visit project_tree_path(project, File.join('master', path))
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
2020-06-26 17:08:51 -04:00
|
|
|
it "renders tree table without errors" do
|
2020-06-21 23:08:17 -04:00
|
|
|
expect(page).to have_selector('.tree-item')
|
|
|
|
expect(page).to have_content('test.txt')
|
|
|
|
expect(page).to have_content(message)
|
2020-06-26 17:08:51 -04:00
|
|
|
|
|
|
|
# Check last commit
|
|
|
|
expect(find('.commit-content').text).to include(message)
|
2020-10-02 20:08:46 -04:00
|
|
|
expect(find('.js-commit-sha-group').text).to eq(short_newrev)
|
2020-06-21 23:08:17 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-02-24 10:09:10 -05:00
|
|
|
context 'gravatar disabled' do
|
|
|
|
let(:gravatar_enabled) { false }
|
|
|
|
|
|
|
|
it 'renders last commit' do
|
|
|
|
visit project_tree_path(project, test_sha)
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
page.within('.project-last-commit') do
|
|
|
|
expect(page).to have_selector('.user-avatar-link')
|
|
|
|
expect(page).to have_content('Merge branch')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-02 12:17:20 -04:00
|
|
|
context 'for signed commit' do
|
|
|
|
it 'displays a GPG badge' do
|
|
|
|
visit project_tree_path(project, '33f3729a45c02fc67d00adb1b8bca394b0e761d9')
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
|
|
|
|
expect(page).to have_selector '.gpg-status-box.invalid'
|
2017-12-12 04:11:01 -05:00
|
|
|
end
|
|
|
|
|
2018-08-02 12:17:20 -04:00
|
|
|
context 'on a directory that has not changed recently' do
|
|
|
|
it 'displays a GPG badge' do
|
|
|
|
tree_path = File.join('eee736adc74341c5d3e26cd0438bc697f26a7575', 'subdir')
|
|
|
|
visit project_tree_path(project, tree_path)
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
|
|
|
|
expect(page).to have_selector '.gpg-status-box.invalid'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'LFS' do
|
2017-12-12 04:11:01 -05:00
|
|
|
it 'renders LFS badge on blob item' do
|
2018-08-02 12:17:20 -04:00
|
|
|
visit project_tree_path(project, File.join('master', 'files/lfs'))
|
|
|
|
|
2020-05-26 17:07:45 -04:00
|
|
|
expect(page).to have_selector('[data-qa-selector="label-lfs"]', text: 'LFS')
|
2017-12-12 04:11:01 -05:00
|
|
|
end
|
|
|
|
end
|
2018-03-21 08:06:44 -04:00
|
|
|
|
2018-08-02 12:17:20 -04:00
|
|
|
context 'web IDE' do
|
|
|
|
it 'opens folder in IDE' do
|
2018-03-21 08:06:44 -04:00
|
|
|
visit project_tree_path(project, File.join('master', 'bar'))
|
|
|
|
|
|
|
|
click_link 'Web IDE'
|
|
|
|
|
2018-08-02 12:17:20 -04:00
|
|
|
wait_for_requests
|
2018-03-21 08:06:44 -04:00
|
|
|
find('.ide-file-list')
|
2018-08-02 12:17:20 -04:00
|
|
|
wait_for_requests
|
|
|
|
expect(page).to have_selector('.is-open', text: 'bar')
|
2018-03-21 08:06:44 -04:00
|
|
|
end
|
2018-08-02 12:17:20 -04:00
|
|
|
end
|
2018-03-21 08:06:44 -04:00
|
|
|
|
2018-08-02 12:17:20 -04:00
|
|
|
context 'for subgroups' do
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:subgroup) { create(:group, parent: group) }
|
|
|
|
let(:project) { create(:project, :repository, group: subgroup) }
|
|
|
|
|
|
|
|
it 'renders tree table without errors' do
|
|
|
|
visit project_tree_path(project, 'master')
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_selector('.tree-item')
|
|
|
|
expect(page).not_to have_selector('.flash-alert')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for signed commit' do
|
|
|
|
it 'displays a GPG badge' do
|
|
|
|
visit project_tree_path(project, '33f3729a45c02fc67d00adb1b8bca394b0e761d9')
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
|
|
|
|
expect(page).to have_selector '.gpg-status-box.invalid'
|
|
|
|
end
|
2018-03-21 08:06:44 -04:00
|
|
|
end
|
|
|
|
end
|
2017-12-12 04:11:01 -05:00
|
|
|
end
|