Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 09:20:29 +01:00
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() {
|
click() {
|
||||||
|
debugger;
|
||||||
DiscourseURL.routeTo(this.subscriptionLink);
|
DiscourseURL.routeTo(this.subscriptionLink);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,7 @@ import DiscourseURL from "discourse/lib/url";
|
||||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
import getUrl from "discourse-common/lib/get-url";
|
import getUrl from "discourse-common/lib/get-url";
|
||||||
import { observes } from "discourse-common/utils/decorators";
|
import { observes } from "discourse-common/utils/decorators";
|
||||||
|
import { dasherize } from "@ember/string";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "custom-wizard-edits",
|
name: "custom-wizard-edits",
|
||||||
|
@ -12,14 +13,6 @@ export default {
|
||||||
return;
|
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) => {
|
withPluginApi("0.8.36", (api) => {
|
||||||
api.onAppEvent("page:changed", (data) => {
|
api.onAppEvent("page:changed", (data) => {
|
||||||
const currentUser = container.lookup("service:current-user");
|
const currentUser = container.lookup("service:current-user");
|
||||||
|
@ -36,7 +29,7 @@ export default {
|
||||||
return data.currentRouteName.indexOf(p) > -1;
|
return data.currentRouteName.indexOf(p) > -1;
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
window.location = "/w/" + redirectToWizard.dasherize();
|
DiscourseURL.routeTo(`/w/${dasherize(redirectToWizard)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,6 +13,8 @@ import {
|
||||||
wizardNoUser,
|
wizardNoUser,
|
||||||
wizardNotPermitted,
|
wizardNotPermitted,
|
||||||
} from "../helpers/wizard";
|
} from "../helpers/wizard";
|
||||||
|
import DiscourseURL from "discourse/lib/url";
|
||||||
|
import sinon from "sinon";
|
||||||
|
|
||||||
acceptance("Wizard | Not logged in", function (needs) {
|
acceptance("Wizard | Not logged in", function (needs) {
|
||||||
needs.pretender((server, helper) => {
|
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) {
|
acceptance("Wizard | Wizard", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
needs.pretender((server, helper) => {
|
needs.pretender((server, helper) => {
|
||||||
|
|
Laden …
In neuem Issue referenzieren