mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 09:21:43 +02:00
Added Registrar feature tests
This commit is contained in:
parent
bcb283e2f1
commit
45bed63cad
12 changed files with 218 additions and 25 deletions
90
spec/features/registrar/contact_spec.rb
Normal file
90
spec/features/registrar/contact_spec.rb
Normal file
|
@ -0,0 +1,90 @@
|
|||
require 'rails_helper'
|
||||
|
||||
feature 'Contact', type: :feature do
|
||||
before :all do
|
||||
create_settings
|
||||
@user = Fabricate(:api_user)
|
||||
end
|
||||
|
||||
context 'as unknown user' do
|
||||
it 'should redirect to sign in page' do
|
||||
visit '/registrar/contacts'
|
||||
current_path.should == '/registrar/login'
|
||||
page.should have_text('You need to sign in or sign up')
|
||||
end
|
||||
end
|
||||
|
||||
context 'as signed in user' do
|
||||
before do
|
||||
registrar_sign_in
|
||||
end
|
||||
|
||||
it 'should navigate to the contact index page' do
|
||||
click_link 'Contacts'
|
||||
current_path.should == '/registrar/contacts'
|
||||
end
|
||||
|
||||
it 'should get contact index page' do
|
||||
visit '/registrar/contacts'
|
||||
current_path.should == '/registrar/contacts'
|
||||
end
|
||||
|
||||
context 'manage contact' do
|
||||
it 'should navigate to new page' do
|
||||
click_link 'Contacts'
|
||||
click_link 'New'
|
||||
|
||||
current_path.should == '/registrar/contacts/new'
|
||||
end
|
||||
|
||||
it 'should get new page' do
|
||||
visit '/registrar/contacts/new'
|
||||
current_path.should == '/registrar/contacts/new'
|
||||
end
|
||||
|
||||
it 'should get warnings' do
|
||||
visit '/registrar/contacts/new'
|
||||
current_path.should == '/registrar/contacts/new'
|
||||
|
||||
fill_in 'depp_contact_ident', with: 'bic-ident'
|
||||
click_button 'Create'
|
||||
|
||||
current_path.should == '/registrar/contacts'
|
||||
page.should have_text('Required parameter missing')
|
||||
end
|
||||
|
||||
def create_contact
|
||||
visit '/registrar/contacts/new'
|
||||
current_path.should == '/registrar/contacts/new'
|
||||
|
||||
fill_in 'depp_contact_ident', with: 'bic-ident'
|
||||
fill_in 'depp_contact_name', with: 'Business Name Ltd'
|
||||
fill_in 'depp_contact_email', with: 'example@example.com'
|
||||
fill_in 'depp_contact_street', with: 'Example street 12'
|
||||
fill_in 'depp_contact_city', with: 'Example City'
|
||||
fill_in 'depp_contact_zip', with: '123456'
|
||||
fill_in 'depp_contact_phone', with: '+372.12345678'
|
||||
click_button 'Create'
|
||||
|
||||
page.should have_text('Business Name Ltd')
|
||||
page.should have_text('bic-ident [EE bic]')
|
||||
|
||||
end
|
||||
|
||||
it 'should create new contact with success' do
|
||||
create_contact
|
||||
end
|
||||
|
||||
it 'should edit sucessfully' do
|
||||
create_contact
|
||||
click_link 'Edit'
|
||||
|
||||
current_path.should match(/edit/)
|
||||
fill_in 'depp_contact_name', with: 'Edited Business Name Ltd'
|
||||
click_button 'Save'
|
||||
|
||||
page.should have_text('Edited Business Name Ltd')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
44
spec/features/registrar/domain_spec.rb
Normal file
44
spec/features/registrar/domain_spec.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
require 'rails_helper'
|
||||
|
||||
feature 'Domains', type: :feature do
|
||||
before :all do
|
||||
create_settings
|
||||
@user = Fabricate(:api_user)
|
||||
end
|
||||
|
||||
context 'as unknown user' do
|
||||
it 'should redirect to sign in page' do
|
||||
visit '/registrar/domains'
|
||||
current_path.should == '/registrar/login'
|
||||
page.should have_text('You need to sign in or sign up')
|
||||
end
|
||||
end
|
||||
|
||||
context 'as signed in user' do
|
||||
before do
|
||||
registrar_sign_in
|
||||
end
|
||||
|
||||
it 'should navigate to the domains index page' do
|
||||
click_link 'Domains'
|
||||
current_path.should == '/registrar/domains'
|
||||
end
|
||||
|
||||
it 'should get domains index page' do
|
||||
visit '/registrar/domains'
|
||||
current_path.should == '/registrar/domains'
|
||||
end
|
||||
|
||||
it 'should navigate to new page' do
|
||||
click_link 'Domains'
|
||||
click_link 'New'
|
||||
|
||||
current_path.should == '/registrar/domains/new'
|
||||
end
|
||||
|
||||
it 'should get new page' do
|
||||
visit '/registrar/domains/new'
|
||||
current_path.should == '/registrar/domains/new'
|
||||
end
|
||||
end
|
||||
end
|
35
spec/features/registrar/invoices_spec.rb
Normal file
35
spec/features/registrar/invoices_spec.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
require 'rails_helper'
|
||||
|
||||
feature 'Invoices', type: :feature do
|
||||
before :all do
|
||||
create_settings
|
||||
@user = Fabricate(:api_user)
|
||||
end
|
||||
|
||||
context 'as unknown user' do
|
||||
it 'should redirect to sign in page' do
|
||||
visit '/registrar/invoices'
|
||||
current_path.should == '/registrar/login'
|
||||
page.should have_text('You need to sign in or sign up')
|
||||
end
|
||||
end
|
||||
|
||||
context 'as signed in user' do
|
||||
before do
|
||||
registrar_sign_in
|
||||
end
|
||||
|
||||
it 'should navigate to the domains index page' do
|
||||
current_path.should == '/registrar'
|
||||
click_link 'Invoices'
|
||||
|
||||
current_path.should == '/registrar/invoices'
|
||||
page.should have_text('invoices index')
|
||||
end
|
||||
|
||||
it 'should get domains index page' do
|
||||
visit '/registrar/invoices'
|
||||
page.should have_text('invoices index')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -109,5 +109,10 @@ feature 'Sessions', type: :feature do
|
|||
page.should have_text('Check your phone for confirmation code')
|
||||
page.should have_text('Welcome!')
|
||||
end
|
||||
|
||||
it 'should log in successfully using helper method', js: true do
|
||||
registrar_sign_in
|
||||
page.should have_text('Welcome!')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
18
spec/support/registrar_helpers.rb
Normal file
18
spec/support/registrar_helpers.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
module RegistrarHelpers
|
||||
def registrar_sign_in(_user = nil)
|
||||
# TODO: try to make it run with before :all and speed it up
|
||||
visit registrar_login_path
|
||||
page.should have_css('a[href="/registrar/login/mid"]')
|
||||
|
||||
page.find('a[href="/registrar/login/mid"]').click
|
||||
|
||||
fill_in 'user_phone', with: '00007'
|
||||
click_button 'Log in'
|
||||
|
||||
page.should have_text('Log out')
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |c|
|
||||
c.include RegistrarHelpers, type: :feature
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue