kayako_spec.rb 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Kayako import', db_strategy: :reset, integration: true, required_envs: %w[IMPORT_KAYAKO_ENDPOINT IMPORT_KAYAKO_ENDPOINT_PASSWORD IMPORT_KAYAKO_ENDPOINT_USERNAME], use_vcr: true do # rubocop:disable RSpec/DescribeClass
  4. let(:job) { ImportJob.last }
  5. before do
  6. Setting.set('import_kayako_endpoint', ENV['IMPORT_KAYAKO_ENDPOINT'])
  7. Setting.set('import_kayako_endpoint_password', ENV['IMPORT_KAYAKO_ENDPOINT_PASSWORD'])
  8. Setting.set('import_kayako_endpoint_username', ENV['IMPORT_KAYAKO_ENDPOINT_USERNAME'])
  9. Setting.set('import_mode', true)
  10. Setting.set('system_init_done', false)
  11. VCR.use_cassette 'kayako_import' do
  12. ImportJob.create(name: 'Import::Kayako').start
  13. end
  14. end
  15. context 'when performing the full Kayako import' do
  16. let(:job) { ImportJob.last }
  17. let(:expected_stats) do
  18. {
  19. 'Groups' => {
  20. 'skipped' => 0,
  21. 'created' => 4,
  22. 'updated' => 0,
  23. 'unchanged' => 0,
  24. 'failed' => 0,
  25. 'deactivated' => 0,
  26. 'sum' => 4,
  27. 'total' => 4,
  28. },
  29. 'Users' => {
  30. 'skipped' => 0,
  31. 'created' => 8,
  32. 'updated' => 0,
  33. 'unchanged' => 0,
  34. 'failed' => 0,
  35. 'deactivated' => 0,
  36. 'sum' => 8,
  37. 'total' => 8,
  38. },
  39. 'Organizations' => {
  40. 'skipped' => 0,
  41. 'created' => 3,
  42. 'updated' => 1,
  43. 'unchanged' => 0,
  44. 'failed' => 0,
  45. 'deactivated' => 0,
  46. 'sum' => 4,
  47. 'total' => 4,
  48. },
  49. 'Tickets' => {
  50. 'skipped' => 0,
  51. 'created' => 6,
  52. 'updated' => 1,
  53. 'unchanged' => 0,
  54. 'failed' => 0,
  55. 'deactivated' => 0,
  56. 'sum' => 7,
  57. 'total' => 7,
  58. },
  59. }
  60. end
  61. it 'imports the correct number of expected objects' do
  62. expect(job.result).to eq expected_stats
  63. end
  64. end
  65. end