facebook_browser_test.rb 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. # encoding: utf-8
  2. require 'browser_test_helper'
  3. class FacebookBrowserTest < TestCase
  4. def test_add_config
  5. # app config
  6. if !ENV['FACEBOOK_APP_ID']
  7. fail "ERROR: Need FACEBOOK_APP_ID - hint FACEBOOK_APP_ID='1234'"
  8. end
  9. app_id = ENV['FACEBOOK_APP_ID']
  10. if !ENV['FACEBOOK_APP_SECRET']
  11. fail "ERROR: Need FACEBOOK_APP_SECRET - hint FACEBOOK_APP_SECRET='1234'"
  12. end
  13. app_secret = ENV['FACEBOOK_APP_SECRET']
  14. if !ENV['FACEBOOK_USER_LOGIN']
  15. fail "ERROR: Need FACEBOOK_USER_LOGIN - hint FACEBOOK_USER_LOGIN='1234'"
  16. end
  17. user_login = ENV['FACEBOOK_USER_LOGIN']
  18. if !ENV['FACEBOOK_USER_PW']
  19. fail "ERROR: Need FACEBOOK_USER_PW - hint FACEBOOK_USER_PW='1234'"
  20. end
  21. user_pw = ENV['FACEBOOK_USER_PW']
  22. @browser = browser_instance
  23. login(
  24. username: 'master@example.com',
  25. password: 'test',
  26. url: browser_url,
  27. auto_wizard: true,
  28. )
  29. tasks_close_all()
  30. click(css: 'a[href="#manage"]')
  31. click(css: 'a[href="#channels/facebook"]')
  32. click(css: '#content .js-configApp')
  33. sleep 2
  34. set(
  35. css: '#content .modal [name=application_id]',
  36. value: app_id,
  37. )
  38. set(
  39. css: '#content .modal [name=application_secret]',
  40. value: 'wrong',
  41. )
  42. click(css: '#content .modal .js-submit')
  43. watch_for(
  44. css: '#content .modal .alert',
  45. value: 'Error',
  46. )
  47. set(
  48. css: '#content .modal [name=application_secret]',
  49. value: app_secret,
  50. )
  51. click(css: '#content .modal .js-submit')
  52. watch_for_disappear(
  53. css: '#content .modal .alert',
  54. value: 'Error',
  55. )
  56. watch_for(
  57. css: '#content .js-new',
  58. value: 'add account',
  59. )
  60. click(css: '#content .js-configApp')
  61. set(
  62. css: '#content .modal [name=application_secret]',
  63. value: 'wrong',
  64. )
  65. click(css: '#content .modal .js-submit')
  66. watch_for(
  67. css: '#content .modal .alert',
  68. value: 'Error',
  69. )
  70. set(
  71. css: '#content .modal [name=application_secret]',
  72. value: app_secret,
  73. )
  74. click(css: '#content .modal .js-submit')
  75. watch_for_disappear(
  76. css: '#content .modal .alert',
  77. value: 'Error',
  78. )
  79. watch_for(
  80. css: '#content .js-new',
  81. value: 'add account',
  82. )
  83. click(css: '#content .js-new')
  84. watch_for(
  85. css: 'body',
  86. value: 'Facebook Login',
  87. )
  88. set(
  89. css: '#email',
  90. value: user_login,
  91. )
  92. set(
  93. css: '#pass',
  94. value: user_pw,
  95. )
  96. click(css: '#login_button_inline')
  97. #sleep 10
  98. #click(css: 'div[role="dialog"] button[type="submit"][name="__CONFIRM__"]')
  99. #sleep 10
  100. #click(css: 'div[role="dialog"] button[type="submit"][name="__CONFIRM__"]')
  101. #sleep 10
  102. #watch_for(
  103. # css: '#content .modal',
  104. # value: '',
  105. #)
  106. watch_for(
  107. css: '#navigation',
  108. value: 'Dashboard',
  109. )
  110. #click(css: '#content .modal .js-close')
  111. watch_for(
  112. css: '#content',
  113. value: 'Hansi Merkur',
  114. )
  115. exists(
  116. css: '#content .main .action:nth-child(1)'
  117. )
  118. exists_not(
  119. css: '#content .main .action:nth-child(2)'
  120. )
  121. click(css: '#content .js-new')
  122. sleep 10
  123. #click(css: '#login_button_inline')
  124. #watch_for(
  125. # css: '#content .modal',
  126. # value: 'Search Terms',
  127. #)
  128. #click(css: '#content .modal .js-close')
  129. watch_for(
  130. css: '#content',
  131. value: 'Hansi Merkur',
  132. )
  133. exists(
  134. css: '#content .main .action:nth-child(1)'
  135. )
  136. exists_not(
  137. css: '#content .main .action:nth-child(2)'
  138. )
  139. end
  140. end