Improve registrar area bulk change UI

#662
This commit is contained in:
Artur Beljajev 2018-04-18 12:44:24 +03:00
parent fb9f7a561e
commit a713d6f811
16 changed files with 133 additions and 82 deletions

View file

@ -91,7 +91,7 @@ class APIDomainContactsTest < ActionDispatch::IntegrationTest
{ 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response :bad_request
assert_equal ({ error: { type: 'invalid_request_error',
message: 'Successor contact must be different from predecessor' } }),
message: 'New contact ID must be different from current contact ID' } }),
JSON.parse(response.body, symbolize_names: true)
end

View file

@ -1,11 +1,11 @@
require 'test_helper'
class RegistrarDomainTransfersTest < ActionDispatch::IntegrationTest
class RegistrarAreaBulkTransferTest < ActionDispatch::IntegrationTest
setup do
login_as users(:api_goodnames)
end
def test_batch_transfer_succeeds
def test_transfer_multiple_domains_in_bulk
request_body = { data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } }
headers = { 'Content-type' => 'application/json' }
request_stub = stub_request(:post, /domain_transfers/).with(body: request_body,
@ -16,28 +16,26 @@ class RegistrarDomainTransfersTest < ActionDispatch::IntegrationTest
}] }.to_json, status: 200)
visit registrar_domains_url
click_link 'Transfer'
click_on 'Batch'
click_link 'Bulk change'
click_link 'Bulk transfer'
attach_file 'Batch file', Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_transfer.csv').to_s
click_button 'Transfer batch'
click_button 'Transfer'
assert_requested request_stub
assert_current_path registrar_domains_path
assert_text '1 domains have been successfully transferred'
end
def test_batch_transfer_fails_gracefully
def test_fail_gracefully
body = { errors: [{ title: 'epic fail' }] }.to_json
headers = { 'Content-type' => 'application/json' }
stub_request(:post, /domain_transfers/).to_return(status: 400, body: body, headers: headers)
visit registrar_domains_url
click_link 'Transfer'
click_on 'Batch'
click_link 'Bulk change'
click_link 'Bulk transfer'
attach_file 'Batch file', Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_transfer.csv').to_s
click_button 'Transfer batch'
click_button 'Transfer'
assert_text 'epic fail'
end

View file

@ -16,8 +16,8 @@ class RegistrarAreaTechContactBulkChangeTest < ActionDispatch::IntegrationTest
visit registrar_domains_url
click_link 'Bulk change'
fill_in 'Predecessor', with: 'william-001'
fill_in 'Successor', with: 'john-001'
fill_in 'Current contact ID', with: 'william-001'
fill_in 'New contact ID', with: 'john-001'
click_on 'Replace technical contacts'
assert_requested request_stub
@ -36,12 +36,12 @@ class RegistrarAreaTechContactBulkChangeTest < ActionDispatch::IntegrationTest
visit registrar_domains_url
click_link 'Bulk change'
fill_in 'Predecessor', with: 'william-001'
fill_in 'Successor', with: 'john-001'
fill_in 'Current contact ID', with: 'william-001'
fill_in 'New contact ID', with: 'john-001'
click_on 'Replace technical contacts'
assert_text 'epic fail'
assert_field 'Predecessor', with: 'william-001'
assert_field 'Successor', with: 'john-001'
assert_field 'Current contact ID', with: 'william-001'
assert_field 'New contact ID', with: 'john-001'
end
end