|
| 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