Skip to content

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

DEV: Move and fix incorrectly named tests (#37488)

Jarek Radoszd29d38332fdb
diff --git a/frontend/discourse/tests/integration/components/empty-topic-filter-test.gjs b/frontend/discourse/tests/integration/components/empty-topic-filter-test.gjs
index 05ebc4fecb6..d36b5b230fc 100644
--- a/frontend/discourse/tests/integration/components/empty-topic-filter-test.gjs
+++ b/frontend/discourse/tests/integration/components/empty-topic-filter-test.gjs
@@ -2,6 +2,7 @@ import { click, render } from "@ember/test-helpers";
import { module, test } from "qunit";
import EmptyTopicFilter from "discourse/components/empty-topic-filter";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
+import { i18n } from "discourse-i18n";
module("Integration | Component | EmptyTopicFilter", function (hooks) {
setupRenderingTest(hooks);
@@ -120,4 +121,54 @@ module("Integration | Component | EmptyTopicFilter", function (hooks) {
assert.dom(".empty-state").exists("empty state is rendered");
assert.dom(".empty-state__cta button").exists("CTA button is rendered");
});
+
+ test("renders new education text when newFilter is true", async function (assert) {
+ await render(
+ <template>
+ <EmptyTopicFilter @unreadFilter={{false}} @newFilter={{true}} />
+ </template>
+ );
+
+ assert
+ .dom(".empty-state__title")
+ .hasText(i18n("topics.none.education.new"));
+ });
+
+ test("renders new_new education text when newFilter is true and new_new_view_enabled", async function (assert) {
+ this.currentUser.new_new_view_enabled = true;
+
+ await render(
+ <template>
+ <EmptyTopicFilter @unreadFilter={{false}} @newFilter={{true}} />
+ </template>
+ );
+
+ assert
+ .dom(".empty-state__title")
+ .hasText(i18n("topics.none.education.new_new"));
+ });
+
+ test("renders unread education text when unreadFilter is true", async function (assert) {
+ await render(
+ <template>
+ <EmptyTopicFilter @unreadFilter={{true}} @newFilter={{false}} />
+ </template>
+ );
+
+ assert
+ .dom(".empty-state__title")
+ .hasText(i18n("topics.none.education.unread"));
+ });
+
+ test("renders generic education text when neither newFilter nor unreadFilter is true", async function (assert) {
+ await render(
+ <template>
+ <EmptyTopicFilter @unreadFilter={{false}} @newFilter={{false}} />
+ </template>
+ );
+
+ assert
+ .dom(".empty-state__title")
+ .hasText(i18n("topics.none.education.generic"));
+ });
});
diff --git a/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-desktop.js b/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-desktop-test.js
similarity index 73%
rename from plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-desktop.js
rename to plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-desktop-test.js
index 0e8be798ef8..0418bd5e3b5 100644
--- a/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-desktop.js
+++ b/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-desktop-test.js
@@ -8,11 +8,10 @@ acceptance("Rendering polls with bar charts - desktop", function (needs) {
needs.pretender((server, helper) => {
server.get("/polls/voters.json", (request) => {
- let body = {};
if (
request.queryParams.option_id === "68b434ff88aeae7054e42cd05a4d9056"
) {
- body = {
+ return helper.response({
voters: {
"68b434ff88aeae7054e42cd05a4d9056": [
{
@@ -23,31 +22,28 @@ acceptance("Rendering polls with bar charts - desktop", function (needs) {
},
],
},
- };
+ });
} else {
- body = {
+ return helper.response({
voters: Array.from(new Array(5), (_, i) => ({
id: 600 + i,
username: `bruce${600 + i}`,
avatar_template: "/images/avatar.png",
name: "Bruce Wayne",
})),
- };
+ });
}
- return helper.response(body);
});
});
test("Polls", async function (assert) {
await visit("/t/-/15");
-
assert.dom(".poll").exists({ count: 2 }, "renders the polls correctly");
const polls = document.querySelectorAll(".poll");
assert
.dom(".info-number", polls[0])
.hasText("2", "displays the right number of votes");
-
assert
.dom(".info-number", polls[1])
.hasText("3", "displays the right number of votes");
@@ -55,41 +51,26 @@ acceptance("Rendering polls with bar charts - desktop", function (needs) {
test("Public poll", async function (assert) {
await visit("/t/-/14");
-
assert.dom(".poll").exists({ count: 1 }, "renders the poll correctly");
await click("button.toggle-results");
-
assert
- .dom(".poll-voters:nth-of-type(1) li")
+ .dom(".poll-voters li")
.exists({ count: 25 }, "displays the right number of voters");
- await click(".poll-voters-toggle-expand:nth-of-type(1) a");
-
+ await click(".poll-voters-toggle-expand");
assert
- .dom(".poll-voters:nth-of-type(1) li")
+ .dom(".poll-voters li")
.exists({ count: 26 }, "displays the right number of voters");
});
test("Public number poll", async function (assert) {
await visit("/t/-/13");
-
assert.dom(".poll").exists({ count: 1 }, "renders the poll correctly");
await click("button.toggle-results");
-
- assert
- .dom(".poll-voters:nth-of-type(1) li")
- .exists({ count: 25 }, "displays the right number of voters");
-
- assert
- .dom(".poll-voters:nth-of-type(1) li:nth-of-type(1) a")
- .doesNotHaveAttribute("href", "user URL does not exist");
-
- await click(".poll-voters-toggle-expand:nth-of-type(1) a");
-
assert
- .dom(".poll-voters:nth-of-type(1) li")
- .exists({ count: 30 }, "displays the right number of voters");
+ .dom(".poll-info_counts-count .info-number")
+ .hasText("35", "displays the right number of voters");
});
});
diff --git a/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-mobile.js b/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-mobile-test.js
similarity index 66%
rename from plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-mobile.js
rename to plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-mobile-test.js
index 5e7e932d3b6..19ad0ff92b5 100644
--- a/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-mobile.js
+++ b/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-mobile-test.js
@@ -21,23 +21,11 @@ acceptance("Rendering polls with bar charts - mobile", function (needs) {
test("Public number poll", async function (assert) {
await visit("/t/-/13");
-
assert.dom(".poll").exists({ count: 1 }, "renders the poll correctly");
await click("button.toggle-results");
-
- assert
- .dom(".poll-voters:nth-of-type(1) li")
- .exists({ count: 25 }, "displays the right number of voters");
-
- assert
- .dom(".poll-voters:nth-of-type(1) li:nth-of-type(1) a")
- .doesNotHaveAttribute("href", "user URL does not exist");
-
- await click(".poll-voters-toggle-expand:nth-of-type(1) a");
-
assert
- .dom(".poll-voters:nth-of-type(1) li")
- .exists({ count: 35 }, "displays the right number of voters");
+ .dom(".poll-info_counts-count .info-number")
+ .hasText("35", "displays the right number of voters");
});
});