Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Add a new test to verify that when the pref is enabled the notificati…
Browse files Browse the repository at this point in the history
…on bar is not shown, and run both tests with built-in version enabled and disabled
  • Loading branch information
marco-c committed Jul 11, 2023
1 parent d4f5bd3 commit ba1ce99
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
40 changes: 39 additions & 1 deletion scripts/tests/browser_translation_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,46 @@ const baseURL = getRootDirectory(gTestPath).replace(
"https://example.com"
);

add_task(async function testTranslationBarNotDisplayed() {
info("Test the Translation functionality when the built-in version is enabled");

if (!Services.prefs.getBoolPref("browser.translations.enable", false)) {
ok(true, "Built-in version is disabled, skipping test.");
return;
}

info("Waiting 10s until the engines are loaded");
// let's wait until the engines are loaded
await new Promise(resolve => setTimeout(resolve, 10000));

info("Opening the test page");

// open the test page.
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
`${baseURL }browser_translation_test.html`
);

// wait for the translation bar to be displayed.
let neverShown = false;
await TestUtils.waitForCondition(() => gBrowser
.getNotificationBox()
.getNotificationWithValue("fxtranslation-notification"))
.catch(() => {
neverShown = true;
});
ok(neverShown, "Translation notification bar was not displayed.");

BrowserTestUtils.removeTab(tab);
});

add_task(async function testTranslationBarDisplayed() {
info("Test the Translation functionality");
info("Test the Translation functionality when the built-in version is disabled");

if (Services.prefs.getBoolPref("browser.translations.enable", false)) {
ok(true, "Built-in version is enabled, skipping test.");
return;
}

info("Waiting 10s until the engines are loaded");
// let's wait until the engines are loaded
Expand Down
1 change: 1 addition & 0 deletions scripts/tests/e2e-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
subprocess.check_output("./mach build", stderr=subprocess.STDOUT, shell=True, universal_newlines=True, cwd="gecko")
print("Running test with faster gemm")
subprocess.check_output("./mach test --setpref=fxtranslations.running.mochitest=true browser/extensions/translations/test/browser/browser_translation_test.js", stderr=subprocess.STDOUT, shell=True, universal_newlines=True, cwd="gecko")
subprocess.check_output("./mach test --setpref=fxtranslations.running.mochitest=true --setpref=browser.translations.enable=false browser/extensions/translations/test/browser/browser_translation_test.js", stderr=subprocess.STDOUT, shell=True, universal_newlines=True, cwd="gecko")
print("Test with faster gemm Succeeded")
except CalledProcessError as cpe:
print(cpe.output)
Expand Down

0 comments on commit ba1ce99

Please sign in to comment.