diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /browser/components/newtab/test/unit/lib | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/newtab/test/unit/lib')
5 files changed, 71 insertions, 5 deletions
diff --git a/browser/components/newtab/test/unit/lib/AboutPreferences.test.js b/browser/components/newtab/test/unit/lib/AboutPreferences.test.js index a19bf698d9..6555a1b77e 100644 --- a/browser/components/newtab/test/unit/lib/AboutPreferences.test.js +++ b/browser/components/newtab/test/unit/lib/AboutPreferences.test.js @@ -54,17 +54,21 @@ describe("AboutPreferences Feed", () => { instance.onAction(action); assert.calledOnce(action._target.browser.ownerGlobal.openPreferences); }); - it("should call .BrowserOpenAddonsMgr with the extension id on OPEN_WEBEXT_SETTINGS", () => { + it("should call .BrowserAddonUI.openAddonsMgr with the extension id on OPEN_WEBEXT_SETTINGS", () => { const action = { type: at.OPEN_WEBEXT_SETTINGS, data: "foo", _target: { - browser: { ownerGlobal: { BrowserOpenAddonsMgr: sinon.spy() } }, + browser: { + ownerGlobal: { + BrowserAddonUI: { openAddonsMgr: sinon.spy() }, + }, + }, }, }; instance.onAction(action); assert.calledWith( - action._target.browser.ownerGlobal.BrowserOpenAddonsMgr, + action._target.browser.ownerGlobal.BrowserAddonUI.openAddonsMgr, "addons://detail/foo" ); }); @@ -122,8 +126,9 @@ describe("AboutPreferences Feed", () => { const [, structure] = stub.firstCall.args; assert.equal(structure[0].id, "search"); assert.equal(structure[1].id, "topsites"); - assert.equal(structure[2].id, "topstories"); - assert.isEmpty(structure[2].rowsPref); + assert.equal(structure[2].id, "weather"); + assert.equal(structure[3].id, "topstories"); + assert.isEmpty(structure[3].rowsPref); }); }); describe("#renderPreferences", () => { diff --git a/browser/components/newtab/test/unit/lib/ActivityStream.test.js b/browser/components/newtab/test/unit/lib/ActivityStream.test.js index 7921ae2c91..ed00eb8202 100644 --- a/browser/components/newtab/test/unit/lib/ActivityStream.test.js +++ b/browser/components/newtab/test/unit/lib/ActivityStream.test.js @@ -311,6 +311,38 @@ describe("ActivityStream", () => { ); }); }); + describe("discoverystream.region-weather-config", () => { + let getVariableStub; + beforeEach(() => { + getVariableStub = sandbox.stub( + global.NimbusFeatures.pocketNewtab, + "getVariable" + ); + sandbox.stub(global.Region, "home").get(() => "CA"); + }); + it("should turn off weather system pref if no region weather config is set and no geo is set", () => { + getVariableStub.withArgs("regionWeatherConfig").returns(""); + sandbox.stub(global.Region, "home").get(() => ""); + + as._updateDynamicPrefs(); + + assert.isFalse(PREFS_CONFIG.get("system.showWeather").value); + }); + it("should turn on weather system pref based on region weather config pref", () => { + getVariableStub.withArgs("regionWeatherConfig").returns("CA"); + + as._updateDynamicPrefs(); + + assert.isTrue(PREFS_CONFIG.get("system.showWeather").value); + }); + it("should turn off weather system pref if no region weather config is set", () => { + getVariableStub.withArgs("regionWeatherConfig").returns(""); + + as._updateDynamicPrefs(); + + assert.isFalse(PREFS_CONFIG.get("system.showWeather").value); + }); + }); describe("_updateDynamicPrefs topstories default value", () => { let getVariableStub; let getBoolPrefStub; diff --git a/browser/components/newtab/test/unit/lib/ActivityStreamStorage.test.js b/browser/components/newtab/test/unit/lib/ActivityStreamStorage.test.js index 0b8baef762..fd56a3e185 100644 --- a/browser/components/newtab/test/unit/lib/ActivityStreamStorage.test.js +++ b/browser/components/newtab/test/unit/lib/ActivityStreamStorage.test.js @@ -47,6 +47,7 @@ describe("ActivityStreamStorage", () => { beforeEach(() => { storeStub = { getAll: sandbox.stub().resolves(), + getAllKeys: sandbox.stub().resolves(), get: sandbox.stub().resolves(), put: sandbox.stub().resolves(), }; @@ -75,6 +76,14 @@ describe("ActivityStreamStorage", () => { assert.calledOnce(storeStub.getAll); assert.deepEqual(result, ["bar"]); }); + it("should return the correct value for getAllKeys", async () => { + storeStub.getAllKeys.resolves(["key1", "key2", "key3"]); + + const result = await testStorage.getAllKeys(); + + assert.calledOnce(storeStub.getAllKeys); + assert.deepEqual(result, ["key1", "key2", "key3"]); + }); it("should query the correct object store", async () => { await testStorage.get(); diff --git a/browser/components/newtab/test/unit/lib/DiscoveryStreamFeed.test.js b/browser/components/newtab/test/unit/lib/DiscoveryStreamFeed.test.js index e10a4cbc04..72fc6bd0b8 100644 --- a/browser/components/newtab/test/unit/lib/DiscoveryStreamFeed.test.js +++ b/browser/components/newtab/test/unit/lib/DiscoveryStreamFeed.test.js @@ -3467,6 +3467,22 @@ describe("DiscoveryStreamFeed", () => { "https://bffApi/desktop/v1/recommendations?locale=$locale®ion=$region&count=30" ); }); + it("should update the new feed url with pocketFeedParameters", async () => { + globals.set("NimbusFeatures", { + pocketNewtab: { + getVariable: sandbox.stub(), + }, + }); + global.NimbusFeatures.pocketNewtab.getVariable + .withArgs("pocketFeedParameters") + .returns("&enableRankingByRegion=1"); + await feed.loadLayout(feed.store.dispatch); + const { layout } = feed.store.getState().DiscoveryStream; + assert.equal( + layout[0].components[2].feed.url, + "https://bffApi/desktop/v1/recommendations?locale=$locale®ion=$region&count=30&enableRankingByRegion=1" + ); + }); it("should fetch proper data from getComponentFeed", async () => { const fakeCache = {}; sandbox.stub(feed.cache, "get").returns(Promise.resolve(fakeCache)); diff --git a/browser/components/newtab/test/unit/lib/DownloadsManager.test.js b/browser/components/newtab/test/unit/lib/DownloadsManager.test.js index 5e2979893d..23ee9ffa34 100644 --- a/browser/components/newtab/test/unit/lib/DownloadsManager.test.js +++ b/browser/components/newtab/test/unit/lib/DownloadsManager.test.js @@ -29,6 +29,10 @@ describe("Downloads Manager", () => { showDownloadedFile: sinon.stub(), }); + globals.set("BrowserUtils", { + whereToOpenLink: sinon.stub().returns("current"), + }); + downloadsManager = new DownloadsManager(); downloadsManager.init({ dispatch() {} }); downloadsManager.onDownloadAdded({ |