]> git.openstreetmap.org Git - rails.git/blob - test/system/profile_links_change_test.rb
Fix eslint warning
[rails.git] / test / system / profile_links_change_test.rb
1 require "application_system_test_case"
2
3 class ProfileLinksChangeTest < ApplicationSystemTestCase
4   test "can't change links when unauthorized" do
5     user = create(:user)
6
7     visit user_path(user)
8
9     within_content_body do
10       assert_no_button "Edit Profile Details"
11       assert_no_link "Edit Links"
12     end
13   end
14
15   test "can't change links of another user" do
16     user = create(:user)
17     another_user = create(:user)
18
19     sign_in_as(user)
20     visit user_path(another_user)
21
22     within_content_body do
23       assert_no_button "Edit Profile Details"
24       assert_no_link "Edit Links"
25     end
26   end
27
28   test "can add and remove social link without submitting" do
29     user = create(:user)
30
31     sign_in_as(user)
32     visit user_path(user)
33
34     within_content_body do
35       click_on "Edit Profile Details"
36       click_on "Edit Links"
37
38       assert_no_field "Social Profile Link 1"
39
40       click_on "Add Social Link"
41
42       assert_field "Social Profile Link 1"
43
44       click_on "Remove Social Profile Link 1"
45
46       assert_no_field "Social Profile Link 1"
47     end
48   end
49
50   test "can add and remove social links" do
51     user = create(:user)
52
53     sign_in_as(user)
54     visit user_path(user)
55
56     within_content_body do
57       click_on "Edit Profile Details"
58       click_on "Edit Links"
59
60       assert_no_field "Social Profile Link 1"
61
62       click_on "Add Social Link"
63       fill_in "Social Profile Link 1", :with => "https://example.com/user/fred"
64       click_on "Update Profile"
65
66       assert_link "example.com/user/fred"
67
68       click_on "Edit Profile Details"
69       click_on "Edit Links"
70       click_on "Remove Social Profile Link 1"
71
72       assert_no_field "Social Profile Link 1"
73
74       click_on "Update Profile"
75
76       assert_no_link "example.com/user/fred"
77     end
78   end
79
80   test "can control social links using keyboard without submitting" do
81     user = create(:user)
82
83     sign_in_as(user)
84     visit user_path(user)
85
86     within_content_body do
87       click_on "Edit Profile Details"
88       click_on "Edit Links"
89       click_on "Add Social Link"
90
91       assert_field "Social Profile Link 1"
92
93       send_keys :tab, :enter
94
95       assert_no_field "Social Profile Link 1"
96     end
97   end
98
99   test "can control social links using keyboard" do
100     user = create(:user)
101
102     sign_in_as(user)
103     visit user_path(user)
104
105     within_content_body do
106       click_on "Edit Profile Details"
107       click_on "Edit Links"
108       click_on "Add Social Link"
109       send_keys "https://example.com/user/typed"
110       click_on "Update Profile"
111
112       assert_link "example.com/user/typed"
113
114       click_on "Edit Profile Details"
115       click_on "Edit Links"
116       find_field("Social Profile Link 1").click
117       send_keys :tab, :enter
118
119       assert_no_field "Social Profile Link 1"
120
121       click_on "Update Profile"
122
123       assert_no_link "example.com/user/typed"
124     end
125   end
126
127   test "can add and remove multiple links" do
128     user = create(:user)
129
130     sign_in_as(user)
131     visit user_path(user)
132
133     within_content_body do
134       click_on "Edit Profile Details"
135       click_on "Edit Links"
136       click_on "Add Social Link"
137       fill_in "Social Profile Link 1", :with => "https://example.com/a"
138       click_on "Add Social Link"
139       fill_in "Social Profile Link 2", :with => "https://example.com/b"
140       click_on "Add Social Link"
141       fill_in "Social Profile Link 3", :with => "https://example.com/c"
142       click_on "Update Profile"
143
144       assert_link "example.com/a"
145       assert_link "example.com/b"
146       assert_link "example.com/c"
147
148       click_on "Edit Profile Details"
149       click_on "Edit Links"
150       assert_field "Social Profile Link 1", :with => "https://example.com/a"
151       assert_field "Social Profile Link 2", :with => "https://example.com/b"
152       assert_field "Social Profile Link 3", :with => "https://example.com/c"
153
154       click_on "Remove Social Profile Link 2"
155
156       assert_field "Social Profile Link 1", :with => "https://example.com/a"
157       assert_field "Social Profile Link 2", :with => "https://example.com/c"
158
159       click_on "Add Social Link"
160       fill_in "Social Profile Link 3", :with => "https://example.com/d"
161       click_on "Update Profile"
162
163       assert_link "example.com/a"
164       assert_no_link "example.com/b"
165       assert_link "example.com/c"
166       assert_link "example.com/d"
167     end
168   end
169 end