A platform for community discussion. Free, open, simple.
DEV: Reduce the use of self/set in tests (#31648)
Jarek Radosz299b1b42ec05
diff --git a/app/assets/javascripts/discourse/tests/integration/components/badge-button-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/badge-button-test.gjsindex 22eb297e908..7e34e51d510 100644--- a/app/assets/javascripts/discourse/tests/integration/components/badge-button-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/badge-button-test.gjs@@ -7,31 +7,25 @@ module("Integration | Component | badge-button", function (hooks) {setupRenderingTest(hooks);test("disabled badge", async function (assert) {- const self = this;-- this.set("badge", { enabled: false });+ const badge = { enabled: false };- await render(<template><BadgeButton @badge={{self.badge}} /></template>);+ await render(<template><BadgeButton @badge={{badge}} /></template>);assert.dom(".user-badge.disabled").exists();});test("enabled badge", async function (assert) {- const self = this;-- this.set("badge", { enabled: true });+ const badge = { enabled: true };- await render(<template><BadgeButton @badge={{self.badge}} /></template>);+ await render(<template><BadgeButton @badge={{badge}} /></template>);assert.dom(".user-badge.disabled").doesNotExist();});test("data-badge-name", async function (assert) {- const self = this;-- this.set("badge", { name: "foo" });+ const badge = { name: "foo" };- await render(<template><BadgeButton @badge={{self.badge}} /></template>);+ await render(<template><BadgeButton @badge={{badge}} /></template>);assert.dom('.user-badge[data-badge-name="foo"]').exists();});@@ -59,23 +53,19 @@ module("Integration | Component | badge-button", function (hooks) {});test("icon", async function (assert) {- const self = this;-- this.set("badge", { icon: "xmark" });+ const badge = { icon: "xmark" };- await render(<template><BadgeButton @badge={{self.badge}} /></template>);+ await render(<template><BadgeButton @badge={{badge}} /></template>);assert.dom(".d-icon.d-icon-xmark").exists();});test("accepts block", async function (assert) {- const self = this;-- this.set("badge", {});+ const badge = {};await render(<template>- <BadgeButton @badge={{self.badge}}>+ <BadgeButton @badge={{badge}}><span class="test"></span></BadgeButton></template>@@ -85,35 +75,27 @@ module("Integration | Component | badge-button", function (hooks) {});test("badgeTypeClassName", async function (assert) {- const self = this;+ const badge = { badgeTypeClassName: "foo" };- this.set("badge", { badgeTypeClassName: "foo" });-- await render(<template><BadgeButton @badge={{self.badge}} /></template>);+ await render(<template><BadgeButton @badge={{badge}} /></template>);assert.dom(".user-badge.foo").exists();});test("setting showName to false hides the name", async function (assert) {- const self = this;-- this.set("badge", { name: "foo" });+ const badge = { name: "foo" };await render(- <template>- <BadgeButton @badge={{self.badge}} @showName={{false}} />- </template>+ <template><BadgeButton @badge={{badge}} @showName={{false}} /></template>);assert.dom(".badge-display-name").doesNotExist();});test("showName defaults to true", async function (assert) {- const self = this;-- this.set("badge", { name: "foo" });+ const badge = { name: "foo" };- await render(<template><BadgeButton @badge={{self.badge}} /></template>);+ await render(<template><BadgeButton @badge={{badge}} /></template>);assert.dom(".badge-display-name").exists();});diff --git a/app/assets/javascripts/discourse/tests/integration/components/badge-title-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/badge-title-test.gjsindex 6d6ccb62e74..5270c3696cf 100644--- a/app/assets/javascripts/discourse/tests/integration/components/badge-title-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/badge-title-test.gjs@@ -10,10 +10,8 @@ module("Integration | Component | badge-title", function (hooks) {setupRenderingTest(hooks);test("badge title", async function (assert) {- const self = this;-- this.set("subject", selectKit());- this.set("selectableUserBadges", [+ const subject = selectKit();+ const selectableUserBadges = [EmberObject.create({id: 0,badge: { name: "(none)" },@@ -23,18 +21,18 @@ module("Integration | Component | badge-title", function (hooks) {badge_id: 102,badge: { name: "Test" },}),- ]);+ ];pretender.put("/u/eviltrout/preferences/badge_title", () => response({}));await render(<template>- <BadgeTitle @selectableUserBadges={{self.selectableUserBadges}} />+ <BadgeTitle @selectableUserBadges={{selectableUserBadges}} /></template>);- await this.subject.expand();- await this.subject.selectRowByValue(42);+ await subject.expand();+ await subject.selectRowByValue(42);await click(".btn");assert.strictEqual(this.currentUser.title, "Test");diff --git a/app/assets/javascripts/discourse/tests/integration/components/d-button-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/d-button-test.gjsindex ee9fc6ce033..47dea743038 100644--- a/app/assets/javascripts/discourse/tests/integration/components/d-button-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/d-button-test.gjs@@ -79,13 +79,7 @@ module("Integration | Component | d-button", function (hooks) {});test("isLoading button explicitly set to undefined state", async function (assert) {- const self = this;-- this.set("isLoading");-- await render(- <template><DButton @isLoading={{self.isLoading}} /></template>- );+ await render(<template><DButton @isLoading={{undefined}} /></template>);assert.dom("button.is-loading")diff --git a/app/assets/javascripts/discourse/tests/integration/components/d-toggle-switch-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/d-toggle-switch-test.gjsindex 79a8f845f5f..193b2cad477 100644--- a/app/assets/javascripts/discourse/tests/integration/components/d-toggle-switch-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/d-toggle-switch-test.gjs@@ -8,33 +8,21 @@ module("Integration | Component | d-toggle-switch", function (hooks) {setupRenderingTest(hooks);test("it renders a toggle button in a disabled state", async function (assert) {- const self = this;-- this.set("state", false);-- await render(<template><DToggleSwitch @state={{self.state}} /></template>);+ await render(<template><DToggleSwitch @state={{false}} /></template>);assert.dom(".d-toggle-switch").exists("renders a toggle switch");assert.dom(".d-toggle-switch__checkbox").hasAria("checked", "false");});test("it renders a toggle button in a enabled state", async function (assert) {- const self = this;-- this.set("state", true);-- await render(<template><DToggleSwitch @state={{self.state}} /></template>);+ await render(<template><DToggleSwitch @state={{true}} /></template>);assert.dom(".d-toggle-switch").exists("renders a toggle switch");assert.dom(".d-toggle-switch__checkbox").hasAria("checked", "true");});test("it renders a checkmark icon when enabled", async function (assert) {- const self = this;-- this.set("state", true);-- await render(<template><DToggleSwitch @state={{self.state}} /></template>);+ await render(<template><DToggleSwitch @state={{true}} /></template>);assert.dom(".d-toggle-switch__checkbox-slider .d-icon-check").exists();});diff --git a/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.gjsindex f8433fca644..126ffc80190 100644--- a/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.gjs@@ -3,10 +3,6 @@ import { module, test } from "qunit";import DateTimeInput from "discourse/components/date-time-input";import { setupRenderingTest } from "discourse/tests/helpers/component-test";-function setDate(date) {- this.set("date", date);-}-const DEFAULT_DATE_TIME = moment("2019-01-29 14:45");module("Integration | Component | date-time-input", function (hooks) {@@ -41,7 +37,7 @@ module("Integration | Component | date-time-input", function (hooks) {const self = this;this.setProperties({ date: DEFAULT_DATE_TIME });- this.set("onChange", setDate);+ this.set("onChange", (date) => this.set("date", date));await render(<template>@@ -75,7 +71,7 @@ module("Integration | Component | date-time-input", function (hooks) {this.setProperties({date: moment.tz("2023-05-05T12:00:00", "Europe/London"),timezone: "Europe/London",- onChange: setDate,+ onChange: (date) => this.set("date", date),});await render(diff --git a/app/assets/javascripts/discourse/tests/integration/components/form-template-field/checkbox-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/form-template-field/checkbox-test.gjsindex eca6284006a..9081abc4346 100644--- a/app/assets/javascripts/discourse/tests/integration/components/form-template-field/checkbox-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/form-template-field/checkbox-test.gjs@@ -19,15 +19,12 @@ module(});test("renders a checkbox with a label", async function (assert) {- const self = this;-const attributes = {label: "Click this box",};- this.set("attributes", attributes);await render(- <template><Checkbox @attributes={{self.attributes}} /></template>+ <template><Checkbox @attributes={{attributes}} /></template>);assertdiff --git a/app/assets/javascripts/discourse/tests/integration/components/form-template-field/input-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/form-template-field/input-test.gjsindex 849a44517c1..56d7a905177 100644--- a/app/assets/javascripts/discourse/tests/integration/components/form-template-field/input-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/form-template-field/input-test.gjs@@ -17,16 +17,13 @@ module(});test("renders a text input with attributes", async function (assert) {- const self = this;-const attributes = {label: "My text label",placeholder: "Enter text here",};- this.set("attributes", attributes);await render(- <template><FormInput @attributes={{self.attributes}} /></template>+ <template><FormInput @attributes={{attributes}} /></template>);assert@@ -40,45 +37,36 @@ module(});test("doesn't render a label when attribute is missing", async function (assert) {- const self = this;-const attributes = {placeholder: "Enter text here",};- this.set("attributes", attributes);await render(- <template><FormInput @attributes={{self.attributes}} /></template>+ <template><FormInput @attributes={{attributes}} /></template>);assert.dom(".form-template-field__label").doesNotExist();});test("renders a description if present", async function (assert) {- const self = this;-const attributes = {description: "Your full name",};- this.set("attributes", attributes);await render(- <template><FormInput @attributes={{self.attributes}} /></template>+ <template><FormInput @attributes={{attributes}} /></template>);assert.dom(".form-template-field__description").hasText("Your full name");});test("renders a description if present", async function (assert) {- const self = this;-const attributes = {description: "Write your bio here",};- this.set("attributes", attributes);await render(- <template><FormInput @attributes={{self.attributes}} /></template>+ <template><FormInput @attributes={{attributes}} /></template>);assertdiff --git a/app/assets/javascripts/discourse/tests/integration/components/topic-participant-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/topic-participant-test.gjsindex 7cea8930663..69ba46cc6d7 100644--- a/app/assets/javascripts/discourse/tests/integration/components/topic-participant-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/topic-participant-test.gjs@@ -7,16 +7,14 @@ module("Integration | Component | topic-participant", function (hooks) {setupRenderingTest(hooks);test("one post", async function (assert) {- const self = this;-- this.set("args", {+ const args = {username: "test",avatar_template: "/images/avatar.png",post_count: 1,- });+ };await render(- <template><TopicParticipant @participant={{self.args}} /></template>+ <template><TopicParticipant @participant={{args}} /></template>);assert.dom("a.poster.trigger-user-card").hasAttribute("href", "/u/test");@@ -25,9 +23,7 @@ module("Integration | Component | topic-participant", function (hooks) {});test("many posts, a primary group with flair", async function (assert) {- const self = this;-- this.set("args", {+ const args = {username: "test",avatar_template: "/images/avatar.png",post_count: 2,@@ -36,10 +32,10 @@ module("Integration | Component | topic-participant", function (hooks) {flair_url: "/images/d-logo-sketch-small.png",flair_bg_color: "222",flair_group_id: "41",- });+ };await render(- <template><TopicParticipant @participant={{self.args}} /></template>+ <template><TopicParticipant @participant={{args}} /></template>);assert.dom("a.poster.trigger-user-card").hasAttribute("href", "/u/test");diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-item-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-item-test.gjsindex 78c42b65e26..af602322700 100644--- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-item-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-item-test.gjs@@ -99,47 +99,51 @@ module(});test("pushes is-warning to the classList if the notification originates from a warning PM", async function (assert) {- const self = this;-- this.set(- "item",- getNotification(this.currentUser, this.siteSettings, this.site, {+ const item = getNotification(+ this.currentUser,+ this.siteSettings,+ this.site,+ {is_warning: true,- })+ });- await render(<template><MenuItem @item={{self.item}} /></template>);++ await render(<template><MenuItem @item={{item}} /></template>);+assert.dom("li.is-warning").exists();});test("doesn't push is-warning to the classList if the notification doesn't originate from a warning PM", async function (assert) {- const self = this;-- this.set(- "item",- getNotification(this.currentUser, this.siteSettings, this.site)+ const item = getNotification(+ this.currentUser,+ this.siteSettings,+ this.site);- await render(<template><MenuItem @item={{self.item}} /></template>);++ await render(<template><MenuItem @item={{item}} /></template>);+assert.dom("li.is-warning").doesNotExist();assert.dom("li").exists();});test("the item's href links to the topic that the notification originates from", async function (assert) {- const self = this;-- this.set(- "item",- getNotification(this.currentUser, this.siteSettings, this.site)+ const item = getNotification(+ this.currentUser,+ this.siteSettings,+ this.site);- await render(<template><MenuItem @item={{self.item}} /></template>);++ await render(<template><MenuItem @item={{item}} /></template>);+assert.dom("li a").hasAttribute("href", "/t/this-is-fancy-title/449/113");});test("the item's href links to the group messages if the notification is for a group messages", async function (assert) {- const self = this;-- this.set(- "item",- getNotification(this.currentUser, this.siteSettings, this.site, {+ const item = getNotification(+ this.currentUser,+ this.siteSettings,+ this.site,+ {topic_id: null,post_number: null,slug: null,@@ -148,20 +152,22 @@ module(group_name: "grouperss",username: "ossaama",},- })+ });- await render(<template><MenuItem @item={{self.item}} /></template>);++ await render(<template><MenuItem @item={{item}} /></template>);+assert.dom("li a").hasAttribute("href", "/u/ossaama/messages/grouperss");});test("the item's link has a title for accessibility", async function (assert) {- const self = this;-- this.set(- "item",- getNotification(this.currentUser, this.siteSettings, this.site)+ const item = getNotification(+ this.currentUser,+ this.siteSettings,+ this.site);- await render(<template><MenuItem @item={{self.item}} /></template>);++ await render(<template><MenuItem @item={{item}} /></template>);assert.dom("li a")@@ -169,13 +175,13 @@ module(});test("has elements for label and description", async function (assert) {- const self = this;-- this.set(- "item",- getNotification(this.currentUser, this.siteSettings, this.site)+ const item = getNotification(+ this.currentUser,+ this.siteSettings,+ this.site);- await render(<template><MenuItem @item={{self.item}} /></template>);++ await render(<template><MenuItem @item={{item}} /></template>);assert.dom("li a .item-label")@@ -190,15 +196,16 @@ module(});test("the description falls back to topic_title from data if fancy_title is absent", async function (assert) {- const self = this;-- this.set(- "item",- getNotification(this.currentUser, this.siteSettings, this.site, {+ const item = getNotification(+ this.currentUser,+ this.siteSettings,+ this.site,+ {fancy_title: null,- })+ });- await render(<template><MenuItem @item={{self.item}} /></template>);++ await render(<template><MenuItem @item={{item}} /></template>);assert.dom("li a .item-description")@@ -209,15 +216,17 @@ module(});test("fancy_title is emoji-unescaped", async function (assert) {- const self = this;-- this.set(- "item",- getNotification(this.currentUser, this.siteSettings, this.site, {+ const item = getNotification(+ this.currentUser,+ this.siteSettings,+ this.site,+ {fancy_title: "title with emoji :phone:",- })+ });- await render(<template><MenuItem @item={{self.item}} /></template>);++ await render(<template><MenuItem @item={{item}} /></template>);+assert.dom("li a .item-description img.emoji").exists(@@ -226,18 +235,19 @@ module(});test("topic_title from data is emoji-unescaped safely", async function (assert) {- const self = this;-- this.set(- "item",- getNotification(this.currentUser, this.siteSettings, this.site, {+ const item = getNotification(+ this.currentUser,+ this.siteSettings,+ this.site,+ {fancy_title: null,data: {topic_title: "unsafe title with <a> unescaped emoji :phone:",},- })+ });- await render(<template><MenuItem @item={{self.item}} /></template>);++ await render(<template><MenuItem @item={{item}} /></template>);assert.dom("li a .item-description")@@ -251,8 +261,6 @@ module(});test("various aspects can be customized according to the notification's render director", async function (assert) {- const self = this;-withPluginApi("0.1", (api) => {api.registerNotificationTypeRenderer("linked",@@ -294,14 +302,16 @@ module();});- this.set(- "item",- getNotification(this.currentUser, this.siteSettings, this.site, {+ const item = getNotification(+ this.currentUser,+ this.siteSettings,+ this.site,+ {notification_type: NOTIFICATION_TYPES.linked,- })+ });- await render(<template><MenuItem @item={{self.item}} /></template>);+ await render(<template><MenuItem @item={{item}} /></template>);assert.dom("li.additional.classes")@@ -342,8 +352,6 @@ module(});test("description can be omitted", async function (assert) {- const self = this;-withPluginApi("0.1", (api) => {api.registerNotificationTypeRenderer("linked",@@ -361,14 +369,17 @@ module();});- this.set(- "item",- getNotification(this.currentUser, this.siteSettings, this.site, {+ const item = getNotification(+ this.currentUser,+ this.siteSettings,+ this.site,+ {notification_type: NOTIFICATION_TYPES.linked,- })+ });- await render(<template><MenuItem @item={{self.item}} /></template>);+ await render(<template><MenuItem @item={{item}} /></template>);+assert.dom(".item-description").doesNotExist("description is not rendered");@@ -378,8 +389,6 @@ module(});test("label can be omitted", async function (assert) {- const self = this;-withPluginApi("0.1", (api) => {api.registerNotificationTypeRenderer("linked",@@ -397,14 +406,17 @@ module();});- this.set(- "item",- getNotification(this.currentUser, this.siteSettings, this.site, {+ const item = getNotification(+ this.currentUser,+ this.siteSettings,+ this.site,+ {notification_type: NOTIFICATION_TYPES.linked,- })+ });- await render(<template><MenuItem @item={{self.item}} /></template>);+ await render(<template><MenuItem @item={{item}} /></template>);+assert.dom("li").hasText(@@ -434,17 +446,14 @@ module(setupRenderingTest(hooks);test("item description is the fancy title of the message", async function (assert) {- const self = this;-- this.set(- "item",- getMessage(- { fancy_title: "This is a <b>safe</b> title!" },- this.siteSettings,- this.site- )+ const item = getMessage(+ { fancy_title: "This is a <b>safe</b> title!" },+ this.siteSettings,+ this.site);- await render(<template><MenuItem @item={{self.item}} /></template>);++ await render(<template><MenuItem @item={{item}} /></template>);+assert.dom("li.message .item-description").hasText("This is a safe title!");@@ -506,42 +515,34 @@ module(setupRenderingTest(hooks);test("uses bookmarkable_url for the href", async function (assert) {- const self = this;-- this.set("item", getBookmark({}, this.siteSettings, this.site));- await render(<template><MenuItem @item={{self.item}} /></template>);+ const item = getBookmark({}, this.siteSettings, this.site);+ await render(<template><MenuItem @item={{item}} /></template>);assert.dom("li.bookmark a").hasAttribute("href", /\/t\/this-bookmarkable-url\/227\/1$/);});test("item label is the bookmarked post author", async function (assert) {- const self = this;-- this.set(- "item",- getBookmark(- { user: { username: "bookmarkPostAuthor" } },- this.siteSettings,- this.site- )+ const item = getBookmark(+ { user: { username: "bookmarkPostAuthor" } },+ this.siteSettings,+ this.site);- await render(<template><MenuItem @item={{self.item}} /></template>);++ await render(<template><MenuItem @item={{item}} /></template>);+assert.dom("li.bookmark .item-label").hasText("bookmarkPostAuthor");});test("item description is the bookmark title", async function (assert) {- const self = this;-- this.set(- "item",- getBookmark(- { title: "Custom bookmark title" },- this.siteSettings,- this.site- )+ const item = getBookmark(+ { title: "Custom bookmark title" },+ this.siteSettings,+ this.site);- await render(<template><MenuItem @item={{self.item}} /></template>);++ await render(<template><MenuItem @item={{item}} /></template>);+assert.dom("li.bookmark .item-description").hasText("Custom bookmark title");@@ -550,19 +551,15 @@ module();function getReviewable(currentUser, siteSettings, site, overrides = {}) {- const reviewable = UserMenuReviewable.create(- Object.assign(- {- flagger_username: "sayo2",- id: 17,- pending: false,- post_number: 3,- topic_fancy_title: "anything hello world",- type: "Reviewable",- },- overrides- )- );+ const reviewable = UserMenuReviewable.create({+ flagger_username: "sayo2",+ id: 17,+ pending: false,+ post_number: 3,+ topic_fancy_title: "anything hello world",+ type: "Reviewable",+ ...overrides,+ });return new UserMenuReviewableItem({reviewable,@@ -578,62 +575,68 @@ module(setupRenderingTest(hooks);test("doesn't push `reviewed` to the classList if the reviewable is pending", async function (assert) {- const self = this;-- this.set(- "item",- getReviewable(this.currentUser, this.siteSettings, this.site, {+ const item = getReviewable(+ this.currentUser,+ this.siteSettings,+ this.site,+ {pending: true,- })+ });- await render(<template><MenuItem @item={{self.item}} /></template>);++ await render(<template><MenuItem @item={{item}} /></template>);+assert.dom("li.reviewed").doesNotExist();assert.dom("li").exists();});test("pushes `reviewed` to the classList if the reviewable isn't pending", async function (assert) {- const self = this;-- this.set(- "item",- getReviewable(this.currentUser, this.siteSettings, this.site, {+ const item = getReviewable(+ this.currentUser,+ this.siteSettings,+ this.site,+ {pending: false,- })+ });- await render(<template><MenuItem @item={{self.item}} /></template>);++ await render(<template><MenuItem @item={{item}} /></template>);+assert.dom("li.reviewed").exists();});test("has elements for label and description", async function (assert) {- const self = this;-- this.set(- "item",- getReviewable(this.currentUser, this.siteSettings, this.site)+ const item = getReviewable(+ this.currentUser,+ this.siteSettings,+ this.site);- await render(<template><MenuItem @item={{self.item}} /></template>);++ await render(<template><MenuItem @item={{item}} /></template>);assert.dom("li .item-label").hasText("sayo2", "the label is the flagger_username");assert.dom("li .item-description").hasText(i18n("user_menu.reviewable.default_item", {- reviewable_id: this.item.reviewable.id,+ reviewable_id: item.reviewable.id,}),"displays the description for the reviewable");});test("the item's label is a placeholder that indicates deleted user if flagger_username is absent", async function (assert) {- const self = this;-- this.set(- "item",- getReviewable(this.currentUser, this.siteSettings, this.site, {+ const item = getReviewable(+ this.currentUser,+ this.siteSettings,+ this.site,+ {flagger_username: null,- })+ });- await render(<template><MenuItem @item={{self.item}} /></template>);++ await render(<template><MenuItem @item={{item}} /></template>);+assert.dom("li .item-label").hasText(i18n("user_menu.reviewable.deleted_user"));diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-status-message-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/user-status-message-test.gjsindex e15c7a847e3..402b76ea42c 100644--- a/app/assets/javascripts/discourse/tests/integration/components/user-status-message-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/user-status-message-test.gjs@@ -141,14 +141,10 @@ module("Integration | Component | user-status-message", function (hooks) {});test("accepts a custom css class", async function (assert) {- const self = this;-- this.set("status", { emoji: "tooth", description: "off to dentist" });+ const status = { emoji: "tooth", description: "off to dentist" };await render(- <template>- <UserStatusMessage @status={{self.status}} class="foo" />- </template>+ <template><UserStatusMessage @status={{status}} class="foo" /></template>);assertdiff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/actions-summary-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/widgets/actions-summary-test.gjsindex 5067b64a1d1..82cea27a50d 100644--- a/app/assets/javascripts/discourse/tests/integration/components/widgets/actions-summary-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/actions-summary-test.gjs@@ -7,17 +7,15 @@ module("Integration | Component | Widget | actions-summary", function (hooks) {setupRenderingTest(hooks);test("post deleted", async function (assert) {- const self = this;-- this.set("args", {+ const args = {deleted_at: "2016-01-01",deletedByUsername: "eviltrout",deletedByAvatarTemplate: "/images/avatar.png",- });+ };await render(<template>- <MountWidget @widget="actions-summary" @args={{self.args}} />+ <MountWidget @widget="actions-summary" @args={{args}} /></template>);diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/avatar-flair-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/widgets/avatar-flair-test.gjsindex b9464faaab5..7776c2a939f 100644--- a/app/assets/javascripts/discourse/tests/integration/components/widgets/avatar-flair-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/avatar-flair-test.gjs@@ -7,18 +7,14 @@ module("Integration | Component | Widget | avatar-flair", function (hooks) {setupRenderingTest(hooks);test("avatar flair with an icon", async function (assert) {- const self = this;-- this.set("args", {+ const args = {flair_url: "bars",flair_bg_color: "CC0000",flair_color: "FFFFFF",- });+ };await render(- <template>- <MountWidget @widget="avatar-flair" @args={{self.args}} />- </template>+ <template><MountWidget @widget="avatar-flair" @args={{args}} /></template>);assert.dom(".avatar-flair").exists("has the tag");@@ -30,16 +26,12 @@ module("Integration | Component | Widget | avatar-flair", function (hooks) {});test("avatar flair with an image", async function (assert) {- const self = this;-- this.set("args", {+ const args = {flair_url: "/images/avatar.png",- });+ };await render(- <template>- <MountWidget @widget="avatar-flair" @args={{self.args}} />- </template>+ <template><MountWidget @widget="avatar-flair" @args={{args}} /></template>);assert.dom(".avatar-flair").exists("has the tag");diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/post-cooked-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/widgets/post-cooked-test.gjsindex e5975c55bce..c65f65c9b74 100644--- a/app/assets/javascripts/discourse/tests/integration/components/widgets/post-cooked-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/post-cooked-test.gjs@@ -10,11 +10,9 @@ module("Integration | Component | Widget | post-cooked", function (hooks) {setupRenderingTest(hooks);test("quotes with no username and no valid topic", async function (assert) {- const self = this;-- this.set("args", {+ const args = {cooked: `<aside class=\"quote no-group quote-post-not-found\" data-post=\"1\" data-topic=\"123456\">\n<blockquote>\n<p>abcd</p>\n</blockquote>\n</aside>\n<p>Testing the issue</p>`,- });+ };createWidget("test-widget", {html(attrs) {@@ -25,9 +23,7 @@ module("Integration | Component | Widget | post-cooked", function (hooks) {});await render(- <template>- <MountWidget @widget="test-widget" @args={{self.args}} />- </template>+ <template><MountWidget @widget="test-widget" @args={{args}} /></template>);assert.dom("blockquote").hasText("abcd");diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/post-links-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/widgets/post-links-test.gjsindex cdd06c137a0..35fddc038eb 100644--- a/app/assets/javascripts/discourse/tests/integration/components/widgets/post-links-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/post-links-test.gjs@@ -7,9 +7,7 @@ module("Integration | Component | Widget | post-links", function (hooks) {setupRenderingTest(hooks);test("duplicate links", async function (assert) {- const self = this;-- this.set("args", {+ const args = {id: 2,links: [{@@ -23,12 +21,10 @@ module("Integration | Component | Widget | post-links", function (hooks) {reflection: true,},],- });+ };await render(- <template>- <MountWidget @widget="post-links" @args={{self.args}} />- </template>+ <template><MountWidget @widget="post-links" @args={{args}} /></template>);assert@@ -37,9 +33,7 @@ module("Integration | Component | Widget | post-links", function (hooks) {});test("collapsed links", async function (assert) {- const self = this;-- this.set("args", {+ const args = {id: 1,links: [{@@ -78,12 +72,10 @@ module("Integration | Component | Widget | post-links", function (hooks) {reflection: true,},],- });+ };await render(- <template>- <MountWidget @widget="post-links" @args={{self.args}} />- </template>+ <template><MountWidget @widget="post-links" @args={{args}} /></template>);assert.dom(".expand-links").exists({ count: 1 }, "collapsed by default");diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/poster-name-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/widgets/poster-name-test.gjsindex a751feb9fc7..2630b14a319 100644--- a/app/assets/javascripts/discourse/tests/integration/components/widgets/poster-name-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/poster-name-test.gjs@@ -9,19 +9,15 @@ module("Integration | Component | Widget | poster-name", function (hooks) {setupRenderingTest(hooks);test("basic rendering", async function (assert) {- const self = this;-- this.set("args", {+ const args = {username: "eviltrout",usernameUrl: "/u/eviltrout",name: "Robin Ward",user_title: "Trout Master",- });+ };await render(- <template>- <MountWidget @widget="poster-name" @args={{self.args}} />- </template>+ <template><MountWidget @widget="poster-name" @args={{args}} /></template>);assert.dom(".names").exists();@@ -32,9 +28,7 @@ module("Integration | Component | Widget | poster-name", function (hooks) {});test("extra classes and glyphs", async function (assert) {- const self = this;-- this.set("args", {+ const args = {username: "eviltrout",usernameUrl: "/u/eviltrout",staff: true,@@ -42,12 +36,10 @@ module("Integration | Component | Widget | poster-name", function (hooks) {moderator: true,new_user: true,primary_group_name: "fish",- });+ };await render(- <template>- <MountWidget @widget="poster-name" @args={{self.args}} />- </template>+ <template><MountWidget @widget="poster-name" @args={{args}} /></template>);assert.dom("span.staff").exists();@@ -59,40 +51,30 @@ module("Integration | Component | Widget | poster-name", function (hooks) {});test("disable display name on posts", async function (assert) {- const self = this;-this.siteSettings.display_name_on_posts = false;- this.set("args", { username: "eviltrout", name: "Robin Ward" });+ const args = { username: "eviltrout", name: "Robin Ward" };await render(- <template>- <MountWidget @widget="poster-name" @args={{self.args}} />- </template>+ <template><MountWidget @widget="poster-name" @args={{args}} /></template>);assert.dom(".full-name").doesNotExist();});test("doesn't render a name if it's similar to the username", async function (assert) {- const self = this;-this.siteSettings.prioritize_username_in_ux = true;this.siteSettings.display_name_on_posts = true;- this.set("args", { username: "eviltrout", name: "evil-trout" });+ const args = { username: "eviltrout", name: "evil-trout" };await render(- <template>- <MountWidget @widget="poster-name" @args={{self.args}} />- </template>+ <template><MountWidget @widget="poster-name" @args={{args}} /></template>);assert.dom(".second").doesNotExist();});test("renders badges that are passed in", async function (assert) {- const self = this;-- this.set("args", {+ const args = {username: "eviltrout",usernameUrl: "/u/eviltrout",user: User.create({@@ -102,12 +84,10 @@ module("Integration | Component | Widget | poster-name", function (hooks) {{ id: 1, icon: "heart", slug: "badge1", name: "Badge One" },{ id: 2, icon: "target", slug: "badge2", name: "Badge Two" },].map((badge) => Badge.createFromJson({ badges: [badge] })[0]),- });+ };await render(- <template>- <MountWidget @widget="poster-name" @args={{self.args}} />- </template>+ <template><MountWidget @widget="poster-name" @args={{args}} /></template>);// Check that the custom CSS classes are setdiff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/small-user-list-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/widgets/small-user-list-test.gjsindex ca84a4c3fa7..3a6ccce8a99 100644--- a/app/assets/javascripts/discourse/tests/integration/components/widgets/small-user-list-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/small-user-list-test.gjs@@ -7,19 +7,17 @@ module("Integration | Component | Widget | small-user-list", function (hooks) {setupRenderingTest(hooks);test("renders avatars and support for unknown", async function (assert) {- const self = this;-- this.set("args", {+ const args = {users: [{ id: 456, username: "eviltrout" },{ id: 457, username: "someone", unknown: true },],isVisible: true,- });+ };await render(<template>- <MountWidget @widget="small-user-list" @args={{self.args}} />+ <MountWidget @widget="small-user-list" @args={{args}} /></template>);diff --git a/app/assets/javascripts/discourse/tests/integration/helpers/body-class-test.gjs b/app/assets/javascripts/discourse/tests/integration/helpers/body-class-test.gjsindex 83281173345..a889370de2f 100644--- a/app/assets/javascripts/discourse/tests/integration/helpers/body-class-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/helpers/body-class-test.gjs@@ -13,10 +13,8 @@ module("Integration | Helper | body-class", function (hooks) {});test("Multiple classes", async function (assert) {- const self = this;-- this.set("bar", "bar");- await render(<template>{{bodyClass "baz" self.bar}}</template>);+ const bar = "bar";+ await render(<template>{{bodyClass "baz" bar}}</template>);assert.dom(document.body).hasClass("baz");assert.dom(document.body).hasClass("bar");diff --git a/app/assets/javascripts/discourse/tests/integration/helpers/category-badge-test.gjs b/app/assets/javascripts/discourse/tests/integration/helpers/category-badge-test.gjsindex 73aa9ca6894..4db6d136cb4 100644--- a/app/assets/javascripts/discourse/tests/integration/helpers/category-badge-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/helpers/category-badge-test.gjs@@ -8,27 +8,21 @@ module("Integration | Helper | category-badge", function (hooks) {setupRenderingTest(hooks);test("displays category", async function (assert) {- const self = this;+ const category = Category.findById(1);- this.set("category", Category.findById(1));+ await render(<template>{{categoryBadge category}}</template>);- await render(<template>{{categoryBadge self.category}}</template>);-- assert.dom(".badge-category__name").hasText(this.category.displayName);+ assert.dom(".badge-category__name").hasText(category.displayName);});test("options.link", async function (assert) {- const self = this;-- this.set("category", Category.findById(1));+ const category = Category.findById(1);- await render(- <template>{{categoryBadge self.category link=true}}</template>- );+ await render(<template>{{categoryBadge category link=true}}</template>);assert.dom(- `a.badge-category__wrapper[href="/c/${this.category.slug}/${this.category.id}"]`+ `a.badge-category__wrapper[href="/c/${category.slug}/${category.id}"]`).exists();});diff --git a/app/assets/javascripts/discourse/tests/integration/helpers/concat-class-test.gjs b/app/assets/javascripts/discourse/tests/integration/helpers/concat-class-test.gjsindex 6d675095a1f..6e856b8e3dd 100644--- a/app/assets/javascripts/discourse/tests/integration/helpers/concat-class-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/helpers/concat-class-test.gjs@@ -14,33 +14,28 @@ module("Integration | Helper | concat-class", function (hooks) {});test("Multiple class given", async function (assert) {- const self = this;+ const bar = "bar";- this.set("bar", "bar");await render(- <template><button class={{concatClass "foo" self.bar}} /></template>+ <template><button class={{concatClass "foo" bar}} /></template>);assert.dom("button").hasAttribute("class", "foo bar");});test("One undefined class given", async function (assert) {- const self = this;-- this.set("bar", null);await render(- <template><button class={{concatClass "foo" self.bar}} /></template>+ <template><button class={{concatClass "foo" undefined}} /></template>);assert.dom("button").hasAttribute("class", "foo");});test("Only undefined class given", async function (assert) {- const self = this;+ const bar = null;- this.set("bar", null);await render(- <template><button class={{concatClass null self.bar}} /></template>+ <template><button class={{concatClass null bar}} /></template>);assert.dom("button").doesNotHaveAttribute("class");diff --git a/app/assets/javascripts/discourse/tests/integration/helpers/emoji-test.gjs b/app/assets/javascripts/discourse/tests/integration/helpers/emoji-test.gjsindex 94cd2310f2c..0e1709fe446 100644--- a/app/assets/javascripts/discourse/tests/integration/helpers/emoji-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/helpers/emoji-test.gjs@@ -12,12 +12,9 @@ module("Integration | Helper | emoji", function (hooks) {});test("it renders custom title", async function (assert) {- const self = this;-const title = "custom title";- this.set("title", title);- await render(<template>{{emoji "tada" title=self.title}}</template>);+ await render(<template>{{emoji "tada" title=title}}</template>);assert.dom(`.emoji[title="${title}"]`).exists();});diff --git a/app/assets/javascripts/discourse/tests/integration/helpers/html-safe-test.gjs b/app/assets/javascripts/discourse/tests/integration/helpers/html-safe-test.gjsindex fa864a36aaa..08d72d33b07 100644--- a/app/assets/javascripts/discourse/tests/integration/helpers/html-safe-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/helpers/html-safe-test.gjs@@ -7,11 +7,9 @@ module("Integration | Helper | html-safe", function (hooks) {setupRenderingTest(hooks);test("default", async function (assert) {- const self = this;+ const string = "<p class='cookies'>biscuits</p>";- this.set("string", "<p class='cookies'>biscuits</p>");-- await render(<template>{{htmlSafe self.string}}</template>);+ await render(<template>{{htmlSafe string}}</template>);assert.dom("p.cookies").exists("displays the string as html");});diff --git a/app/assets/javascripts/discourse/tests/integration/helpers/slice-test.gjs b/app/assets/javascripts/discourse/tests/integration/helpers/slice-test.gjsindex afaae5a7143..9326ed591e2 100644--- a/app/assets/javascripts/discourse/tests/integration/helpers/slice-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/helpers/slice-test.gjs@@ -8,21 +8,17 @@ module("Integration | Helper | {{slice}}", function (hooks) {setupRenderingTest(hooks);test("it slices an array with positional params", async function (assert) {- const self = this;-- this.set("array", [2, 4, 6]);+ const array = [2, 4, 6];- await render(<template>{{slice 1 3 self.array}}</template>);+ await render(<template>{{slice 1 3 array}}</template>);assert.dom().hasText("4,6", "sliced values");});test("it slices when only 2 params are passed", async function (assert) {- const self = this;-- this.set("array", [2, 4, 6]);+ const array = [2, 4, 6];- await render(<template>{{slice 1 self.array}}</template>);+ await render(<template>{{slice 1 array}}</template>);assert.dom().hasText("4,6", "sliced values");});@@ -43,14 +39,10 @@ module("Integration | Helper | {{slice}}", function (hooks) {});test("it allows null array", async function (assert) {- const self = this;-- this.set("array", null);-await render(<template>this is all that will render- {{#each (slice 1 2 self.array) as |value|}}+ {{#each (slice 1 2 null) as |value|}}{{value}}{{/each}}</template>@@ -60,14 +52,10 @@ module("Integration | Helper | {{slice}}", function (hooks) {});test("it allows undefined array", async function (assert) {- const self = this;-- this.set("array", undefined);-await render(<template>this is all that will render- {{#each (slice 1 2 self.array) as |value|}}+ {{#each (slice 1 2 undefined) as |value|}}{{value}}{{/each}}</template>