Bug 1850303 - Split up largest Translations tests r=gregtatum

This just splits out the two largest Translations tests
into smaller files to prevent timeouts in CI.

Depends on D187085

Differential Revision: https://phabricator.services.mozilla.com/D187490
This commit is contained in:
Erik Nordin 2023-09-06 16:31:01 +00:00
parent 9adfe09955
commit 4e50035ffb
8 changed files with 426 additions and 209 deletions

View File

@ -5,7 +5,9 @@ support-files =
!/toolkit/components/translations/tests/browser/translations-test.mjs
[browser_manage_languages.js]
[browser_translations_panel_a11y_focus.js]
[browser_translations_panel_always_translate_language.js]
[browser_translations_panel_always_translate_language_basic.js]
[browser_translations_panel_always_translate_language_manual.js]
[browser_translations_panel_always_translate_language_restore.js]
[browser_translations_panel_app_menu_never_translate_language.js]
[browser_translations_panel_app_menu_never_translate_site.js]
[browser_translations_panel_auto_translate_error_view.js]
@ -19,7 +21,9 @@ support-files =
[browser_translations_panel_firstrun_revisit.js]
[browser_translations_panel_gear.js]
[browser_translations_panel_never_translate_language.js]
[browser_translations_panel_never_translate_site.js]
[browser_translations_panel_never_translate_site_auto.js]
[browser_translations_panel_never_translate_site_basic.js]
[browser_translations_panel_never_translate_site_manual.js]
[browser_translations_panel_retry.js]
[browser_translations_panel_settings_unsupported_lang.js]
[browser_translations_panel_switch_languages.js]

View File

@ -1,207 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests the effect of toggling the always-translate-language menuitem.
* Checking the box on an untranslated page should immediately translate the page.
* Unchecking the box on a translated page should immediately restore the page.
*/
add_task(async function test_toggle_always_translate_language_menuitem() {
const { cleanup, resolveDownloads, runInPage } = await loadTestPage({
page: SPANISH_PAGE_URL,
languagePairs: LANGUAGE_PAIRS,
prefs: [["browser.translations.alwaysTranslateLanguages", "pl,fr"]],
});
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"The translations button is visible."
);
await assertPageIsUntranslated(runInPage);
await openTranslationsPanel({ onOpenPanel: assertPanelDefaultView });
await openTranslationsSettingsMenu();
await assertIsAlwaysTranslateLanguage("es", { checked: false });
await clickAlwaysTranslateLanguage({
downloadHandler: resolveDownloads,
});
await assertIsAlwaysTranslateLanguage("es", { checked: true });
await assertPageIsTranslated(
"es",
"en",
runInPage,
"The page should be automatically translated."
);
await navigate("Navigate to a different Spanish page", {
url: SPANISH_PAGE_URL_DOT_ORG,
downloadHandler: resolveDownloads,
});
await assertPageIsTranslated(
"es",
"en",
runInPage,
"The page should be automatically translated."
);
await openTranslationsPanel({ onOpenPanel: assertPanelRevisitView });
await openTranslationsSettingsMenu();
await assertIsAlwaysTranslateLanguage("es", { checked: true });
await clickAlwaysTranslateLanguage();
await assertIsAlwaysTranslateLanguage("es", { checked: false });
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"Only the button appears"
);
await assertPageIsUntranslated(runInPage);
await cleanup();
});
/**
* Tests the effect of toggling the always-translate-language menuitem after the page has
* been manually translated. This should not reload or retranslate the page, but just check
* the box.
*/
add_task(
async function test_activate_always_translate_language_after_manual_translation() {
const { cleanup, resolveDownloads, runInPage } = await loadTestPage({
page: SPANISH_PAGE_URL,
languagePairs: LANGUAGE_PAIRS,
prefs: [["browser.translations.alwaysTranslateLanguages", "pl,fr"]],
});
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"The button is available."
);
await assertPageIsUntranslated(runInPage);
await openTranslationsPanel({ onOpenPanel: assertPanelDefaultView });
await clickTranslateButton({
downloadHandler: resolveDownloads,
});
await assertPageIsTranslated("es", "en", runInPage);
await openTranslationsPanel({ onOpenPanel: assertPanelRevisitView });
await openTranslationsSettingsMenu();
await assertIsAlwaysTranslateLanguage("es", { checked: false });
await clickAlwaysTranslateLanguage();
await assertIsAlwaysTranslateLanguage("es", { checked: true });
await assertPageIsTranslated("es", "en", runInPage);
await openTranslationsPanel({ onOpenPanel: assertPanelRevisitView });
await openTranslationsSettingsMenu();
await assertIsAlwaysTranslateLanguage("es", { checked: true });
await clickAlwaysTranslateLanguage();
await assertIsAlwaysTranslateLanguage("es", { checked: false });
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"Only the button appears"
);
await assertPageIsUntranslated(runInPage);
await cleanup();
}
);
/**
* Tests the effect of unchecking the always-translate language menuitem after the page has
* been manually restored to its original form.
* This should have no effect on the page, and further page loads should no longer auto-translate.
*/
add_task(
async function test_deactivate_always_translate_language_after_restore() {
const { cleanup, resolveDownloads, runInPage } = await loadTestPage({
page: SPANISH_PAGE_URL,
languagePairs: LANGUAGE_PAIRS,
prefs: [["browser.translations.alwaysTranslateLanguages", "pl,fr"]],
});
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"The translations button is visible."
);
await assertPageIsUntranslated(runInPage);
await openTranslationsPanel({ onOpenPanel: assertPanelDefaultView });
await openTranslationsSettingsMenu();
await assertIsAlwaysTranslateLanguage("es", { checked: false });
await clickAlwaysTranslateLanguage({
downloadHandler: resolveDownloads,
});
await assertIsAlwaysTranslateLanguage("es", { checked: true });
await assertPageIsTranslated(
"es",
"en",
runInPage,
"The page should be automatically translated."
);
await navigate("Navigate to a different Spanish page", {
url: SPANISH_PAGE_URL_DOT_ORG,
downloadHandler: resolveDownloads,
});
await assertPageIsTranslated(
"es",
"en",
runInPage,
"The page should be automatically translated."
);
await openTranslationsPanel({ onOpenPanel: assertPanelRevisitView });
await clickRestoreButton();
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"The button is reverted to have an icon."
);
await assertPageIsUntranslated(runInPage);
await openTranslationsPanel({ onOpenPanel: assertPanelDefaultView });
await openTranslationsSettingsMenu();
await assertIsAlwaysTranslateLanguage("es", { checked: true });
await clickAlwaysTranslateLanguage();
await assertIsAlwaysTranslateLanguage("es", { checked: false });
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"The button shows only the icon."
);
await navigate("Reload the page", { url: SPANISH_PAGE_URL_DOT_ORG });
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"The button shows only the icon."
);
await assertPageIsUntranslated(runInPage);
await cleanup();
}
);

View File

@ -0,0 +1,68 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests the effect of toggling the always-translate-language menuitem.
* Checking the box on an untranslated page should immediately translate the page.
* Unchecking the box on a translated page should immediately restore the page.
*/
add_task(async function test_toggle_always_translate_language_menuitem() {
const { cleanup, resolveDownloads, runInPage } = await loadTestPage({
page: SPANISH_PAGE_URL,
languagePairs: LANGUAGE_PAIRS,
prefs: [["browser.translations.alwaysTranslateLanguages", "pl,fr"]],
});
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"The translations button is visible."
);
await assertPageIsUntranslated(runInPage);
await openTranslationsPanel({ onOpenPanel: assertPanelDefaultView });
await openTranslationsSettingsMenu();
await assertIsAlwaysTranslateLanguage("es", { checked: false });
await clickAlwaysTranslateLanguage({
downloadHandler: resolveDownloads,
});
await assertIsAlwaysTranslateLanguage("es", { checked: true });
await assertPageIsTranslated(
"es",
"en",
runInPage,
"The page should be automatically translated."
);
await navigate("Navigate to a different Spanish page", {
url: SPANISH_PAGE_URL_DOT_ORG,
downloadHandler: resolveDownloads,
});
await assertPageIsTranslated(
"es",
"en",
runInPage,
"The page should be automatically translated."
);
await openTranslationsPanel({ onOpenPanel: assertPanelRevisitView });
await openTranslationsSettingsMenu();
await assertIsAlwaysTranslateLanguage("es", { checked: true });
await clickAlwaysTranslateLanguage();
await assertIsAlwaysTranslateLanguage("es", { checked: false });
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"Only the button appears"
);
await assertPageIsUntranslated(runInPage);
await cleanup();
});

View File

@ -0,0 +1,59 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests the effect of toggling the always-translate-language menuitem after the page has
* been manually translated. This should not reload or retranslate the page, but just check
* the box.
*/
add_task(
async function test_activate_always_translate_language_after_manual_translation() {
const { cleanup, resolveDownloads, runInPage } = await loadTestPage({
page: SPANISH_PAGE_URL,
languagePairs: LANGUAGE_PAIRS,
prefs: [["browser.translations.alwaysTranslateLanguages", "pl,fr"]],
});
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"The button is available."
);
await assertPageIsUntranslated(runInPage);
await openTranslationsPanel({ onOpenPanel: assertPanelDefaultView });
await clickTranslateButton({
downloadHandler: resolveDownloads,
});
await assertPageIsTranslated("es", "en", runInPage);
await openTranslationsPanel({ onOpenPanel: assertPanelRevisitView });
await openTranslationsSettingsMenu();
await assertIsAlwaysTranslateLanguage("es", { checked: false });
await clickAlwaysTranslateLanguage();
await assertIsAlwaysTranslateLanguage("es", { checked: true });
await assertPageIsTranslated("es", "en", runInPage);
await openTranslationsPanel({ onOpenPanel: assertPanelRevisitView });
await openTranslationsSettingsMenu();
await assertIsAlwaysTranslateLanguage("es", { checked: true });
await clickAlwaysTranslateLanguage();
await assertIsAlwaysTranslateLanguage("es", { checked: false });
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"Only the button appears"
);
await assertPageIsUntranslated(runInPage);
await cleanup();
}
);

View File

@ -0,0 +1,88 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests the effect of unchecking the always-translate language menuitem after the page has
* been manually restored to its original form.
* This should have no effect on the page, and further page loads should no longer auto-translate.
*/
add_task(
async function test_deactivate_always_translate_language_after_restore() {
const { cleanup, resolveDownloads, runInPage } = await loadTestPage({
page: SPANISH_PAGE_URL,
languagePairs: LANGUAGE_PAIRS,
prefs: [["browser.translations.alwaysTranslateLanguages", "pl,fr"]],
});
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"The translations button is visible."
);
await assertPageIsUntranslated(runInPage);
await openTranslationsPanel({ onOpenPanel: assertPanelDefaultView });
await openTranslationsSettingsMenu();
await assertIsAlwaysTranslateLanguage("es", { checked: false });
await clickAlwaysTranslateLanguage({
downloadHandler: resolveDownloads,
});
await assertIsAlwaysTranslateLanguage("es", { checked: true });
await assertPageIsTranslated(
"es",
"en",
runInPage,
"The page should be automatically translated."
);
await navigate("Navigate to a different Spanish page", {
url: SPANISH_PAGE_URL_DOT_ORG,
downloadHandler: resolveDownloads,
});
await assertPageIsTranslated(
"es",
"en",
runInPage,
"The page should be automatically translated."
);
await openTranslationsPanel({ onOpenPanel: assertPanelRevisitView });
await clickRestoreButton();
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"The button is reverted to have an icon."
);
await assertPageIsUntranslated(runInPage);
await openTranslationsPanel({ onOpenPanel: assertPanelDefaultView });
await openTranslationsSettingsMenu();
await assertIsAlwaysTranslateLanguage("es", { checked: true });
await clickAlwaysTranslateLanguage();
await assertIsAlwaysTranslateLanguage("es", { checked: false });
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"The button shows only the icon."
);
await navigate("Reload the page", { url: SPANISH_PAGE_URL_DOT_ORG });
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"The button shows only the icon."
);
await assertPageIsUntranslated(runInPage);
await cleanup();
}
);

View File

@ -0,0 +1,79 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests the effect of toggling the never-translate-site menuitem on a page where
* where translation is already active via always-translate.
* Checking the box on a translated page should restore the page and hide the button.
* The button should not appear again for sites that share the same content principal
* of the disabled site, and no auto-translation should occur.
* Other sites should still auto-translate for this language.
*/
add_task(
async function test_toggle_never_translate_site_menuitem_with_always_translate_active() {
const { cleanup, resolveDownloads, runInPage } = await loadTestPage({
page: SPANISH_PAGE_URL,
languagePairs: LANGUAGE_PAIRS,
prefs: [["browser.translations.alwaysTranslateLanguages", "uk,it"]],
permissionsUrls: [SPANISH_PAGE_URL],
});
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"The button is available."
);
await openTranslationsPanel({ onOpenPanel: assertPanelDefaultView });
await openTranslationsSettingsMenu();
await assertIsAlwaysTranslateLanguage("es", { checked: false });
await assertIsNeverTranslateSite(SPANISH_PAGE_URL, { checked: false });
await clickAlwaysTranslateLanguage({
downloadHandler: resolveDownloads,
});
await assertIsAlwaysTranslateLanguage("es", { checked: true });
await assertIsNeverTranslateSite(SPANISH_PAGE_URL, { checked: false });
await assertPageIsTranslated("es", "en", runInPage);
await openTranslationsPanel({ onOpenPanel: assertPanelRevisitView });
await openTranslationsSettingsMenu();
await assertIsAlwaysTranslateLanguage("es", { checked: true });
await assertIsNeverTranslateSite(SPANISH_PAGE_URL, { checked: false });
await clickNeverTranslateSite();
await assertIsAlwaysTranslateLanguage("es", { checked: true });
await assertIsNeverTranslateSite(SPANISH_PAGE_URL, { checked: true });
await assertPageIsUntranslated(runInPage);
await navigate("Reload the page", { url: SPANISH_PAGE_URL });
await assertPageIsUntranslated(runInPage);
await navigate(
"Navigate to a Spanish page with the same content principal",
{ url: SPANISH_PAGE_URL_2 }
);
await assertPageIsUntranslated(runInPage);
await navigate(
"Navigate to a Spanish page with a different content principal",
{
url: SPANISH_PAGE_URL_DOT_ORG,
downloadHandler: resolveDownloads,
}
);
await assertPageIsTranslated("es", "en", runInPage);
await cleanup();
}
);

View File

@ -0,0 +1,55 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests the effect of toggling the never-translate-site menuitem.
* Checking the box on an untranslated page should immediately hide the button.
* The button should not appear again for sites that share the same content principal
* of the disabled site.
*/
add_task(async function test_toggle_never_translate_site_menuitem() {
const { cleanup, runInPage } = await loadTestPage({
page: SPANISH_PAGE_URL,
languagePairs: LANGUAGE_PAIRS,
permissionsUrls: [SPANISH_PAGE_URL],
});
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"The translations button is visible."
);
await assertPageIsUntranslated(runInPage);
await openTranslationsPanel({ onOpenPanel: assertPanelDefaultView });
await openTranslationsSettingsMenu();
await assertIsNeverTranslateSite(SPANISH_PAGE_URL, { checked: false });
await clickNeverTranslateSite();
await assertIsNeverTranslateSite(SPANISH_PAGE_URL, { checked: true });
await assertPageIsUntranslated(runInPage);
await navigate("Navigate to a Spanish page with the same content principal", {
url: SPANISH_PAGE_URL_2,
});
await assertPageIsUntranslated(runInPage);
await navigate(
"Navigate to a Spanish page with a different content principal",
{ url: SPANISH_PAGE_URL_DOT_ORG }
);
await assertTranslationsButton(
{ button: true },
"The translations button should be visible, because this content principal " +
"has not been denied translations permissions"
);
await assertPageIsUntranslated(runInPage);
await cleanup();
});

View File

@ -0,0 +1,71 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests the effect of toggling the never-translate-site menuitem on a page where
* where translation is already active.
* Checking the box on a translated page should restore the page and hide the button.
* The button should not appear again for sites that share the same content principal
* of the disabled site.
*/
add_task(
async function test_toggle_never_translate_site_menuitem_with_active_translations() {
const { cleanup, resolveDownloads, runInPage } = await loadTestPage({
page: SPANISH_PAGE_URL,
languagePairs: LANGUAGE_PAIRS,
permissionsUrls: [SPANISH_PAGE_URL],
});
await assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"The translations button is visible."
);
await assertPageIsUntranslated(runInPage);
await openTranslationsPanel({ onOpenPanel: assertPanelDefaultView });
await clickTranslateButton({
downloadHandler: resolveDownloads,
});
await assertPageIsTranslated("es", "en", runInPage);
await openTranslationsPanel({ onOpenPanel: assertPanelRevisitView });
await openTranslationsSettingsMenu();
await assertIsNeverTranslateSite(SPANISH_PAGE_URL, { checked: false });
await clickNeverTranslateSite();
await assertIsNeverTranslateSite(SPANISH_PAGE_URL, { checked: true });
await assertPageIsUntranslated(runInPage);
await navigate("Reload the page", { url: SPANISH_PAGE_URL });
await assertPageIsUntranslated(runInPage);
await navigate(
"Navigate to a Spanish page with the same content principal",
{ url: SPANISH_PAGE_URL_2 }
);
await assertPageIsUntranslated(runInPage);
await navigate(
"Navigate to a Spanish page with a different content principal",
{ url: SPANISH_PAGE_URL_DOT_ORG }
);
await assertTranslationsButton(
{ button: true },
"The translations button should be visible, because this content principal " +
"has not been denied translations permissions"
);
await assertPageIsUntranslated(runInPage);
await cleanup();
}
);