system_spec.rb 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. require 'rails_helper'
  2. RSpec.describe 'System setup process', type: :system, set_up: false, authenticated_as: false do
  3. def fqdn
  4. match_data = %r{://(.+?)(:.+?|/.+?|)$}.match(app_host)
  5. return match_data.captures.first if match_data.present?
  6. raise "Unable to get fqdn based on #{app_host}"
  7. end
  8. it 'Setting up a new system' do
  9. if !ENV['MAILBOX_INIT']
  10. skip("NOTICE: Need MAILBOX_INIT as ENV variable like export MAILBOX_INIT='unittest01@znuny.com:somepass'")
  11. end
  12. mailbox_user = ENV['MAILBOX_INIT'].split(':')[0]
  13. mailbox_password = ENV['MAILBOX_INIT'].split(':')[1]
  14. visit '/'
  15. expect(page).to have_css('.setup.wizard', text: 'Setup new System')
  16. # choose setup (over migration)
  17. click_on('Setup new System')
  18. # admin user form
  19. expect(page).to have_css('.js-admin h2', text: 'Administrator Account')
  20. within('.js-admin') do
  21. fill_in 'firstname', with: 'Test Master'
  22. fill_in 'lastname', with: 'Agent'
  23. fill_in 'email', with: 'master@example.com'
  24. fill_in 'password', with: 'TEst1234äöüß'
  25. fill_in 'password_confirm', with: 'TEst1234äöüß'
  26. click_on('Create')
  27. end
  28. # configure Organization
  29. expect(page).to have_css('.js-base h2', text: 'Organization')
  30. within('.js-base') do
  31. fill_in 'organization', with: 'Some Organization'
  32. # fill in wrong URL
  33. fill_in 'url', with: 'some host'
  34. click_on('Next')
  35. expect(page).to have_css('.alert', text: 'An URL looks like')
  36. # fill in valild/current URL
  37. fill_in 'url', with: app_host
  38. click_on('Next')
  39. end
  40. # configure Email Notification
  41. expect(page).to have_css('.js-outbound h2', text: 'Email Notification')
  42. expect_current_route 'getting_started/email_notification'
  43. click_on('Continue')
  44. # create email account
  45. expect(page).to have_css('.js-channel h2', text: 'Connect Channels')
  46. expect_current_route 'getting_started/channel'
  47. click('.js-channel .btn.email')
  48. within('.js-intro') do
  49. fill_in 'realname', with: 'Some Realname'
  50. fill_in 'email', with: mailbox_user
  51. fill_in 'password', with: mailbox_password
  52. click_on('Connect')
  53. end
  54. # wait for verification process to start
  55. expect(page).to have_css('body', text: 'Verify sending and receiving', wait: 20)
  56. # wait for verification process to finish
  57. expect(page).to have_css('.js-agent h2', text: 'Invite Colleagues', wait: 2.minutes)
  58. expect_current_route 'getting_started/agents'
  59. # invite agent1
  60. within('.js-agent') do
  61. fill_in 'firstname', with: 'Agent 1'
  62. fill_in 'lastname', with: 'Test'
  63. fill_in 'email', with: 'agent12@example.com'
  64. click_on('Invite')
  65. end
  66. expect(page).to have_css('body', text: 'Invitation sent!')
  67. # expect to still be on the same page
  68. expect_current_route 'getting_started/agents'
  69. within('.js-agent') do
  70. click_on('Continue')
  71. end
  72. # expect Dashboard of a fresh system
  73. expect(page).to have_css('body', text: 'My Stats')
  74. expect_current_route 'clues'
  75. find(:clues_close, wait: 4).in_fixed_position.click
  76. # verify organization and fqdn
  77. click(:manage)
  78. within(:active_content) do
  79. click(:href, '#settings/branding')
  80. expect(page).to have_field('organization', with: 'Some Organization')
  81. click(:href, '#settings/system')
  82. expect(page).to have_field('fqdn', with: fqdn)
  83. end
  84. end
  85. # https://github.com/zammad/zammad/issues/3106
  86. it 'Shows an error message if too weak password is filled in' do
  87. visit '/'
  88. click_on('Setup new System')
  89. within('.js-admin') do
  90. fill_in 'firstname', with: 'Test Master'
  91. fill_in 'lastname', with: 'Agent'
  92. fill_in 'email', with: 'master@example.com'
  93. fill_in 'password', with: 'asd'
  94. fill_in 'password_confirm', with: 'asd'
  95. click_on('Create')
  96. expect(page).to have_text 'Invalid password'
  97. end
  98. end
  99. end