zendesk_import_browser_test.rb 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. # encoding: utf-8
  2. require 'browser_test_helper'
  3. class ZendeskImportBrowserTest < TestCase
  4. def test_import
  5. if !ENV['IMPORT_BT_ZENDESK_ENDPOINT']
  6. raise "ERROR: Need IMPORT_BT_ZENDESK_ENDPOINT - hint IMPORT_BT_ZENDESK_ENDPOINT='https://example.zendesk.com/' (including trailing slash!)"
  7. end
  8. if !ENV['IMPORT_BT_ZENDESK_ENDPOINT_USERNAME']
  9. raise "ERROR: Need IMPORT_BT_ZENDESK_ENDPOINT_USERNAME - hint IMPORT_BT_ZENDESK_ENDPOINT_USERNAME='your@email.com'"
  10. end
  11. if !ENV['IMPORT_BT_ZENDESK_ENDPOINT_KEY']
  12. raise "ERROR: Need IMPORT_BT_ZENDESK_ENDPOINT_KEY - hint IMPORT_BT_ZENDESK_ENDPOINT_KEY='XYZ3133723421111'"
  13. end
  14. @browser = browser_instance
  15. location(url: browser_url)
  16. click(css: 'a[href="#import"]')
  17. click(css: 'a[href="#import/zendesk"]')
  18. set(
  19. css: '#zendesk-url',
  20. value: 'https://reallybadexample.zendesk.com/'
  21. )
  22. sleep 5
  23. watch_for(
  24. css: '.zendesk-url-error',
  25. value: 'Hostname not found!',
  26. )
  27. set(
  28. css: '#zendesk-url',
  29. value: ENV['IMPORT_BT_ZENDESK_ENDPOINT']
  30. )
  31. sleep 5
  32. watch_for_disappear(
  33. css: '.zendesk-url-error',
  34. value: 'Hostname not found!',
  35. )
  36. click(css: '.js-zendesk-credentials')
  37. set(
  38. css: '#zendesk-email',
  39. value: ENV['IMPORT_BT_ZENDESK_ENDPOINT_USERNAME']
  40. )
  41. set(
  42. css: '#zendesk-api-token',
  43. value: '1nv4l1dT0K3N'
  44. )
  45. sleep 5
  46. watch_for(
  47. css: '.zendesk-api-token-error',
  48. value: 'Invalid credentials!',
  49. )
  50. set(
  51. css: '#zendesk-api-token',
  52. value: ENV['IMPORT_BT_ZENDESK_ENDPOINT_KEY']
  53. )
  54. sleep 5
  55. watch_for_disappear(
  56. css: '.zendesk-url-error',
  57. value: 'Invalid credentials!',
  58. )
  59. click(css: '.js-migration-start')
  60. watch_for(
  61. css: '.js-group .js-done',
  62. value: '2',
  63. timeout: 60,
  64. )
  65. watch_for(
  66. css: '.js-organization .js-done',
  67. value: '1',
  68. timeout: 60,
  69. )
  70. watch_for(
  71. css: '.js-user .js-done',
  72. value: '141',
  73. timeout: 60,
  74. )
  75. watch_for(
  76. css: '.js-ticket .js-done',
  77. value: '143',
  78. timeout: 300,
  79. )
  80. watch_for(
  81. css: 'body',
  82. value: 'login',
  83. )
  84. end
  85. end