Merge branch 'trailhead'
This commit is contained in:
Коммит
a5d38d1610
|
@ -371,9 +371,10 @@
|
|||
color: var(--newtab-text-conditional-color);
|
||||
background: var(--trailhead-card-button-background-color);
|
||||
border: 0;
|
||||
height: 30px;
|
||||
margin: 14px;
|
||||
min-width: 70%;
|
||||
padding: 0 14px;
|
||||
padding: 6px 14px;
|
||||
white-space: pre-wrap;
|
||||
|
||||
&:focus,
|
||||
&:hover {
|
||||
|
@ -391,9 +392,8 @@
|
|||
}
|
||||
|
||||
.onboardingButtonContainer {
|
||||
height: 60px;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
bottom: 16px;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
|
|
|
@ -705,6 +705,15 @@ class _ASRouter {
|
|||
}
|
||||
}
|
||||
|
||||
async _hasAddonAttributionData() {
|
||||
try {
|
||||
const data = await AttributionCode.getAttrDataAsync() || {};
|
||||
return data.source === "addons.mozilla.org";
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* _generateTrailheadBranches - Generates and returns Trailhead configuration and chooses an experiment
|
||||
* based on clientID and locale.
|
||||
|
@ -724,7 +733,7 @@ class _ASRouter {
|
|||
|
||||
const locale = Services.locale.appLocaleAsLangTag;
|
||||
|
||||
if (TRAILHEAD_CONFIG.LOCALES.includes(locale)) {
|
||||
if (TRAILHEAD_CONFIG.LOCALES.includes(locale) && !(await this._hasAddonAttributionData())) {
|
||||
const {userId} = ClientEnvironment;
|
||||
experiment = await chooseBranch(`${userId}-trailhead-experiments`, TRAILHEAD_CONFIG.EXPERIMENT_RATIOS);
|
||||
|
||||
|
|
|
@ -1708,6 +1708,10 @@ describe("ASRouter", () => {
|
|||
sandbox.stub(global.Services.locale, "appLocaleAsLangTag").get(() => "zh-CN");
|
||||
checkReturnValue({experiment: "", interrupt: "control", triplet: ""});
|
||||
});
|
||||
it("should return control experience with no experiment if attribution data contains an addon source", async () => {
|
||||
sandbox.stub(fakeAttributionCode, "getAttrDataAsync").resolves({source: "addons.mozilla.org"});
|
||||
checkReturnValue({experiment: "", interrupt: "control", triplet: ""});
|
||||
});
|
||||
it("should use values in override pref if it is set with no experiment", async () => {
|
||||
getStringPrefStub.withArgs(TRAILHEAD_CONFIG.OVERRIDE_PREF).returns("join-privacy");
|
||||
checkReturnValue({experiment: "", interrupt: "join", triplet: "privacy"});
|
||||
|
@ -1728,6 +1732,19 @@ describe("ASRouter", () => {
|
|||
sandbox.stub(global.Services.locale, "appLocaleAsLangTag").get(() => "en-US");
|
||||
checkReturnValue({experiment: "interrupts", interrupt: "join", triplet: "supercharge"});
|
||||
});
|
||||
it("should roll for experiment if attribution data is empty", async () => {
|
||||
sandbox.stub(global.Sampling, "ratioSample").resolves(1); // 1 = interrupts experiment
|
||||
sandbox.stub(global.Services.locale, "appLocaleAsLangTag").get(() => "en-US");
|
||||
sandbox.stub(fakeAttributionCode, "getAttrDataAsync").resolves(null);
|
||||
|
||||
checkReturnValue({experiment: "interrupts", interrupt: "join", triplet: "supercharge"});
|
||||
});
|
||||
it("should roll for experiment if attribution data rejects with an error", async () => {
|
||||
sandbox.stub(global.Sampling, "ratioSample").resolves(1); // 1 = interrupts experiment
|
||||
sandbox.stub(global.Services.locale, "appLocaleAsLangTag").get(() => "en-US");
|
||||
sandbox.stub(fakeAttributionCode, "getAttrDataAsync").rejects(new Error("whoops"));
|
||||
checkReturnValue({experiment: "interrupts", interrupt: "join", triplet: "supercharge"});
|
||||
});
|
||||
it("should roll a triplet experiment", async () => {
|
||||
sandbox.stub(global.Sampling, "ratioSample").resolves(2); // 2 = triplets experiment
|
||||
sandbox.stub(global.Services.locale, "appLocaleAsLangTag").get(() => "en-US");
|
||||
|
|
Загрузка…
Ссылка в новой задаче