Commit 70e1870b authored by Daisuke Akatsuka's avatar Daisuke Akatsuka
Browse files

Bug 1833975: Use MockRemoteSettings for QuickSuggestTestUtils.setConfig r=adw

parent c8f798e4
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -261,10 +261,6 @@ class _QuickSuggestRemoteSettings {
    return this.#rs;
  }

  _test_setConfig(config) {
    this.#setConfig(config);
  }

  // The `RemoteSettings` client.
  #rs = null;

+4 −5
Original line number Diff line number Diff line
@@ -357,10 +357,9 @@ class _QuickSuggestTestUtils {
   *
   * @param {object} config
   *   The config to be applied. See
   *   {@link QuickSuggestRemoteSettings._test_setConfig}
   */
  setConfig(config) {
    lazy.QuickSuggestRemoteSettings._test_setConfig(config);
  async setConfig(config) {
    await this.#mockRemoteSettings.update({ config });
  }

  /**
@@ -378,9 +377,9 @@ class _QuickSuggestTestUtils {
   */
  async withConfig({ config, callback }) {
    let original = lazy.QuickSuggestRemoteSettings.config;
    this.setConfig(config);
    await this.setConfig(config);
    await callback();
    this.setConfig(original);
    await this.setConfig(original);
  }

  /**
+4 −2
Original line number Diff line number Diff line
@@ -209,7 +209,9 @@ add_task(async function nonsponsoredBestMatch() {
  await SpecialPowers.pushPrefEnv({
    set: [["browser.urlbar.bestMatch.enabled", true]],
  });
  QuickSuggestTestUtils.setConfig(QuickSuggestTestUtils.BEST_MATCH_CONFIG);
  await QuickSuggestTestUtils.setConfig(
    QuickSuggestTestUtils.BEST_MATCH_CONFIG
  );
  await doTelemetryTest({
    index,
    suggestion: REMOTE_SETTINGS_RESULT,
@@ -361,6 +363,6 @@ add_task(async function nonsponsoredBestMatch() {
      },
    },
  });
  QuickSuggestTestUtils.setConfig(QuickSuggestTestUtils.DEFAULT_CONFIG);
  await QuickSuggestTestUtils.setConfig(QuickSuggestTestUtils.DEFAULT_CONFIG);
  await SpecialPowers.popPrefEnv();
});
+4 −2
Original line number Diff line number Diff line
@@ -208,7 +208,9 @@ add_task(async function sponsoredBestMatch() {
  await SpecialPowers.pushPrefEnv({
    set: [["browser.urlbar.bestMatch.enabled", true]],
  });
  QuickSuggestTestUtils.setConfig(QuickSuggestTestUtils.BEST_MATCH_CONFIG);
  await QuickSuggestTestUtils.setConfig(
    QuickSuggestTestUtils.BEST_MATCH_CONFIG
  );
  await doTelemetryTest({
    index,
    suggestion: REMOTE_SETTINGS_RESULT,
@@ -360,6 +362,6 @@ add_task(async function sponsoredBestMatch() {
      },
    },
  });
  QuickSuggestTestUtils.setConfig(QuickSuggestTestUtils.DEFAULT_CONFIG);
  await QuickSuggestTestUtils.setConfig(QuickSuggestTestUtils.DEFAULT_CONFIG);
  await SpecialPowers.popPrefEnv();
});
+9 −9
Original line number Diff line number Diff line
@@ -2025,7 +2025,7 @@ add_task(async function configChange_sameIntervalLowerCap_1() {
              },
            },
          ]);
          QuickSuggestTestUtils.setConfig({
          await QuickSuggestTestUtils.setConfig({
            impression_caps: {
              sponsored: {
                custom: [{ interval_s: 3, max_count: 1 }],
@@ -2108,7 +2108,7 @@ add_task(async function configChange_sameIntervalLowerCap_2() {
            });
          }
          await checkTelemetryEvents([]);
          QuickSuggestTestUtils.setConfig({
          await QuickSuggestTestUtils.setConfig({
            impression_caps: {
              sponsored: {
                custom: [{ interval_s: 3, max_count: 1 }],
@@ -2208,7 +2208,7 @@ add_task(async function configChange_sameIntervalHigherCap() {
              },
            },
          ]);
          QuickSuggestTestUtils.setConfig({
          await QuickSuggestTestUtils.setConfig({
            impression_caps: {
              sponsored: {
                custom: [{ interval_s: 3, max_count: 5 }],
@@ -2329,7 +2329,7 @@ add_task(async function configChange_1IntervalTo2NewIntervalsHigher() {
              },
            },
          ]);
          QuickSuggestTestUtils.setConfig({
          await QuickSuggestTestUtils.setConfig({
            impression_caps: {
              sponsored: {
                custom: [
@@ -2493,7 +2493,7 @@ add_task(async function configChange_2IntervalsTo1NewIntervalHigher() {
              },
            },
          ]);
          QuickSuggestTestUtils.setConfig({
          await QuickSuggestTestUtils.setConfig({
            impression_caps: {
              sponsored: {
                custom: [{ interval_s: 6, max_count: 5 }],
@@ -2620,7 +2620,7 @@ add_task(async function configChange_1IntervalTo1NewIntervalLower() {
              },
            },
          ]);
          QuickSuggestTestUtils.setConfig({
          await QuickSuggestTestUtils.setConfig({
            impression_caps: {
              sponsored: {
                custom: [{ interval_s: 3, max_count: 3 }],
@@ -2699,7 +2699,7 @@ add_task(async function configChange_1IntervalToLifetime() {
              },
            },
          ]);
          QuickSuggestTestUtils.setConfig({
          await QuickSuggestTestUtils.setConfig({
            impression_caps: {
              sponsored: {
                lifetime: 3,
@@ -2760,7 +2760,7 @@ add_task(async function configChange_lifetimeCapHigher() {
              },
            },
          ]);
          QuickSuggestTestUtils.setConfig({
          await QuickSuggestTestUtils.setConfig({
            impression_caps: {
              sponsored: {
                lifetime: 5,
@@ -2842,7 +2842,7 @@ add_task(async function configChange_lifetimeCapLower() {
              },
            },
          ]);
          QuickSuggestTestUtils.setConfig({
          await QuickSuggestTestUtils.setConfig({
            impression_caps: {
              sponsored: {
                lifetime: 1,
Loading