From 55a4ec0e84d172136b34cd7c8a4ee920c0955496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergei=20Ts=C3=B5ganov?= Date: Mon, 10 Jan 2022 11:53:18 +0200 Subject: [PATCH] Added system tests for creating/upating registrar contacts --- test/system/registrar_area/contact_test.rb | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/system/registrar_area/contact_test.rb diff --git a/test/system/registrar_area/contact_test.rb b/test/system/registrar_area/contact_test.rb new file mode 100644 index 000000000..49726029b --- /dev/null +++ b/test/system/registrar_area/contact_test.rb @@ -0,0 +1,45 @@ +require 'application_system_test_case' + +class RegistrarAreaContactTest < ApplicationSystemTestCase + setup do + @registrar = registrars(:bestnames) + @contact = contacts(:john) + sign_in users(:api_bestnames) + end + + def test_creates_contact_with_invalid_phone + visit registrar_contacts_path + click_on 'New' + + fill_in 'Ident', with: @contact.ident + fill_in 'Name', with: @contact.name + fill_in 'E-mail', with: @contact.email + fill_in 'Phone', with: '372' + click_on 'Create' + + assert_text 'Phone number must be in +XXX.YYYYYYY format' + end + + def test_updates_contact_with_invalid_phone + depp_contact = Depp::Contact.new( + id: @contact.id, + name: @contact.name, + code: @contact.code, + email: @contact.email, + phone: @contact.phone, + ident: @contact.ident, + ident_type: @contact.ident_type, + ident_country_code: @contact.ident_country_code) + + Spy.on(Depp::Contact, :find_by_id).and_return(depp_contact) + + visit edit_registrar_contact_path(depp_contact.code) + + assert_text "Edit: #{depp_contact.name}" + + fill_in 'Phone', with: '372' + click_on 'Save' + + assert_text 'Phone number must be in +XXX.YYYYYYY format' + end +end