This PR adds an edit button to the topic timer info message which opens the modal. Also, I have cleaned up a few more places where we were referencing "topic status update" which is what these were called prior to being called topic timers. The category settings for auto-close topic hours has now also been modified to use the new relative-time-picker component. Finally, the relative-time-picker input step and min is dynamic based on mins/other intervals selected, see https://review.discourse.org/t/feature-relative-time-input-for-timers-and-bookmarks-and-promote-auto-close-after-last-post-timer-12063/19204/7?u=martin
83 lines
2.4 KiB
JavaScript
83 lines
2.4 KiB
JavaScript
import componentTest, {
|
|
setupRenderingTest,
|
|
} from "discourse/tests/helpers/component-test";
|
|
import { discourseModule, exists } from "discourse/tests/helpers/qunit-helpers";
|
|
import Category from "discourse/models/category";
|
|
import Topic from "discourse/models/topic";
|
|
import hbs from "htmlbars-inline-precompile";
|
|
|
|
const createArgs = (topic) => {
|
|
return {
|
|
topic: topic,
|
|
openUpwards: "true",
|
|
toggleMultiSelect: () => {},
|
|
deleteTopic: () => {},
|
|
recoverTopic: () => {},
|
|
toggleClosed: () => {},
|
|
toggleArchived: () => {},
|
|
toggleVisibility: () => {},
|
|
showTopicTimerModal: () => {},
|
|
showFeatureTopic: () => {},
|
|
showChangeTimestamp: () => {},
|
|
resetBumpDate: () => {},
|
|
convertToPublicTopic: () => {},
|
|
convertToPrivateMessage: () => {},
|
|
};
|
|
};
|
|
|
|
discourseModule(
|
|
"Integration | Component | Widget | topic-admin-menu-button",
|
|
function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
componentTest("topic-admin-menu-button is present for admin/moderators", {
|
|
template: hbs`{{mount-widget widget="topic-admin-menu-button" args=args}}`,
|
|
|
|
beforeEach() {
|
|
this.currentUser.setProperties({
|
|
admin: true,
|
|
moderator: true,
|
|
id: 123,
|
|
});
|
|
const topic = Topic.create({ user_id: this.currentUser.id });
|
|
topic.set("category_id", Category.create({ read_restricted: true }).id);
|
|
this.siteSettings.allow_featured_topic_on_user_profiles = true;
|
|
this.set("args", createArgs(topic));
|
|
},
|
|
|
|
test(assert) {
|
|
assert.ok(exists(".toggle-admin-menu"), "admin wrench is present");
|
|
},
|
|
});
|
|
|
|
componentTest(
|
|
"topic-admin-menu-button hides for non-admin when there is no action",
|
|
{
|
|
template: hbs`{{mount-widget widget="topic-admin-menu-button" args=args}}`,
|
|
|
|
beforeEach() {
|
|
this.currentUser.setProperties({
|
|
admin: false,
|
|
moderator: false,
|
|
id: 123,
|
|
});
|
|
const topic = Topic.create({ user_id: this.currentUser.id });
|
|
topic.set(
|
|
"category_id",
|
|
Category.create({ read_restricted: true }).id
|
|
);
|
|
this.siteSettings.allow_featured_topic_on_user_profiles = true;
|
|
this.set("args", createArgs(topic));
|
|
},
|
|
|
|
test(assert) {
|
|
assert.ok(
|
|
!exists(".toggle-admin-menu"),
|
|
"admin wrench is not present"
|
|
);
|
|
},
|
|
}
|
|
);
|
|
}
|
|
);
|