system_spec.rb 3.9 KB

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