1 require "application_system_test_case"
3 class UserSocialLinksTest < ApplicationSystemTestCase
5 stub_request(:get, /.*gravatar.com.*d=404/).to_return(:status => 404)
12 test "can add and remove social link without submitting" do
13 within_content_body do
14 click_on "Edit Profile"
16 assert_no_field "Social Profile Link 1"
18 click_on "Add Social Link"
20 assert_field "Social Profile Link 1"
22 click_on "Remove Social Profile Link 1"
24 assert_no_field "Social Profile Link 1"
28 test "can add and remove social links" do
29 within_content_body do
30 click_on "Edit Profile"
32 assert_no_field "Social Profile Link 1"
34 click_on "Add Social Link"
35 fill_in "Social Profile Link 1", :with => "https://example.com/user/fred"
36 click_on "Update Profile"
38 assert_link "example.com/user/fred"
40 click_on "Edit Profile"
41 click_on "Remove Social Profile Link 1"
43 assert_no_field "Social Profile Link 1"
45 click_on "Update Profile"
47 assert_no_link "example.com/user/fred"
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"
56 assert_field "Social Profile Link 1"
58 send_keys :tab, :enter
60 assert_no_field "Social Profile Link 1"
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"
71 assert_link "example.com/user/typed"
73 click_on "Edit Profile"
74 find_field("Social Profile Link 1").click
75 send_keys :tab, :enter
77 assert_no_field "Social Profile Link 1"
79 click_on "Update Profile"
81 assert_no_link "example.com/user/typed"
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"
96 assert_link "example.com/a"
97 assert_link "example.com/b"
98 assert_link "example.com/c"
100 click_on "Edit Profile"
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"
106 click_on "Remove Social Profile Link 2"
108 assert_field "Social Profile Link 1", :with => "https://example.com/a"
109 assert_field "Social Profile Link 2", :with => "https://example.com/c"
111 click_on "Add Social Link"
112 fill_in "Social Profile Link 3", :with => "https://example.com/d"
113 click_on "Update Profile"
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"