otrs_spec.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. # Mark this job as integration test to run it in the separate job with the required containers.
  4. RSpec.describe 'Import from OTRS', authenticated_as: false, db_strategy: :reset, integration: true, integration_standalone: :otrs, performs_jobs: true, required_envs: %w[IMPORT_OTRS_ENDPOINT IMPORT_OTRS_ENDPOINT_KEY], set_up: false, type: :system do
  5. let(:job) { ImportJob.find_by(name: 'Import::OTRS') }
  6. it 'performs the import and redirects to the login screen' do
  7. visit '#import'
  8. click '.js-otrs'
  9. click '.js-download:last-child'
  10. click '.js-otrs-link'
  11. find('#otrs-link').fill_in(with: "#{ENV['IMPORT_OTRS_ENDPOINT']};Key=invalid_key")
  12. expect(page).to have_text('Invalid API key')
  13. find('#otrs-link').fill_in(with: "#{ENV['IMPORT_OTRS_ENDPOINT']};Key=#{ENV['IMPORT_OTRS_ENDPOINT_KEY']}", fill_options: { clear: :backspace })
  14. expect(page).to have_no_text('Invalid API Key')
  15. click '.js-migration-check'
  16. expect(page).to have_text('Many dynamic fields were found')
  17. click '.js-migration-start'
  18. await_empty_ajax_queue
  19. # Suppress to avoid: #<Thread:0x000000012d5ef5f0 /Users/mg/wz/zammad/lib/import/otrs.rb:70 run> terminated with exception (report_on_exception is true):
  20. allow(ActiveRecord::Base.connection).to receive(:close)
  21. perform_enqueued_jobs
  22. expect(page).to have_css('#login')
  23. end
  24. end