зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1367696 - PART III add OnboardingTourType tests;r=mossop
MozReview-Commit-ID: 8tyiqkQJ5CX --HG-- extra : rebase_source : 8b13da016e9de1a37aec9b5c3071eaab28b1c750
This commit is contained in:
Родитель
69dd530e1b
Коммит
d8042b776d
|
@ -25,6 +25,7 @@ if (!extensionDir.exists()) {
|
|||
Components.manager.addBootstrappedManifestLocation(extensionDir);
|
||||
|
||||
const TOURSET_VERSION = 1;
|
||||
const NEXT_TOURSET_VERSION = 2;
|
||||
const PREF_TOUR_TYPE = "browser.onboarding.tour-type";
|
||||
const PREF_TOURSET_VERSION = "browser.onboarding.tourset-version";
|
||||
const PREF_SEEN_TOURSET_VERSION = "browser.onboarding.seen-tourset-version";
|
||||
|
@ -37,3 +38,11 @@ function resetOnboardingDefaultState() {
|
|||
Services.prefs.clearUserPref(PREF_SEEN_TOURSET_VERSION);
|
||||
Services.prefs.clearUserPref(PREF_TOUR_TYPE);
|
||||
}
|
||||
|
||||
function resetOldProfileDefaultState() {
|
||||
// All the prefs should be reset to what prefs should looks like in a older new user profile
|
||||
Services.prefs.setIntPref(PREF_TOURSET_VERSION, TOURSET_VERSION);
|
||||
Services.prefs.setIntPref(PREF_SEEN_TOURSET_VERSION, 0);
|
||||
Services.prefs.clearUserPref(PREF_ONBOARDING_HIDDEN);
|
||||
Services.prefs.clearUserPref(PREF_TOUR_TYPE);
|
||||
}
|
||||
|
|
|
@ -4,10 +4,96 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
add_task(async function() {
|
||||
do_print("Starting testcase: New user state");
|
||||
resetOnboardingDefaultState();
|
||||
Cu.import("resource://onboarding/modules/OnboardingTourType.jsm");
|
||||
|
||||
do_check_eq(Preferences.get(PREF_TOURSET_VERSION), TOURSET_VERSION);
|
||||
do_check_eq(Preferences.get(PREF_ONBOARDING_HIDDEN), false);
|
||||
add_task(async function() {
|
||||
do_print("Starting testcase: When New user open the browser first time");
|
||||
resetOnboardingDefaultState();
|
||||
OnboardingTourType.check();
|
||||
|
||||
do_check_eq(Preferences.get(PREF_TOUR_TYPE), "new", "should show the new user tour");
|
||||
do_check_eq(Preferences.get(PREF_TOURSET_VERSION), TOURSET_VERSION,
|
||||
"tourset version should not change");
|
||||
do_check_eq(Preferences.get(PREF_SEEN_TOURSET_VERSION), TOURSET_VERSION,
|
||||
"seen tourset version should be set as the tourset version");
|
||||
do_check_eq(Preferences.get(PREF_ONBOARDING_HIDDEN), false, "should show the user tour");
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
do_print("Starting testcase: When New user restart the browser");
|
||||
resetOnboardingDefaultState();
|
||||
Preferences.set(PREF_TOUR_TYPE, "new");
|
||||
Preferences.set(PREF_SEEN_TOURSET_VERSION, TOURSET_VERSION);
|
||||
Preferences.set(PREF_ONBOARDING_HIDDEN, false);
|
||||
OnboardingTourType.check();
|
||||
|
||||
do_check_eq(Preferences.get(PREF_TOUR_TYPE), "new", "should show the new user tour");
|
||||
do_check_eq(Preferences.get(PREF_TOURSET_VERSION), TOURSET_VERSION),
|
||||
"tourset version should not change";
|
||||
do_check_eq(Preferences.get(PREF_SEEN_TOURSET_VERSION), TOURSET_VERSION,
|
||||
"seen tourset version should be set as the tourset version");
|
||||
do_check_eq(Preferences.get(PREF_ONBOARDING_HIDDEN), false, "should show the user tour");
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
do_print("Starting testcase: When New User choosed to hide the overlay and restart the browser");
|
||||
resetOnboardingDefaultState();
|
||||
Preferences.set(PREF_TOUR_TYPE, "new");
|
||||
Preferences.set(PREF_SEEN_TOURSET_VERSION, TOURSET_VERSION);
|
||||
Preferences.set(PREF_ONBOARDING_HIDDEN, true);
|
||||
OnboardingTourType.check();
|
||||
|
||||
do_check_eq(Preferences.get(PREF_TOUR_TYPE), "new", "should show the new user tour");
|
||||
do_check_eq(Preferences.get(PREF_TOURSET_VERSION), TOURSET_VERSION),
|
||||
"tourset version should not change";
|
||||
do_check_eq(Preferences.get(PREF_SEEN_TOURSET_VERSION), TOURSET_VERSION,
|
||||
"seen tourset version should be set as the tourset version");
|
||||
do_check_eq(Preferences.get(PREF_ONBOARDING_HIDDEN), true, "should hide the user tour");
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
do_print("Starting testcase: When New User updated to the next major version and restart the browser");
|
||||
resetOnboardingDefaultState();
|
||||
Preferences.set(PREF_TOURSET_VERSION, NEXT_TOURSET_VERSION);
|
||||
Preferences.set(PREF_TOUR_TYPE, "new");
|
||||
Preferences.set(PREF_SEEN_TOURSET_VERSION, TOURSET_VERSION);
|
||||
Preferences.set(PREF_ONBOARDING_HIDDEN, false);
|
||||
OnboardingTourType.check();
|
||||
|
||||
do_check_eq(Preferences.get(PREF_TOUR_TYPE), "update", "should show the update user tour");
|
||||
do_check_eq(Preferences.get(PREF_TOURSET_VERSION), NEXT_TOURSET_VERSION),
|
||||
"tourset version should not change";
|
||||
do_check_eq(Preferences.get(PREF_SEEN_TOURSET_VERSION), NEXT_TOURSET_VERSION,
|
||||
"seen tourset version should be set as the tourset version");
|
||||
do_check_eq(Preferences.get(PREF_ONBOARDING_HIDDEN), false, "should show the user tour");
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
do_print("Starting testcase: When New User prefer hide the tour, then updated to the next major version and restart the browser");
|
||||
resetOnboardingDefaultState();
|
||||
Preferences.set(PREF_TOURSET_VERSION, NEXT_TOURSET_VERSION);
|
||||
Preferences.set(PREF_TOUR_TYPE, "new");
|
||||
Preferences.set(PREF_SEEN_TOURSET_VERSION, TOURSET_VERSION);
|
||||
Preferences.set(PREF_ONBOARDING_HIDDEN, true);
|
||||
OnboardingTourType.check();
|
||||
|
||||
do_check_eq(Preferences.get(PREF_TOUR_TYPE), "update", "should show the update user tour");
|
||||
do_check_eq(Preferences.get(PREF_TOURSET_VERSION), NEXT_TOURSET_VERSION),
|
||||
"tourset version should not change";
|
||||
do_check_eq(Preferences.get(PREF_SEEN_TOURSET_VERSION), NEXT_TOURSET_VERSION,
|
||||
"seen tourset version should be set as the tourset version");
|
||||
do_check_eq(Preferences.get(PREF_ONBOARDING_HIDDEN), false, "should show the user tour");
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
do_print("Starting testcase: When User update from browser version < 56");
|
||||
resetOldProfileDefaultState();
|
||||
OnboardingTourType.check();
|
||||
|
||||
do_check_eq(Preferences.get(PREF_TOUR_TYPE), "update", "should show the update user tour");
|
||||
do_check_eq(Preferences.get(PREF_TOURSET_VERSION), TOURSET_VERSION),
|
||||
"tourset version should not change";
|
||||
do_check_eq(Preferences.get(PREF_SEEN_TOURSET_VERSION), TOURSET_VERSION,
|
||||
"seen tourset version should be set as the tourset version");
|
||||
do_check_eq(Preferences.get(PREF_ONBOARDING_HIDDEN), false, "should show the user tour");
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче