diff --git a/test/javascripts/acceptance/activity-pub-about-test.js b/test/javascripts/acceptance/activity-pub-about-test.js
index e0d65cda..c737435b 100644
--- a/test/javascripts/acceptance/activity-pub-about-test.js
+++ b/test/javascripts/acceptance/activity-pub-about-test.js
@@ -1,11 +1,7 @@
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
-import {
- acceptance,
- query,
- queryAll,
-} from "discourse/tests/helpers/qunit-helpers";
-import { default as AboutFixtures } from "../fixtures/about-fixtures";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+import AboutFixtures from "../fixtures/about-fixtures";
acceptance("Discourse Activity Pub | About", function (needs) {
needs.site({ activity_pub_enabled: false });
@@ -18,22 +14,18 @@ acceptance("Discourse Activity Pub | About", function (needs) {
test("lists the forum's actors", async function (assert) {
await visit("/ap/about");
- const categoryActors = queryAll(
- ".activity-pub-actors.categories .activity-pub-actor-card"
- );
- assert.strictEqual(categoryActors.length, 2);
+ assert
+ .dom(".activity-pub-actors.categories .activity-pub-actor-card")
+ .exists({ count: 2 });
- const tagActors = queryAll(
- ".activity-pub-actors.tags .activity-pub-actor-card"
- );
- assert.strictEqual(tagActors.length, 1);
+ assert
+ .dom(".activity-pub-actors.tags .activity-pub-actor-card")
+ .exists({ count: 1 });
- assert.strictEqual(
- query(
+ assert
+ .dom(
".activity-pub-actors.categories div.activity-pub-actor-card:first-of-type .follower-count"
- ).innerText.trim(),
- "4 followers",
- "shows the right follower counts"
- );
+ )
+ .hasText("4 followers", "shows the right follower counts");
});
});
diff --git a/test/javascripts/acceptance/activity-pub-admin-test.js b/test/javascripts/acceptance/activity-pub-admin-test.js
index 718ef8a9..d616dac4 100644
--- a/test/javascripts/acceptance/activity-pub-admin-test.js
+++ b/test/javascripts/acceptance/activity-pub-admin-test.js
@@ -6,16 +6,12 @@ import pretender, {
parsePostData,
response,
} from "discourse/tests/helpers/create-pretender";
-import {
- acceptance,
- exists,
- query,
-} from "discourse/tests/helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { i18n } from "discourse-i18n";
-import { default as AdminActors } from "../fixtures/admin-actors-fixtures";
-import { default as Logs } from "../fixtures/logs-fixtures";
-import { default as SiteActors } from "../fixtures/site-actors-fixtures";
+import AdminActors from "../fixtures/admin-actors-fixtures";
+import Logs from "../fixtures/logs-fixtures";
+import SiteActors from "../fixtures/site-actors-fixtures";
const categoryActors =
AdminActors["/admin/plugins/ap/actor?model_type=category"];
@@ -62,57 +58,47 @@ acceptance("Discourse Activity Pub | Admin | Index", function (needs) {
});
await visit("/admin/plugins/ap/actor");
- assert.ok(
- exists(".activity-pub-actor-table"),
- "the actors table is visible"
- );
- assert.strictEqual(
- document.querySelectorAll(".activity-pub-actor-table-row").length,
- 2,
- "enabled and deleted actors are visible"
- );
- assert.ok(
- exists(
+ assert
+ .dom(".activity-pub-actor-table")
+ .exists("the actors table is visible");
+ assert
+ .dom(".activity-pub-actor-table-row")
+ .exists({ count: 2 }, "enabled and deleted actors are visible");
+ assert
+ .dom(
".activity-pub-actor-table-row:nth-of-type(1) .activity-pub-edit-actor-btn"
- ),
- "the edit btn is visible for enabled actors"
- );
- assert.notOk(
- exists(
+ )
+ .exists("the edit btn is visible for enabled actors");
+ assert
+ .dom(
".activity-pub-actor-table-row:nth-of-type(2) .activity-pub-edit-actor-btn"
- ),
- "the edit btn is not visible for deleted actors"
- );
- assert.notOk(
- exists(
+ )
+ .doesNotExist("the edit btn is not visible for deleted actors");
+ assert
+ .dom(
".activity-pub-actor-table-row:nth-of-type(1) .activity-pub-destroy-actor-btn"
- ),
- "the destroy btn is not visible for enabled actors"
- );
- assert.ok(
- exists(
+ )
+ .doesNotExist("the destroy btn is not visible for enabled actors");
+ assert
+ .dom(
".activity-pub-actor-table-row:nth-of-type(2) .activity-pub-destroy-actor-btn"
- ),
- "the destroy btn is visible for deleted actors"
- );
- assert.notOk(
- exists(
+ )
+ .exists("the destroy btn is visible for deleted actors");
+ assert
+ .dom(
".activity-pub-actor-table-row:nth-of-type(1) .activity-pub-restore-actor-btn"
- ),
- "the restore btn is not visible for enabled actors"
- );
- assert.ok(
- exists(
+ )
+ .doesNotExist("the restore btn is not visible for enabled actors");
+ assert
+ .dom(
".activity-pub-actor-table-row:nth-of-type(2) .activity-pub-restore-actor-btn"
- ),
- "the restore btn is visible for deleted actors"
- );
+ )
+ .exists("the restore btn is visible for deleted actors");
await click(".activity-pub-edit-actor-btn");
- assert.ok(
- exists(".admin-plugins.activity-pub.actor-show"),
- "edit button routes to actor show"
- );
+ assert
+ .dom(".admin-plugins.activity-pub.actor-show")
+ .exists("edit button routes to actor show");
});
test("destroy actor", async function (assert) {
@@ -137,7 +123,7 @@ acceptance("Discourse Activity Pub | Admin | Index", function (needs) {
await click(".activity-pub-destroy-actor-btn");
- assert.ok(exists("#dialog-holder"), "confirmation dialog is visible");
+ assert.dom("#dialog-holder").exists("confirmation dialog is visible");
assert.dom(".dialog-body p").hasHtml(
i18n("admin.discourse_activity_pub.actor.destroy.confirm.message", {
actor: deletedActor.handle,
@@ -220,10 +206,9 @@ acceptance("Discourse Activity Pub | Admin | Index", function (needs) {
});
await visit("/admin/plugins/ap/actor");
- assert.ok(
- exists(".activity-pub-add-actor.category"),
- "the add category actor button is visible"
- );
+ assert
+ .dom(".activity-pub-add-actor.category")
+ .exists("the add category actor button is visible");
await click(".activity-pub-add-actor");
assert.strictEqual(
queryParams.model_type,
@@ -232,10 +217,9 @@ acceptance("Discourse Activity Pub | Admin | Index", function (needs) {
);
await visit("/admin/plugins/ap/actor?model_type=tag");
- assert.ok(
- exists(".activity-pub-add-actor.tag"),
- "the add tag actor button is visible"
- );
+ assert
+ .dom(".activity-pub-add-actor.tag")
+ .exists("the add tag actor button is visible");
await click(".activity-pub-add-actor");
assert.strictEqual(
queryParams.model_type,
@@ -261,28 +245,24 @@ acceptance("Discourse Activity Pub | Admin | New Actor", function (needs) {
test("creates a new actor", async function (assert) {
await visit("/admin/plugins/ap/actor/new");
- assert.ok(
- exists(".activity-pub-actor-add"),
- "add actor container is visible"
- );
- assert.ok(
- exists(".activity-pub-new-actor-model"),
- "actor model controls are visible"
- );
+ assert
+ .dom(".activity-pub-actor-add")
+ .exists("add actor container is visible");
+ assert
+ .dom(".activity-pub-new-actor-model")
+ .exists("actor model controls are visible");
- assert.ok(
- exists(".activity-pub-category-chooser"),
- "activity pub category chooser is visible"
- );
+ assert
+ .dom(".activity-pub-category-chooser")
+ .exists("activity pub category chooser is visible");
const categories = selectKit(".activity-pub-category-chooser");
await categories.expand();
await categories.selectRowByValue(6);
- assert.ok(
- exists(".activity-pub-actor-form"),
- "activity pub actor form is visible"
- );
+ assert
+ .dom(".activity-pub-actor-form")
+ .exists("activity pub actor form is visible");
const actor = {
username: "ap_username",
@@ -340,23 +320,20 @@ acceptance("Discourse Activity Pub | Admin | New Actor", function (needs) {
test("creates a new actor with a tag model", async function (assert) {
await visit("/admin/plugins/ap/actor/new?model_type=tag");
- assert.ok(
- exists(".activity-pub-actor-add"),
- "add actor container is visible"
- );
- assert.ok(
- exists(".activity-pub-new-actor-model"),
- "actor model controls are visible"
- );
+ assert
+ .dom(".activity-pub-actor-add")
+ .exists("add actor container is visible");
+ assert
+ .dom(".activity-pub-new-actor-model")
+ .exists("actor model controls are visible");
const tags = selectKit(".activity-pub-actor-add .tag-chooser");
await tags.expand();
await tags.selectRowByName("dog");
- assert.ok(
- exists(".activity-pub-actor-form"),
- "activity pub actor form is visible"
- );
+ assert
+ .dom(".activity-pub-actor-form")
+ .exists("activity pub actor form is visible");
const actor = {
username: "ap_dog",
@@ -415,10 +392,9 @@ acceptance("Discourse Activity Pub | Admin | New Actor", function (needs) {
siteActors.tag.some((a) => a.name === createdActor.name),
"adds the actor to site actors"
);
- assert.ok(
- query(".activity-pub-actor-status.active"),
- "actor has the right status"
- );
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasClass("active", "actor has the right status");
});
});
@@ -442,16 +418,13 @@ acceptance("Discourse Activity Pub | Admin | Edit Actor", function (needs) {
test("edits an actor", async function (assert) {
await visit(`/admin/plugins/ap/actor/${actor.id}`);
- assert.ok(
- exists(".activity-pub-actor-edit"),
- "edit actor container is visible"
- );
- assert.ok(exists(".activity-pub-actor-model"), "actor model is visible");
- assert.strictEqual(
- query(".activity-pub-handle .handle").innerText.trim(),
- actor.handle,
- "shows the right handle"
- );
+ assert
+ .dom(".activity-pub-actor-edit")
+ .exists("edit actor container is visible");
+ assert.dom(".activity-pub-actor-model").exists("actor model is visible");
+ assert
+ .dom(".activity-pub-handle .handle")
+ .hasText(actor.handle, "shows the right handle");
const updates = {
name: "Updated name",
@@ -493,7 +466,7 @@ acceptance("Discourse Activity Pub | Admin | Edit Actor", function (needs) {
await click(".activity-pub-delete-actor");
- assert.ok(exists("#dialog-holder"), "confirmation dialog is visible");
+ assert.dom("#dialog-holder").exists("confirmation dialog is visible");
assert.dom(".dialog-body p").hasHtml(
i18n("admin.discourse_activity_pub.actor.delete.confirm.message", {
actor: actor.handle,
@@ -535,31 +508,26 @@ acceptance("Discourse Activity Pub | Admin | Logs", function (needs) {
test("displays logs", async function (assert) {
await visit("/admin/plugins/ap/log");
- assert.ok(exists(".activity-pub-log-table"), "log table is visible");
- assert.strictEqual(
- document.querySelectorAll(".activity-pub-log-row").length,
- 2,
- "logs are visible"
- );
- assert.ok(
- exists(
+ assert.dom(".activity-pub-log-table").exists("log table is visible");
+ assert
+ .dom(".activity-pub-log-row")
+ .exists({ count: 2 }, "logs are visible");
+ assert
+ .dom(
".activity-pub-log-row:nth-of-type(1) .activity-pub-log-show-json-btn"
- ),
- "shows show json button if log has json"
- );
- assert.notOk(
- exists(
+ )
+ .exists("shows show json button if log has json");
+ assert
+ .dom(
".activity-pub-log-row:nth-of-type(2) .activity-pub-log-show-json-btn"
- ),
- "does not show json button if log does not have json"
- );
+ )
+ .doesNotExist("does not show json button if log does not have json");
await click(
".activity-pub-log-row:nth-of-type(1) .activity-pub-log-show-json-btn"
);
- assert.ok(
- exists(".modal.activity-pub-json-modal"),
- "it shows the log json modal"
- );
+ assert
+ .dom(".modal.activity-pub-json-modal")
+ .exists("shows the log json modal");
});
});
diff --git a/test/javascripts/acceptance/activity-pub-composer-test.js b/test/javascripts/acceptance/activity-pub-composer-test.js
index 5a50981d..c666ac0f 100644
--- a/test/javascripts/acceptance/activity-pub-composer-test.js
+++ b/test/javascripts/acceptance/activity-pub-composer-test.js
@@ -2,14 +2,10 @@ import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
import { cloneJSON } from "discourse/lib/object";
import Site from "discourse/models/site";
-import {
- acceptance,
- exists,
- query,
-} from "discourse/tests/helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { i18n } from "discourse-i18n";
-import { default as SiteActors } from "../fixtures/site-actors-fixtures";
+import SiteActors from "../fixtures/site-actors-fixtures";
acceptance("Discourse Activity Pub | composer", function (needs) {
needs.user();
@@ -24,10 +20,9 @@ acceptance("Discourse Activity Pub | composer", function (needs) {
await visit("/");
await click("#create-topic");
- assert.notOk(
- exists("#reply-control .activity-pub-actor-status"),
- "the status label is not visible"
- );
+ assert
+ .dom("#reply-control .activity-pub-actor-status")
+ .doesNotExist("the status label is not visible");
});
test("with a category with activity pub ready", async function (assert) {
@@ -44,17 +39,15 @@ acceptance("Discourse Activity Pub | composer", function (needs) {
await categoryChooser.expand();
await categoryChooser.selectRowByValue(2);
- assert.ok(
- exists("#reply-control .activity-pub-actor-status"),
- "the status label is visible"
- );
- assert.strictEqual(
- query(
- "#reply-control .activity-pub-actor-status .label"
- ).innerText.trim(),
- i18n("discourse_activity_pub.visibility.label.public"),
- "the status label has the right text"
- );
+ assert
+ .dom("#reply-control .activity-pub-actor-status")
+ .exists("the status label is visible");
+ assert
+ .dom("#reply-control .activity-pub-actor-status .label")
+ .hasText(
+ i18n("discourse_activity_pub.visibility.label.public"),
+ "the status label has the right text"
+ );
});
test("when the plugin is disabled", async function (assert) {
@@ -71,9 +64,8 @@ acceptance("Discourse Activity Pub | composer", function (needs) {
await categoryChooser.expand();
await categoryChooser.selectRowByValue(2);
- assert.notOk(
- exists("#reply-control .activity-pub-actor-status"),
- "the status label is not visible"
- );
+ assert
+ .dom("#reply-control .activity-pub-actor-status")
+ .doesNotExist("the status label is not visible");
});
});
diff --git a/test/javascripts/acceptance/activity-pub-discovery-test.js b/test/javascripts/acceptance/activity-pub-discovery-test.js
index 8fee66a9..a682a4c6 100644
--- a/test/javascripts/acceptance/activity-pub-discovery-test.js
+++ b/test/javascripts/acceptance/activity-pub-discovery-test.js
@@ -2,17 +2,13 @@ import { click, currentURL, triggerEvent, visit } from "@ember/test-helpers";
import { test } from "qunit";
import Category from "discourse/models/category";
import Site from "discourse/models/site";
-import {
- acceptance,
- exists,
- query,
-} from "discourse/tests/helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { i18n } from "discourse-i18n";
-import { default as Actors } from "../fixtures/actors-fixtures";
-import { default as Followers } from "../fixtures/followers-fixtures";
-import { default as Follows } from "../fixtures/follows-fixtures";
-import { default as SiteActors } from "../fixtures/site-actors-fixtures";
+import Actors from "../fixtures/actors-fixtures";
+import Followers from "../fixtures/followers-fixtures";
+import Follows from "../fixtures/follows-fixtures";
+import SiteActors from "../fixtures/site-actors-fixtures";
const actorPath = `/ap/local/actor/2`;
const followsPath = `${actorPath}/follows`;
@@ -31,10 +27,9 @@ acceptance(
test("with a non-category route", async function (assert) {
await visit("/latest");
- assert.notOk(
- exists(".activity-pub-discovery"),
- "the discovery button is not visible"
- );
+ assert
+ .dom(".activity-pub-discovery")
+ .doesNotExist("the discovery button is not visible");
});
test("with a category route without category enabled", async function (assert) {
@@ -42,10 +37,9 @@ acceptance(
await visit(category.url);
- assert.notOk(
- exists(".activity-pub-category-nav.visible"),
- "the activitypub nav button is not visible"
- );
+ assert
+ .dom(".activity-pub-category-nav.visible")
+ .doesNotExist("the ActivityPub nav button is not visible");
});
test("with a category route with category enabled", async function (assert) {
@@ -54,10 +48,9 @@ acceptance(
await visit(category.url);
- assert.notOk(
- exists(".activity-pub-category-nav.visible"),
- "the activitypub nav button is not visible"
- );
+ assert
+ .dom(".activity-pub-category-nav.visible")
+ .doesNotExist("the ActivityPub nav button is not visible");
});
}
);
@@ -111,10 +104,9 @@ acceptance(
await visit("/latest");
- assert.notOk(
- exists(".activity-pub-category-nav.visible"),
- "the activitypub nav button is not visible"
- );
+ assert
+ .dom(".activity-pub-category-nav.visible")
+ .doesNotExist("the ActivityPub nav button is not visible");
});
test("with a category without an activity pub actor", async function (assert) {
@@ -124,10 +116,9 @@ acceptance(
await visit(category.url);
- assert.notOk(
- exists(".activity-pub-category-nav.visible"),
- "the activitypub nav button is not visible"
- );
+ assert
+ .dom(".activity-pub-category-nav.visible")
+ .doesNotExist("the ActivityPub nav button is not visible");
});
test("with a category with an activity pub actor", async function (assert) {
@@ -137,19 +128,16 @@ acceptance(
await visit(category.url);
- assert.ok(
- exists(".activity-pub-route-nav.visible"),
- "the activitypub nav button is visible"
- );
+ assert
+ .dom(".activity-pub-route-nav.visible")
+ .exists("the ActivityPub nav button is visible");
await click(".activity-pub-route-nav");
- assert.ok(
- exists(".activity-pub-banner"),
- "the activitypub category banner is visible"
- );
- assert.strictEqual(
- query(".activity-pub-banner-text .desktop").textContent.trim(),
+ assert
+ .dom(".activity-pub-banner")
+ .exists("the ActivityPub category banner is visible");
+ assert.dom(".activity-pub-banner-text .desktop").hasText(
i18n("discourse_activity_pub.banner.text", {
model_name: "Cat 2",
}),
@@ -157,11 +145,12 @@ acceptance(
);
await triggerEvent(".fk-d-tooltip__trigger", "pointermove");
- assert.equal(
- query(".fk-d-tooltip__inner-content").textContent.trim(),
- i18n("discourse_activity_pub.banner.public_first_post"),
- "shows the right category banner tip"
- );
+ assert
+ .dom(".fk-d-tooltip__inner-content")
+ .hasText(
+ i18n("discourse_activity_pub.banner.public_first_post"),
+ "shows the right category banner tip"
+ );
});
test("when routing from a category with an actor to one without", async function (assert) {
@@ -170,19 +159,17 @@ acceptance(
await visit(category.url);
- assert.ok(
- exists(".activity-pub-route-nav.visible"),
- "the activitypub nav button is visible"
- );
+ assert
+ .dom(".activity-pub-route-nav.visible")
+ .exists("the ActivityPub nav button is visible");
const categoryDrop = selectKit(".category-drop");
await categoryDrop.expand();
await categoryDrop.selectRowByValue(7);
- assert.notOk(
- exists(".activity-pub-route-nav.visible"),
- "the activitypub nav button is not visible"
- );
+ assert
+ .dom(".activity-pub-route-nav.visible")
+ .doesNotExist("the ActivityPub nav button is not visible");
});
test("when routing from a tag with an actor to one without", async function (assert) {
@@ -193,19 +180,17 @@ acceptance(
await visit("/tag/monkey");
- assert.ok(
- exists(".activity-pub-route-nav.visible"),
- "the activitypub nav button is visible"
- );
+ assert
+ .dom(".activity-pub-route-nav.visible")
+ .exists("the ActivityPub nav button is visible");
const tagDrop = selectKit(".tag-drop");
await tagDrop.expand();
await tagDrop.selectRowByName("dog");
- assert.notOk(
- exists(".activity-pub-route-nav.visible"),
- "the activitypub nav button is not visible"
- );
+ assert
+ .dom(".activity-pub-route-nav.visible")
+ .doesNotExist("the ActivityPub nav button is not visible");
});
}
);
@@ -230,16 +215,15 @@ acceptance(
await visit(category.url);
await click(".activity-pub-route-nav");
- assert.notOk(
- exists(".activity-pub-banner"),
- "the activitypub banner is not visible"
- );
+ assert
+ .dom(".activity-pub-banner")
+ .doesNotExist("the ActivityPub banner is not visible");
});
}
);
acceptance(
- "Discourse Activity Pub | Discovery activitypub followers route with publishing disabled",
+ "Discourse Activity Pub | Discovery ActivityPub followers route with publishing disabled",
function (needs) {
needs.user();
needs.site({
@@ -261,7 +245,7 @@ acceptance(
);
acceptance(
- "Discourse Activity Pub | Discovery activitypub followers route without followers",
+ "Discourse Activity Pub | Discovery ActivityPub followers route without followers",
function (needs) {
needs.user();
needs.site({
@@ -279,21 +263,18 @@ acceptance(
test("with activity pub ready", async function (assert) {
await visit(followersPath);
- assert.notOk(
- exists(".activity-pub-follow-table.followers"),
- "the activitypub followers table is not visible"
- );
- assert.equal(
- query(".activity-pub-followers-container").innerText,
- i18n("search.no_results"),
- "no results shown"
- );
+ assert
+ .dom(".activity-pub-follow-table.followers")
+ .doesNotExist("the ActivityPub followers table is not visible");
+ assert
+ .dom(".activity-pub-followers-container")
+ .hasText(i18n("search.no_results"), "no results shown");
});
}
);
acceptance(
- "Discourse Activity Pub | Discovery activitypub followers route with followers",
+ "Discourse Activity Pub | Discovery ActivityPub followers route with followers",
function (needs) {
needs.user();
needs.site({
@@ -311,64 +292,52 @@ acceptance(
test("with activity pub ready", async function (assert) {
await visit(followersPath);
- assert.ok(
- exists(".activity-pub-follow-table.followers"),
- "the activitypub followers table is visible"
- );
+ assert
+ .dom(".activity-pub-follow-table.followers")
+ .exists("the ActivityPub followers table is visible");
assert.strictEqual(
document.querySelectorAll(".activity-pub-follow-table-row").length,
2,
"followers are visible"
);
- assert.ok(
- query(".activity-pub-actor-image img").src.includes(
- "/images/avatar.png"
- ),
- "follower image is visible"
- );
- assert.equal(
- query(".activity-pub-actor-name").innerText,
- "Angus",
- "follower name is visible"
- );
- assert.equal(
- query(".activity-pub-actor-handle").innerText,
- "@angus_ap@test.local",
- "follower handle is visible"
- );
- assert.ok(
- query(".activity-pub-follow-table-user a.avatar").href.includes(
- "/u/angus"
- ),
- "follower user avatar is visible"
- );
- assert.equal(
- query(".activity-pub-follow-table-followed-at").innerText,
- "Feb 8, 2013",
- "follower followed at is visible"
- );
- assert.ok(
- exists(".activity-pub-follow-btn"),
- "the activitypub follow btn is visible"
- );
+ assert
+ .dom(".activity-pub-actor-image img")
+ .hasAttribute(
+ "src",
+ /\/images\/avatar\.png/,
+ "follower image is visible"
+ );
+ assert
+ .dom(".activity-pub-actor-name")
+ .hasText("Angus", "follower name is visible");
+ assert
+ .dom(".activity-pub-actor-handle")
+ .hasText("@angus_ap@test.local", "follower handle is visible");
+ assert
+ .dom(".activity-pub-follow-table-user a.avatar")
+ .hasAttribute("href", /\/u\/angus/, "follower user avatar is visible");
+ assert
+ .dom(".activity-pub-follow-table-followed-at")
+ .hasText("Feb 8, 2013", "follower followed at is visible");
+ assert
+ .dom(".activity-pub-follow-btn")
+ .exists("the ActivityPub follow btn is visible");
await click(".activity-pub-follow-btn");
- assert.ok(
- exists(".modal.activity-pub-follow-modal"),
- "it shows the activitypub follow modal"
- );
- assert.equal(
- query("#discourse-modal-title").innerText,
+ assert
+ .dom(".modal.activity-pub-follow-modal")
+ .exists("shows the ActivityPub follow modal");
+ assert.dom("#discourse-modal-title").hasText(
i18n("discourse_activity_pub.follow.title", {
actor: "Cat 2",
}),
- "activitypub modal has the right title"
+ "ActivityPub modal has the right title"
);
});
}
);
acceptance(
- "Discourse Activity Pub | Discovery activitypub follows route with no admin actor permission",
+ "Discourse Activity Pub | Discovery ActivityPub follows route with no admin actor permission",
function (needs) {
needs.user();
needs.site({
@@ -388,56 +357,45 @@ acceptance(
test("with activity pub ready", async function (assert) {
await visit("/ap/local/actor/1/follows");
- assert.ok(
- exists(".activity-pub-follow-table.follows"),
- "the activitypub follows table is visible"
- );
+ assert
+ .dom(".activity-pub-follow-table.follows")
+ .exists("the ActivityPub follows table is visible");
assert.strictEqual(
document.querySelectorAll(".activity-pub-follow-table-row").length,
2,
"follows are visible"
);
- assert.ok(
- query(".activity-pub-actor-image img").src.includes(
- "/images/avatar.png"
- ),
- "follower image is visible"
- );
- assert.equal(
- query(".activity-pub-actor-name").innerText,
- "Angus",
- "follower name is visible"
- );
- assert.equal(
- query(".activity-pub-actor-handle").innerText,
- "@angus_ap@test.local",
- "follow handle is visible"
- );
- assert.ok(
- query(".activity-pub-follow-table-user a.avatar").href.includes(
- "/u/angus"
- ),
- "follow user avatar is visible"
- );
- assert.equal(
- query(".activity-pub-follow-table-followed-at").innerText,
- "Feb 8, 2013",
- "follower followed at is visible"
- );
- assert.notOk(
- exists(".activity-pub-actor-follow-btn"),
- "the activitypub actor follow btn is not visible"
- );
- assert.notOk(
- exists(".activity-pub-actor-unfollow-btn"),
- "the activitypub actor unfollow btn is not visible"
- );
+ assert
+ .dom(".activity-pub-actor-image img")
+ .hasAttribute(
+ "src",
+ /\/images\/avatar\.png/,
+ "follower image is visible"
+ );
+ assert
+ .dom(".activity-pub-actor-name")
+ .hasText("Angus", "follower name is visible");
+ assert
+ .dom(".activity-pub-actor-handle")
+ .hasText("@angus_ap@test.local", "follow handle is visible");
+ assert
+ .dom(".activity-pub-follow-table-user a.avatar")
+ .hasAttribute("href", /\/u\/angus/, "follow user avatar is visible");
+ assert
+ .dom(".activity-pub-follow-table-followed-at")
+ .hasText("Feb 8, 2013", "follower followed at is visible");
+ assert
+ .dom(".activity-pub-actor-follow-btn")
+ .doesNotExist("the ActivityPub actor follow btn is not visible");
+ assert
+ .dom(".activity-pub-actor-unfollow-btn")
+ .doesNotExist("the ActivityPub actor unfollow btn is not visible");
});
}
);
acceptance(
- "Discourse Activity Pub | Discovery activitypub subcategory follows route with admin actor permission",
+ "Discourse Activity Pub | Discovery ActivityPub subcategory follows route with admin actor permission",
function (needs) {
needs.user();
needs.site({
@@ -457,16 +415,15 @@ acceptance(
test("with activity pub ready", async function (assert) {
await visit("/ap/local/actor/3/follows");
- assert.ok(
- exists(".activity-pub-follows-container"),
- "the activitypub follows route is visible"
- );
+ assert
+ .dom(".activity-pub-follows-container")
+ .exists("the ActivityPub follows route is visible");
});
}
);
acceptance(
- "Discourse Activity Pub | Discovery activitypub category follows route with admin actor permission with followers",
+ "Discourse Activity Pub | Discovery ActivityPub category follows route with admin actor permission with followers",
function (needs) {
needs.user();
needs.site({
@@ -484,75 +441,60 @@ acceptance(
test("with activity pub ready", async function (assert) {
await visit(followsPath);
- assert.ok(
- exists(".activity-pub-follow-table.follows"),
- "the activitypub follows table is visible"
- );
+ assert
+ .dom(".activity-pub-follow-table.follows")
+ .exists("the ActivityPub follows table is visible");
assert.strictEqual(
document.querySelectorAll(".activity-pub-follow-table-row").length,
2,
"follows are visible"
);
- assert.ok(
- query(".activity-pub-actor-image img").src.includes(
- "/images/avatar.png"
- ),
- "follower image is visible"
- );
- assert.equal(
- query(".activity-pub-actor-name").innerText,
- "Angus",
- "follower name is visible"
- );
- assert.equal(
- query(".activity-pub-actor-handle").innerText,
- "@angus_ap@test.local",
- "follow handle is visible"
- );
- assert.ok(
- query(".activity-pub-follow-table-user a.avatar").href.includes(
- "/u/angus"
- ),
- "follow user avatar is visible"
- );
- assert.equal(
- query(".activity-pub-follow-table-followed-at").innerText,
- "Feb 8, 2013",
- "follower followed at is visible"
- );
-
- assert.ok(
- exists(".activity-pub-actor-follow-btn"),
- "the activitypub actor follow btn is visible"
- );
+ assert
+ .dom(".activity-pub-actor-image img")
+ .hasAttribute(
+ "src",
+ /\/images\/avatar\.png/,
+ "follower image is visible"
+ );
+ assert
+ .dom(".activity-pub-actor-name")
+ .hasText("Angus", "follower name is visible");
+ assert
+ .dom(".activity-pub-actor-handle")
+ .hasText("@angus_ap@test.local", "follow handle is visible");
+ assert
+ .dom(".activity-pub-follow-table-user a.avatar")
+ .hasAttribute("href", /\/u\/angus/, "follow user avatar is visible");
+ assert
+ .dom(".activity-pub-follow-table-followed-at")
+ .hasText("Feb 8, 2013", "follower followed at is visible");
+
+ assert
+ .dom(".activity-pub-actor-follow-btn")
+ .exists("the ActivityPub actor follow btn is visible");
await click(".activity-pub-actor-follow-btn");
- assert.ok(
- exists(".modal.activity-pub-actor-follow-modal"),
- "it shows the activitypub actor follow modal"
- );
- assert.equal(
- query("#discourse-modal-title").innerText,
+ assert
+ .dom(".modal.activity-pub-actor-follow-modal")
+ .exists("shows the ActivityPub actor follow modal");
+ assert.dom("#discourse-modal-title").hasText(
i18n("discourse_activity_pub.actor_follow.title", {
actor: "Cat 2",
}),
- "activitypub actor follow modal has the right title"
+ "ActivityPub actor follow modal has the right title"
);
- assert.ok(
- exists(".activity-pub-actor-unfollow-btn"),
- "the activitypub actor unfollow btn is visible"
- );
+ assert
+ .dom(".activity-pub-actor-unfollow-btn")
+ .exists("the ActivityPub actor unfollow btn is visible");
await click(".activity-pub-actor-unfollow-btn");
- assert.ok(
- exists(".modal.activity-pub-actor-unfollow-modal"),
- "it shows the activitypub actor unfollow modal"
- );
- assert.equal(
- query("#discourse-modal-title").innerText,
+ assert
+ .dom(".modal.activity-pub-actor-unfollow-modal")
+ .exists("shows the ActivityPub actor unfollow modal");
+ assert.dom("#discourse-modal-title").hasText(
i18n("discourse_activity_pub.actor_unfollow.modal_title", {
actor: "Cat 2",
}),
- "activitypub actor unfollow modal has the right title"
+ "ActivityPub actor unfollow modal has the right title"
);
});
}
diff --git a/test/javascripts/acceptance/activity-pub-preferences-test.js b/test/javascripts/acceptance/activity-pub-preferences-test.js
index a1fd5f2b..38f8b626 100644
--- a/test/javascripts/acceptance/activity-pub-preferences-test.js
+++ b/test/javascripts/acceptance/activity-pub-preferences-test.js
@@ -2,11 +2,9 @@ import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import {
acceptance,
- exists,
loggedInUser,
- query,
} from "discourse/tests/helpers/qunit-helpers";
-import { default as Authorizations } from "../fixtures/authorization-fixtures";
+import Authorizations from "../fixtures/authorization-fixtures";
acceptance("Discourse Activity Pub | Preferences", function (needs) {
needs.user();
@@ -19,34 +17,30 @@ acceptance("Discourse Activity Pub | Preferences", function (needs) {
test("displays account authorization section", async function (assert) {
await visit(`/u/${loggedInUser().username}/preferences/activity-pub`);
- assert.ok(exists(".activity-pub-authorize"));
+ assert.dom(".activity-pub-authorize").exists();
});
test("displays account authorizations", async function (assert) {
await visit(`/u/${loggedInUser().username}/preferences/activity-pub`);
- assert.ok(
- exists(".activity-pub-authorizations .activity-pub-actor-table"),
- "the authorizations table is visible"
- );
- assert.strictEqual(
- document.querySelectorAll(".activity-pub-actor-table-row").length,
- 2,
- "authorized actors are visible"
- );
- assert.ok(
- query(".activity-pub-actor-image img").src.includes("/images/avatar.png"),
- "authorized actor image is visible"
- );
- assert.equal(
- query(".activity-pub-actor-name").innerText,
- "Angus",
- "authorized actor name is visible"
- );
- assert.equal(
- query(".activity-pub-actor-handle").innerText,
- "@angus_ap@test.local",
- "authorized actor handle is visible"
- );
+ assert
+ .dom(".activity-pub-authorizations .activity-pub-actor-table")
+ .exists("the authorizations table is visible");
+ assert
+ .dom(".activity-pub-actor-table-row")
+ .exists({ count: 2 }, "authorized actors are visible");
+ assert
+ .dom(".activity-pub-actor-image img")
+ .hasAttribute(
+ "src",
+ /\/images\/avatar\.png/,
+ "authorized actor image is visible"
+ );
+ assert
+ .dom(".activity-pub-actor-name")
+ .hasText("Angus", "authorized actor name is visible");
+ assert
+ .dom(".activity-pub-actor-handle")
+ .hasText("@angus_ap@test.local", "authorized actor handle is visible");
});
});
diff --git a/test/javascripts/acceptance/activity-pub-topic-test.js b/test/javascripts/acceptance/activity-pub-topic-test.js
index be540c3c..f2b5518d 100644
--- a/test/javascripts/acceptance/activity-pub-topic-test.js
+++ b/test/javascripts/acceptance/activity-pub-topic-test.js
@@ -6,12 +6,10 @@ import Site from "discourse/models/site";
import topicFixtures from "discourse/tests/fixtures/topic";
import {
acceptance,
- exists,
publishToMessageBus,
- query,
} from "discourse/tests/helpers/qunit-helpers";
import { i18n } from "discourse-i18n";
-import { default as SiteActors } from "../fixtures/site-actors-fixtures";
+import SiteActors from "../fixtures/site-actors-fixtures";
const createdAt = moment().subtract(2, "days");
const scheduledAt = moment().add(3, "minutes");
@@ -80,14 +78,12 @@ acceptance(
await visit("/t/280");
- assert.notOk(
- exists(".topic-map__activity-pub"),
- "the topic map is not visible"
- );
- assert.notOk(
- exists(".topic-post:nth-of-type(2) .post-info.activity-pub"),
- "the post status is not visible"
- );
+ assert
+ .dom(".topic-map__activity-pub")
+ .doesNotExist("the topic map is not visible");
+ assert
+ .dom(".topic-post:nth-of-type(2) .post-info.activity-pub")
+ .doesNotExist("the post status is not visible");
});
}
);
@@ -119,10 +115,9 @@ acceptance(
await visit("/t/280");
- assert.notOk(
- exists(".topic-map__activity-pub"),
- "the activity pub topic map is not visible"
- );
+ assert
+ .dom(".topic-map__activity-pub")
+ .doesNotExist("the activity pub topic map is not visible");
});
test("When the plugin is enabled", async function (assert) {
@@ -134,11 +129,10 @@ acceptance(
await visit("/t/280");
- assert.ok(exists(".topic-map__activity-pub"), "the topic map is visible");
- assert.ok(
- exists(".topic-post:nth-of-type(3) .post-info.activity-pub"),
- "is visible"
- );
+ assert.dom(".topic-map__activity-pub").exists("the topic map is visible");
+ assert
+ .dom(".topic-post:nth-of-type(3) .post-info.activity-pub")
+ .exists("is visible");
});
test("post status update", async function (assert) {
@@ -161,14 +155,13 @@ acceptance(
};
await publishToMessageBus("/activity-pub", postStatusUpdate);
- assert.ok(
- exists(
+ assert
+ .dom(
`.topic-post:nth-of-type(3) .activity-pub-post-status[title='Post was deleted via ActivityPub on ${deletedAt.format(
i18n("dates.time_short_day")
)}.']`
- ),
- "shows the right post status text"
- );
+ )
+ .exists("shows the right post status text");
});
}
);
@@ -199,10 +192,9 @@ acceptance(
await visit("/t/280");
- assert.notOk(
- exists(".topic-map__activity-pub"),
- "the activity pub topic map is not visible"
- );
+ assert
+ .dom(".topic-map__activity-pub")
+ .doesNotExist("the activity pub topic map is not visible");
});
test("When the plugin is enabled", async function (assert) {
@@ -214,11 +206,10 @@ acceptance(
await visit("/t/280");
- assert.ok(exists(".topic-map__activity-pub"), "the topic map is visible");
- assert.ok(
- exists(".topic-post:nth-of-type(3) .post-info.activity-pub"),
- "is visible"
- );
+ assert.dom(".topic-map__activity-pub").exists("the topic map is visible");
+ assert
+ .dom(".topic-post:nth-of-type(3) .post-info.activity-pub")
+ .exists("is visible");
});
}
);
@@ -248,15 +239,14 @@ acceptance(
await visit("/t/280");
- assert.strictEqual(
- query(
- ".topic-map__activity-pub .activity-pub-topic-status"
- ).innerText.trim(),
- `Topic is scheduled to be published via ActivityPub on ${scheduledAt.format(
- i18n("dates.time_short_day")
- )}.`,
- "shows the right status text"
- );
+ assert
+ .dom(".topic-map__activity-pub .activity-pub-topic-status")
+ .hasText(
+ `Topic is scheduled to be published via ActivityPub on ${scheduledAt.format(
+ i18n("dates.time_short_day")
+ )}.`,
+ "shows the right status text"
+ );
});
}
);
@@ -298,10 +288,9 @@ acceptance(
await visit("/t/280");
- assert.notOk(
- exists(".topic-map__activity-pub"),
- "the topic map is not visible"
- );
+ assert
+ .dom(".topic-map__activity-pub")
+ .doesNotExist("the topic map is not visible");
});
test("topic map", async function (assert) {
@@ -312,15 +301,14 @@ acceptance(
await visit("/t/280");
- assert.strictEqual(
- query(
- ".topic-map__activity-pub .activity-pub-topic-status"
- ).innerText.trim(),
- `Topic was published via ActivityPub on ${publishedAt.format(
- i18n("dates.time_short_day")
- )}.`,
- "shows the right status text"
- );
+ assert
+ .dom(".topic-map__activity-pub .activity-pub-topic-status")
+ .hasText(
+ `Topic was published via ActivityPub on ${publishedAt.format(
+ i18n("dates.time_short_day")
+ )}.`,
+ "shows the right status text"
+ );
});
test("topic status update", async function (assert) {
@@ -341,15 +329,14 @@ acceptance(
};
await publishToMessageBus("/activity-pub", topicStatusUpdate);
- assert.strictEqual(
- query(
- ".topic-map__activity-pub .activity-pub-topic-status"
- ).innerText.trim(),
- `Topic was deleted via ActivityPub on ${deletedAt.format(
- i18n("dates.time_short_day")
- )}.`,
- "shows the right status text"
- );
+ assert
+ .dom(".topic-map__activity-pub .activity-pub-topic-status")
+ .hasText(
+ `Topic was deleted via ActivityPub on ${deletedAt.format(
+ i18n("dates.time_short_day")
+ )}.`,
+ "shows the right status text"
+ );
});
test("topic modal", async function (assert) {
@@ -361,38 +348,34 @@ acceptance(
await visit("/t/280");
await click(".topic-map__activity-pub .activity-pub-topic-status");
- assert.ok(exists(".activity-pub-topic-info-modal"), "shows the modal");
-
- assert.strictEqual(
- query(
- ".activity-pub-topic-info-modal .activity-pub-topic-status"
- ).innerText.trim(),
- `Topic was published on ${publishedAt.format(
- i18n("dates.long_with_year")
- )}.`,
- "shows the right topic status text"
- );
- assert.strictEqual(
- query(
- ".activity-pub-topic-info-modal .activity-pub-post-status"
- ).innerText.trim(),
- `Post was published on ${publishedAt.format(
- i18n("dates.long_with_year")
- )}.`,
- "shows the right post status text"
- );
- assert.ok(
- exists(
+ assert.dom(".activity-pub-topic-info-modal").exists("shows the modal");
+
+ assert
+ .dom(".activity-pub-topic-info-modal .activity-pub-topic-status")
+ .hasText(
+ `Topic was published on ${publishedAt.format(
+ i18n("dates.long_with_year")
+ )}.`,
+ "shows the right topic status text"
+ );
+ assert
+ .dom(".activity-pub-topic-info-modal .activity-pub-post-status")
+ .hasText(
+ `Post was published on ${publishedAt.format(
+ i18n("dates.long_with_year")
+ )}.`,
+ "shows the right post status text"
+ );
+ assert
+ .dom(
".activity-pub-topic-info-modal .activity-pub-attribute.object-type.collection"
- ),
- "shows the right topic object type attribute"
- );
- assert.ok(
- exists(
+ )
+ .exists("shows the right topic object type attribute");
+ assert
+ .dom(
".activity-pub-topic-info-modal .activity-pub-attribute.object-type.note"
- ),
- "shows the right post object type attribute"
- );
+ )
+ .exists("shows the right post object type attribute");
const topicStatusUpdate = {
model: {
@@ -404,31 +387,29 @@ acceptance(
};
await publishToMessageBus("/activity-pub", topicStatusUpdate);
- assert.strictEqual(
- query(
- ".activity-pub-topic-info-modal .activity-pub-topic-status"
- ).innerText.trim(),
- `Topic was deleted on ${deletedAt.format(
- i18n("dates.long_with_year")
- )}.`,
- "handles a status update"
- );
-
- assert.ok(
- query(".activity-pub-topic-actions .action.publish-all"),
- "shows the publish all posts action"
- );
- assert.strictEqual(
- query(
+ assert
+ .dom(".activity-pub-topic-info-modal .activity-pub-topic-status")
+ .hasText(
+ `Topic was deleted on ${deletedAt.format(
+ i18n("dates.long_with_year")
+ )}.`,
+ "handles a status update"
+ );
+
+ assert
+ .dom(".activity-pub-topic-actions .action.publish-all")
+ .exists("shows the publish all posts action");
+ assert
+ .dom(
".activity-pub-topic-actions .action.publish-all .action-description"
- ).innerText.trim(),
- `Publish 18 unpublished posts in Topic #280. Posts will not be delivered to the followers of the Group Actors.`,
- "shows the right publish all description"
- );
- assert.ok(
- query(".activity-pub-post-actions .action.deliver"),
- "shows the post deliver action"
- );
+ )
+ .hasText(
+ `Publish 18 unpublished posts in Topic #280. Posts will not be delivered to the followers of the Group Actors.`,
+ "shows the right publish all description"
+ );
+ assert
+ .dom(".activity-pub-post-actions .action.deliver")
+ .exists("shows the post deliver action");
const topicActionStatusUpdate = {
model: {
@@ -439,13 +420,14 @@ acceptance(
},
};
await publishToMessageBus("/activity-pub", topicActionStatusUpdate);
- assert.strictEqual(
- query(
+ assert
+ .dom(
".activity-pub-topic-actions .action.publish-all .action-description"
- ).innerText.trim(),
- `Publish all posts is disabled. All posts in Topic #280 are already published.`,
- "handles topic action status updates"
- );
+ )
+ .hasText(
+ `Publish all posts is disabled. All posts in Topic #280 are already published.`,
+ "handles topic action status updates"
+ );
});
test("post modal", async function (assert) {
@@ -458,26 +440,20 @@ acceptance(
await visit("/t/280");
await click(".topic-post:nth-of-type(4) .activity-pub-post-status");
- assert.ok(exists(".activity-pub-post-info-modal"), "shows the modal");
-
- assert.strictEqual(
- query(
- ".activity-pub-post-info-modal .activity-pub-post-status"
- ).innerText.trim(),
- "Post is not published.",
- "shows the right status text"
- );
- assert.ok(
- query(".activity-pub-post-actions .action.publish"),
- "shows the publish post action"
- );
- assert.strictEqual(
- query(
- ".activity-pub-post-actions .action.publish .action-description"
- ).innerText.trim(),
- `Publish Post #3 without delivering it. The Group Actors have no followers to deliver to.`,
- "shows the right publish description"
- );
+ assert.dom(".activity-pub-post-info-modal").exists("shows the modal");
+
+ assert
+ .dom(".activity-pub-post-info-modal .activity-pub-post-status")
+ .hasText("Post is not published.", "shows the right status text");
+ assert
+ .dom(".activity-pub-post-actions .action.publish")
+ .exists("shows the publish post action");
+ assert
+ .dom(".activity-pub-post-actions .action.publish .action-description")
+ .hasText(
+ `Publish Post #3 without delivering it. The Group Actors have no followers to deliver to.`,
+ "shows the right publish description"
+ );
const topicStatusUpdate = {
model: {
id: 280,
@@ -486,13 +462,12 @@ acceptance(
},
};
await publishToMessageBus("/activity-pub", topicStatusUpdate);
- assert.strictEqual(
- query(
- ".activity-pub-post-actions .action.publish .action-description"
- ).innerText.trim(),
- "Publish is disabled for Post #3. Topic #280 is not published.",
- "handles topic status updates"
- );
+ assert
+ .dom(".activity-pub-post-actions .action.publish .action-description")
+ .hasText(
+ "Publish is disabled for Post #3. Topic #280 is not published.",
+ "handles topic status updates"
+ );
});
}
);
@@ -526,42 +501,37 @@ acceptance(
await visit("/t/280");
await click(".topic-map__activity-pub .activity-pub-topic-status");
- assert.ok(exists(".activity-pub-topic-info-modal"), "shows the modal");
-
- assert.strictEqual(
- query(
- ".activity-pub-topic-info-modal .activity-pub-topic-status"
- ).innerText.trim(),
- `Topic was published on ${publishedAt.format(
- i18n("dates.long_with_year")
- )}.`,
- "shows the right topic status text"
- );
- assert.strictEqual(
- query(
- ".activity-pub-topic-info-modal .activity-pub-post-status"
- ).innerText.trim(),
- `Post was published on ${publishedAt.format(
- i18n("dates.long_with_year")
- )}.`,
- "shows the right post status text"
- );
- assert.notOk(
- exists(
+ assert.dom(".activity-pub-topic-info-modal").exists("shows the modal");
+
+ assert
+ .dom(".activity-pub-topic-info-modal .activity-pub-topic-status")
+ .hasText(
+ `Topic was published on ${publishedAt.format(
+ i18n("dates.long_with_year")
+ )}.`,
+ "shows the right topic status text"
+ );
+ assert
+ .dom(".activity-pub-topic-info-modal .activity-pub-post-status")
+ .hasText(
+ `Post was published on ${publishedAt.format(
+ i18n("dates.long_with_year")
+ )}.`,
+ "shows the right post status text"
+ );
+ assert
+ .dom(
".activity-pub-topic-info-modal .activity-pub-attribute.object-type.collection"
- ),
- "does not show a topic object type attribute"
- );
- assert.ok(
- exists(
+ )
+ .doesNotExist("does not show a topic object type attribute");
+ assert
+ .dom(
".activity-pub-topic-info-modal .activity-pub-attribute.object-type.note"
- ),
- "shows the right post object type attribute"
- );
- assert.notOk(
- query(".activity-pub-topic-actions .action.publish-all"),
- "does not show the publish all posts action"
- );
+ )
+ .exists("shows the right post object type attribute");
+ assert
+ .dom(".activity-pub-topic-actions .action.publish-all")
+ .doesNotExist("does not show the publish all posts action");
});
}
);
@@ -604,21 +574,21 @@ acceptance(
await visit("/t/280");
- assert.strictEqual(
- query(".activity-pub-topic-status").innerText.trim(),
- `Topic was published via ActivityPub by @cat_1@test.local on ${publishedAt.format(
- i18n("dates.time_short_day")
- )}.`,
- "shows the right topic status text"
- );
- assert.ok(
- exists(
+ assert
+ .dom(".activity-pub-topic-status")
+ .hasText(
+ `Topic was published via ActivityPub by @cat_1@test.local on ${publishedAt.format(
+ i18n("dates.time_short_day")
+ )}.`,
+ "shows the right topic status text"
+ );
+ assert
+ .dom(
`.topic-post:nth-of-type(3) .activity-pub-post-status[title='Post was published via ActivityPub by actor1@domain.com on ${publishedAt.format(
i18n("dates.time_short_day")
)}.']`
- ),
- "shows the right post status text"
- );
+ )
+ .exists("shows the right post status text");
});
test("ActivityPub topic info modal", async function (assert) {
@@ -630,35 +600,32 @@ acceptance(
await visit("/t/280");
await click(".topic-map__activity-pub .activity-pub-topic-status");
- assert.ok(exists(".activity-pub-topic-info-modal"), "shows the modal");
-
- assert.strictEqual(
- query(
- ".activity-pub-topic-info-modal .activity-pub-topic-status"
- ).innerText.trim(),
- `Topic was published on ${publishedAt.format(
- i18n("dates.long_with_year")
- )}.`,
- "shows the right topic status text"
- );
- assert.strictEqual(
- query(
- ".activity-pub-topic-info-modal .activity-pub-post-status"
- ).innerText.trim(),
- `Post was published on ${publishedAt.format(
- i18n("dates.long_with_year")
- )}.`,
- "shows the right post status text"
- );
- assert.strictEqual(
- query(
- ".activity-pub-topic-info-modal .activity-pub-post-status"
- ).innerText.trim(),
- `Post was published on ${publishedAt.format(
- i18n("dates.long_with_year")
- )}.`,
- "shows the right post status text"
- );
+ assert.dom(".activity-pub-topic-info-modal").exists("shows the modal");
+
+ assert
+ .dom(".activity-pub-topic-info-modal .activity-pub-topic-status")
+ .hasText(
+ `Topic was published on ${publishedAt.format(
+ i18n("dates.long_with_year")
+ )}.`,
+ "shows the right topic status text"
+ );
+ assert
+ .dom(".activity-pub-topic-info-modal .activity-pub-post-status")
+ .hasText(
+ `Post was published on ${publishedAt.format(
+ i18n("dates.long_with_year")
+ )}.`,
+ "shows the right post status text"
+ );
+ assert
+ .dom(".activity-pub-topic-info-modal .activity-pub-post-status")
+ .hasText(
+ `Post was published on ${publishedAt.format(
+ i18n("dates.long_with_year")
+ )}.`,
+ "shows the right post status text"
+ );
});
test("ActivityPub post info modal", async function (assert) {
@@ -670,23 +637,18 @@ acceptance(
await visit("/t/280");
await click(".topic-post:nth-of-type(3) .activity-pub-post-status");
- assert.ok(exists(".activity-pub-post-info-modal"), "shows the modal");
- assert.strictEqual(
- query(
- ".activity-pub-post-info-modal .activity-pub-post-status"
- ).innerText.trim(),
- `Post was published on ${publishedAt.format(
- i18n("dates.long_with_year")
- )}.`,
- "shows the right status text"
- );
- assert.strictEqual(
- query(
- ".activity-pub-post-info-modal .activity-pub-attribute.visibility"
- ).innerText.trim(),
- "Public",
- "shows the right visibility text"
- );
+ assert.dom(".activity-pub-post-info-modal").exists("shows the modal");
+ assert
+ .dom(".activity-pub-post-info-modal .activity-pub-post-status")
+ .hasText(
+ `Post was published on ${publishedAt.format(
+ i18n("dates.long_with_year")
+ )}.`,
+ "shows the right status text"
+ );
+ assert
+ .dom(".activity-pub-post-info-modal .activity-pub-attribute.visibility")
+ .hasText("Public", "shows the right visibility text");
});
}
);
diff --git a/test/javascripts/components/activity-pub-authorize-test.js b/test/javascripts/components/activity-pub-authorize-test.js
index d3fa58ef..9ac8f893 100644
--- a/test/javascripts/components/activity-pub-authorize-test.js
+++ b/test/javascripts/components/activity-pub-authorize-test.js
@@ -4,7 +4,6 @@ import { module, test } from "qunit";
import sinon from "sinon";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import pretender, { response } from "discourse/tests/helpers/create-pretender";
-import { exists, query } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
module(
@@ -12,8 +11,6 @@ module(
function (hooks) {
setupRenderingTest(hooks);
- const template = hbs``;
-
test("verifies a domain", async function (assert) {
let domain = "test.com";
let authType = "discourse";
@@ -24,12 +21,12 @@ module(
assert.strictEqual(
request.requestBody,
`domain=${domain}&auth_type=${authType}`,
- "it sets correct request parameters"
+ "sets correct request parameters"
);
return response({ success: true });
});
- await render(template);
+ await render(hbs``);
const authTypes = selectKit("#user_activity_pub_authorize_auth_type");
await authTypes.expand();
@@ -39,19 +36,15 @@ module(
await click("#user_activity_pub_authorize_verify_domain");
assert.strictEqual(requests, 1, "performs one request");
- assert.strictEqual(
- query(".activity-pub-authorize-verified-domain span").textContent,
- domain,
- "displays the verified domain"
- );
- assert.ok(
- exists("#user_activity_pub_authorize_clear_domain"),
- "displays the clear verified domain button"
- );
- assert.ok(
- exists("#user_activity_pub_authorize_authorize_domain"),
- "displays the authorize domain button"
- );
+ assert
+ .dom(".activity-pub-authorize-verified-domain span")
+ .hasText(domain, "displays the verified domain");
+ assert
+ .dom("#user_activity_pub_authorize_clear_domain")
+ .exists("displays the clear verified domain button");
+ assert
+ .dom("#user_activity_pub_authorize_authorize_domain")
+ .exists("displays the authorize domain button");
});
test("pressing Enter in input triggers domain verification", async function (assert) {
@@ -64,12 +57,12 @@ module(
assert.strictEqual(
request.requestBody,
`domain=${domain}&auth_type=${authType}`,
- "it sets correct request parameters"
+ "sets correct request parameters"
);
return response({ success: true });
});
- await render(template);
+ await render(hbs``);
const authTypes = selectKit("#user_activity_pub_authorize_auth_type");
await authTypes.expand();
@@ -90,7 +83,7 @@ module(
return response({ success: true });
});
- await render(template);
+ await render(hbs``);
const authTypes = selectKit("#user_activity_pub_authorize_auth_type");
await authTypes.expand();
@@ -100,19 +93,15 @@ module(
await click("#user_activity_pub_authorize_verify_domain");
await click("#user_activity_pub_authorize_clear_domain");
- assert.ok(
- exists("#user_activity_pub_authorize_domain"),
- "displays the domain input"
- );
- assert.strictEqual(
- query("#user_activity_pub_authorize_domain").textContent,
- "",
- "the domain input is empty"
- );
- assert.ok(
- exists("#user_activity_pub_authorize_verify_domain"),
- "displays the verify domain button"
- );
+ assert
+ .dom("#user_activity_pub_authorize_domain")
+ .exists("displays the domain input");
+ assert
+ .dom("#user_activity_pub_authorize_domain")
+ .hasNoText("the domain input is empty");
+ assert
+ .dom("#user_activity_pub_authorize_verify_domain")
+ .exists("displays the verify domain button");
});
test("authorizes a verified domain", async function (assert) {
@@ -124,7 +113,7 @@ module(
const openStub = sinon.stub(window, "open").returns(null);
- await render(template);
+ await render(hbs``);
const authTypes = selectKit("#user_activity_pub_authorize_auth_type");
await authTypes.expand();
@@ -136,7 +125,7 @@ module(
assert.true(
openStub.calledWith(`/ap/auth/authorize/${authType}`, "_self"),
- "it loads the authorize route in the current tab"
+ "loads the authorize route in the current tab"
);
});
}
diff --git a/test/javascripts/components/activity-pub-follow-domain-test.js b/test/javascripts/components/activity-pub-follow-domain-test.js
index 231b40c5..e6668d41 100644
--- a/test/javascripts/components/activity-pub-follow-domain-test.js
+++ b/test/javascripts/components/activity-pub-follow-domain-test.js
@@ -7,9 +7,8 @@ import Category from "discourse/models/category";
import Site from "discourse/models/site";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import pretender, { response } from "discourse/tests/helpers/create-pretender";
-import { query } from "discourse/tests/helpers/qunit-helpers";
import { i18n } from "discourse-i18n";
-import { default as Mastodon } from "../fixtures/mastodon-fixtures";
+import Mastodon from "../fixtures/mastodon-fixtures";
const mastodonAboutPath = "api/v2/instance";
@@ -27,41 +26,45 @@ module(
this.model = category;
});
- const template = hbs``;
-
test("with a non domain input", async function (assert) {
let domain = "notADomain";
- await render(template);
+ await render(
+ hbs``
+ );
await fillIn("#activity_pub_follow_domain_input", domain);
await click("#activity_pub_follow_domain_button");
- assert.strictEqual(
- query(".activity-pub-follow-domain-footer.error").textContent.trim(),
- i18n("discourse_activity_pub.follow.domain.invalid"),
- "displays an invalid message"
- );
+ assert
+ .dom(".activity-pub-follow-domain-footer.error")
+ .hasText(
+ i18n("discourse_activity_pub.follow.domain.invalid"),
+ "displays an invalid message"
+ );
});
- test("with a non activitypub domain", async function (assert) {
+ test("with a non ActivityPub domain", async function (assert) {
let domain = "google.com";
pretender.get(`https://${domain}/${mastodonAboutPath}`, () => {
return response(404, "not found");
});
- await render(template);
+ await render(
+ hbs``
+ );
await fillIn("#activity_pub_follow_domain_input", domain);
await click("#activity_pub_follow_domain_button");
- assert.strictEqual(
- query(".activity-pub-follow-domain-footer.error")?.textContent.trim(),
- i18n("discourse_activity_pub.follow.domain.invalid"),
- "displays an invalid message"
- );
+ assert
+ .dom(".activity-pub-follow-domain-footer.error")
+ .hasText(
+ i18n("discourse_activity_pub.follow.domain.invalid"),
+ "displays an invalid message"
+ );
});
- test("with an activitypub domain", async function (assert) {
+ test("with an ActivityPub domain", async function (assert) {
let domain = "mastodon.social";
pretender.get(`https://${domain}/${mastodonAboutPath}`, () => {
@@ -72,7 +75,9 @@ module(
.stub(DiscourseURL, "redirectAbsolute")
.returns(null);
- await render(template);
+ await render(
+ hbs``
+ );
await fillIn("#activity_pub_follow_domain_input", domain);
await click("#activity_pub_follow_domain_button");
@@ -81,7 +86,7 @@ module(
)}`;
assert.true(
openStub.calledWith(url),
- "it loads the mastodon authorize interaction route in a new tab"
+ "loads the mastodon authorize interaction route in a new tab"
);
});
}
diff --git a/test/javascripts/components/activity-pub-post-test.js b/test/javascripts/components/activity-pub-post-test.js
index 8758791d..0c5df054 100644
--- a/test/javascripts/components/activity-pub-post-test.js
+++ b/test/javascripts/components/activity-pub-post-test.js
@@ -2,7 +2,6 @@ import { click, render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile";
import { module, skip } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
-import { exists } from "discourse/tests/helpers/qunit-helpers";
module("Discourse Activity Pub | Component | Widget | post", function (hooks) {
setupRenderingTest(hooks);
@@ -17,10 +16,9 @@ module("Discourse Activity Pub | Component | Widget | post", function (hooks) {
`);
await click(".post-menu-area .show-post-admin-menu");
- assert.ok(
- exists(".post-admin-menu button.change-owner"),
- "the change owner button is visible"
- );
+ assert
+ .dom(".post-admin-menu button.change-owner")
+ .exists("the change owner button is visible");
});
skip("activity pub topic", async function (assert) {
@@ -33,9 +31,8 @@ module("Discourse Activity Pub | Component | Widget | post", function (hooks) {
`);
await click(".post-menu-area .show-post-admin-menu");
- assert.ok(
- !exists(".post-admin-menu button.change-owner"),
- "the change owner button is not visible"
- );
+ assert
+ .dom(".post-admin-menu button.change-owner")
+ .doesNotExist("the change owner button is not visible");
});
});
diff --git a/test/javascripts/components/activity-pub-status-test.js b/test/javascripts/components/activity-pub-status-test.js
index ea092ffb..c5b5c422 100644
--- a/test/javascripts/components/activity-pub-status-test.js
+++ b/test/javascripts/components/activity-pub-status-test.js
@@ -9,10 +9,9 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import {
currentUser,
publishToMessageBus,
- query,
} from "discourse/tests/helpers/qunit-helpers";
import { i18n } from "discourse-i18n";
-import { default as SiteActors } from "../fixtures/site-actors-fixtures";
+import SiteActors from "../fixtures/site-actors-fixtures";
function setSite(context, attrs = {}) {
context.siteSettings.activity_pub_enabled = attrs.activity_pub_enabled;
@@ -48,8 +47,6 @@ module(
"Discourse Activity Pub | Component | activity-pub-actor-status with category",
function (hooks) {
setupRenderingTest(hooks);
- const template = hbs``;
-
test("with publishing disabled", async function (assert) {
setSite(this, {
activity_pub_enabled: true,
@@ -58,20 +55,26 @@ module(
});
setCategory(this);
- await render(template);
-
- const status = query(".activity-pub-actor-status.publishing-disabled");
- assert.ok(status, "has the right class");
- assert.strictEqual(
- status.title,
- i18n("discourse_activity_pub.status.title.publishing_disabled"),
- "has the right title"
- );
- assert.strictEqual(
- status.innerText.trim(),
- i18n("discourse_activity_pub.status.label.publishing_disabled"),
- "has the right label"
+ await render(
+ hbs``
);
+
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasClass("publishing-disabled", "has the right class");
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasAttribute(
+ "title",
+ i18n("discourse_activity_pub.status.title.publishing_disabled"),
+ "has the right title"
+ );
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasText(
+ i18n("discourse_activity_pub.status.label.publishing_disabled"),
+ "has the right label"
+ );
});
test("with plugin disabled", async function (assert) {
@@ -82,20 +85,26 @@ module(
});
setCategory(this);
- await render(template);
-
- const status = query(".activity-pub-actor-status.not-active");
- assert.ok(status, "has the right class");
- assert.strictEqual(
- status.title,
- i18n("discourse_activity_pub.status.title.plugin_disabled"),
- "has the right title"
- );
- assert.strictEqual(
- status.innerText.trim(),
- i18n("discourse_activity_pub.status.label.not_active"),
- "has the right label"
+ await render(
+ hbs``
);
+
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasClass("not-active", "has the right class");
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasAttribute(
+ "title",
+ i18n("discourse_activity_pub.status.title.plugin_disabled"),
+ "has the right title"
+ );
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasText(
+ i18n("discourse_activity_pub.status.label.not_active"),
+ "has the right label"
+ );
});
test("with activity pub disabled on category", async function (assert) {
@@ -114,22 +123,26 @@ module(
});
setCategory(this);
- await render(template);
+ await render(
+ hbs``
+ );
- const status = query(".activity-pub-actor-status.not-active");
- assert.ok(status, "has the right class");
- assert.strictEqual(
- status.title,
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasClass("not-active", "has the right class");
+ assert.dom(".activity-pub-actor-status").hasAttribute(
+ "title",
i18n("discourse_activity_pub.status.title.model_disabled", {
model_type: "category",
}),
"has the right title"
);
- assert.strictEqual(
- status.innerText.trim(),
- i18n("discourse_activity_pub.status.label.not_active"),
- "has the right label"
- );
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasText(
+ i18n("discourse_activity_pub.status.label.not_active"),
+ "has the right label"
+ );
});
test("with activity pub not ready on category", async function (assert) {
@@ -149,22 +162,26 @@ module(
});
setCategory(this);
- await render(template);
+ await render(
+ hbs``
+ );
- const status = query(".activity-pub-actor-status.not-active");
- assert.ok(status, "has the right class");
- assert.strictEqual(
- status.title,
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasClass("not-active", "has the right class");
+ assert.dom(".activity-pub-actor-status").hasAttribute(
+ "title",
i18n("discourse_activity_pub.status.title.model_not_ready", {
model_type: "category",
}),
"has the right title"
);
- assert.strictEqual(
- status.innerText.trim(),
- i18n("discourse_activity_pub.status.label.not_active"),
- "has the right label"
- );
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasText(
+ i18n("discourse_activity_pub.status.label.not_active"),
+ "has the right label"
+ );
});
test("with active activity pub", async function (assert) {
@@ -175,22 +192,26 @@ module(
});
setCategory(this);
- await render(template);
+ await render(
+ hbs``
+ );
- const status = query(".activity-pub-actor-status.active");
- assert.ok(status, "has the right class");
- assert.strictEqual(
- status.title,
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasClass("active", "has the right class");
+ assert.dom(".activity-pub-actor-status").hasAttribute(
+ "title",
i18n("discourse_activity_pub.status.title.model_active.first_post", {
delay_minutes: this.siteSettings.activity_pub_delivery_delay_minutes,
}),
"has the right title"
);
- assert.strictEqual(
- status.innerText.trim(),
- i18n("discourse_activity_pub.status.label.active"),
- "has the right label"
- );
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasText(
+ i18n("discourse_activity_pub.status.label.active"),
+ "has the right label"
+ );
});
test("updates correctly after messageBus message", async function (assert) {
@@ -201,7 +222,9 @@ module(
});
setCategory(this);
- await render(template);
+ await render(
+ hbs``
+ );
await publishToMessageBus("/activity-pub", {
model: {
id: this.category.id,
@@ -211,25 +234,25 @@ module(
},
});
- const status = query(".activity-pub-actor-status.not-active");
- assert.ok(status, "has the right class");
- assert.strictEqual(
- status.title,
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasClass("not-active", "has the right class");
+ assert.dom(".activity-pub-actor-status").hasAttribute(
+ "title",
i18n("discourse_activity_pub.status.title.model_not_ready", {
model_type: "category",
}),
"has the right title"
);
- assert.strictEqual(
- status.innerText.trim(),
- i18n("discourse_activity_pub.status.label.not_active"),
- "has the right label"
- );
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasText(
+ i18n("discourse_activity_pub.status.label.not_active"),
+ "has the right label"
+ );
});
test("when in the composer", async function (assert) {
- const composerTemplate = hbs``;
-
setSite(this, {
activity_pub_enabled: true,
activity_pub_publishing_enabled: true,
@@ -240,14 +263,16 @@ module(
categoryId: this.category.id,
});
- await render(composerTemplate);
-
- const label = query(".activity-pub-actor-status .label");
- assert.strictEqual(
- label.innerText.trim(),
- i18n("discourse_activity_pub.visibility.label.public"),
- "has the right label text"
+ await render(
+ hbs``
);
+
+ assert
+ .dom(".activity-pub-actor-status .label")
+ .hasText(
+ i18n("discourse_activity_pub.visibility.label.public"),
+ "has the right label text"
+ );
});
}
);
@@ -256,7 +281,6 @@ module(
"Discourse Activity Pub | Component | activity-pub-actor-status with tag",
function (hooks) {
setupRenderingTest(hooks);
- const template = hbs``;
test("with publishing disabled", async function (assert) {
setSite(this, {
@@ -266,20 +290,26 @@ module(
});
setTag(this);
- await render(template);
-
- const status = query(".activity-pub-actor-status.publishing-disabled");
- assert.ok(status, "has the right class");
- assert.strictEqual(
- status.title,
- i18n("discourse_activity_pub.status.title.publishing_disabled"),
- "has the right title"
- );
- assert.strictEqual(
- status.innerText.trim(),
- i18n("discourse_activity_pub.status.label.publishing_disabled"),
- "has the right label"
+ await render(
+ hbs``
);
+
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasClass("publishing-disabled", "has the right class");
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasAttribute(
+ "title",
+ i18n("discourse_activity_pub.status.title.publishing_disabled"),
+ "has the right title"
+ );
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasText(
+ i18n("discourse_activity_pub.status.label.publishing_disabled"),
+ "has the right label"
+ );
});
test("with plugin disabled", async function (assert) {
@@ -290,20 +320,26 @@ module(
});
setTag(this);
- await render(template);
-
- const status = query(".activity-pub-actor-status.not-active");
- assert.ok(status, "has the right class");
- assert.strictEqual(
- status.title,
- i18n("discourse_activity_pub.status.title.plugin_disabled"),
- "has the right title"
- );
- assert.strictEqual(
- status.innerText.trim(),
- i18n("discourse_activity_pub.status.label.not_active"),
- "has the right label"
+ await render(
+ hbs``
);
+
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasClass("not-active", "has the right class");
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasAttribute(
+ "title",
+ i18n("discourse_activity_pub.status.title.plugin_disabled"),
+ "has the right title"
+ );
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasText(
+ i18n("discourse_activity_pub.status.label.not_active"),
+ "has the right label"
+ );
});
test("with activity pub disabled on tag", async function (assert) {
@@ -322,22 +358,26 @@ module(
});
setTag(this);
- await render(template);
+ await render(
+ hbs``
+ );
- const status = query(".activity-pub-actor-status.not-active");
- assert.ok(status, "has the right class");
- assert.strictEqual(
- status.title,
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasClass("not-active", "has the right class");
+ assert.dom(".activity-pub-actor-status").hasAttribute(
+ "title",
i18n("discourse_activity_pub.status.title.model_disabled", {
model_type: "tag",
}),
"has the right title"
);
- assert.strictEqual(
- status.innerText.trim(),
- i18n("discourse_activity_pub.status.label.not_active"),
- "has the right label"
- );
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasText(
+ i18n("discourse_activity_pub.status.label.not_active"),
+ "has the right label"
+ );
});
test("with activity pub not ready on tag", async function (assert) {
@@ -357,22 +397,26 @@ module(
});
setTag(this);
- await render(template);
+ await render(
+ hbs``
+ );
- const status = query(".activity-pub-actor-status.not-active");
- assert.ok(status, "has the right class");
- assert.strictEqual(
- status.title,
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasClass("not-active", "has the right class");
+ assert.dom(".activity-pub-actor-status").hasAttribute(
+ "title",
i18n("discourse_activity_pub.status.title.model_not_ready", {
model_type: "tag",
}),
"has the right title"
);
- assert.strictEqual(
- status.innerText.trim(),
- i18n("discourse_activity_pub.status.label.not_active"),
- "has the right label"
- );
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasText(
+ i18n("discourse_activity_pub.status.label.not_active"),
+ "has the right label"
+ );
});
test("with active activity pub", async function (assert) {
@@ -383,22 +427,26 @@ module(
});
setTag(this);
- await render(template);
+ await render(
+ hbs``
+ );
- const status = query(".activity-pub-actor-status.active");
- assert.ok(status, "has the right class");
- assert.strictEqual(
- status.title,
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasClass("active", "has the right class");
+ assert.dom(".activity-pub-actor-status").hasAttribute(
+ "title",
i18n("discourse_activity_pub.status.title.model_active.first_post", {
delay_minutes: this.siteSettings.activity_pub_delivery_delay_minutes,
}),
"has the right title"
);
- assert.strictEqual(
- status.innerText.trim(),
- i18n("discourse_activity_pub.status.label.active"),
- "has the right label"
- );
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasText(
+ i18n("discourse_activity_pub.status.label.active"),
+ "has the right label"
+ );
});
test("updates correctly after messageBus message", async function (assert) {
@@ -409,7 +457,9 @@ module(
});
setTag(this);
- await render(template);
+ await render(
+ hbs``
+ );
await publishToMessageBus("/activity-pub", {
model: {
id: this.tag.id,
@@ -419,25 +469,25 @@ module(
},
});
- const status = query(".activity-pub-actor-status.not-active");
- assert.ok(status, "has the right class");
- assert.strictEqual(
- status.title,
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasClass("not-active", "has the right class");
+ assert.dom(".activity-pub-actor-status").hasAttribute(
+ "title",
i18n("discourse_activity_pub.status.title.model_not_ready", {
model_type: "tag",
}),
"has the right title"
);
- assert.strictEqual(
- status.innerText.trim(),
- i18n("discourse_activity_pub.status.label.not_active"),
- "has the right label"
- );
+ assert
+ .dom(".activity-pub-actor-status")
+ .hasText(
+ i18n("discourse_activity_pub.status.label.not_active"),
+ "has the right label"
+ );
});
test("when in the composer", async function (assert) {
- const composerTemplate = hbs``;
-
setSite(this, {
activity_pub_enabled: true,
activity_pub_publishing_enabled: true,
@@ -448,14 +498,16 @@ module(
tags: [this.tag.name],
});
- await render(composerTemplate);
-
- const label = query(".activity-pub-actor-status .label");
- assert.strictEqual(
- label.innerText.trim(),
- i18n("discourse_activity_pub.visibility.label.public"),
- "has the right label text"
+ await render(
+ hbs``
);
+
+ assert
+ .dom(".activity-pub-actor-status .label")
+ .hasText(
+ i18n("discourse_activity_pub.visibility.label.public"),
+ "has the right label text"
+ );
});
}
);