Commit c8f798e4 authored by Daisuke Akatsuka's avatar Daisuke Akatsuka
Browse files

Bug 1833975: Use MockRemoteSettings for QuickSuggestTestUtils.setRemoteSettingsResults() r=adw

parent bcf837f8
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -276,9 +276,5 @@ export class AdmWikipedia extends BaseFeature {
    return rs.attachments.downloadToDisk(record);
  }

  get _test_suggestionsMap() {
    return this.#suggestionsMap;
  }

  #suggestionsMap;
}
+2 −14
Original line number Diff line number Diff line
@@ -199,15 +199,11 @@ class _QuickSuggestRemoteSettings {
  }

  async #syncConfig() {
    if (this._test_ignoreSettingsSync) {
      return;
    }

    this.logger.debug("Syncing config");
    let rs = this.#rs;

    let configArray = await rs.get({ filters: { type: "configuration" } });
    if (rs != this.#rs || this._test_ignoreSettingsSync) {
    if (rs != this.#rs) {
      return;
    }

@@ -216,19 +212,11 @@ class _QuickSuggestRemoteSettings {
  }

  async #syncFeature(feature) {
    if (this._test_ignoreSettingsSync) {
      return;
    }

    this.logger.debug("Syncing feature: " + feature.name);
    await feature.onRemoteSettingsSync(this.#rs);
  }

  async #syncAll({ event = null } = {}) {
    if (this._test_ignoreSettingsSync) {
      return;
    }

    this.logger.debug("Syncing all");
    let rs = this.#rs;

@@ -244,7 +232,7 @@ class _QuickSuggestRemoteSettings {
            ])
          )
      );
      if (rs != this.#rs || this._test_ignoreSettingsSync) {
      if (rs != this.#rs) {
        return;
      }
    }
+0 −5
Original line number Diff line number Diff line
@@ -476,11 +476,6 @@ export class Weather extends BaseFeature {
    await this.#fetch();
  }

  _test_setRsData(data) {
    this.#rsData = data;
    this.#updateConfig();
  }

  _test_setSuggestionToNull() {
    this.#suggestion = null;
  }
+4 −0
Original line number Diff line number Diff line
@@ -117,6 +117,10 @@ async function ensureQuickSuggestInit({
          },
        ],
      },
      {
        type: "weather",
        weather: MerinoTestUtils.WEATHER_RS_DATA,
      },
    ],
  });
}
+0 −4
Original line number Diff line number Diff line
@@ -6,8 +6,6 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
  PromiseUtils: "resource://gre/modules/PromiseUtils.sys.mjs",
  QuickSuggest: "resource:///modules/QuickSuggest.sys.mjs",
  QuickSuggestRemoteSettings:
    "resource:///modules/urlbar/private/QuickSuggestRemoteSettings.sys.mjs",
  TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.sys.mjs",
  UrlbarPrefs: "resource:///modules/UrlbarPrefs.sys.mjs",
});
@@ -322,13 +320,11 @@ class _MerinoTestUtils {
    await this.server.start();
    this.server.response.body.suggestions = [WEATHER_SUGGESTION];

    lazy.QuickSuggestRemoteSettings._test_ignoreSettingsSync = true;
    lazy.QuickSuggest.weather._test_fetchIntervalMs = WEATHER_FETCH_INTERVAL_MS;

    // Enabling weather will trigger a fetch. Wait for it to finish so the
    // suggestion is ready when this function returns.
    let fetchPromise = lazy.QuickSuggest.weather.waitForFetches();
    lazy.QuickSuggest.weather._test_setRsData({ ...WEATHER_RS_DATA });
    lazy.UrlbarPrefs.set("weather.featureGate", true);
    lazy.UrlbarPrefs.set("suggest.weather", true);
    await fetchPromise;
Loading