mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 13:06:56 +08:00
DEV: Fix setting-on-hash
deprecation (#23506)
``` deprecate-shim.js:33 DEPRECATION: You set the 'hasSavedVote' property on a {{hash}} object. Setting properties on objects generated by {{hash}} is deprecated. Please update to use an object created with a tracked property or getter, or with a custom helper. [deprecation id: setting-on-hash] ```
This commit is contained in:
@ -46,44 +46,36 @@ module("Integration | Component | Widget | discourse-poll", function (hooks) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const template = hbs`
|
|
||||||
<MountWidget
|
|
||||||
@widget="discourse-poll"
|
|
||||||
@args={{hash
|
|
||||||
id=this.id
|
|
||||||
post=this.post
|
|
||||||
poll=this.poll
|
|
||||||
vote=this.vote
|
|
||||||
groupableUserFields=this.groupableUserFields
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
`;
|
|
||||||
|
|
||||||
test("can vote", async function (assert) {
|
test("can vote", async function (assert) {
|
||||||
this.setProperties({
|
this.set(
|
||||||
post: EmberObject.create({
|
"args",
|
||||||
id: 42,
|
EmberObject.create({
|
||||||
topic: {
|
post: EmberObject.create({
|
||||||
archived: false,
|
id: 42,
|
||||||
},
|
topic: {
|
||||||
}),
|
archived: false,
|
||||||
poll: EmberObject.create({
|
},
|
||||||
name: "poll",
|
}),
|
||||||
type: "regular",
|
poll: EmberObject.create({
|
||||||
status: "open",
|
name: "poll",
|
||||||
results: "always",
|
type: "regular",
|
||||||
options: [
|
status: "open",
|
||||||
{ id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 },
|
results: "always",
|
||||||
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 },
|
options: [
|
||||||
],
|
{ id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 },
|
||||||
voters: 0,
|
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 },
|
||||||
chart_type: "bar",
|
],
|
||||||
}),
|
voters: 0,
|
||||||
vote: [],
|
chart_type: "bar",
|
||||||
groupableUserFields: [],
|
}),
|
||||||
});
|
vote: [],
|
||||||
|
groupableUserFields: [],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
await render(template);
|
await render(
|
||||||
|
hbs`<MountWidget @widget="discourse-poll" @args={{this.args}} />`
|
||||||
|
);
|
||||||
|
|
||||||
requests = 0;
|
requests = 0;
|
||||||
|
|
||||||
@ -103,31 +95,36 @@ module("Integration | Component | Widget | discourse-poll", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("cannot vote if not member of the right group", async function (assert) {
|
test("cannot vote if not member of the right group", async function (assert) {
|
||||||
this.setProperties({
|
this.set(
|
||||||
post: EmberObject.create({
|
"args",
|
||||||
id: 42,
|
EmberObject.create({
|
||||||
topic: {
|
post: EmberObject.create({
|
||||||
archived: false,
|
id: 42,
|
||||||
},
|
topic: {
|
||||||
}),
|
archived: false,
|
||||||
poll: EmberObject.create({
|
},
|
||||||
name: "poll",
|
}),
|
||||||
type: "regular",
|
poll: EmberObject.create({
|
||||||
status: "open",
|
name: "poll",
|
||||||
results: "always",
|
type: "regular",
|
||||||
options: [
|
status: "open",
|
||||||
{ id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 },
|
results: "always",
|
||||||
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 },
|
options: [
|
||||||
],
|
{ id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 },
|
||||||
voters: 0,
|
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 },
|
||||||
chart_type: "bar",
|
],
|
||||||
groups: "foo",
|
voters: 0,
|
||||||
}),
|
chart_type: "bar",
|
||||||
vote: [],
|
groups: "foo",
|
||||||
groupableUserFields: [],
|
}),
|
||||||
});
|
vote: [],
|
||||||
|
groupableUserFields: [],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
await render(template);
|
await render(
|
||||||
|
hbs`<MountWidget @widget="discourse-poll" @args={{this.args}} />`
|
||||||
|
);
|
||||||
|
|
||||||
requests = 0;
|
requests = 0;
|
||||||
|
|
||||||
@ -141,31 +138,36 @@ module("Integration | Component | Widget | discourse-poll", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("voting on a multiple poll with no min attribute", async function (assert) {
|
test("voting on a multiple poll with no min attribute", async function (assert) {
|
||||||
this.setProperties({
|
this.set(
|
||||||
post: EmberObject.create({
|
"args",
|
||||||
id: 42,
|
EmberObject.create({
|
||||||
topic: {
|
post: EmberObject.create({
|
||||||
archived: false,
|
id: 42,
|
||||||
},
|
topic: {
|
||||||
}),
|
archived: false,
|
||||||
poll: EmberObject.create({
|
},
|
||||||
name: "poll",
|
}),
|
||||||
type: "multiple",
|
poll: EmberObject.create({
|
||||||
status: "open",
|
name: "poll",
|
||||||
results: "always",
|
type: "multiple",
|
||||||
max: 2,
|
status: "open",
|
||||||
options: [
|
results: "always",
|
||||||
{ id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 },
|
max: 2,
|
||||||
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 },
|
options: [
|
||||||
],
|
{ id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 },
|
||||||
voters: 0,
|
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 },
|
||||||
chart_type: "bar",
|
],
|
||||||
}),
|
voters: 0,
|
||||||
vote: [],
|
chart_type: "bar",
|
||||||
groupableUserFields: [],
|
}),
|
||||||
});
|
vote: [],
|
||||||
|
groupableUserFields: [],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
await render(template);
|
await render(
|
||||||
|
hbs`<MountWidget @widget="discourse-poll" @args={{this.args}} />`
|
||||||
|
);
|
||||||
assert.ok(exists(".poll-buttons .cast-votes[disabled=true]"));
|
assert.ok(exists(".poll-buttons .cast-votes[disabled=true]"));
|
||||||
|
|
||||||
await click("li[data-poll-option-id='1f972d1df351de3ce35a787c89faad29']");
|
await click("li[data-poll-option-id='1f972d1df351de3ce35a787c89faad29']");
|
||||||
|
Reference in New Issue
Block a user