chat_test.rb 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. # encoding: utf-8
  2. require 'browser_test_helper'
  3. class ChatTest < TestCase
  4. def test_websocket
  5. message = 'message 1äöüß ' + rand(99999999999999999).to_s
  6. tests = [
  7. {
  8. :name => 'start',
  9. :instance1 => browser_instance,
  10. :instance2 => browser_instance,
  11. :instance1_username => 'master@example.com',
  12. :instance1_password => 'test',
  13. :instance2_username => 'agent1@example.com',
  14. :instance2_password => 'test',
  15. :url => browser_url,
  16. :action => [
  17. {
  18. :where => :instance1,
  19. :execute => 'check',
  20. :css => '#login',
  21. :result => false,
  22. },
  23. {
  24. :where => :instance2,
  25. :execute => 'check',
  26. :css => '#login',
  27. :result => false,
  28. },
  29. {
  30. :execute => 'wait',
  31. :value => 1,
  32. },
  33. {
  34. :where => :instance1,
  35. :execute => 'click',
  36. :css => '#chat_toogle',
  37. },
  38. {
  39. :execute => 'wait',
  40. :value => 8,
  41. },
  42. {
  43. :where => :instance1,
  44. :execute => 'click',
  45. :css => '#chat_toogle',
  46. },
  47. {
  48. :execute => 'wait',
  49. :value => 4,
  50. },
  51. {
  52. :where => :instance2,
  53. :execute => 'click',
  54. :css => '#chat_toogle',
  55. },
  56. {
  57. :where => :instance1,
  58. :execute => 'click',
  59. :css => '#chat_toogle',
  60. },
  61. {
  62. :execute => 'wait',
  63. :value => 2,
  64. },
  65. {
  66. :where => :instance1,
  67. :execute => 'set',
  68. :css => 'input[name="chat_message"]',
  69. :value => message,
  70. },
  71. {
  72. :where => :instance1,
  73. :execute => 'send_key',
  74. :css => 'input[name="chat_message"]',
  75. :value => :enter,
  76. },
  77. {
  78. :execute => 'wait',
  79. :value => 6,
  80. },
  81. {
  82. :where => :instance1,
  83. :execute => 'match',
  84. :css => '#chat_log_container',
  85. :value => message,
  86. :match_result => true,
  87. },
  88. {
  89. :where => :instance2,
  90. :execute => 'match',
  91. :css => '#chat_log_container',
  92. :value => message,
  93. :match_result => true,
  94. },
  95. {
  96. :where => :instance1,
  97. :execute => 'navigate',
  98. :to => browser_url,
  99. },
  100. {
  101. :execute => 'wait',
  102. :value => 8,
  103. },
  104. {
  105. :where => :instance1,
  106. :execute => 'click',
  107. :css => '#chat_toogle',
  108. },
  109. {
  110. :execute => 'wait',
  111. :value => 8,
  112. },
  113. {
  114. :where => :instance1,
  115. :execute => 'match',
  116. :css => '#chat_log_container',
  117. :value => message,
  118. :match_result => true,
  119. },
  120. ],
  121. },
  122. ]
  123. browser_double_test(tests)
  124. end
  125. end