1 require "application_system_test_case"
3 class ProfileLinksChangeTest < ApplicationSystemTestCase
5 stub_request(:get, /.*gravatar.com.*d=404/).to_return(:status => 404)
9 visit profile_links_path
12 test "can add and remove social link without submitting" do
13 within_content_body do
14 assert_no_field "Social Profile Link 1"
16 click_on "Add Social Link"
18 assert_field "Social Profile Link 1"
20 click_on "Remove Social Profile Link 1"
22 assert_no_field "Social Profile Link 1"
26 test "can add and remove social links" do
27 within_content_body do
28 assert_no_field "Social Profile Link 1"
30 click_on "Add Social Link"
31 fill_in "Social Profile Link 1", :with => "https://example.com/user/fred"
32 click_on "Update Profile"
34 assert_link "example.com/user/fred"
36 click_on "Edit Profile"
39 within_content_heading do
43 within_content_body do
44 click_on "Remove Social Profile Link 1"
46 assert_no_field "Social Profile Link 1"
48 click_on "Update Profile"
50 assert_no_link "example.com/user/fred"
54 test "can control social links using keyboard without submitting" do
55 within_content_body do
56 click_on "Add Social Link"
58 assert_field "Social Profile Link 1"
60 send_keys :tab, :enter
62 assert_no_field "Social Profile Link 1"
66 test "can control social links using keyboard" do
67 within_content_body do
68 click_on "Add Social Link"
69 send_keys "https://example.com/user/typed"
70 click_on "Update Profile"
72 assert_link "example.com/user/typed"
74 click_on "Edit Profile"
77 within_content_heading do
81 within_content_body do
82 find_field("Social Profile Link 1").click
83 send_keys :tab, :enter
85 assert_no_field "Social Profile Link 1"
87 click_on "Update Profile"
89 assert_no_link "example.com/user/typed"
93 test "can add and remove multiple links" do
94 within_content_body do
95 click_on "Add Social Link"
96 fill_in "Social Profile Link 1", :with => "https://example.com/a"
97 click_on "Add Social Link"
98 fill_in "Social Profile Link 2", :with => "https://example.com/b"
99 click_on "Add Social Link"
100 fill_in "Social Profile Link 3", :with => "https://example.com/c"
101 click_on "Update Profile"
103 assert_link "example.com/a"
104 assert_link "example.com/b"
105 assert_link "example.com/c"
107 click_on "Edit Profile"
110 within_content_heading do
114 within_content_body do
115 assert_field "Social Profile Link 1", :with => "https://example.com/a"
116 assert_field "Social Profile Link 2", :with => "https://example.com/b"
117 assert_field "Social Profile Link 3", :with => "https://example.com/c"
119 click_on "Remove Social Profile Link 2"
121 assert_field "Social Profile Link 1", :with => "https://example.com/a"
122 assert_field "Social Profile Link 2", :with => "https://example.com/c"
124 click_on "Add Social Link"
125 fill_in "Social Profile Link 3", :with => "https://example.com/d"
126 click_on "Update Profile"
128 assert_link "example.com/a"
129 assert_no_link "example.com/b"
130 assert_link "example.com/c"
131 assert_link "example.com/d"