system_spec.rb 4.1 KB

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