]> git.openstreetmap.org Git - rails.git/blob - test/system/user_social_links_test.rb
Merge remote-tracking branch 'upstream/pull/5201'
[rails.git] / test / system / user_social_links_test.rb
1 require "application_system_test_case"
2
3 class UserSocialLinksTest < ApplicationSystemTestCase
4   def setup
5     stub_request(:get, /.*gravatar.com.*d=404/).to_return(:status => 404)
6
7     @user = create(:user)
8     sign_in_as(@user)
9     visit user_path(@user)
10   end
11
12   test "can add and remove social link without submitting" do
13     within_content_body do
14       click_on "Edit Profile"
15
16       assert_no_field "Social Profile Link 1"
17
18       click_on "Add Social Link"
19
20       assert_field "Social Profile Link 1"
21
22       click_on "Remove Social Profile Link 1"
23
24       assert_no_field "Social Profile Link 1"
25     end
26   end
27
28   test "can add and remove social links" do
29     within_content_body do
30       click_on "Edit Profile"
31
32       assert_no_field "Social Profile Link 1"
33
34       click_on "Add Social Link"
35       fill_in "Social Profile Link 1", :with => "https://example.com/user/fred"
36       click_on "Update Profile"
37
38       assert_link "example.com/user/fred"
39
40       click_on "Edit Profile"
41       click_on "Remove Social Profile Link 1"
42
43       assert_no_field "Social Profile Link 1"
44
45       click_on "Update Profile"
46
47       assert_no_link "example.com/user/fred"
48     end
49   end
50
51   test "can control social links using keyboard without submitting" do
52     within_content_body do
53       click_on "Edit Profile"
54       click_on "Add Social Link"
55
56       assert_field "Social Profile Link 1"
57
58       send_keys :tab, :enter
59
60       assert_no_field "Social Profile Link 1"
61     end
62   end
63
64   test "can control social links using keyboard" do
65     within_content_body do
66       click_on "Edit Profile"
67       click_on "Add Social Link"
68       send_keys "https://example.com/user/typed"
69       click_on "Update Profile"
70
71       assert_link "example.com/user/typed"
72
73       click_on "Edit Profile"
74       find_field("Social Profile Link 1").click
75       send_keys :tab, :enter
76
77       assert_no_field "Social Profile Link 1"
78
79       click_on "Update Profile"
80
81       assert_no_link "example.com/user/typed"
82     end
83   end
84
85   test "can add and remove multiple links" do
86     within_content_body do
87       click_on "Edit Profile"
88       click_on "Add Social Link"
89       fill_in "Social Profile Link 1", :with => "https://example.com/a"
90       click_on "Add Social Link"
91       fill_in "Social Profile Link 2", :with => "https://example.com/b"
92       click_on "Add Social Link"
93       fill_in "Social Profile Link 3", :with => "https://example.com/c"
94       click_on "Update Profile"
95
96       assert_link "example.com/a"
97       assert_link "example.com/b"
98       assert_link "example.com/c"
99
100       click_on "Edit Profile"
101
102       assert_field "Social Profile Link 1", :with => "https://example.com/a"
103       assert_field "Social Profile Link 2", :with => "https://example.com/b"
104       assert_field "Social Profile Link 3", :with => "https://example.com/c"
105
106       click_on "Remove Social Profile Link 2"
107
108       assert_field "Social Profile Link 1", :with => "https://example.com/a"
109       assert_field "Social Profile Link 2", :with => "https://example.com/c"
110
111       click_on "Add Social Link"
112       fill_in "Social Profile Link 3", :with => "https://example.com/d"
113       click_on "Update Profile"
114
115       assert_link "example.com/a"
116       assert_no_link "example.com/b"
117       assert_link "example.com/c"
118       assert_link "example.com/d"
119     end
120   end
121 end