summaryrefslogtreecommitdiffstats
path: root/browser/components/translations/tests/browser/browser_translations_select_context_menu_with_text_selected.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /browser/components/translations/tests/browser/browser_translations_select_context_menu_with_text_selected.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/translations/tests/browser/browser_translations_select_context_menu_with_text_selected.js')
-rw-r--r--browser/components/translations/tests/browser/browser_translations_select_context_menu_with_text_selected.js76
1 files changed, 76 insertions, 0 deletions
diff --git a/browser/components/translations/tests/browser/browser_translations_select_context_menu_with_text_selected.js b/browser/components/translations/tests/browser/browser_translations_select_context_menu_with_text_selected.js
new file mode 100644
index 0000000000..deb5911a37
--- /dev/null
+++ b/browser/components/translations/tests/browser/browser_translations_select_context_menu_with_text_selected.js
@@ -0,0 +1,76 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/**
+ * This test case verifies the functionality of the translate-selection context menu item
+ * when the selected text is not in the user's preferred language. The menu item should be
+ * localized to translate to the target language matching the user's top preferred language
+ * when the selected text is detected to be in a different language.
+ */
+add_task(
+ async function test_translate_selection_menuitem_when_selected_text_is_not_preferred_language() {
+ const { cleanup, runInPage } = await loadTestPage({
+ page: SPANISH_PAGE_URL,
+ languagePairs: LANGUAGE_PAIRS,
+ prefs: [["browser.translations.select.enable", true]],
+ });
+
+ await FullPageTranslationsTestUtils.assertTranslationsButton(
+ { button: true, circleArrows: false, locale: false, icon: true },
+ "The button is available."
+ );
+
+ await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
+
+ await SelectTranslationsTestUtils.assertContextMenuTranslateSelectionItem(
+ runInPage,
+ {
+ selectSpanishParagraph: true,
+ openAtSpanishParagraph: true,
+ expectMenuItemVisible: true,
+ expectedTargetLanguage: "en",
+ },
+ "The translate-selection context menu item should display a target language " +
+ "when the selected text is not the preferred language."
+ );
+
+ await cleanup();
+ }
+);
+
+/**
+ * This test case verifies the functionality of the translate-selection context menu item
+ * when the selected text is detected to be in the user's preferred language. The menu item
+ * should not be localized to display a target language when the selected text matches the
+ * user's top preferred language.
+ */
+add_task(
+ async function test_translate_selection_menuitem_when_selected_text_is_preferred_language() {
+ const { cleanup, runInPage } = await loadTestPage({
+ page: ENGLISH_PAGE_URL,
+ languagePairs: LANGUAGE_PAIRS,
+ prefs: [["browser.translations.select.enable", true]],
+ });
+
+ await FullPageTranslationsTestUtils.assertTranslationsButton(
+ { button: false },
+ "The button is available."
+ );
+
+ await SelectTranslationsTestUtils.assertContextMenuTranslateSelectionItem(
+ runInPage,
+ {
+ selectFirstParagraph: true,
+ openAtFirstParagraph: true,
+ expectMenuItemVisible: true,
+ expectedTargetLanguage: null,
+ },
+ "The translate-selection context menu item should not display a target language " +
+ "when the selected text is in the preferred language."
+ );
+
+ await cleanup();
+ }
+);