Skip to content

Commit d5cd841

Browse files
committed
account admin developer keys spec
moved account_admin_auth_config_spec to a more logical directory and removed some unused cruft from accounts_spec Change-Id: Iff823df200731a037c2c52d0da1e12e5e3030c62 Reviewed-on: https://gerrit.instructure.com/63194 Reviewed-by: Derek Hansen <dhansen@instructure.com> Tested-by: Jenkins Product-Review: August Thornton <august@instructure.com> QA-Review: August Thornton <august@instructure.com>
1 parent 7361855 commit d5cd841

3 files changed

Lines changed: 105 additions & 11 deletions

File tree

spec/selenium/accounts_spec.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@
77
course_with_admin_logged_in
88
end
99

10-
def add_auth_type(auth_type)
11-
f("#add-authentication-provider button").click
12-
driver.find_elements(:css, "#add-authentication-provider a").each do |link|
13-
if link.text == auth_type
14-
link.click
15-
end
16-
end
17-
end
18-
1910
describe "course and term create/update" do
2011

2112
it "should show Login and Email fields in add user dialog for delegated auth accounts" do

spec/selenium/accounts_auth_configs_spec.rb renamed to spec/selenium/admin/account_admin_auth_configs_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
require File.expand_path(File.dirname(__FILE__) + '/common')
2-
require File.expand_path(File.dirname(__FILE__) + '/helpers/accounts_auth_configs_common')
1+
require File.expand_path(File.dirname(__FILE__) + '/../common')
2+
require File.expand_path(File.dirname(__FILE__) + '/../helpers/accounts_auth_configs_common')
33

44
describe 'account authentication' do
55
include_context 'in-process server selenium tests'
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
require File.expand_path(File.dirname(__FILE__) + '/../common')
2+
3+
describe 'developer keys' do
4+
include_context 'in-process server selenium tests'
5+
6+
before(:each) do
7+
course_with_admin_logged_in
8+
end
9+
10+
def add_developer_key
11+
Account.default.developer_keys.create!(name: 'Cool Tool', email: 'admin@example.com', tool_id: 'cool_tool',
12+
redirect_uri: 'http://example.com', icon_url: '/images/delete.png')
13+
end
14+
15+
it 'should create without error', priority: "1", test_id: 344077 do
16+
get "/accounts/#{Account.default.id}/developer_keys"
17+
expect(ff("#keys tbody tr").length).to eq 0
18+
19+
f(".add_key").click
20+
expect(f("#edit_dialog")).to be_displayed
21+
f("#key_name").send_keys("Cool Tool")
22+
f("#email").send_keys("admin@example.com")
23+
f("#tool_id").send_keys("cool_tool")
24+
f("#redirect_uri").send_keys("http://example.com")
25+
f("#icon_url").send_keys("/images/delete.png")
26+
submit_dialog("#edit_dialog", '.submit')
27+
wait_for_ajaximations
28+
29+
expect(f("#edit_dialog")).not_to be_displayed
30+
expect(Account.default.developer_keys.count).to eq 1
31+
key = Account.default.developer_keys.last
32+
expect(key.name).to eq "Cool Tool"
33+
expect(key.tool_id).to eq "cool_tool"
34+
expect(key.email).to eq "admin@example.com"
35+
expect(key.redirect_uri).to eq "http://example.com"
36+
expect(key.icon_url).to eq "/images/delete.png"
37+
expect(ff("#keys tbody tr").length).to eq 1
38+
end
39+
40+
it 'should update without error', priority: "1", test_id: 344078 do
41+
add_developer_key
42+
get "/accounts/#{Account.default.id}/developer_keys"
43+
f("#keys tbody tr.key .edit_link").click
44+
expect(f("#edit_dialog")).to be_displayed
45+
replace_content(f("#key_name"), "Cooler Tool")
46+
replace_content(f("#email"), "admins@example.com")
47+
replace_content(f("#tool_id"), "cooler_tool")
48+
replace_content(f("#redirect_uri"), "https://example.com")
49+
replace_content(f("#icon_url"), "/images/add.png")
50+
submit_dialog("#edit_dialog", '.submit')
51+
wait_for_ajaximations
52+
53+
expect(f("#edit_dialog")).not_to be_displayed
54+
expect(Account.default.developer_keys.count).to eq 1
55+
key = Account.default.developer_keys.last
56+
expect(key.name).to eq "Cooler Tool"
57+
expect(key.email).to eq "admins@example.com"
58+
expect(key.tool_id).to eq "cooler_tool"
59+
expect(key.redirect_uri).to eq "https://example.com"
60+
expect(key.icon_url).to eq "/images/add.png"
61+
expect(ff("#keys tbody tr").length).to eq 1
62+
end
63+
64+
it 'should delete without error', priority: "1", test_id: 344079 do
65+
add_developer_key
66+
get "/accounts/#{Account.default.id}/developer_keys"
67+
f("#keys tbody tr.key .edit_link").click
68+
expect(f("#edit_dialog")).to be_displayed
69+
f("#tool_id").clear
70+
f("#icon_url").clear
71+
submit_dialog("#edit_dialog", '.submit')
72+
wait_for_ajaximations
73+
74+
expect(f("#edit_dialog")).not_to be_displayed
75+
expect(Account.default.developer_keys.count).to eq 1
76+
key = Account.default.developer_keys.last
77+
expect(key.tool_id).to eq nil
78+
expect(key.icon_url).to eq nil
79+
expect(ff("#keys tbody tr").length).to eq 1
80+
81+
f("#keys tbody tr.key .delete_link").click
82+
driver.switch_to.alert.accept
83+
driver.switch_to.default_content
84+
keep_trying_until { ff("#keys tbody tr").length == 0 }
85+
expect(Account.default.developer_keys.count).to eq 0
86+
end
87+
88+
it "should be paginated", priority: "1", test_id: 344532 do
89+
25.times { |i| Account.default.developer_keys.create!(name: "tool #{i}") }
90+
get "/accounts/#{Account.default.id}/developer_keys"
91+
expect(f("#loading")).not_to have_class('loading')
92+
# pagination should load 10 objects by default
93+
expect(ff("#keys tbody tr").length).to eq 10
94+
expect(f('#loading')).to have_class('show_more')
95+
f("#loading .show_all").click
96+
wait_for_ajaximations
97+
keep_trying_until do
98+
expect(f("#loading")).not_to have_class('loading')
99+
true
100+
end
101+
expect(ff("#keys tbody tr").length).to eq 25
102+
end
103+
end

0 commit comments

Comments
 (0)