zendesk_import_browser_test.rb 2.1 KB

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