add test
Dieser Commit ist enthalten in:
Ursprung
7fd4d9bd24
Commit
603886b394
3 geänderte Dateien mit 25 neuen und 9 gelöschten Zeilen
|
@ -25,6 +25,7 @@ export default Component.extend(Subscription, {
|
|||
},
|
||||
|
||||
click() {
|
||||
debugger;
|
||||
DiscourseURL.routeTo(this.subscriptionLink);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -2,6 +2,7 @@ import DiscourseURL from "discourse/lib/url";
|
|||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import getUrl from "discourse-common/lib/get-url";
|
||||
import { observes } from "discourse-common/utils/decorators";
|
||||
import { dasherize } from "@ember/string";
|
||||
|
||||
export default {
|
||||
name: "custom-wizard-edits",
|
||||
|
@ -12,14 +13,6 @@ export default {
|
|||
return;
|
||||
}
|
||||
|
||||
const existing = DiscourseURL.routeTo;
|
||||
DiscourseURL.routeTo = function (path, opts) {
|
||||
if (path && path.indexOf("/w/") > -1) {
|
||||
return (window.location = path);
|
||||
}
|
||||
return existing.apply(this, [path, opts]);
|
||||
};
|
||||
|
||||
withPluginApi("0.8.36", (api) => {
|
||||
api.onAppEvent("page:changed", (data) => {
|
||||
const currentUser = container.lookup("service:current-user");
|
||||
|
@ -36,7 +29,7 @@ export default {
|
|||
return data.currentRouteName.indexOf(p) > -1;
|
||||
})
|
||||
) {
|
||||
window.location = "/w/" + redirectToWizard.dasherize();
|
||||
DiscourseURL.routeTo(`/w/${dasherize(redirectToWizard)}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -13,6 +13,8 @@ import {
|
|||
wizardNoUser,
|
||||
wizardNotPermitted,
|
||||
} from "../helpers/wizard";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
import sinon from "sinon";
|
||||
|
||||
acceptance("Wizard | Not logged in", function (needs) {
|
||||
needs.pretender((server, helper) => {
|
||||
|
@ -54,6 +56,26 @@ acceptance("Wizard | Completed", function (needs) {
|
|||
});
|
||||
});
|
||||
|
||||
acceptance("Wizard | Redirect", function (needs) {
|
||||
needs.user({
|
||||
redirect_to_wizard: "wizard"
|
||||
});
|
||||
needs.pretender((server, helper) => {
|
||||
server.get("/w/wizard.json", () => {
|
||||
return helper.response(wizard);
|
||||
});
|
||||
});
|
||||
|
||||
test("Redirect to pending Wizard", async function (assert) {
|
||||
sinon.stub(DiscourseURL, "routeTo");
|
||||
await visit("/latest");
|
||||
assert.ok(
|
||||
DiscourseURL.routeTo.calledWith("/w/wizard"),
|
||||
"pending wizard routing works"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
acceptance("Wizard | Wizard", function (needs) {
|
||||
needs.user();
|
||||
needs.pretender((server, helper) => {
|
||||
|
|
Laden …
In neuem Issue referenzieren