123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- require 'browser_test_helper'
- class TranslationTest < TestCase
- def test_preferences
- @browser = browser_instance
- login(
- username: 'master@example.com',
- password: 'test',
- url: browser_url,
- )
- tasks_close_all()
- click(css: 'a[href="#current_user"]')
- click(css: 'a[href="#profile"]')
- click(css: 'a[href="#profile/language"]')
- select(
- css: '.language_item [name="locale"]',
- value: 'English (United States)',
- )
- click(css: '.content.active button[type="submit"]')
- sleep 2
- watch_for(
- css: 'body',
- value: 'Language',
- )
- click(css: 'a[href="#manage"]')
- click(css: 'a[href="#system/translation"]')
- watch_for(
- css: '.content.active',
- value: 'English is the source language, so we have nothing to translate',
- )
- click(css: 'a[href="#current_user"]')
- click(css: 'a[href="#profile"]')
- click(css: 'a[href="#profile/language"]')
- select(
- css: '.language_item [name="locale"]',
- value: 'Deutsch',
- )
- click(css: '.content.active button[type="submit"]')
- watch_for(
- css: 'body',
- value: 'Sprache',
- )
- click(css: 'a[href="#manage"]')
- click(css: 'a[href="#system/translation"]')
- notify_close(optional: true) # to be not in click area
- set(
- css: '.content.active input.js-Item[data-source="Translations"]',
- value: 'Übersetzung2',
- )
- sleep 5 # wait until nofify is gone
- click(css: '#global-search')
- sleep 4 # wait till rerender
- click(css: 'a[href="#dashboard"]')
- sleep 2 # wait till nav is rendered
- click(css: 'a[href="#manage"]')
- click(css: 'a[href="#system/translation"]')
- match(
- css: '.content.active .sidebar',
- value: 'Übersetzung2',
- )
- match(
- css: '.content.active input.js-Item[data-source="Translations"]',
- value: 'Übersetzung2',
- )
- execute(
- js: "$('.js-Item[data-source=Translations]').parents('tr').find('.js-Reset:visible').click()",
- )
- sleep 5
- match(
- css: '.content.active .sidebar',
- value: 'Übersetzung2',
- )
- match_not(
- css: '.content.active input.js-Item[data-source="Translations"]',
- value: 'Übersetzung2',
- )
- click(css: 'a[href="#dashboard"]')
- sleep 4 # wait till rerender
- click(css: 'a[href="#manage"]')
- click(css: 'a[href="#system/translation"]')
- sleep 2
- match_not(
- css: '.content.active .sidebar',
- value: 'Übersetzung2',
- )
- match_not(
- css: '.content.active input.js-Item[data-source="Translations"]',
- value: 'Übersetzung2',
- )
- match_not(
- css: '.content.active .sidebar',
- value: 'Übersetzung2',
- )
- @browser.action.key_down(:control)
- .key_down(:shift)
- .send_keys('t')
- .key_up(:shift)
- .key_up(:control)
- .perform
- watch_for(
- css: 'span.translation[title="Overviews"]',
- value: 'Übersichten',
- )
- set(
- css: 'span.translation[title="Overviews"]',
- value: 'Übersichten123',
- )
- sleep 1
- click(css: 'a[href="#dashboard"]')
- sleep 5
- @browser.action.key_down(:control)
- .key_down(:shift)
- .send_keys('t')
- .key_up(:shift)
- .key_up(:control)
- .perform
- sleep 5
- exists_not(
- css: 'span.translation[title="Overviews"]',
- )
- match(
- css: '.js-menu',
- value: 'Übersichten123',
- )
- reload()
- exists_not(
- css: 'span.translation[title="Overviews"]',
- )
- match(
- css: '.js-menu',
- value: 'Übersichten123',
- )
- click(css: 'a[href="#manage"]')
- click(css: 'a[href="#system/translation"]')
- sleep 4
- match(
- css: '.content.active input.js-Item[data-source="Overviews"]',
- value: 'Übersichten123',
- )
- execute(
- js: "$('.js-Item[data-source=Overviews]').parents('tr').find('.js-Reset:visible').click()",
- )
- sleep 5
- click(css: 'a[href="#dashboard"]')
- sleep 5
- match_not(
- css: '.js-menu',
- value: 'Übersichten123',
- )
- match(
- css: '.js-menu',
- value: 'Übersichten',
- )
- click(css: 'a[href="#current_user"]')
- click(css: 'a[href="#profile"]')
- click(css: 'a[href="#profile/language"]')
- select(
- css: '.language_item [name="locale"]',
- value: 'English (United States)',
- )
- click(css: '.content.active button[type="submit"]')
- sleep 2
- watch_for(
- css: 'body',
- value: 'Language',
- )
- sleep 5
- @browser.action.key_down(:control)
- .key_down(:shift)
- .send_keys('t')
- .key_up(:shift)
- .key_up(:control)
- .perform
- watch_for(
- css: 'span.translation[title="Overviews"]',
- value: 'Overviews',
- )
- set(
- css: 'span.translation[title="Overviews"]',
- value: 'Overviews123',
- )
- sleep 1
- click(css: 'a[href="#dashboard"]')
- sleep 5
- @browser.action.key_down(:control)
- .key_down(:shift)
- .send_keys('t')
- .key_up(:shift)
- .key_up(:control)
- .perform
- sleep 5
- exists_not(
- css: 'span.translation[title="Overviews"]',
- )
- match(
- css: '.js-menu',
- value: 'Overviews123',
- )
- click(css: 'a[href="#manage"]')
- click(css: 'a[href="#system/translation"]')
- sleep 4
- match(
- css: '.content.active input.js-Item[data-source="Overviews"]',
- value: 'Overviews123',
- )
- match_not(
- css: '.content.active',
- value: 'English is the source language, so we have nothing to translate',
- )
- execute(
- js: "$('.js-Item[data-source=Overviews]').parents('tr').find('.js-Reset:visible').click()",
- )
- watch_for(
- css: '.content.active',
- value: 'English is the source language, so we have nothing to translate',
- )
- end
- def test_admin_sync
- @browser = browser_instance
- login(
- username: 'master@example.com',
- password: 'test',
- url: browser_url,
- )
- tasks_close_all()
- click(css: 'a[href="#current_user"]')
- click(css: 'a[href="#profile"]')
- click(css: 'a[href="#profile/language"]')
- select(
- css: '.language_item [name="locale"]',
- value: 'Deutsch',
- )
- click(css: '.content.active button[type="submit"]')
- watch_for(
- css: 'body',
- value: 'Sprache',
- )
- click(css: 'a[href="#manage"]')
- click(css: 'a[href="#system/translation"]')
- watch_for(
- css: '.content.active',
- value: 'Inline Übersetzung',
- )
- click(css: '.content.active .js-syncChanges')
- modal_ready()
- watch_for(
- css: '.content.active .modal',
- value: 'Letzte Übersetzung laden',
- )
- modal_disappear(
- timeout: 6.minutes,
- )
- click(css: 'a[href="#current_user"]')
- click(css: 'a[href="#profile"]')
- click(css: 'a[href="#profile/language"]')
- select(
- css: '.language_item [name="locale"]',
- value: 'English (United States)',
- )
- click(css: '.content.active button[type="submit"]')
- watch_for(
- css: 'body',
- value: 'Language',
- )
- end
- # see https://github.com/zammad/zammad/issues/2056
- #
- # The purpose of this test is to verify that
- # the Translation admin panel automatically re-renders
- # under certain edge cases:
- #
- # Clicking into the Translation panel from another admin panel ALWAYS causes a rerender,
- # but clicking into it from, e.g., a Ticket or the Dashboard does not.
- #
- # We want to ensure that in the latter case,
- # the Translation panel rerenders automatically if there are new phrases to translate.
- def test_rerender_when_new_phrases_detected
- @browser = browser_instance
- login(
- username: 'master@example.com',
- password: 'test',
- url: browser_url,
- )
- tasks_close_all()
- click(css: 'a[href="#current_user"]')
- click(css: 'a[href="#profile"]')
- click(css: 'a[href="#profile/language"]')
- select(
- css: '.language_item [name="locale"]',
- value: 'Deutsch',
- )
- click(css: '.content.active button[type="submit"]')
- watch_for(
- css: 'body',
- value: 'Sprache',
- )
- # The only way to test the edge case describe above
- # (i.e., visiting the Translation panel directly from a Ticket or the Dashboard)
- # is to first click into the admin settings and visit the Translation panel,
- # then leave, then come back.
- #
- # (/#manage remembers the most-recent admin panel.)
- click(css: 'a[href="#manage"]')
- click(css: 'a[href="#system/translation"]')
- watch_for(
- css: '.content.active',
- value: 'Inline Übersetzung',
- )
- click(css: 'a[href="#dashboard"]')
- new_ui_phrase = 'Charlie bit me!'
- @browser.execute_script("App.i18n.translateContent('#{new_ui_phrase}')")
- click(css: 'a[href="#manage"]')
- watch_for(
- css: %(td[title="#{new_ui_phrase}"]),
- value: new_ui_phrase,
- timeout: 3
- )
- end
- end
|