integration_sipgate_test.rb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. require 'browser_test_helper'
  2. class IntegrationSipgateTest < TestCase
  3. # Regression test for #2017
  4. def test_nav_menu_notification_badge_clears
  5. id = rand(99_999_999)
  6. @browser = browser_instance
  7. login(
  8. username: 'master@example.com',
  9. password: 'test',
  10. url: browser_url,
  11. )
  12. click(css: 'a[href="#manage"]')
  13. click(css: 'a[href="#system/integration"]')
  14. click(css: 'a[href="#system/integration/sipgate"]')
  15. switch(
  16. css: '.content.active .js-switch',
  17. type: 'on'
  18. )
  19. watch_for(
  20. css: 'a[href="#cti"]',
  21. timeout: 4,
  22. )
  23. click(css: 'a[href="#cti"]')
  24. call_counter = @browser.find_elements(css: '.js-phoneMenuItem .counter')
  25. .first&.text.to_i
  26. # simulate cti callbacks
  27. url = URI.join(browser_url, 'api/v1/sipgate/in')
  28. params = {
  29. direction: 'in',
  30. from: '491715000003',
  31. to: '4930600000004',
  32. callId: "4991155921769858279-#{id}",
  33. cause: 'busy'
  34. }
  35. Net::HTTP.post_form(url, params.merge(event: 'newCall'))
  36. Net::HTTP.post_form(url, params.merge(event: 'hangup'))
  37. watch_for(
  38. css: '.js-phoneMenuItem .counter',
  39. value: (call_counter + 1).to_s,
  40. timeout: 4,
  41. )
  42. check(css: '.content.active .table-checkbox input')
  43. watch_for_disappear(
  44. css: '.js-phoneMenuItem .counter',
  45. timeout: 6,
  46. )
  47. click(css: 'a[href="#manage"]')
  48. click(css: 'a[href="#system/integration"]')
  49. click(css: 'a[href="#system/integration/sipgate"]')
  50. switch(
  51. css: '.content.active .js-switch',
  52. type: 'off'
  53. )
  54. end
  55. end