From 992737e592c6c4a2928314ee98efa0858c7465a6 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Mon, 11 Sep 2023 16:15:44 +0200 Subject: [PATCH] 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] ``` --- .../widgets/discourse-poll-test.js | 170 +++++++++--------- 1 file changed, 86 insertions(+), 84 deletions(-) diff --git a/plugins/poll/test/javascripts/widgets/discourse-poll-test.js b/plugins/poll/test/javascripts/widgets/discourse-poll-test.js index 546392129a1..f37d3a22144 100644 --- a/plugins/poll/test/javascripts/widgets/discourse-poll-test.js +++ b/plugins/poll/test/javascripts/widgets/discourse-poll-test.js @@ -46,44 +46,36 @@ module("Integration | Component | Widget | discourse-poll", function (hooks) { }); }); - const template = hbs` - - `; - test("can vote", async function (assert) { - this.setProperties({ - post: EmberObject.create({ - id: 42, - topic: { - archived: false, - }, - }), - poll: EmberObject.create({ - name: "poll", - type: "regular", - status: "open", - results: "always", - options: [ - { id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 }, - { id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 }, - ], - voters: 0, - chart_type: "bar", - }), - vote: [], - groupableUserFields: [], - }); + this.set( + "args", + EmberObject.create({ + post: EmberObject.create({ + id: 42, + topic: { + archived: false, + }, + }), + poll: EmberObject.create({ + name: "poll", + type: "regular", + status: "open", + results: "always", + options: [ + { id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 }, + { id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 }, + ], + voters: 0, + chart_type: "bar", + }), + vote: [], + groupableUserFields: [], + }) + ); - await render(template); + await render( + hbs`` + ); 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) { - this.setProperties({ - post: EmberObject.create({ - id: 42, - topic: { - archived: false, - }, - }), - poll: EmberObject.create({ - name: "poll", - type: "regular", - status: "open", - results: "always", - options: [ - { id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 }, - { id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 }, - ], - voters: 0, - chart_type: "bar", - groups: "foo", - }), - vote: [], - groupableUserFields: [], - }); + this.set( + "args", + EmberObject.create({ + post: EmberObject.create({ + id: 42, + topic: { + archived: false, + }, + }), + poll: EmberObject.create({ + name: "poll", + type: "regular", + status: "open", + results: "always", + options: [ + { id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 }, + { id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 }, + ], + voters: 0, + chart_type: "bar", + groups: "foo", + }), + vote: [], + groupableUserFields: [], + }) + ); - await render(template); + await render( + hbs`` + ); 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) { - this.setProperties({ - post: EmberObject.create({ - id: 42, - topic: { - archived: false, - }, - }), - poll: EmberObject.create({ - name: "poll", - type: "multiple", - status: "open", - results: "always", - max: 2, - options: [ - { id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 }, - { id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 }, - ], - voters: 0, - chart_type: "bar", - }), - vote: [], - groupableUserFields: [], - }); + this.set( + "args", + EmberObject.create({ + post: EmberObject.create({ + id: 42, + topic: { + archived: false, + }, + }), + poll: EmberObject.create({ + name: "poll", + type: "multiple", + status: "open", + results: "always", + max: 2, + options: [ + { id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 }, + { id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 }, + ], + voters: 0, + chart_type: "bar", + }), + vote: [], + groupableUserFields: [], + }) + ); - await render(template); + await render( + hbs`` + ); assert.ok(exists(".poll-buttons .cast-votes[disabled=true]")); await click("li[data-poll-option-id='1f972d1df351de3ce35a787c89faad29']");