integration_sipgate_test.rb 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. # flanky
  38. watch_for(
  39. css: '.js-phoneMenuItem .counter',
  40. value: (call_counter + 1).to_s,
  41. timeout: 4,
  42. )
  43. check(css: '.content.active .table-checkbox input')
  44. watch_for_disappear(
  45. css: '.js-phoneMenuItem .counter',
  46. timeout: 6,
  47. )
  48. click(css: 'a[href="#manage"]')
  49. click(css: 'a[href="#system/integration"]')
  50. click(css: 'a[href="#system/integration/sipgate"]')
  51. switch(
  52. css: '.content.active .js-switch',
  53. type: 'off'
  54. )
  55. end
  56. end