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,
|
acceptance,
|
||||||
updateCurrentUser,
|
updateCurrentUser,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import { visit } from "@ember/test-helpers";
|
||||||
import { clearTopicFooterButtons } from "discourse/lib/register-topic-footer-button";
|
import { clearTopicFooterButtons } from "discourse/lib/register-topic-footer-button";
|
||||||
|
import { test } from "qunit";
|
||||||
|
|
||||||
acceptance("Assign disabled mobile", function (needs) {
|
acceptance("Assign disabled mobile", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||||
import {
|
import {
|
||||||
acceptance,
|
acceptance,
|
||||||
|
exists,
|
||||||
updateCurrentUser,
|
updateCurrentUser,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import { click, visit } from "@ember/test-helpers";
|
||||||
import { clearTopicFooterButtons } from "discourse/lib/register-topic-footer-button";
|
import { clearTopicFooterButtons } from "discourse/lib/register-topic-footer-button";
|
||||||
|
import { test } from "qunit";
|
||||||
|
|
||||||
acceptance("Assign mobile", function (needs) {
|
acceptance("Assign mobile", function (needs) {
|
||||||
needs.user();
|
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 { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import { visit } from "@ember/test-helpers";
|
||||||
import AssignedTopics from "../fixtures/assigned-group-assignments-fixtures";
|
import AssignedTopics from "../fixtures/assigned-group-assignments-fixtures";
|
||||||
import GroupMembers from "../fixtures/group-members-fixtures";
|
import GroupMembers from "../fixtures/group-members-fixtures";
|
||||||
|
import { test } from "qunit";
|
||||||
|
|
||||||
acceptance("GroupAssignments", function (needs) {
|
acceptance("GroupAssignments", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
|
@ -19,13 +21,11 @@ acceptance("GroupAssignments", function (needs) {
|
||||||
|
|
||||||
test("Group Assignments Everyone", async (assert) => {
|
test("Group Assignments Everyone", async (assert) => {
|
||||||
await visit("/g/discourse/assigned");
|
await visit("/g/discourse/assigned");
|
||||||
assert.equal(currentPath(), "group.assigned.show");
|
|
||||||
assert.equal(count(".topic-list-item"), 1);
|
assert.equal(count(".topic-list-item"), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Group Assignments Ahmedgagan", async (assert) => {
|
test("Group Assignments Ahmedgagan", async (assert) => {
|
||||||
await visit("/g/discourse/assigned/ahmedgagan6");
|
await visit("/g/discourse/assigned/ahmedgagan6");
|
||||||
assert.equal(currentPath(), "group.assigned.show");
|
|
||||||
assert.equal(count(".topic-list-item"), 1);
|
assert.equal(count(".topic-list-item"), 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,9 @@ import {
|
||||||
query,
|
query,
|
||||||
updateCurrentUser,
|
updateCurrentUser,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import { click, currentURL, visit } from "@ember/test-helpers";
|
||||||
import AssignedTopics from "../fixtures/assigned-topics-fixtures";
|
import AssignedTopics from "../fixtures/assigned-topics-fixtures";
|
||||||
|
import { test } from "qunit";
|
||||||
|
|
||||||
acceptance("Quick access assignments panel", function (needs) {
|
acceptance("Quick access assignments panel", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
|
@ -29,8 +31,8 @@ acceptance("Quick access assignments panel", function (needs) {
|
||||||
|
|
||||||
await click(".widget-button.assigned");
|
await click(".widget-button.assigned");
|
||||||
assert.equal(
|
assert.equal(
|
||||||
currentPath(),
|
currentURL(),
|
||||||
"user.userActivity.assigned",
|
"/u/eviltrout/activity/assigned",
|
||||||
"a second click should redirect to the full assignments page"
|
"a second click should redirect to the full assignments page"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,14 +1,28 @@
|
||||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||||
import {
|
import {
|
||||||
acceptance,
|
acceptance,
|
||||||
|
query,
|
||||||
updateCurrentUser,
|
updateCurrentUser,
|
||||||
waitFor,
|
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} 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) {
|
acceptance("Search - Full Page", function (needs) {
|
||||||
needs.settings({ assign_enabled: true });
|
needs.settings({ assign_enabled: true });
|
||||||
needs.user();
|
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) => {
|
test("update in:assigned filter through advanced search ui", async (assert) => {
|
||||||
updateCurrentUser({ can_assign: true });
|
updateCurrentUser({ can_assign: true });
|
||||||
|
@ -25,9 +39,9 @@ acceptance("Search - Full Page", function (needs) {
|
||||||
'has "are assigned" populated'
|
'has "are assigned" populated'
|
||||||
);
|
);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find(".search-query").val(),
|
query(".search-query").value,
|
||||||
"none in:assigned",
|
"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'
|
'has "are unassigned" populated'
|
||||||
);
|
);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find(".search-query").val(),
|
query(".search-query").value,
|
||||||
"none in:unassigned",
|
"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 });
|
updateCurrentUser({ can_assign: true });
|
||||||
|
const assignedField = selectKit(".assigned-advanced-search .select-kit");
|
||||||
|
|
||||||
await visit("/search");
|
await visit("/search");
|
||||||
|
|
||||||
await fillIn(".search-query", "none");
|
await fillIn(".search-query", "none");
|
||||||
await fillIn(".search-advanced-options .user-selector-assigned", "admin");
|
await assignedField.expand();
|
||||||
await click(".search-advanced-options .user-selector-assigned");
|
await assignedField.fillInFilter("admin");
|
||||||
await keyEvent(
|
await assignedField.selectRowByValue("admin");
|
||||||
".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 click(".search-advanced-options .autocomplete ul li a:first");
|
assert.equal(
|
||||||
|
assignedField.header().value(),
|
||||||
assert.ok(
|
"admin",
|
||||||
exists('.search-advanced-options span:contains("admin")'),
|
'has "admin" filled in'
|
||||||
'has "admin" pre-populated'
|
|
||||||
);
|
);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find(".search-query").val(),
|
query(".search-query").value,
|
||||||
"none assigned:admin",
|
"none assigned:admin",
|
||||||
'has updated search term to "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 selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||||
import { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
|
import { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import { visit } from "@ember/test-helpers";
|
||||||
import AssignedTopics from "../fixtures/assigned-topics-fixtures";
|
import AssignedTopics from "../fixtures/assigned-topics-fixtures";
|
||||||
|
import { test } from "qunit";
|
||||||
|
|
||||||
acceptance("UnAssign/Re-assign from the topics list", function (needs) {
|
acceptance("UnAssign/Re-assign from the topics list", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
|
@ -11,7 +13,7 @@ acceptance("UnAssign/Re-assign from the topics list", function (needs) {
|
||||||
server.get(messagesPath, () => helper.response(assigns));
|
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");
|
const options = selectKit(".assign-actions-dropdown");
|
||||||
|
|
||||||
await visit("/u/eviltrout/activity/assigned");
|
await visit("/u/eviltrout/activity/assigned");
|
||||||
|
|
|
@ -2,6 +2,7 @@ import componentTest, {
|
||||||
setupRenderingTest,
|
setupRenderingTest,
|
||||||
} from "discourse/tests/helpers/component-test";
|
} from "discourse/tests/helpers/component-test";
|
||||||
import { discourseModule, query } from "discourse/tests/helpers/qunit-helpers";
|
import { discourseModule, query } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import hbs from "htmlbars-inline-precompile";
|
||||||
|
|
||||||
discourseModule(
|
discourseModule(
|
||||||
"Integration | Component | group-assigned-filter",
|
"Integration | Component | group-assigned-filter",
|
||||||
|
@ -9,7 +10,7 @@ discourseModule(
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
componentTest("displays username and name", {
|
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() {
|
beforeEach() {
|
||||||
this.set("filter", {
|
this.set("filter", {
|
||||||
|
|
Loading…
Reference in New Issue