2019-06-14 08:54:20 -04:00
|
|
|
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
2018-10-05 07:04:48 -04:00
|
|
|
import DiscoveryFixtures from "fixtures/discovery_fixtures";
|
|
|
|
|
|
|
|
acceptance("Redirect to Top", {
|
|
|
|
pretend(server, helper) {
|
2019-06-03 14:17:25 -04:00
|
|
|
server.get("/top/weekly.json", () => {
|
|
|
|
return helper.response(DiscoveryFixtures["/latest.json"]);
|
|
|
|
});
|
|
|
|
server.get("/top/monthly.json", () => {
|
|
|
|
return helper.response(DiscoveryFixtures["/latest.json"]);
|
|
|
|
});
|
2018-10-05 07:04:48 -04:00
|
|
|
server.get("/top/all.json", () => {
|
|
|
|
return helper.response(DiscoveryFixtures["/latest.json"]);
|
|
|
|
});
|
2019-06-14 08:54:20 -04:00
|
|
|
},
|
|
|
|
loggedIn: true,
|
2018-10-05 07:04:48 -04:00
|
|
|
});
|
|
|
|
|
2019-06-03 14:17:25 -04:00
|
|
|
QUnit.test("redirects categories to weekly top", async (assert) => {
|
2019-06-14 08:54:20 -04:00
|
|
|
updateCurrentUser({
|
2018-10-05 07:04:48 -04:00
|
|
|
should_be_redirected_to_top: true,
|
|
|
|
redirected_to_top: {
|
2019-06-03 14:17:25 -04:00
|
|
|
period: "weekly",
|
2018-10-05 07:04:48 -04:00
|
|
|
reason: "Welcome back!",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
await visit("/categories");
|
2019-06-03 14:17:25 -04:00
|
|
|
assert.equal(currentPath(), "discovery.topWeekly", "it works for categories");
|
2018-10-05 07:04:48 -04:00
|
|
|
});
|
|
|
|
|
2019-06-03 14:17:25 -04:00
|
|
|
QUnit.test("redirects latest to monthly top", async (assert) => {
|
2019-06-14 08:54:20 -04:00
|
|
|
updateCurrentUser({
|
2019-06-03 14:17:25 -04:00
|
|
|
should_be_redirected_to_top: true,
|
|
|
|
redirected_to_top: {
|
|
|
|
period: "monthly",
|
|
|
|
reason: "Welcome back!",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2018-10-05 07:04:48 -04:00
|
|
|
await visit("/latest");
|
2019-06-03 14:17:25 -04:00
|
|
|
assert.equal(currentPath(), "discovery.topMonthly", "it works for latest");
|
2018-10-05 07:04:48 -04:00
|
|
|
});
|
|
|
|
|
2019-06-03 14:17:25 -04:00
|
|
|
QUnit.test("redirects root to All top", async (assert) => {
|
2019-06-14 08:54:20 -04:00
|
|
|
updateCurrentUser({
|
2019-06-03 14:17:25 -04:00
|
|
|
should_be_redirected_to_top: true,
|
|
|
|
redirected_to_top: {
|
|
|
|
period: null,
|
|
|
|
reason: "Welcome back!",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2018-10-05 07:04:48 -04:00
|
|
|
await visit("/");
|
|
|
|
assert.equal(currentPath(), "discovery.topAll", "it works for root");
|
|
|
|
});
|