auto_wizard_spec.rb 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Auto wizard', set_up: false, type: :system do
  4. shared_examples 'showing that auto wizard is enabled' do
  5. it 'shows the auto wizard enable message' do
  6. visit '/'
  7. within '.wizard.setup .wizard-slide' do
  8. expect(page).to have_content('The auto wizard is enabled. Please use the provided auto wizard url.')
  9. end
  10. end
  11. end
  12. context 'with auto wizard enabled' do
  13. before do
  14. FileUtils.ln(
  15. Rails.root.join('contrib/auto_wizard_test.json'),
  16. Rails.root.join('auto_wizard.json'),
  17. force: true
  18. )
  19. end
  20. it_behaves_like 'showing that auto wizard is enabled'
  21. it 'automatically set up and login' do
  22. visit 'getting_started/auto_wizard'
  23. # auto wizard is enabled
  24. expect(current_login).to eq('admin@example.com')
  25. end
  26. end
  27. context 'when auto wizard is enabled with secret token' do
  28. before do
  29. FileUtils.ln(
  30. Rails.root.join('contrib/auto_wizard_example.json'),
  31. Rails.root.join('auto_wizard.json'),
  32. force: true
  33. )
  34. end
  35. it_behaves_like 'showing that auto wizard is enabled'
  36. it 'automatically setup and login with token params' do
  37. visit 'getting_started/auto_wizard/secret_token'
  38. close_clues_modal
  39. expect(current_login).to eq('hans.atila@zammad.org')
  40. end
  41. it 'allows user to login and logout' do
  42. visit 'getting_started/auto_wizard/secret_token'
  43. close_clues_modal
  44. logout
  45. login(
  46. username: 'hans.atila@zammad.org',
  47. password: 'Z4mm4dr0ckZ!'
  48. )
  49. refresh
  50. expect(current_login).to eq('hans.atila@zammad.org')
  51. end
  52. context 'with organisation in the auto_wizard data', searchindex: true do
  53. before do
  54. visit 'getting_started/auto_wizard/secret_token'
  55. searchindex_model_reload([User, Organization])
  56. close_clues_modal
  57. end
  58. it 'shows the organization from the auto wizard' do
  59. fill_in id: 'global-search', with: 'Demo Organization'
  60. click_on 'Show Search Details'
  61. find('[data-tab-content=Organization]').click
  62. find('.js-content .js-tableBody tr.item').click
  63. within '.active .profile-window' do
  64. expect(page).to have_content 'Demo Organization'
  65. expect(page).to have_content 'Atila'
  66. end
  67. end
  68. end
  69. end
  70. def close_clues_modal
  71. within '.js-modal--clue.modal--clue-ready' do
  72. find('.modal-close.js-close').click
  73. end
  74. end
  75. end