guided_setup_spec.rb 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Desktop > Guided Setup', app: :desktop_view, 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. allow(NotificationFactory::Mailer).to receive(:notification)
  8. end
  9. after do
  10. # Make sure lock is lifted even on test errors.
  11. Redis.new(driver: :hiredis, url: ENV['REDIS_URL'].presence || 'redis://localhost:6379').del('Zammad::System::Setup')
  12. end
  13. it 'Perform the basic system set-up' do
  14. visit '/'
  15. click_on 'Set up a new system'
  16. # Invalid password
  17. fill_in 'First name', with: 'John'
  18. fill_in 'Last name', with: 'Doe'
  19. fill_in 'Email', with: 'john.doe@example.com'
  20. fill_in 'Password', with: '1234'
  21. fill_in 'Confirm password', with: '1234'
  22. click_on 'Create account'
  23. expect(page).to have_text('Invalid password')
  24. # Valid password, create account
  25. fill_in 'Password', with: 'testTEST1234'
  26. fill_in 'Confirm password', with: 'testTEST1234'
  27. click_on 'Create account'
  28. fill_in 'Organization name', with: 'Test corp.'
  29. find('input[name="logo"]', visible: :all).set(Rails.root.join('test/data/image/1000x1000.png'))
  30. fill_in 'System URL', with: app_host
  31. click_on 'Save and Continue'
  32. # Accept default setting (local MTA).
  33. expect(page).to have_text('Email Notification')
  34. click_on 'Save and Continue'
  35. click_on 'Email Channel'
  36. fill_in 'Full name', with: 'John Doe'
  37. fill_in 'Email address', with: ENV['MAIL_ADDRESS']
  38. fill_in 'Password', with: ENV['MAIL_PASS']
  39. click_on 'Connect and Continue'
  40. expect(page).to have_text('Verifying and saving your configuration…')
  41. expect(page).to have_text('Invite Colleagues', wait: 2.minutes)
  42. fill_in 'First name', with: 'Jim'
  43. fill_in 'Last name', with: 'Doe'
  44. fill_in 'Email', with: 'jim.doe@example.com'
  45. click_on 'Send Invitation'
  46. expect(page).to have_text('Invitation sent!')
  47. click_on('Finish Setup')
  48. expect(NotificationFactory::Mailer).to have_received(:notification).once
  49. expect_current_route('/')
  50. # TODO: check for "clues" in UI, not available yet.
  51. end
  52. end