Skip to content

A platform for community discussion. Free, open, simple.

DEV: Inline the test templates (#31614)

Jarek Radoszb0cf0f89be76
diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/bookmarks-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/bookmarks-list-test.js
index c4d9ff812bd..f6d765554d5 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/bookmarks-list-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/bookmarks-list-test.js
@@ -12,10 +12,8 @@ module(
function (hooks) {
setupRenderingTest(hooks);
- const template = hbs`<UserMenu::BookmarksList/>`;
-
test("renders notifications on top and bookmarks on bottom", async function (assert) {
- await render(template);
+ await render(hbs`<UserMenu::BookmarksList/>`);
const items = queryAll("ul li");
assert.strictEqual(items.length, 2);
@@ -28,7 +26,7 @@ module(
});
test("show all button for bookmark notifications", async function (assert) {
- await render(template);
+ await render(hbs`<UserMenu::BookmarksList/>`);
assert
.dom(".panel-body-bottom .show-all")
.hasAttribute(
@@ -42,7 +40,7 @@ module(
this.currentUser.set("grouped_unread_notifications", {
[NOTIFICATION_TYPES.bookmark_reminder]: 72,
});
- await render(template);
+ await render(hbs`<UserMenu::BookmarksList/>`);
assert
.dom(".panel-body-bottom .notifications-dismiss")
.exists(
@@ -70,7 +68,7 @@ module(
pretender.get("/u/eviltrout/user-menu-bookmarks", () => {
return response({ notifications: [], bookmarks: [] });
});
- await render(template);
+ await render(hbs`<UserMenu::BookmarksList/>`);
assert
.dom(".empty-state-title")
.hasText(i18n("user.no_bookmarks_title"), "empty state title is shown");
diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-item-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-item-test.js
index df574c9cb7c..84025c60886 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-item-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-item-test.js
@@ -52,15 +52,13 @@ module(
function (hooks) {
setupRenderingTest(hooks);
- const template = hbs`<UserMenu::MenuItem @item={{this.item}}/>`;
-
test("pushes `read` to the classList if the notification is read and `unread` if it isn't", async function (assert) {
this.set(
"item",
getNotification(this.currentUser, this.siteSettings, this.site)
);
this.item.notification.read = false;
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert.dom("li.read").doesNotExist();
assert.dom("li.unread").exists();
@@ -80,7 +78,7 @@ module(
"item",
getNotification(this.currentUser, this.siteSettings, this.site)
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert.dom("li").hasClass("mentioned");
this.set(
@@ -103,7 +101,7 @@ module(
is_warning: true,
})
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert.dom("li.is-warning").exists();
});
@@ -112,7 +110,7 @@ module(
"item",
getNotification(this.currentUser, this.siteSettings, this.site)
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert.dom("li.is-warning").doesNotExist();
assert.dom("li").exists();
});
@@ -122,7 +120,7 @@ module(
"item",
getNotification(this.currentUser, this.siteSettings, this.site)
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert.dom("li a").hasAttribute("href", "/t/this-is-fancy-title/449/113");
});
@@ -140,7 +138,7 @@ module(
},
})
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert.dom("li a").hasAttribute("href", "/u/ossaama/messages/grouperss");
});
@@ -149,7 +147,7 @@ module(
"item",
getNotification(this.currentUser, this.siteSettings, this.site)
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert
.dom("li a")
@@ -161,7 +159,7 @@ module(
"item",
getNotification(this.currentUser, this.siteSettings, this.site)
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert
.dom("li a .item-label")
@@ -182,7 +180,7 @@ module(
fancy_title: null,
})
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert
.dom("li a .item-description")
@@ -199,7 +197,7 @@ module(
fancy_title: "title with emoji :phone:",
})
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert
.dom("li a .item-description img.emoji")
.exists(
@@ -217,7 +215,7 @@ module(
},
})
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert
.dom("li a .item-description")
@@ -279,7 +277,7 @@ module(
})
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert
.dom("li.additional.classes")
@@ -344,7 +342,7 @@ module(
})
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert
.dom(".item-description")
.doesNotExist("description is not rendered");
@@ -378,7 +376,7 @@ module(
})
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert
.dom("li")
.hasText(
@@ -407,8 +405,6 @@ module(
function (hooks) {
setupRenderingTest(hooks);
- const template = hbs`<UserMenu::MenuItem @item={{this.item}}/>`;
-
test("item description is the fancy title of the message", async function (assert) {
this.set(
"item",
@@ -418,7 +414,7 @@ module(
this.site
)
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert
.dom("li.message .item-description")
.hasText("This is a safe title!");
@@ -479,11 +475,9 @@ module(
function (hooks) {
setupRenderingTest(hooks);
- const template = hbs`<UserMenu::MenuItem @item={{this.item}}/>`;
-
test("uses bookmarkable_url for the href", async function (assert) {
this.set("item", getBookmark({}, this.siteSettings, this.site));
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert
.dom("li.bookmark a")
.hasAttribute("href", /\/t\/this-bookmarkable-url\/227\/1$/);
@@ -498,7 +492,7 @@ module(
this.site
)
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert.dom("li.bookmark .item-label").hasText("bookmarkPostAuthor");
});
@@ -511,7 +505,7 @@ module(
this.site
)
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert
.dom("li.bookmark .item-description")
.hasText("Custom bookmark title");
@@ -547,8 +541,6 @@ module(
function (hooks) {
setupRenderingTest(hooks);
- const template = hbs`<UserMenu::MenuItem @item={{this.item}}/>`;
-
test("doesn't push `reviewed` to the classList if the reviewable is pending", async function (assert) {
this.set(
"item",
@@ -556,7 +548,7 @@ module(
pending: true,
})
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert.dom("li.reviewed").doesNotExist();
assert.dom("li").exists();
});
@@ -568,7 +560,7 @@ module(
pending: false,
})
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert.dom("li.reviewed").exists();
});
@@ -577,7 +569,7 @@ module(
"item",
getReviewable(this.currentUser, this.siteSettings, this.site)
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert
.dom("li .item-label")
@@ -597,7 +589,7 @@ module(
flagger_username: null,
})
);
- await render(template);
+ await render(hbs`<UserMenu::MenuItem @item={{this.item}}/>`);
assert
.dom("li .item-label")
.hasText(i18n("user_menu.reviewable.deleted_user"));
diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-test.js
index d034257be80..6418a8c12b3 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-test.js
@@ -9,10 +9,8 @@ import { queryAll } from "discourse/tests/helpers/qunit-helpers";
module("Integration | Component | user-menu", function (hooks) {
setupRenderingTest(hooks);
- const template = hbs`<UserMenu::Menu/>`;
-
test("default tab is all notifications", async function (assert) {
- await render(template);
+ await render(hbs`<UserMenu::Menu/>`);
assert
.dom(".top-tabs.tabs-list .btn.active")
@@ -25,13 +23,13 @@ module("Integration | Component | user-menu", function (hooks) {
});
test("active tab has a11y attributes that indicate it's active", async function (assert) {
- await render(template);
+ await render(hbs`<UserMenu::Menu/>`);
assert.dom(".top-tabs.tabs-list .btn.active").hasAttribute("tabindex", "0");
assert.dom(".top-tabs.tabs-list .btn.active").hasAria("selected", "true");
});
test("inactive tab has a11y attributes that indicate it's inactive", async function (assert) {
- await render(template);
+ await render(hbs`<UserMenu::Menu/>`);
assert
.dom(".top-tabs.tabs-list .btn:not(.active)")
.hasAttribute("tabindex", "-1");
@@ -42,7 +40,7 @@ module("Integration | Component | user-menu", function (hooks) {
test("the menu has a group of tabs at the top", async function (assert) {
this.currentUser.set("can_send_private_messages", true);
- await render(template);
+ await render(hbs`<UserMenu::Menu/>`);
const tabs = queryAll(".top-tabs.tabs-list .btn");
assert.strictEqual(tabs.length, 6);
["all-notifications", "replies", "likes", "messages", "bookmarks"].forEach(
@@ -56,7 +54,7 @@ module("Integration | Component | user-menu", function (hooks) {
test("the menu has a group of tabs at the bottom", async function (assert) {
this.currentUser.set("can_send_private_messages", true);
- await render(template);
+ await render(hbs`<UserMenu::Menu/>`);
const tabs = queryAll(".bottom-tabs.tabs-list .btn");
assert.strictEqual(tabs.length, 1);
const profileTab = tabs[0];
@@ -68,7 +66,7 @@ module("Integration | Component | user-menu", function (hooks) {
test("likes tab is hidden if current user's like notifications frequency is 'never'", async function (assert) {
this.currentUser.set("user_option.likes_notifications_disabled", true);
this.currentUser.set("can_send_private_messages", true);
- await render(template);
+ await render(hbs`<UserMenu::Menu/>`);
assert.dom("#user-menu-button-likes").doesNotExist();
const tabs = Array.from(queryAll(".tabs-list .btn")); // top and bottom tabs
@@ -85,7 +83,7 @@ module("Integration | Component | user-menu", function (hooks) {
this.currentUser.set("can_review", true);
this.currentUser.set("reviewable_count", 1);
this.currentUser.set("can_send_private_messages", true);
- await render(template);
+ await render(hbs`<UserMenu::Menu/>`);
assert
.dom("#user-menu-button-review-queue")
@@ -104,7 +102,7 @@ module("Integration | Component | user-menu", function (hooks) {
test("reviewables tab is not shown if current user can review but there are no pending reviewables", async function (assert) {
this.currentUser.set("can_review", true);
this.currentUser.set("reviewable_count", 0);
- await render(template);
+ await render(hbs`<UserMenu::Menu/>`);
assert.dom("#user-menu-button-review-queue").doesNotExist();
});
@@ -114,7 +112,7 @@ module("Integration | Component | user-menu", function (hooks) {
this.currentUser.set("groups", []);
this.currentUser.set("can_send_private_messages", false);
- await render(template);
+ await render(hbs`<UserMenu::Menu/>`);
assert.dom("#user-menu-button-messages").doesNotExist();
@@ -134,7 +132,7 @@ module("Integration | Component | user-menu", function (hooks) {
this.currentUser.set("groups", []);
this.currentUser.set("can_send_private_messages", true);
- await render(template);
+ await render(hbs`<UserMenu::Menu/>`);
assert.dom("#user-menu-button-messages").exists();
});
@@ -142,7 +140,7 @@ module("Integration | Component | user-menu", function (hooks) {
test("reviewables count is shown on the reviewables tab", async function (assert) {
this.currentUser.set("can_review", true);
this.currentUser.set("reviewable_count", 4);
- await render(template);
+ await render(hbs`<UserMenu::Menu/>`);
assert
.dom("#user-menu-button-review-queue .badge-notification")
.hasText("4");
@@ -158,7 +156,7 @@ module("Integration | Component | user-menu", function (hooks) {
test("changing tabs", async function (assert) {
this.currentUser.set("can_review", true);
this.currentUser.set("reviewable_count", 1);
- await render(template);
+ await render(hbs`<UserMenu::Menu/>`);
let queryParams;
pretender.get("/notifications", (request) => {
queryParams = request.queryParams;
@@ -317,7 +315,7 @@ module("Integration | Component | user-menu", function (hooks) {
[NOTIFICATION_TYPES.reaction]: 3,
[NOTIFICATION_TYPES.bookmark_reminder]: 10,
});
- await render(template);
+ await render(hbs`<UserMenu::Menu/>`);
assert
.dom("#user-menu-button-likes .badge-notification")
diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/messages-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/messages-list-test.js
index eec103b195a..a0b186a0496 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/messages-list-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/messages-list-test.js
@@ -92,8 +92,6 @@ function getGroupMessageSummaryNotification(overrides = {}) {
module("Integration | Component | user-menu | messages-list", function (hooks) {
setupRenderingTest(hooks);
- const template = hbs`<UserMenu::MessagesList/>`;
-
test("renders unread PM notifications first followed by messages and read group_message_summary notifications", async function (assert) {
pretender.get("/u/eviltrout/user-menu-private-messages", () => {
const copy = cloneJSON(
@@ -102,7 +100,7 @@ module("Integration | Component | user-menu | messages-list", function (hooks) {
copy.read_notifications = [getGroupMessageSummaryNotification()];
return response(copy);
});
- await render(template);
+ await render(hbs`<UserMenu::MessagesList/>`);
const items = queryAll("ul li");
assert.strictEqual(items.length, 3);
@@ -127,7 +125,7 @@ module("Integration | Component | user-menu | messages-list", function (hooks) {
return response(copy);
});
- await render(template);
+ await render(hbs`<UserMenu::MessagesList/>`);
const items = queryAll("ul li");
assert.strictEqual(items.length, 2);
@@ -149,7 +147,7 @@ module("Integration | Component | user-menu | messages-list", function (hooks) {
return response(copy);
});
- await render(template);
+ await render(hbs`<UserMenu::MessagesList/>`);
const items = queryAll("ul li");
assert.strictEqual(items.length, 2);
@@ -208,7 +206,7 @@ module("Integration | Component | user-menu | messages-list", function (hooks) {
];
return response(copy);
});
- await render(template);
+ await render(hbs`<UserMenu::MessagesList/>`);
const items = queryAll("ul li");
assert.strictEqual(items.length, 6);
@@ -242,7 +240,7 @@ module("Integration | Component | user-menu | messages-list", function (hooks) {
});
test("show all button for message notifications", async function (assert) {
- await render(template);
+ await render(hbs`<UserMenu::MessagesList/>`);
assert
.dom(".panel-body-bottom .show-all")
.hasAttribute(
@@ -256,7 +254,7 @@ module("Integration | Component | user-menu | messages-list", function (hooks) {
this.currentUser.set("grouped_unread_notifications", {
[NOTIFICATION_TYPES.private_message]: 72,
});
- await render(template);
+ await render(hbs`<UserMenu::MessagesList/>`);
assert
.dom(".panel-body-bottom .notifications-dismiss")
@@ -290,7 +288,7 @@ module("Integration | Component | user-menu | messages-list", function (hooks) {
});
});
- await render(template);
+ await render(hbs`<UserMenu::MessagesList/>`);
assert
.dom(".empty-state-title")
diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/notifications-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/notifications-list-test.js
index 1d32999ab1d..569c24b64d8 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/notifications-list-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/notifications-list-test.js
@@ -42,17 +42,15 @@ module(
notificationsFetches = 0;
});
- const template = hbs`<UserMenu::NotificationsList/>`;
-
test("empty state when there are no notifications", async function (assert) {
notificationsData.clear();
- await render(template);
+ await render(hbs`<UserMenu::NotificationsList/>`);
assert.dom(".empty-state .empty-state-title").exists();
assert.dom(".empty-state .empty-state-body").exists();
});
test("doesn't set filter_by_types in the params of the request that fetches the notifications", async function (assert) {
- await render(template);
+ await render(hbs`<UserMenu::NotificationsList/>`);
assert.strictEqual(
queryParams.filter_by_types,
undefined,
@@ -61,12 +59,12 @@ module(
});
test("doesn't request the full notifications list in silent mode", async function (assert) {
- await render(template);
+ await render(hbs`<UserMenu::NotificationsList/>`);
assert.strictEqual(queryParams.silent, undefined);
});
test("show all button for all notifications page", async function (assert) {
- await render(template);
+ await render(hbs`<UserMenu::NotificationsList/>`);
assert
.dom(".panel-body-bottom .btn.show-all")
.hasAttribute(
@@ -80,7 +78,7 @@ module(
this.currentUser.set("grouped_unread_notifications", {
[NOTIFICATION_TYPES.mentioned]: 1,
});
- await render(template);
+ await render(hbs`<UserMenu::NotificationsList/>`);
assert
.dom(".panel-body-bottom .btn.notifications-dismiss")
.hasText(i18n("user.dismiss"), "dismiss button has a label");
@@ -97,14 +95,14 @@ module(
notificationsData.forEach((notification) => {
notification.read = true;
});
- await render(template);
+ await render(hbs`<UserMenu::NotificationsList/>`);
assert
.dom(".panel-body-bottom .btn.notifications-dismiss")
.doesNotExist();
});
test("dismiss button makes a request to the server and then refreshes the notifications list", async function (assert) {
- await render(template);
+ await render(hbs`<UserMenu::NotificationsList/>`);
this.currentUser.set("grouped_unread_notifications", {
[NOTIFICATION_TYPES.mentioned]: 1,
});
@@ -206,7 +204,7 @@ module(
],
});
});
- await render(template);
+ await render(hbs`<UserMenu::NotificationsList/>`);
const items = queryAll("ul li");
assert
.dom(items[0])
diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/reviewables-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/reviewables-list-test.js
index 8a6922698a2..405afbef013 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/reviewables-list-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/reviewables-list-test.js
@@ -10,10 +10,8 @@ module(
function (hooks) {
setupRenderingTest(hooks);
- const template = hbs`<UserMenu::ReviewablesList/>`;
-
test("show all button for reviewable notifications", async function (assert) {
- await render(template);
+ await render(hbs`<UserMenu::ReviewablesList/>`);
assert
.dom(".panel-body-bottom .show-all")
.hasAttribute(
@@ -24,7 +22,7 @@ module(
});
test("renders a list of reviewables", async function (assert) {
- await render(template);
+ await render(hbs`<UserMenu::ReviewablesList/>`);
const reviewables = queryAll("ul li");
assert.strictEqual(reviewables.length, 8);
});
diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/widget-dropdown-test.js b/app/assets/javascripts/discourse/tests/integration/components/widgets/widget-dropdown-test.js
index e0ee65a2919..3c13b7e96cd 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/widgets/widget-dropdown-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/widget-dropdown-test.js
@@ -16,21 +16,6 @@ const DEFAULT_CONTENT = {
label: "foo",
};
-const TEMPLATE = hbs`
- <MountWidget
- @widget="widget-dropdown"
- @args={{hash
- id="my-dropdown"
- icon=this.icon
- label=this.label
- class=this.class
- translatedLabel=this.translatedLabel
- content=this.content
- options=this.options
- }}
- />
-`;
-
module("Integration | Component | Widget | widget-dropdown", function (hooks) {
setupRenderingTest(hooks);
@@ -43,7 +28,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
test("dropdown id", async function (assert) {
this.setProperties(DEFAULT_CONTENT);
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
assert.dom("#my-dropdown").exists();
});
@@ -52,7 +50,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
I18n.translations = { en: { js: { foo: "FooBaz" } } };
this.setProperties(DEFAULT_CONTENT);
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
assert.dom("#my-dropdown .widget-dropdown-header .label").hasText("FooBaz");
});
@@ -62,7 +73,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
this.setProperties(DEFAULT_CONTENT);
this.set("translatedLabel", "BazFoo");
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
assert.dom("#my-dropdown .widget-dropdown-header .label").hasText("BazFoo");
});
@@ -70,7 +94,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
test("content", async function (assert) {
this.setProperties(DEFAULT_CONTENT);
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
await click("#my-dropdown .widget-dropdown-header");
assert
@@ -108,7 +145,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
test("can be opened and closed", async function (assert) {
this.setProperties(DEFAULT_CONTENT);
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
assert.dom("#my-dropdown.closed").exists();
assert.dom("#my-dropdown .widget-dropdown-body").doesNotExist();
@@ -125,7 +175,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
this.setProperties(DEFAULT_CONTENT);
this.set("icon", "xmark");
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
assert.dom("#my-dropdown .widget-dropdown-header .d-icon-xmark").exists();
});
@@ -134,7 +197,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
this.setProperties(DEFAULT_CONTENT);
this.set("class", "activated");
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
assert.dom("#my-dropdown.activated").exists();
});
@@ -142,7 +218,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
test("content with translatedLabel", async function (assert) {
this.setProperties(DEFAULT_CONTENT);
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
await click("#my-dropdown .widget-dropdown-header");
assert.dom("#my-dropdown .widget-dropdown-item.item-2").hasText("FooBar");
@@ -152,7 +241,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
I18n.translations = { en: { js: { foo: "FooBaz" } } };
this.setProperties(DEFAULT_CONTENT);
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
await click("#my-dropdown .widget-dropdown-header");
assert.dom("#my-dropdown .widget-dropdown-item.item-1").hasText("FooBaz");
@@ -161,7 +263,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
test("content with icon", async function (assert) {
this.setProperties(DEFAULT_CONTENT);
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
await click("#my-dropdown .widget-dropdown-header");
assert
@@ -172,7 +287,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
test("content with html", async function (assert) {
this.setProperties(DEFAULT_CONTENT);
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
await click("#my-dropdown .widget-dropdown-header");
assert
@@ -183,7 +311,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
test("separator", async function (assert) {
this.setProperties(DEFAULT_CONTENT);
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
await click("#my-dropdown .widget-dropdown-header");
assert
@@ -194,7 +335,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
test("hides widget if no content", async function (assert) {
this.setProperties({ content: null, label: "foo" });
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
assert.dom("#my-dropdown .widget-dropdown-header").doesNotExist();
assert.dom("#my-dropdown .widget-dropdown-body").doesNotExist();
@@ -204,7 +358,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
this.setProperties(DEFAULT_CONTENT);
this.set("options", { headerClass: "btn-small and-text" });
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
assert.dom("#my-dropdown .widget-dropdown-header").hasClass("btn-small");
assert.dom("#my-dropdown .widget-dropdown-header").hasClass("and-text");
@@ -214,7 +381,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
this.setProperties(DEFAULT_CONTENT);
this.set("options", { bodyClass: "gigantic and-yet-small" });
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
await click("#my-dropdown .widget-dropdown-header");
assert.dom("#my-dropdown .widget-dropdown-body").hasClass("gigantic");
@@ -225,7 +405,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
this.setProperties(DEFAULT_CONTENT);
this.set("options", { caret: true });
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
assert
.dom("#my-dropdown .widget-dropdown-header .d-icon-caret-down")
@@ -236,7 +429,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
this.setProperties(DEFAULT_CONTENT);
this.set("options", { disabled: true });
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
assert.dom("#my-dropdown.disabled").exists();
@@ -249,7 +455,20 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
test("disabled item", async function (assert) {
this.setProperties(DEFAULT_CONTENT);
- await render(TEMPLATE);
+ await render(hbs`
+ <MountWidget
+ @widget="widget-dropdown"
+ @args={{hash
+ id="my-dropdown"
+ icon=this.icon
+ label=this.label
+ class=this.class
+ translatedLabel=this.translatedLabel
+ content=this.content
+ options=this.options
+ }}
+ />
+ `);
await click("#my-dropdown .widget-dropdown-header");
assert.dom(".widget-dropdown-item.item-5.disabled").exists();