diff --git a/assets/javascripts/discourse/initializers/activity-pub-initializer.gjs b/assets/javascripts/discourse/initializers/activity-pub-initializer.gjs
index f9a4dc93..80c0ef66 100644
--- a/assets/javascripts/discourse/initializers/activity-pub-initializer.gjs
+++ b/assets/javascripts/discourse/initializers/activity-pub-initializer.gjs
@@ -1,10 +1,7 @@
import { service } from "@ember/service";
-import { hbs } from "ember-cli-htmlbars";
import { Promise } from "rsvp";
import { bind } from "discourse/lib/decorators";
-import { withSilencedDeprecations } from "discourse/lib/deprecated";
import { withPluginApi } from "discourse/lib/plugin-api";
-import RenderGlimmer from "discourse/widgets/render-glimmer";
import { i18n } from "discourse-i18n";
import ActivityPubPostStatus from "../components/activity-pub-post-status";
import ActivityPubTopicMap from "../components/activity-pub-topic-map";
@@ -109,14 +106,10 @@ export default {
activity_pub_updated_at: data.model.updated_at,
activity_pub_delivered_at: data.model.delivered_at,
};
- topic.postStream
- .triggerActivityPubStateChange(data.model.id, props)
- .then(() =>
- // TODO (glimmer-post-stream) the Glimmer Post Stream does not listen to this event
- this.appEvents.trigger("post-stream:refresh", {
- id: data.model.id,
- })
- );
+ topic.postStream.triggerActivityPubStateChange(
+ data.model.id,
+ props
+ );
this.appEvents.trigger(
"activity-pub:post-updated",
data.model.id,
@@ -230,52 +223,4 @@ function customizePost(api, container) {
};
}
});
-
- withSilencedDeprecations("discourse.post-stream-widget-overrides", () =>
- customizeWidgetPost(api, container)
- );
-}
-
-function customizeWidgetPost(api, container) {
- const currentUser = api.getCurrentUser();
- const site = container.lookup("service:site");
- const siteSettings = container.lookup("service:site-settings");
-
- api.reopenWidget("post-meta-data", {
- html(attrs) {
- const result = this._super(attrs);
- let postStatuses = result[result.length - 1].children;
- postStatuses = postStatuses.filter(
- (n) => n.renderInto !== "div.post-info.activity-pub"
- );
- if (
- site.activity_pub_enabled &&
- attrs.activity_pub_enabled &&
- attrs.post_number !== 1 &&
- showStatusToUser(currentUser, siteSettings)
- ) {
- const status = activityPubPostStatus(attrs);
- if (status) {
- let replyToTabIndex = postStatuses.findIndex((postStatus) => {
- return postStatus.name === "reply-to-tab";
- });
- const post = this.findAncestorModel();
- postStatuses.splice(
- replyToTabIndex !== -1 ? replyToTabIndex + 1 : 0,
- 0,
- new RenderGlimmer(
- this,
- "div.post-info.activity-pub",
- hbs``,
- {
- post,
- }
- )
- );
- }
- }
- result[result.length - 1].children = postStatuses;
- return result;
- },
- });
}
diff --git a/test/javascripts/acceptance/activity-pub-topic-test.js b/test/javascripts/acceptance/activity-pub-topic-test.js
index 4c3e28e8..5a0f26a3 100644
--- a/test/javascripts/acceptance/activity-pub-topic-test.js
+++ b/test/javascripts/acceptance/activity-pub-topic-test.js
@@ -53,642 +53,612 @@ const setupServer = (needs, postAttrs = [], topicAttrs = {}) => {
});
};
-["enabled", "disabled"].forEach((postStreamMode) => {
- acceptance(
- `Discourse Activity Pub | ActivityPub topic as user with post status not visible (glimmer_post_stream_mode = ${postStreamMode})`,
- function (needs) {
- needs.user({
- moderator: false,
- admin: false,
- groups: [AUTO_GROUPS.trust_level_0, AUTO_GROUPS.trust_level_1],
- });
- needs.settings({
- glimmer_post_stream_mode: postStreamMode,
- });
+acceptance(
+ `Discourse Activity Pub | ActivityPub topic as user with post status not visible`,
+ function (needs) {
+ needs.user({
+ moderator: false,
+ admin: false,
+ groups: [AUTO_GROUPS.trust_level_0, AUTO_GROUPS.trust_level_1],
+ });
- setupServer(needs, [
- {
- activity_pub_published_at: publishedAt,
- activity_pub_local: true,
- },
- {
- activity_pub_published_at: publishedAt,
- activity_pub_local: true,
- },
- ]);
+ setupServer(needs, [
+ {
+ activity_pub_published_at: publishedAt,
+ activity_pub_local: true,
+ },
+ {
+ activity_pub_published_at: publishedAt,
+ activity_pub_local: true,
+ },
+ ]);
+
+ test("ActivityPub topic and post elements", async function (assert) {
+ this.siteSettings.activity_pub_post_status_visibility_groups = "1";
+ Site.current().set("activity_pub_enabled", true);
+
+ await visit("/t/280");
+
+ assert
+ .dom(".topic-map__activity-pub")
+ .doesNotExist("the topic map is not visible");
+ assert
+ .dom(".topic-post[data-post-number='2'] .post-info.activity-pub")
+ .doesNotExist("the post status is not visible");
+ });
+ }
+);
+
+acceptance(
+ `Discourse Activity Pub | ActivityPub topic as user in a group with post status visible`,
+ function (needs) {
+ needs.user({ moderator: true, admin: false });
+
+ setupServer(needs, [
+ {
+ activity_pub_published_at: publishedAt,
+ activity_pub_visibility: "public",
+ activity_pub_domain: "external.com",
+ activity_pub_local: false,
+ },
+ {
+ activity_pub_published_at: publishedAt,
+ activity_pub_visibility: "public",
+ activity_pub_local: true,
+ },
+ ]);
+
+ test("When the plugin is disabled", async function (assert) {
+ this.siteSettings.activity_pub_post_status_visibility_groups = "2";
+ Site.current().setProperties({
+ activity_pub_enabled: false,
+ activity_pub_publishing_enabled: false,
+ });
- test("ActivityPub topic and post elements", async function (assert) {
- this.siteSettings.activity_pub_post_status_visibility_groups = "1";
- Site.current().set("activity_pub_enabled", true);
+ await visit("/t/280");
- await visit("/t/280");
+ assert
+ .dom(".topic-map__activity-pub")
+ .doesNotExist("the activity pub topic map is not visible");
+ });
- assert
- .dom(".topic-map__activity-pub")
- .doesNotExist("the topic map is not visible");
- assert
- .dom(".topic-post[data-post-number='2'] .post-info.activity-pub")
- .doesNotExist("the post status is not visible");
+ test("When the plugin is enabled", async function (assert) {
+ this.siteSettings.activity_pub_post_status_visibility_groups = "2";
+ Site.current().setProperties({
+ activity_pub_enabled: true,
+ activity_pub_publishing_enabled: true,
});
- }
- );
-
- acceptance(
- `Discourse Activity Pub | ActivityPub topic as user in a group with post status visible (glimmer_post_stream_mode = ${postStreamMode})`,
- function (needs) {
- needs.user({ moderator: true, admin: false });
- needs.settings({
- glimmer_post_stream_mode: postStreamMode,
+
+ await visit("/t/280");
+
+ assert.dom(".topic-map__activity-pub").exists("the topic map is visible");
+ assert
+ .dom(".topic-post[data-post-number='2'] .post-info.activity-pub")
+ .exists("is visible");
+ });
+
+ test("post status update", async function (assert) {
+ this.siteSettings.activity_pub_post_status_visibility_groups = "2";
+ Site.current().setProperties({
+ activity_pub_enabled: true,
+ activity_pub_publishing_enabled: true,
});
- setupServer(needs, [
- {
- activity_pub_published_at: publishedAt,
- activity_pub_visibility: "public",
- activity_pub_domain: "external.com",
- activity_pub_local: false,
- },
- {
- activity_pub_published_at: publishedAt,
- activity_pub_visibility: "public",
- activity_pub_local: true,
+ await visit("/t/280");
+
+ const postStatusUpdate = {
+ model: {
+ id: 419,
+ type: "post",
+ topic_id: 280,
+ published_at: publishedAt,
+ deleted_at: deletedAt,
},
- ]);
+ };
+ await publishToMessageBus("/activity-pub", postStatusUpdate);
+
+ assert
+ .dom(
+ `.topic-post[data-post-number='2'] .activity-pub-post-status[title='Post was deleted via ActivityPub on ${deletedAt.format(
+ i18n("dates.time_short_day")
+ )}.']`
+ )
+ .exists("shows the right post status text");
+ });
+ }
+);
+
+acceptance(
+ `Discourse Activity Pub | ActivityPub topic as anon user when post status is visible to everyone`,
+ function (needs) {
+ setupServer(needs, [
+ {
+ activity_pub_published_at: publishedAt,
+ activity_pub_visibility: "public",
+ activity_pub_domain: "external.com",
+ activity_pub_local: false,
+ },
+ {
+ activity_pub_published_at: publishedAt,
+ activity_pub_visibility: "public",
+ activity_pub_local: true,
+ },
+ ]);
+
+ test("When the plugin is disabled", async function (assert) {
+ this.siteSettings.activity_pub_post_status_visibility_groups = "0";
+ Site.current().setProperties({
+ activity_pub_enabled: false,
+ activity_pub_publishing_enabled: false,
+ });
- test("When the plugin is disabled", async function (assert) {
- this.siteSettings.activity_pub_post_status_visibility_groups = "2";
- Site.current().setProperties({
- activity_pub_enabled: false,
- activity_pub_publishing_enabled: false,
- });
+ await visit("/t/280");
- await visit("/t/280");
+ assert
+ .dom(".topic-map__activity-pub")
+ .doesNotExist("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) {
+ this.siteSettings.activity_pub_post_status_visibility_groups = "0";
+ Site.current().setProperties({
+ activity_pub_enabled: true,
+ activity_pub_publishing_enabled: true,
});
- test("When the plugin is enabled", async function (assert) {
- this.siteSettings.activity_pub_post_status_visibility_groups = "2";
- Site.current().setProperties({
- activity_pub_enabled: true,
- activity_pub_publishing_enabled: true,
- });
-
- await visit("/t/280");
-
- assert
- .dom(".topic-map__activity-pub")
- .exists("the topic map is visible");
- assert
- .dom(".topic-post[data-post-number='2'] .post-info.activity-pub")
- .exists("is visible");
- });
+ await visit("/t/280");
- test("post status update", async function (assert) {
- this.siteSettings.activity_pub_post_status_visibility_groups = "2";
- Site.current().setProperties({
- activity_pub_enabled: true,
- activity_pub_publishing_enabled: true,
- });
-
- await visit("/t/280");
-
- const postStatusUpdate = {
- model: {
- id: 419,
- type: "post",
- topic_id: 280,
- published_at: publishedAt,
- deleted_at: deletedAt,
- },
- };
- await publishToMessageBus("/activity-pub", postStatusUpdate);
-
- assert
- .dom(
- `.topic-post[data-post-number='2'] .activity-pub-post-status[title='Post was deleted via ActivityPub on ${deletedAt.format(
- i18n("dates.time_short_day")
- )}.']`
- )
- .exists("shows the right post status text");
- });
- }
- );
-
- acceptance(
- `Discourse Activity Pub | ActivityPub topic as anon user when post status is visible to everyone (glimmer_post_stream_mode = ${postStreamMode})`,
- function (needs) {
- needs.settings({
- glimmer_post_stream_mode: postStreamMode,
+ assert.dom(".topic-map__activity-pub").exists("the topic map is visible");
+ assert
+ .dom(".topic-post[data-post-number='2'] .post-info.activity-pub")
+ .exists("is visible");
+ });
+ }
+);
+
+acceptance(
+ `Discourse Activity Pub | Scheduled ActivityPub topic as staff`,
+ function (needs) {
+ needs.user({ moderator: true, admin: false });
+
+ setupServer(
+ needs,
+ [
+ {
+ activity_pub_scheduled_at: scheduledAt,
+ activity_pub_visibility: "public",
+ },
+ ],
+ {
+ activity_pub_scheduled_at: scheduledAt,
+ }
+ );
+
+ test("topic map", async function (assert) {
+ Site.current().setProperties({
+ activity_pub_enabled: true,
+ activity_pub_publishing_enabled: true,
});
- setupServer(needs, [
+ await visit("/t/280");
+
+ 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"
+ );
+ });
+ }
+);
+
+acceptance(
+ `Discourse Activity Pub | Published ActivityPub full_topic topic as staff`,
+ function (needs) {
+ needs.user({ moderator: true, admin: false });
+
+ setupServer(
+ needs,
+ [
{
activity_pub_published_at: publishedAt,
activity_pub_visibility: "public",
- activity_pub_domain: "external.com",
- activity_pub_local: false,
+ activity_pub_local: true,
+ activity_pub_full_topic: true,
},
{
activity_pub_published_at: publishedAt,
activity_pub_visibility: "public",
activity_pub_local: true,
+ activity_pub_full_topic: true,
},
- ]);
+ {},
+ ],
+ {
+ activity_pub_published_at: publishedAt,
+ activity_pub_object_type: "Collection",
+ activity_pub_object_id: "https://local.com/collection/1234567",
+ activity_pub_full_topic: true,
+ }
+ );
+
+ test("When the plugin is disabled", async function (assert) {
+ Site.current().setProperties({
+ activity_pub_enabled: false,
+ activity_pub_publishing_enabled: false,
+ });
- test("When the plugin is disabled", async function (assert) {
- this.siteSettings.activity_pub_post_status_visibility_groups = "0";
- Site.current().setProperties({
- activity_pub_enabled: false,
- activity_pub_publishing_enabled: false,
- });
+ await visit("/t/280");
- await visit("/t/280");
+ assert
+ .dom(".topic-map__activity-pub")
+ .doesNotExist("the topic map is not visible");
+ });
- assert
- .dom(".topic-map__activity-pub")
- .doesNotExist("the activity pub topic map is not visible");
+ test("topic map", async function (assert) {
+ Site.current().setProperties({
+ activity_pub_enabled: true,
+ activity_pub_publishing_enabled: true,
});
- test("When the plugin is enabled", async function (assert) {
- this.siteSettings.activity_pub_post_status_visibility_groups = "0";
- Site.current().setProperties({
- activity_pub_enabled: true,
- activity_pub_publishing_enabled: true,
- });
-
- await visit("/t/280");
-
- assert
- .dom(".topic-map__activity-pub")
- .exists("the topic map is visible");
- assert
- .dom(".topic-post[data-post-number='2'] .post-info.activity-pub")
- .exists("is visible");
- });
- }
- );
-
- acceptance(
- `Discourse Activity Pub | Scheduled ActivityPub topic as staff (glimmer_post_stream_mode = ${postStreamMode})`,
- function (needs) {
- needs.user({ moderator: true, admin: false });
- needs.settings({
- glimmer_post_stream_mode: postStreamMode,
- });
+ await visit("/t/280");
- setupServer(
- needs,
- [
- {
- activity_pub_scheduled_at: scheduledAt,
- activity_pub_visibility: "public",
- },
- ],
- {
- activity_pub_scheduled_at: scheduledAt,
- }
- );
+ 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 map", async function (assert) {
- Site.current().setProperties({
- activity_pub_enabled: true,
- activity_pub_publishing_enabled: true,
- });
-
- await visit("/t/280");
-
- 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"
- );
- });
- }
- );
-
- acceptance(
- `Discourse Activity Pub | Published ActivityPub full_topic topic as staff (glimmer_post_stream_mode = ${postStreamMode})`,
- function (needs) {
- needs.user({ moderator: true, admin: false });
- needs.settings({
- glimmer_post_stream_mode: postStreamMode,
+ test("topic status update", async function (assert) {
+ Site.current().setProperties({
+ activity_pub_enabled: true,
+ activity_pub_publishing_enabled: true,
});
- setupServer(
- needs,
- [
- {
- activity_pub_published_at: publishedAt,
- activity_pub_visibility: "public",
- activity_pub_local: true,
- activity_pub_full_topic: true,
- },
- {
- activity_pub_published_at: publishedAt,
- activity_pub_visibility: "public",
- activity_pub_local: true,
- activity_pub_full_topic: true,
- },
- {},
- ],
- {
+ await visit("/t/280");
+
+ const topicStatusUpdate = {
+ model: {
+ id: 280,
+ type: "topic",
activity_pub_published_at: publishedAt,
- activity_pub_object_type: "Collection",
- activity_pub_object_id: "https://local.com/collection/1234567",
- activity_pub_full_topic: true,
- }
- );
+ activity_pub_deleted_at: deletedAt,
+ },
+ };
+ await publishToMessageBus("/activity-pub", topicStatusUpdate);
+
+ 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("When the plugin is disabled", async function (assert) {
- Site.current().setProperties({
- activity_pub_enabled: false,
- activity_pub_publishing_enabled: false,
- });
+ test("topic modal", async function (assert) {
+ Site.current().setProperties({
+ activity_pub_enabled: true,
+ activity_pub_publishing_enabled: true,
+ });
- await visit("/t/280");
+ await visit("/t/280");
- assert
- .dom(".topic-map__activity-pub")
- .doesNotExist("the topic map is not visible");
- });
+ await click(".topic-map__activity-pub .activity-pub-topic-status");
+ assert.dom(".activity-pub-topic-info-modal").exists("shows the modal");
- test("topic map", async function (assert) {
- Site.current().setProperties({
- activity_pub_enabled: true,
- activity_pub_publishing_enabled: true,
- });
-
- await visit("/t/280");
-
- 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"
- );
- });
+ 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"
+ )
+ .exists("shows the right topic object type attribute");
+ assert
+ .dom(
+ ".activity-pub-topic-info-modal .activity-pub-attribute.object-type.note"
+ )
+ .exists("shows the right post object type attribute");
+
+ const topicStatusUpdate = {
+ model: {
+ id: 280,
+ type: "topic",
+ activity_pub_published_at: publishedAt,
+ activity_pub_deleted_at: deletedAt,
+ },
+ };
+ await publishToMessageBus("/activity-pub", topicStatusUpdate);
+
+ 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"
+ );
- test("topic status update", async function (assert) {
- Site.current().setProperties({
- activity_pub_enabled: true,
- activity_pub_publishing_enabled: true,
- });
-
- await visit("/t/280");
-
- const topicStatusUpdate = {
- model: {
- id: 280,
- type: "topic",
- activity_pub_published_at: publishedAt,
- activity_pub_deleted_at: deletedAt,
- },
- };
- await publishToMessageBus("/activity-pub", topicStatusUpdate);
-
- 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"
- );
- });
+ 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"
+ )
+ .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: {
+ id: 280,
+ type: "topic",
+ activity_pub_published_post_count: 20,
+ activity_pub_total_post_count: 20,
+ },
+ };
+ await publishToMessageBus("/activity-pub", topicActionStatusUpdate);
+ assert
+ .dom(
+ ".activity-pub-topic-actions .action.publish-all .action-description"
+ )
+ .hasText(
+ `Publish all posts is disabled. All posts in Topic #280 are already published.`,
+ "handles topic action status updates"
+ );
+ });
- test("topic modal", async function (assert) {
- Site.current().setProperties({
- activity_pub_enabled: true,
- activity_pub_publishing_enabled: true,
- });
-
- await visit("/t/280");
-
- await click(".topic-map__activity-pub .activity-pub-topic-status");
- 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"
- )
- .exists("shows the right topic object type attribute");
- assert
- .dom(
- ".activity-pub-topic-info-modal .activity-pub-attribute.object-type.note"
- )
- .exists("shows the right post object type attribute");
-
- const topicStatusUpdate = {
- model: {
- id: 280,
- type: "topic",
- activity_pub_published_at: publishedAt,
- activity_pub_deleted_at: deletedAt,
- },
- };
- await publishToMessageBus("/activity-pub", topicStatusUpdate);
-
- 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"
- )
- .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: {
- id: 280,
- type: "topic",
- activity_pub_published_post_count: 20,
- activity_pub_total_post_count: 20,
- },
- };
- await publishToMessageBus("/activity-pub", topicActionStatusUpdate);
- assert
- .dom(
- ".activity-pub-topic-actions .action.publish-all .action-description"
- )
- .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) {
+ Site.current().setProperties({
+ activity_pub_enabled: true,
+ activity_pub_publishing_enabled: true,
+ activity_pub_actors: SiteActors,
});
- test("post modal", async function (assert) {
- Site.current().setProperties({
- activity_pub_enabled: true,
- activity_pub_publishing_enabled: true,
- activity_pub_actors: SiteActors,
- });
+ await visit("/t/280");
- await visit("/t/280");
-
- await click(
- ".topic-post[data-post-number='3'] .activity-pub-post-status"
+ await click(
+ ".topic-post[data-post-number='3'] .activity-pub-post-status"
+ );
+ 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"
);
- 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,
- type: "topic",
- activity_pub_published_at: null,
- },
- };
- await publishToMessageBus("/activity-pub", topicStatusUpdate);
- 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"
- );
- });
- }
- );
-
- acceptance(
- `Discourse Activity Pub | Published ActivityPub first_post topic as staff (glimmer_post_stream_mode = ${postStreamMode})`,
- function (needs) {
- needs.user({ moderator: true, admin: false });
- needs.settings({
- glimmer_post_stream_mode: postStreamMode,
- });
+ const topicStatusUpdate = {
+ model: {
+ id: 280,
+ type: "topic",
+ activity_pub_published_at: null,
+ },
+ };
+ await publishToMessageBus("/activity-pub", topicStatusUpdate);
+ 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"
+ );
+ });
+ }
+);
- setupServer(
- needs,
- [
- {
- activity_pub_first_post: true,
- activity_pub_published_at: publishedAt,
- activity_pub_visibility: "public",
- activity_pub_local: true,
- },
- ],
+acceptance(
+ `Discourse Activity Pub | Published ActivityPub first_post topic as staff`,
+ function (needs) {
+ needs.user({ moderator: true, admin: false });
+
+ setupServer(
+ needs,
+ [
{
+ activity_pub_first_post: true,
activity_pub_published_at: publishedAt,
- activity_pub_full_topic: false,
- }
- );
-
- test("ActivityPub topic info modal", async function (assert) {
- Site.current().setProperties({
- activity_pub_enabled: true,
- activity_pub_publishing_enabled: true,
- });
-
- await visit("/t/280");
-
- await click(".topic-map__activity-pub .activity-pub-topic-status");
- 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"
- )
- .doesNotExist("does not show a topic object type attribute");
- assert
- .dom(
- ".activity-pub-topic-info-modal .activity-pub-attribute.object-type.note"
- )
- .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");
- });
- }
- );
-
- acceptance(
- `Discourse Activity Pub | Published ActivityPub topic as staff with a remote Note (glimmer_post_stream_mode = ${postStreamMode})`,
- function (needs) {
- needs.user({ moderator: true, admin: false });
- needs.settings({
- glimmer_post_stream_mode: postStreamMode,
+ activity_pub_visibility: "public",
+ activity_pub_local: true,
+ },
+ ],
+ {
+ activity_pub_published_at: publishedAt,
+ activity_pub_full_topic: false,
+ }
+ );
+
+ test("ActivityPub topic info modal", async function (assert) {
+ Site.current().setProperties({
+ activity_pub_enabled: true,
+ activity_pub_publishing_enabled: true,
});
- setupServer(
- needs,
- [
- {
- post_number: 1,
- activity_pub_published_at: publishedAt,
- activity_pub_visibility: "public",
- activity_pub_local: false,
- activity_pub_domain: "external.com",
- activity_pub_url: "https://external.com/note/1",
- },
- {
- post_number: 2,
- activity_pub_published_at: publishedAt,
- activity_pub_visibility: "public",
- activity_pub_local: false,
- activity_pub_domain: "external.com",
- activity_pub_url: "https://external.com/note/3",
- },
- ],
+ await visit("/t/280");
+
+ await click(".topic-map__activity-pub .activity-pub-topic-status");
+ 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"
+ )
+ .doesNotExist("does not show a topic object type attribute");
+ assert
+ .dom(
+ ".activity-pub-topic-info-modal .activity-pub-attribute.object-type.note"
+ )
+ .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");
+ });
+ }
+);
+
+acceptance(
+ `Discourse Activity Pub | Published ActivityPub topic as staff with a remote Note`,
+ function (needs) {
+ needs.user({ moderator: true, admin: false });
+
+ setupServer(
+ needs,
+ [
{
+ post_number: 1,
activity_pub_published_at: publishedAt,
+ activity_pub_visibility: "public",
activity_pub_local: false,
- }
- );
-
- test("ActivityPub topic and post status", async function (assert) {
- Site.current().setProperties({
- activity_pub_enabled: true,
- activity_pub_publishing_enabled: true,
- });
-
- await visit("/t/280");
-
- 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[data-post-number='2'] .activity-pub-post-status[title='Post was published via ActivityPub by actor1@domain.com on ${publishedAt.format(
- i18n("dates.time_short_day")
- )}.']`
- )
- .exists("shows the right post status text");
+ activity_pub_domain: "external.com",
+ activity_pub_url: "https://external.com/note/1",
+ },
+ {
+ post_number: 2,
+ activity_pub_published_at: publishedAt,
+ activity_pub_visibility: "public",
+ activity_pub_local: false,
+ activity_pub_domain: "external.com",
+ activity_pub_url: "https://external.com/note/3",
+ },
+ ],
+ {
+ activity_pub_published_at: publishedAt,
+ activity_pub_local: false,
+ }
+ );
+
+ test("ActivityPub topic and post status", async function (assert) {
+ Site.current().setProperties({
+ activity_pub_enabled: true,
+ activity_pub_publishing_enabled: true,
});
- test("ActivityPub topic info modal", async function (assert) {
- Site.current().setProperties({
- activity_pub_enabled: true,
- activity_pub_publishing_enabled: true,
- });
-
- await visit("/t/280");
-
- await click(".topic-map__activity-pub .activity-pub-topic-status");
- 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"
- );
+ await visit("/t/280");
+
+ 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[data-post-number='2'] .activity-pub-post-status[title='Post was published via ActivityPub by actor1@domain.com on ${publishedAt.format(
+ i18n("dates.time_short_day")
+ )}.']`
+ )
+ .exists("shows the right post status text");
+ });
+
+ test("ActivityPub topic info modal", async function (assert) {
+ Site.current().setProperties({
+ activity_pub_enabled: true,
+ activity_pub_publishing_enabled: true,
});
- test("ActivityPub post info modal", async function (assert) {
- Site.current().setProperties({
- activity_pub_enabled: true,
- activity_pub_publishing_enabled: true,
- });
+ await visit("/t/280");
- await visit("/t/280");
+ await click(".topic-map__activity-pub .activity-pub-topic-status");
+ assert.dom(".activity-pub-topic-info-modal").exists("shows the modal");
- await click(
- ".topic-post[data-post-number='2'] .activity-pub-post-status"
+ 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-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");
+ 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) {
+ Site.current().setProperties({
+ activity_pub_enabled: true,
+ activity_pub_publishing_enabled: true,
});
- }
- );
-});
+
+ await visit("/t/280");
+
+ await click(
+ ".topic-post[data-post-number='2'] .activity-pub-post-status"
+ );
+ 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-post-test.gjs b/test/javascripts/components/activity-pub-post-test.gjs
index defe6421..23d1b883 100644
--- a/test/javascripts/components/activity-pub-post-test.gjs
+++ b/test/javascripts/components/activity-pub-post-test.gjs
@@ -1,31 +1,49 @@
+import { getOwner } from "@ember/owner";
import { click, render } from "@ember/test-helpers";
import { module, skip } from "qunit";
-import MountWidget from "discourse/components/mount-widget";
+import Post from "discourse/components/post";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
+import DMenus from "float-kit/components/d-menus";
-module("Discourse Activity Pub | Component | Widget | post", function (hooks) {
+module("Discourse Activity Pub | Component | post", function (hooks) {
setupRenderingTest(hooks);
+ hooks.beforeEach(function () {
+ this.siteSettings.post_menu_hidden_items = "";
+
+ this.store = getOwner(this).lookup("service:store");
+ const topic = this.store.createRecord("topic", { id: 123 });
+ const post = this.store.createRecord("post", {
+ id: 123,
+ post_number: 1,
+ topic,
+ like_count: 3,
+ actions_summary: [{ id: 2, count: 1, hidden: false, can_act: true }],
+ created_at: new Date(new Date().getTime() - 30 * 60 * 1000),
+ user_id: 1,
+ username: "eviltrout",
+ });
+
+ this.post = post;
+ });
skip("non activity pub topic", async function (assert) {
const self = this;
this.currentUser.admin = true;
- this.set("args", { canManage: true, activity_pub_enabled: false });
+ this.currentUser.staff = true;
+ this.post.activity_pub_enabled = false;
this.set("changePostOwner", () => (this.owned = true));
await render(
-
+
+
);
await click(".post-menu-area .show-post-admin-menu");
assert
- .dom(".post-admin-menu button.change-owner")
+ .dom("[data-content][data-identifier='admin-post-menu'] .change-owner")
.exists("the change owner button is visible");
});
@@ -33,22 +51,21 @@ module("Discourse Activity Pub | Component | Widget | post", function (hooks) {
const self = this;
this.currentUser.admin = true;
- this.set("args", { canManage: true, activity_pub_enabled: true });
+ this.currentUser.staff = true;
+ this.post.activity_pub_enabled = true;
this.set("changePostOwner", () => (this.owned = true));
await render(
-
+
+
);
await click(".post-menu-area .show-post-admin-menu");
+
assert
- .dom(".post-admin-menu button.change-owner")
+ .dom("[data-content][data-identifier='admin-post-menu'] .change-owner")
.doesNotExist("the change owner button is not visible");
});
});