blob: 626d4de7baffd638796f795ab432fea20f7e6bec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Projects > Show > Collaboration links', :js, feature_category: :groups_and_projects do
using RSpec::Parameterized::TableSyntax
let_it_be(:project) { create(:project, :repository, :public) }
let_it_be(:user) { create(:user, :no_super_sidebar) }
before do
sign_in(user)
end
def find_new_menu_toggle
find('#js-onboarding-new-project-link')
end
context 'with developer user' do
before_all do
project.add_developer(user)
end
it 'shows all the expected links' do
visit project_path(project)
# The navigation bar
page.within('.header-new') do
find_new_menu_toggle.click
aggregate_failures 'dropdown links in the navigation bar' do
expect(page).to have_link('New issue')
expect(page).to have_link('New merge request')
expect(page).to have_link('New snippet', href: new_project_snippet_path(project))
end
find_new_menu_toggle.click
end
# The dropdown above the tree
page.within('.repo-breadcrumb') do
find('[data-testid="add-to-tree"]').click
aggregate_failures 'dropdown links above the repo tree' do
expect(page).to have_link('New file')
expect(page).to have_button('Upload file')
expect(page).to have_button('New directory')
expect(page).to have_link('New branch')
expect(page).to have_link('New tag')
end
end
# The Web IDE
click_button 'Edit'
expect(page).to have_button('Web IDE')
end
it 'hides the links when the project is archived' do
project.update!(archived: true)
visit project_path(project)
page.within('.header-new') do
find_new_menu_toggle.click
aggregate_failures 'dropdown links' do
expect(page).not_to have_link('New issue')
expect(page).not_to have_link('New merge request')
expect(page).not_to have_link('New snippet', href: new_project_snippet_path(project))
end
find_new_menu_toggle.click
end
expect(page).not_to have_selector('[data-testid="add-to-tree"]')
expect(page).not_to have_button('Edit')
end
end
context "Web IDE link" do
where(:merge_requests_access_level, :user_level, :expect_ide_link) do
::ProjectFeature::DISABLED | :guest | false
::ProjectFeature::DISABLED | :developer | true
::ProjectFeature::PRIVATE | :guest | false
::ProjectFeature::PRIVATE | :developer | true
::ProjectFeature::ENABLED | :guest | true
::ProjectFeature::ENABLED | :developer | true
end
with_them do
before do
project.project_feature.update!({ merge_requests_access_level: merge_requests_access_level })
project.add_member(user, user_level)
visit project_path(project)
end
it "updates Web IDE link" do
expect(page.has_button?('Edit')).to be(expect_ide_link)
end
end
end
end
|