1 require "application_system_test_case"
3 class ProfileLinksChangeTest < ApplicationSystemTestCase
4 test "can't change links when unauthorized" do
10 assert_no_button "Edit Profile Details"
11 assert_no_link "Edit Links"
15 test "can't change links of another user" do
17 another_user = create(:user)
20 visit user_path(another_user)
22 within_content_body do
23 assert_no_button "Edit Profile Details"
24 assert_no_link "Edit Links"
28 test "can add and remove social link without submitting" do
34 within_content_body do
35 click_on "Edit Profile Details"
38 assert_no_field "Social Profile Link 1"
40 click_on "Add Social Link"
42 assert_field "Social Profile Link 1"
44 click_on "Remove Social Profile Link 1"
46 assert_no_field "Social Profile Link 1"
50 test "can add and remove social links" do
56 within_content_body do
57 click_on "Edit Profile Details"
60 assert_no_field "Social Profile Link 1"
62 click_on "Add Social Link"
63 fill_in "Social Profile Link 1", :with => "https://example.com/user/fred"
64 click_on "Update Profile"
66 assert_link "example.com/user/fred"
68 click_on "Edit Profile Details"
70 click_on "Remove Social Profile Link 1"
72 assert_no_field "Social Profile Link 1"
74 click_on "Update Profile"
76 assert_no_link "example.com/user/fred"
80 test "can control social links using keyboard without submitting" do
86 within_content_body do
87 click_on "Edit Profile Details"
89 click_on "Add Social Link"
91 assert_field "Social Profile Link 1"
93 send_keys :tab, :enter
95 assert_no_field "Social Profile Link 1"
99 test "can control social links using keyboard" do
103 visit user_path(user)
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"
112 assert_link "example.com/user/typed"
114 click_on "Edit Profile Details"
115 click_on "Edit Links"
116 find_field("Social Profile Link 1").click
117 send_keys :tab, :enter
119 assert_no_field "Social Profile Link 1"
121 click_on "Update Profile"
123 assert_no_link "example.com/user/typed"
127 test "can add and remove multiple links" do
131 visit user_path(user)
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"
144 assert_link "example.com/a"
145 assert_link "example.com/b"
146 assert_link "example.com/c"
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"
154 click_on "Remove Social Profile Link 2"
156 assert_field "Social Profile Link 1", :with => "https://example.com/a"
157 assert_field "Social Profile Link 2", :with => "https://example.com/c"
159 click_on "Add Social Link"
160 fill_in "Social Profile Link 3", :with => "https://example.com/d"
161 click_on "Update Profile"
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"