DEV: Update tests (#177)
Included: * DEV: Add "assigned topic" test * DEV: Update and re-enable disabled test * DEV: Add missing imports * DEV: Fix typos * DEV: Don't use find() * DEV: Use the hbs helper
This commit is contained in:
parent
4024eb078c
commit
53d3bda543
|
@ -3,7 +3,9 @@ import {
|
|||
acceptance,
|
||||
updateCurrentUser,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
import { clearTopicFooterButtons } from "discourse/lib/register-topic-footer-button";
|
||||
import { test } from "qunit";
|
||||
|
||||
acceptance("Assign disabled mobile", function (needs) {
|
||||
needs.user();
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import {
|
||||
acceptance,
|
||||
exists,
|
||||
updateCurrentUser,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { click, visit } from "@ember/test-helpers";
|
||||
import { clearTopicFooterButtons } from "discourse/lib/register-topic-footer-button";
|
||||
import { test } from "qunit";
|
||||
|
||||
acceptance("Assign mobile", function (needs) {
|
||||
needs.user();
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
import { test } from "qunit";
|
||||
import {
|
||||
acceptance,
|
||||
exists,
|
||||
query,
|
||||
updateCurrentUser,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
import { cloneJSON } from "discourse-common/lib/object";
|
||||
import topicFixtures from "discourse/tests/fixtures/topic";
|
||||
|
||||
acceptance("Assigned topic", function (needs) {
|
||||
needs.user();
|
||||
needs.settings({
|
||||
assign_enabled: true,
|
||||
tagging_enabled: true,
|
||||
assigns_user_url_path: "/",
|
||||
});
|
||||
|
||||
needs.pretender((server, helper) => {
|
||||
server.get("/t/44.json", () => {
|
||||
let topic = cloneJSON(topicFixtures["/t/28830/1.json"]);
|
||||
topic["assigned_to_user"] = {
|
||||
username: "eviltrout",
|
||||
name: "Robin Ward",
|
||||
avatar_template:
|
||||
"/letter_avatar/eviltrout/{size}/3_f9720745f5ce6dfc2b5641fca999d934.png",
|
||||
assigned_at: "2021-06-13T16:33:14.189Z",
|
||||
};
|
||||
return helper.response(topic);
|
||||
});
|
||||
});
|
||||
|
||||
test("Shows assignment info", async (assert) => {
|
||||
updateCurrentUser({ can_assign: true });
|
||||
await visit("/t/assignment-topic/44");
|
||||
|
||||
assert.equal(
|
||||
query("#topic-title .assigned-to").innerText,
|
||||
"eviltrout",
|
||||
"shows assignment in the header"
|
||||
);
|
||||
assert.equal(
|
||||
query("#post_1 .assigned-to-username").innerText,
|
||||
"eviltrout",
|
||||
"shows assignment in the first post"
|
||||
);
|
||||
assert.ok(
|
||||
exists("#topic-footer-button-assign .unassign-label"),
|
||||
"shows unassign button at the bottom of the topic"
|
||||
);
|
||||
});
|
||||
});
|
|
@ -1,6 +1,8 @@
|
|||
import { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
import AssignedTopics from "../fixtures/assigned-group-assignments-fixtures";
|
||||
import GroupMembers from "../fixtures/group-members-fixtures";
|
||||
import { test } from "qunit";
|
||||
|
||||
acceptance("GroupAssignments", function (needs) {
|
||||
needs.user();
|
||||
|
@ -19,13 +21,11 @@ acceptance("GroupAssignments", function (needs) {
|
|||
|
||||
test("Group Assignments Everyone", async (assert) => {
|
||||
await visit("/g/discourse/assigned");
|
||||
assert.equal(currentPath(), "group.assigned.show");
|
||||
assert.equal(count(".topic-list-item"), 1);
|
||||
});
|
||||
|
||||
test("Group Assignments Ahmedgagan", async (assert) => {
|
||||
await visit("/g/discourse/assigned/ahmedgagan6");
|
||||
assert.equal(currentPath(), "group.assigned.show");
|
||||
assert.equal(count(".topic-list-item"), 1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,7 +3,9 @@ import {
|
|||
query,
|
||||
updateCurrentUser,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { click, currentURL, visit } from "@ember/test-helpers";
|
||||
import AssignedTopics from "../fixtures/assigned-topics-fixtures";
|
||||
import { test } from "qunit";
|
||||
|
||||
acceptance("Quick access assignments panel", function (needs) {
|
||||
needs.user();
|
||||
|
@ -29,8 +31,8 @@ acceptance("Quick access assignments panel", function (needs) {
|
|||
|
||||
await click(".widget-button.assigned");
|
||||
assert.equal(
|
||||
currentPath(),
|
||||
"user.userActivity.assigned",
|
||||
currentURL(),
|
||||
"/u/eviltrout/activity/assigned",
|
||||
"a second click should redirect to the full assignments page"
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,14 +1,28 @@
|
|||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import {
|
||||
acceptance,
|
||||
query,
|
||||
updateCurrentUser,
|
||||
waitFor,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { skip, test } from "qunit";
|
||||
import { fillIn, visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
|
||||
acceptance("Search - Full Page", function (needs) {
|
||||
needs.settings({ assign_enabled: true });
|
||||
needs.user();
|
||||
needs.pretender((server, helper) => {
|
||||
server.get("/u/search/users", () => {
|
||||
return helper.response({
|
||||
users: [
|
||||
{
|
||||
username: "admin",
|
||||
name: "admin",
|
||||
avatar_template: "/images/avatar.png",
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test("update in:assigned filter through advanced search ui", async (assert) => {
|
||||
updateCurrentUser({ can_assign: true });
|
||||
|
@ -25,9 +39,9 @@ acceptance("Search - Full Page", function (needs) {
|
|||
'has "are assigned" populated'
|
||||
);
|
||||
assert.equal(
|
||||
find(".search-query").val(),
|
||||
query(".search-query").value,
|
||||
"none in:assigned",
|
||||
'has updated search term to "none in:assinged"'
|
||||
'has updated search term to "none in:assigned"'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -46,46 +60,32 @@ acceptance("Search - Full Page", function (needs) {
|
|||
'has "are unassigned" populated'
|
||||
);
|
||||
assert.equal(
|
||||
find(".search-query").val(),
|
||||
query(".search-query").value,
|
||||
"none in:unassigned",
|
||||
'has updated search term to "none in:unassinged"'
|
||||
'has updated search term to "none in:unassigned"'
|
||||
);
|
||||
});
|
||||
|
||||
skip("update assigned to through advanced search ui", async (assert) => {
|
||||
test("update assigned to through advanced search ui", async (assert) => {
|
||||
updateCurrentUser({ can_assign: true });
|
||||
const assignedField = selectKit(".assigned-advanced-search .select-kit");
|
||||
|
||||
await visit("/search");
|
||||
|
||||
await fillIn(".search-query", "none");
|
||||
await fillIn(".search-advanced-options .user-selector-assigned", "admin");
|
||||
await click(".search-advanced-options .user-selector-assigned");
|
||||
await keyEvent(
|
||||
".search-advanced-options .user-selector-assigned",
|
||||
"keydown",
|
||||
8
|
||||
);
|
||||
waitFor(assert, async () => {
|
||||
assert.ok(
|
||||
visible(".search-advanced-options .autocomplete"),
|
||||
'"autocomplete" popup is visible'
|
||||
);
|
||||
assert.ok(
|
||||
exists(
|
||||
'.search-advanced-options .autocomplete ul li a span.username:contains("admin")'
|
||||
),
|
||||
'"autocomplete" popup has an entry for "admin"'
|
||||
);
|
||||
await assignedField.expand();
|
||||
await assignedField.fillInFilter("admin");
|
||||
await assignedField.selectRowByValue("admin");
|
||||
|
||||
await click(".search-advanced-options .autocomplete ul li a:first");
|
||||
|
||||
assert.ok(
|
||||
exists('.search-advanced-options span:contains("admin")'),
|
||||
'has "admin" pre-populated'
|
||||
assert.equal(
|
||||
assignedField.header().value(),
|
||||
"admin",
|
||||
'has "admin" filled in'
|
||||
);
|
||||
assert.equal(
|
||||
find(".search-query").val(),
|
||||
query(".search-query").value,
|
||||
"none assigned:admin",
|
||||
'has updated search term to "none assigned:admin"'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
import AssignedTopics from "../fixtures/assigned-topics-fixtures";
|
||||
import { test } from "qunit";
|
||||
|
||||
acceptance("UnAssign/Re-assign from the topics list", function (needs) {
|
||||
needs.user();
|
||||
|
@ -11,7 +13,7 @@ acceptance("UnAssign/Re-assign from the topics list", function (needs) {
|
|||
server.get(messagesPath, () => helper.response(assigns));
|
||||
});
|
||||
|
||||
test("Unassing/Re-assign options are visible", async (assert) => {
|
||||
test("Unassign/Re-assign options are visible", async (assert) => {
|
||||
const options = selectKit(".assign-actions-dropdown");
|
||||
|
||||
await visit("/u/eviltrout/activity/assigned");
|
||||
|
|
|
@ -2,6 +2,7 @@ import componentTest, {
|
|||
setupRenderingTest,
|
||||
} from "discourse/tests/helpers/component-test";
|
||||
import { discourseModule, query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
|
||||
discourseModule(
|
||||
"Integration | Component | group-assigned-filter",
|
||||
|
@ -9,7 +10,7 @@ discourseModule(
|
|||
setupRenderingTest(hooks);
|
||||
|
||||
componentTest("displays username and name", {
|
||||
template: "{{group-assigned-filter show-avatar=true filter=filter}}",
|
||||
template: hbs`{{group-assigned-filter show-avatar=true filter=filter}}`,
|
||||
|
||||
beforeEach() {
|
||||
this.set("filter", {
|
||||
|
|
Loading…
Reference in New Issue