debian-mirror-gitlab/spec/features/projects/tree/tree_show_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

176 lines
5.5 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Projects tree', :js, feature_category: :web_ide do
2023-06-20 00:43:36 +05:30
include Features::WebIdeSpecHelpers
2020-07-28 23:09:34 +05:30
include RepoHelpers
2023-04-23 21:23:45 +05:30
include ListboxHelpers
2020-07-28 23:09:34 +05:30
2018-03-17 18:26:18 +05:30
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
2020-03-13 15:44:24 +05:30
let(:gravatar_enabled) { true }
2018-03-17 18:26:18 +05:30
2018-11-20 20:47:30 +05:30
# This commit has a known state on the master branch of gitlab-test
let(:test_sha) { '7975be0116940bf2ad4321f79d02a55c5f7779aa' }
2018-03-17 18:26:18 +05:30
before do
2020-03-13 15:44:24 +05:30
stub_application_setting(gravatar_enabled: gravatar_enabled)
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2018-03-17 18:26:18 +05:30
sign_in(user)
2018-11-18 11:00:15 +05:30
end
2018-03-17 18:26:18 +05:30
2018-11-18 11:00:15 +05:30
it 'renders tree table without errors' do
2018-11-20 20:47:30 +05:30
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')
2022-04-04 11:22:00 +05:30
expect(page).not_to have_selector('[data-testid="alert-danger"]')
2022-10-11 01:57:18 +05:30
expect(page).not_to have_selector('[data-testid="label-lfs"]', text: 'LFS')
2018-11-20 20:47:30 +05:30
end
it 'renders tree table for a subtree without errors' do
visit project_tree_path(project, File.join(test_sha, 'files'))
2018-11-18 11:00:15 +05:30
wait_for_requests
2018-03-17 18:26:18 +05:30
expect(page).to have_selector('.tree-item')
2018-11-20 20:47:30 +05:30
expect(page).to have_content('add spaces in whitespace file')
2022-10-11 01:57:18 +05:30
expect(page).not_to have_selector('[data-testid="label-lfs"]', text: 'LFS')
2022-04-04 11:22:00 +05:30
expect(page).not_to have_selector('[data-testid="alert-danger"]')
2018-03-17 18:26:18 +05:30
end
2020-03-13 15:44:24 +05:30
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')
2022-04-04 11:22:00 +05:30
expect(page).not_to have_selector('[data-testid="alert-danger"]')
2020-03-13 15:44:24 +05:30
end
2020-07-28 23:09:34 +05:30
context "with a tree that contains pathspec characters" do
let(:path) { ':wq' }
let(:filename) { File.join(path, 'test.txt') }
let(:newrev) { project.repository.commit('master').sha }
let(:short_newrev) { project.repository.commit('master').short_id }
2022-08-27 11:52:29 +05:30
let(:message) { 'Glob characters' }
2020-07-28 23:09:34 +05:30
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
it "renders tree table without errors" do
expect(page).to have_selector('.tree-item')
expect(page).to have_content('test.txt')
expect(page).to have_content(message)
# Check last commit
expect(find('.commit-content').text).to include(message)
2021-01-03 14:25:43 +05:30
expect(find('.js-commit-sha-group').text).to eq(short_newrev)
2020-07-28 23:09:34 +05:30
end
end
2020-03-13 15:44:24 +05:30
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
2022-07-16 23:28:13 +05:30
expect(page).to have_selector('.gl-avatar')
2020-03-13 15:44:24 +05:30
expect(page).to have_content('Merge branch')
end
end
end
2018-11-18 11:00:15 +05:30
context 'for signed commit' do
it 'displays a GPG badge' do
visit project_tree_path(project, '33f3729a45c02fc67d00adb1b8bca394b0e761d9')
wait_for_requests
2023-04-23 21:23:45 +05:30
expect(page).not_to have_selector '.js-loading-signature-badge'
expect(page).to have_selector '.gl-badge.badge-muted'
2018-03-17 18:26:18 +05:30
end
2018-11-18 11:00:15 +05:30
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
2023-04-23 21:23:45 +05:30
expect(page).not_to have_selector '.js-loading-signature-badge'
expect(page).to have_selector '.gl-badge.badge-muted'
2018-11-18 11:00:15 +05:30
end
end
end
context 'LFS' do
2018-03-17 18:26:18 +05:30
it 'renders LFS badge on blob item' do
2018-11-18 11:00:15 +05:30
visit project_tree_path(project, File.join('master', 'files/lfs'))
2022-10-11 01:57:18 +05:30
expect(page).to have_selector('[data-testid="label-lfs"]', text: 'LFS')
2018-03-17 18:26:18 +05:30
end
end
2018-05-09 12:01:36 +05:30
2018-11-18 11:00:15 +05:30
context 'web IDE' do
2022-10-11 01:57:18 +05:30
before do
stub_feature_flags(vscode_web_ide: false)
end
2018-11-18 11:00:15 +05:30
it 'opens folder in IDE' do
2018-05-09 12:01:36 +05:30
visit project_tree_path(project, File.join('master', 'bar'))
2023-03-17 16:20:25 +05:30
ide_visit_from_link
2018-05-09 12:01:36 +05:30
2023-03-17 16:20:25 +05:30
wait_for_all_requests
2018-05-09 12:01:36 +05:30
find('.ide-file-list')
2018-11-18 11:00:15 +05:30
wait_for_requests
expect(page).to have_selector('.is-open', text: 'bar')
2018-05-09 12:01:36 +05:30
end
2018-11-18 11:00:15 +05:30
end
2018-05-09 12:01:36 +05:30
2018-11-18 11:00:15 +05:30
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')
2022-04-04 11:22:00 +05:30
expect(page).not_to have_selector('[data-testid="alert-danger"]')
2018-11-18 11:00:15 +05:30
end
context 'for signed commit' do
it 'displays a GPG badge' do
visit project_tree_path(project, '33f3729a45c02fc67d00adb1b8bca394b0e761d9')
wait_for_requests
2023-04-23 21:23:45 +05:30
expect(page).not_to have_selector '.js-loading-signature-badge'
expect(page).to have_selector '.gl-badge.badge-muted'
2018-11-18 11:00:15 +05:30
end
2018-05-09 12:01:36 +05:30
end
end
2022-07-16 23:28:13 +05:30
2023-03-04 22:38:38 +05:30
context 'ref switcher', :js do
2023-04-23 21:23:45 +05:30
it 'switches ref to branch', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/391780' do
2023-03-04 22:38:38 +05:30
ref_selector = '.ref-selector'
2023-04-23 21:23:45 +05:30
ref_name = 'fix'
2022-07-16 23:28:13 +05:30
visit project_tree_path(project, 'master')
2023-04-23 21:23:45 +05:30
click_button 'master'
send_keys ref_name
2023-03-04 22:38:38 +05:30
2023-04-23 21:23:45 +05:30
select_listbox_item ref_name
2022-07-16 23:28:13 +05:30
2023-03-04 22:38:38 +05:30
expect(find(ref_selector)).to have_text(ref_name)
2022-07-16 23:28:13 +05:30
end
end
2018-03-17 18:26:18 +05:30
end