Skip to content

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

1.9 KB
Raw Blame
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { cloneJSON } from "discourse/lib/object";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import AssignedTopics from "../fixtures/assigned-topics-fixtures.js";

acceptance("Unassign/reassign from the topics list", function (needs) {
  needs.user();
  needs.settings({ assign_enabled: true, assigns_user_url_path: "/" });
  needs.pretender((server, helper) => {
    const messagesPath = "/topics/messages-assigned/eviltrout.json";
    server.get(messagesPath, () =>
      helper.response(cloneJSON(AssignedTopics[messagesPath]))
    );
  });

  test("unassign/reassign options are visible", async function (assert) {
    const options = selectKit(".assign-actions-dropdown");

    await visit("/u/eviltrout/activity/assigned");
    await options.expand();

    assert.dom("li[data-value='unassign']").exists({ count: 1 });
    assert.dom("li[data-value='reassign']").exists({ count: 1 });
  });
});

acceptance(
  "Discourse Assign | A user doesn't have assignments",
  function (needs) {
    needs.user();
    needs.settings({ assign_enabled: true, assigns_user_url_path: "/" });
    needs.pretender((server, helper) => {
      const assignments = cloneJSON(
        AssignedTopics["/topics/messages-assigned/eviltrout.json"]
      );
      assignments.topic_list.topics = [];
      server.get("/topics/messages-assigned/eviltrout.json", () =>
        helper.response(assignments)
      );
    });

    test("renders the empty state panel", async function (assert) {
      await visit("/u/eviltrout/activity/assigned");
      assert.dom("div.empty-state").exists();
    });

    test("does not render the search form", async function (assert) {
      await visit("/u/eviltrout/activity/assigned");
      assert.dom("div.topic-search-div").doesNotExist();
    });
  }
);