translation_test.rb 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. require 'browser_test_helper'
  2. class TranslationTest < TestCase
  3. def test_preferences
  4. @browser = browser_instance
  5. login(
  6. username: 'master@example.com',
  7. password: 'test',
  8. url: browser_url,
  9. )
  10. tasks_close_all()
  11. click(css: 'a[href="#current_user"]')
  12. click(css: 'a[href="#profile"]')
  13. click(css: 'a[href="#profile/language"]')
  14. select(
  15. css: '.js-language [name="locale"]',
  16. value: 'English (United States)',
  17. )
  18. click(css: '.content.active button[type="submit"]')
  19. sleep 2
  20. watch_for(
  21. css: 'body',
  22. value: 'Language',
  23. )
  24. click(css: 'a[href="#manage"]')
  25. click(css: 'a[href="#system/translation"]')
  26. watch_for(
  27. css: '.content.active',
  28. value: 'English is the source language, so we have nothing to translate',
  29. )
  30. click(css: 'a[href="#current_user"]')
  31. click(css: 'a[href="#profile"]')
  32. click(css: 'a[href="#profile/language"]')
  33. select(
  34. css: '.js-language [name="locale"]',
  35. value: 'Deutsch',
  36. )
  37. click(css: '.content.active button[type="submit"]')
  38. watch_for(
  39. css: 'body',
  40. value: 'Sprache',
  41. )
  42. click(css: 'a[href="#manage"]')
  43. click(css: 'a[href="#system/translation"]')
  44. notify_close(optional: true) # to be not in click area
  45. set(
  46. css: '.content.active input.js-Item[data-source="Translations"]',
  47. value: 'Übersetzung2',
  48. )
  49. sleep 5 # wait until nofify is gone
  50. click(css: '#global-search')
  51. sleep 4 # wait till rerender
  52. click(css: 'a[href="#dashboard"]')
  53. sleep 2 # wait till nav is rendered
  54. click(css: 'a[href="#manage"]')
  55. click(css: 'a[href="#system/translation"]')
  56. match(
  57. css: '.content.active .sidebar',
  58. value: 'Übersetzung2',
  59. )
  60. match(
  61. css: '.content.active input.js-Item[data-source="Translations"]',
  62. value: 'Übersetzung2',
  63. )
  64. execute(
  65. js: "$('.js-Item[data-source=Translations]').parents('tr').find('.js-Reset:visible').click()",
  66. )
  67. sleep 5
  68. match(
  69. css: '.content.active .sidebar',
  70. value: 'Übersetzung2',
  71. )
  72. match_not(
  73. css: '.content.active input.js-Item[data-source="Translations"]',
  74. value: 'Übersetzung2',
  75. )
  76. click(css: 'a[href="#dashboard"]')
  77. sleep 4 # wait till rerender
  78. click(css: 'a[href="#manage"]')
  79. click(css: 'a[href="#system/translation"]')
  80. sleep 2
  81. match_not(
  82. css: '.content.active .sidebar',
  83. value: 'Übersetzung2',
  84. )
  85. match_not(
  86. css: '.content.active input.js-Item[data-source="Translations"]',
  87. value: 'Übersetzung2',
  88. )
  89. match_not(
  90. css: '.content.active .sidebar',
  91. value: 'Übersetzung2',
  92. )
  93. @browser.action.key_down(:control)
  94. .key_down(:shift)
  95. .send_keys('t')
  96. .key_up(:shift)
  97. .key_up(:control)
  98. .perform
  99. watch_for(
  100. css: 'span.translation[title="Overviews"]',
  101. value: 'Übersichten',
  102. )
  103. set(
  104. css: 'span.translation[title="Overviews"]',
  105. value: 'Übersichten123',
  106. )
  107. sleep 1
  108. click(css: 'a[href="#dashboard"]')
  109. sleep 5
  110. @browser.action.key_down(:control)
  111. .key_down(:shift)
  112. .send_keys('t')
  113. .key_up(:shift)
  114. .key_up(:control)
  115. .perform
  116. sleep 5
  117. exists_not(
  118. css: 'span.translation[title="Overviews"]',
  119. )
  120. match(
  121. css: '.js-menu',
  122. value: 'Übersichten123',
  123. )
  124. reload()
  125. exists_not(
  126. css: 'span.translation[title="Overviews"]',
  127. )
  128. match(
  129. css: '.js-menu',
  130. value: 'Übersichten123',
  131. )
  132. click(css: 'a[href="#manage"]')
  133. click(css: 'a[href="#system/translation"]')
  134. sleep 4
  135. match(
  136. css: '.content.active input.js-Item[data-source="Overviews"]',
  137. value: 'Übersichten123',
  138. )
  139. execute(
  140. js: "$('.js-Item[data-source=Overviews]').parents('tr').find('.js-Reset:visible').click()",
  141. )
  142. sleep 5
  143. click(css: 'a[href="#dashboard"]')
  144. sleep 5
  145. match_not(
  146. css: '.js-menu',
  147. value: 'Übersichten123',
  148. )
  149. match(
  150. css: '.js-menu',
  151. value: 'Übersichten',
  152. )
  153. click(css: 'a[href="#current_user"]')
  154. click(css: 'a[href="#profile"]')
  155. click(css: 'a[href="#profile/language"]')
  156. select(
  157. css: '.js-language [name="locale"]',
  158. value: 'English (United States)',
  159. )
  160. click(css: '.content.active button[type="submit"]')
  161. sleep 2
  162. watch_for(
  163. css: 'body',
  164. value: 'Language',
  165. )
  166. sleep 5
  167. @browser.action.key_down(:control)
  168. .key_down(:shift)
  169. .send_keys('t')
  170. .key_up(:shift)
  171. .key_up(:control)
  172. .perform
  173. watch_for(
  174. css: 'span.translation[title="Overviews"]',
  175. value: 'Overviews',
  176. )
  177. set(
  178. css: 'span.translation[title="Overviews"]',
  179. value: 'Overviews123',
  180. )
  181. sleep 1
  182. click(css: 'a[href="#dashboard"]')
  183. sleep 5
  184. @browser.action.key_down(:control)
  185. .key_down(:shift)
  186. .send_keys('t')
  187. .key_up(:shift)
  188. .key_up(:control)
  189. .perform
  190. sleep 5
  191. exists_not(
  192. css: 'span.translation[title="Overviews"]',
  193. )
  194. match(
  195. css: '.js-menu',
  196. value: 'Overviews123',
  197. )
  198. click(css: 'a[href="#manage"]')
  199. click(css: 'a[href="#system/translation"]')
  200. sleep 4
  201. match(
  202. css: '.content.active input.js-Item[data-source="Overviews"]',
  203. value: 'Overviews123',
  204. )
  205. match_not(
  206. css: '.content.active',
  207. value: 'English is the source language, so we have nothing to translate',
  208. )
  209. execute(
  210. js: "$('.js-Item[data-source=Overviews]').parents('tr').find('.js-Reset:visible').click()",
  211. )
  212. watch_for(
  213. css: '.content.active',
  214. value: 'English is the source language, so we have nothing to translate',
  215. )
  216. end
  217. def test_admin_sync
  218. @browser = browser_instance
  219. login(
  220. username: 'master@example.com',
  221. password: 'test',
  222. url: browser_url,
  223. )
  224. tasks_close_all()
  225. click(css: 'a[href="#current_user"]')
  226. click(css: 'a[href="#profile"]')
  227. click(css: 'a[href="#profile/language"]')
  228. select(
  229. css: '.js-language [name="locale"]',
  230. value: 'Deutsch',
  231. )
  232. click(css: '.content.active button[type="submit"]')
  233. watch_for(
  234. css: 'body',
  235. value: 'Sprache',
  236. )
  237. click(css: 'a[href="#manage"]')
  238. click(css: 'a[href="#system/translation"]')
  239. watch_for(
  240. css: '.content.active',
  241. value: 'Inline Übersetzung',
  242. )
  243. click(css: '.content.active .js-syncChanges')
  244. modal_ready()
  245. watch_for(
  246. css: '.content.active .modal',
  247. value: 'Letzte Übersetzung laden',
  248. )
  249. modal_disappear(
  250. timeout: 6.minutes,
  251. )
  252. click(css: 'a[href="#current_user"]')
  253. click(css: 'a[href="#profile"]')
  254. click(css: 'a[href="#profile/language"]')
  255. select(
  256. css: '.js-language [name="locale"]',
  257. value: 'English (United States)',
  258. )
  259. click(css: '.content.active button[type="submit"]')
  260. watch_for(
  261. css: 'body',
  262. value: 'Language',
  263. )
  264. end
  265. # see https://github.com/zammad/zammad/issues/2056
  266. #
  267. # The purpose of this test is to verify that
  268. # the Translation admin panel automatically re-renders
  269. # under certain edge cases:
  270. #
  271. # Clicking into the Translation panel from another admin panel ALWAYS causes a rerender,
  272. # but clicking into it from, e.g., a Ticket or the Dashboard does not.
  273. #
  274. # We want to ensure that in the latter case,
  275. # the Translation panel rerenders automatically if there are new phrases to translate.
  276. def test_rerender_when_new_phrases_detected
  277. @browser = browser_instance
  278. login(
  279. username: 'master@example.com',
  280. password: 'test',
  281. url: browser_url,
  282. )
  283. tasks_close_all()
  284. click(css: 'a[href="#current_user"]')
  285. click(css: 'a[href="#profile"]')
  286. click(css: 'a[href="#profile/language"]')
  287. select(
  288. css: '.js-language [name="locale"]',
  289. value: 'Deutsch',
  290. )
  291. click(css: '.content.active button[type="submit"]')
  292. watch_for(
  293. css: 'body',
  294. value: 'Sprache',
  295. )
  296. # The only way to test the edge case describe above
  297. # (i.e., visiting the Translation panel directly from a Ticket or the Dashboard)
  298. # is to first click into the admin settings and visit the Translation panel,
  299. # then leave, then come back.
  300. #
  301. # (/#manage remembers the most-recent admin panel.)
  302. click(css: 'a[href="#manage"]')
  303. click(css: 'a[href="#system/translation"]')
  304. watch_for(
  305. css: '.content.active',
  306. value: 'Inline Übersetzung',
  307. )
  308. click(css: 'a[href="#dashboard"]')
  309. new_ui_phrase = 'Charlie bit me!'
  310. @browser.execute_script("App.i18n.translateContent('#{new_ui_phrase}')")
  311. click(css: 'a[href="#manage"]')
  312. watch_for(
  313. css: %(td[title="#{new_ui_phrase}"]),
  314. value: new_ui_phrase,
  315. timeout: 3
  316. )
  317. end
  318. end