1
0
Fork 0

Fix tests and linting

Dieser Commit ist enthalten in:
Angus McLeod 2023-01-26 11:26:24 +01:00
Ursprung 7d2e876584
Commit dfc1540d52
8 geänderte Dateien mit 40 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -46,10 +46,9 @@ export default SingleSelectComponent.extend(Subscription, {
if (allowGuests) {
const filteredFeature = wizardSchema.filters.allow_guests[feature];
if (filteredFeature) {
const filteredAttribute = filteredFeature[attribute];
if (filteredAttribute) {
attributes = attributes.filter(a => filteredAttribute.includes(a))
attributes = attributes.filter((a) => filteredAttribute.includes(a));
}
}
}

Datei anzeigen

@ -18,7 +18,6 @@ const wizard = {
allow_guests: null,
theme_id: null,
permitted: null,
allow_guests: null
},
mapped: ["permitted"],
required: ["id"],
@ -209,10 +208,10 @@ const action = {
const filters = {
allow_guests: {
action: {
type: ['route_to', 'send_message']
}
}
}
type: ["route_to", "send_message"],
},
},
};
const custom_field = {
klass: ["topic", "post", "group", "category"],
@ -228,7 +227,7 @@ const wizardSchema = {
field,
custom_field,
action,
filters
filters,
};
export function buildFieldTypes(types) {

Datei anzeigen

@ -6,6 +6,7 @@ export default Route.extend({
const wizard = getCachedWizard();
if (
wizard &&
(wizard.user || wizard.allow_guests) &&
wizard.permitted &&
!wizard.completed &&
wizard.start

Datei anzeigen

@ -7,7 +7,12 @@ export default Route.extend({
const wizard = getCachedWizard();
this.set("wizard", wizard);
if (!wizard || !wizard.permitted || wizard.completed) {
if (
!wizard ||
(!wizard.user && !wizard.allow_guests) ||
!wizard.permitted ||
wizard.completed
) {
this.replaceWith("customWizard");
}
},

Datei anzeigen

@ -24,6 +24,12 @@ class CustomWizard::Subscription
standard: ['*'],
business: ['*'],
community: ['*']
},
allow_guests: {
none: [],
standard: ['*'],
business: ['*'],
community: ['*']
}
},
step: {

Datei anzeigen

@ -24,6 +24,7 @@ describe CustomWizard::StepsController do
context "with allow_guests enabled" do
before do
enable_subscription("standard")
new_template = wizard_template.dup
new_template["allow_guests"] = true
new_template.delete("actions")

Datei anzeigen

@ -9,6 +9,7 @@ import {
import {
wizard,
wizardCompleted,
wizardGuest,
wizardNoUser,
wizardNotPermitted,
} from "../helpers/wizard";
@ -106,3 +107,19 @@ acceptance("Wizard | Wizard", function (needs) {
assert.strictEqual($("body.custom-wizard").length, 0);
});
});
acceptance("Wizard | Guest access", function (needs) {
needs.pretender((server, helper) => {
server.get("/w/wizard.json", () => helper.response(wizardGuest));
});
test("Does not require login", async function (assert) {
await visit("/w/wizard");
assert.ok(!exists(".wizard-no-access.requires-login"));
});
test("Starts", async function (assert) {
await visit("/w/wizard");
assert.ok(query(".wizard-column"), true);
});
});

Datei anzeigen

@ -6,6 +6,8 @@ import updateJson from "../fixtures/update";
import { cloneJSON } from "discourse-common/lib/object";
const wizardNoUser = cloneJSON(wizardJson);
const wizardGuest = cloneJSON(wizardJson);
wizardGuest.allow_guests = true;
const wizard = cloneJSON(wizardJson);
wizard.user = cloneJSON(userJson);
@ -40,6 +42,7 @@ export {
wizardNoUser,
wizardNotPermitted,
wizardCompleted,
wizardGuest,
stepNotPermitted,
allFieldsWizard,
wizard,