REFACTOR: Use the new format for acceptance tests. (#126)

This commit is contained in:
Roman Rizzi 2020-12-30 17:02:45 -03:00 committed by GitHub
parent 1663b3ab18
commit b824e19e91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 177 additions and 185 deletions

View File

@ -1,22 +1,20 @@
import selectKit from "helpers/select-kit-helper";
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { acceptance, updateCurrentUser } from "discourse/tests/helpers/qunit-helpers";
import { clearTopicFooterButtons } from "discourse/lib/register-topic-footer-button";
acceptance("Assign disabled mobile", {
loggedIn: true,
mobileView: true,
settings: { assign_enabled: false },
beforeEach() {
clearTopicFooterButtons();
},
});
QUnit.test("Footer dropdown does not contain button", async (assert) => {
updateCurrentUser({ can_assign: true });
const menu = selectKit(".topic-footer-mobile-dropdown");
await visit("/t/internationalization-localization/280");
await menu.expand();
assert.notOk(menu.rowByValue("assign").exists());
acceptance("Assign disabled mobile", function (needs) {
needs.user();
needs.mobileView();
needs.settings({ assign_enabled: false });
needs.hooks.beforeEach(() => clearTopicFooterButtons());
test("Footer dropdown does not contain button", async (assert) => {
updateCurrentUser({ can_assign: true });
const menu = selectKit(".topic-footer-mobile-dropdown");
await visit("/t/internationalization-localization/280");
await menu.expand();
assert.notOk(menu.rowByValue("assign").exists());
});
});

View File

@ -1,22 +1,20 @@
import selectKit from "helpers/select-kit-helper";
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { acceptance, updateCurrentUser } from "discourse/tests/helpers/qunit-helpers";
import { clearTopicFooterButtons } from "discourse/lib/register-topic-footer-button";
acceptance("Assign mobile", {
loggedIn: true,
mobileView: true,
settings: { assign_enabled: true },
beforeEach() {
clearTopicFooterButtons();
},
});
QUnit.test("Footer dropdown contains button", async (assert) => {
updateCurrentUser({ can_assign: true });
const menu = selectKit(".topic-footer-mobile-dropdown");
await visit("/t/internationalization-localization/280");
await menu.expand();
assert.ok(menu.rowByValue("assign").exists());
acceptance("Assign mobile", function (needs) {
needs.user();
needs.mobileView();
needs.settings({ assign_enabled: true });
needs.hooks.beforeEach(() => clearTopicFooterButtons());
test("Footer dropdown contains button", async (assert) => {
updateCurrentUser({ can_assign: true });
const menu = selectKit(".topic-footer-mobile-dropdown");
await visit("/t/internationalization-localization/280");
await menu.expand();
assert.ok(menu.rowByValue("assign").exists());
});
});

View File

@ -1,11 +1,11 @@
import { acceptance } from "helpers/qunit-helpers";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { default as AssignedTopics } from "../fixtures/assigned-group-assignments-fixtures";
import { default as GroupMembers } from "../fixtures/group-members-fixtures";
acceptance("GroupAssignments", {
loggedIn: true,
settings: { assign_enabled: true, assigns_user_url_path: "/" },
pretend(server, helper) {
acceptance("GroupAssignments", function (needs) {
needs.user();
needs.settings({ assign_enabled: true, assigns_user_url_path: "/" });
needs.pretender((server, helper) => {
const groupPath = "/topics/group-topics-assigned/discourse.json";
const memberPath = "/topics/messages-assigned/ahmedgagan6.json";
const getMembersPath = "/assign/members/discourse";
@ -15,17 +15,17 @@ acceptance("GroupAssignments", {
server.get(groupPath, () => helper.response(groupAssigns));
server.get(memberPath, () => helper.response(memberAssigns));
server.get(getMembersPath, () => helper.response(getMembers));
},
});
});
QUnit.test("Group Assignments Everyone", async (assert) => {
await visit("/g/discourse/assigned");
assert.equal(currentPath(), "group.assigned.show");
assert.ok(find(".topic-list-item").length === 1);
});
test("Group Assignments Everyone", async (assert) => {
await visit("/g/discourse/assigned");
assert.equal(currentPath(), "group.assigned.show");
assert.ok(find(".topic-list-item").length === 1);
});
QUnit.test("Group Assignments Ahmedgagan", async (assert) => {
await visit("/g/discourse/assigned/ahmedgagan6");
assert.equal(currentPath(), "group.assigned.show");
assert.ok(find(".topic-list-item").length === 1);
test("Group Assignments Ahmedgagan", async (assert) => {
await visit("/g/discourse/assigned/ahmedgagan6");
assert.equal(currentPath(), "group.assigned.show");
assert.ok(find(".topic-list-item").length === 1);
});
});

View File

@ -1,38 +1,36 @@
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
import { acceptance, updateCurrentUser } from "discourse/tests/helpers/qunit-helpers";
import { default as AssignedTopics } from "../fixtures/assigned-topics-fixtures";
const USER_MENU = "#current-user.header-dropdown-toggle";
const QUICK_ACCESS_ASSIGNMENTS_TAB = ".widget-link.assigned";
acceptance("Quick access assignments panel", {
loggedIn: true,
settings: {
assign_enabled: true,
assigns_user_url_path: "/",
},
pretend(server, helper) {
acceptance("Quick access assignments panel", function (needs) {
needs.user();
needs.settings({ assign_enabled: true, assigns_user_url_path: "/"});
needs.pretender((server, helper) => {
const messagesPath = "/topics/messages-assigned/eviltrout.json";
const assigns = AssignedTopics[messagesPath];
server.get(messagesPath, () => helper.response(assigns));
},
});
QUnit.test("Quick access assignments panel", async (assert) => {
updateCurrentUser({ can_assign: true });
await visit("/");
await click(USER_MENU);
await click(QUICK_ACCESS_ASSIGNMENTS_TAB);
const assignment = find(".quick-access-panel li a")[0];
assert.ok(assignment.innerText.includes("Greetings!"));
assert.ok(assignment.href.includes("/t/greetings/10/5"));
await click(QUICK_ACCESS_ASSIGNMENTS_TAB);
assert.equal(
currentPath(),
"user.userActivity.assigned",
"a second click should redirect to the full assignments page"
);
});
test("Quick access assignments panel", async (assert) => {
updateCurrentUser({ can_assign: true });
await visit("/");
await click(USER_MENU);
await click(QUICK_ACCESS_ASSIGNMENTS_TAB);
const assignment = find(".quick-access-panel li a")[0];
assert.ok(assignment.innerText.includes("Greetings!"));
assert.ok(assignment.href.includes("/t/greetings/10/5"));
await click(QUICK_ACCESS_ASSIGNMENTS_TAB);
assert.equal(
currentPath(),
"user.userActivity.assigned",
"a second click should redirect to the full assignments page"
);
});
});

View File

@ -1,91 +1,92 @@
import selectKit from "helpers/select-kit-helper";
import { acceptance, waitFor, updateCurrentUser } from "helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { acceptance, waitFor, updateCurrentUser } from "discourse/tests/helpers/qunit-helpers";
acceptance("Search - Full Page", {
settings: { assign_enabled: true },
loggedIn: true,
});
QUnit.test(
"update in:assigned filter through advanced search ui",
async (assert) => {
updateCurrentUser({ can_assign: true });
const inSelector = selectKit(".search-advanced-options .select-kit#in");
acceptance("Search - Full Page", function (needs) {
needs.settings({ assign_enabled: true });
needs.user();
await visit("/search");
test(
"update in:assigned filter through advanced search ui",
async (assert) => {
updateCurrentUser({ can_assign: true });
const inSelector = selectKit(".search-advanced-options .select-kit#in");
await fillIn(".search-query", "none");
await inSelector.expand();
await inSelector.selectRowByValue("assigned");
assert.equal(
inSelector.header().label(),
"are assigned",
'has "are assigned" populated'
);
assert.equal(
find(".search-query").val(),
"none in:assigned",
'has updated search term to "none in:assinged"'
);
}
);
await visit("/search");
QUnit.test(
"update in:unassigned filter through advanced search ui",
async (assert) => {
updateCurrentUser({ can_assign: true });
const inSelector = selectKit(".search-advanced-options .select-kit#in");
await visit("/search");
await fillIn(".search-query", "none");
await inSelector.expand();
await inSelector.selectRowByValue("unassigned");
assert.equal(
inSelector.header().label(),
"are unassigned",
'has "are unassigned" populated'
);
assert.equal(
find(".search-query").val(),
"none in:unassigned",
'has updated search term to "none in:unassinged"'
);
}
);
QUnit.skip("update assigned to through advanced search ui", async (assert) => {
updateCurrentUser({ can_assign: true });
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
await fillIn(".search-query", "none");
await inSelector.expand();
await inSelector.selectRowByValue("assigned");
assert.equal(
inSelector.header().label(),
"are assigned",
'has "are assigned" populated'
);
assert.equal(
find(".search-query").val(),
"none in:assigned",
'has updated search term to "none in:assinged"'
);
}
);
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");
test(
"update in:unassigned filter through advanced search ui",
async (assert) => {
updateCurrentUser({ can_assign: true });
const inSelector = selectKit(".search-advanced-options .select-kit#in");
assert.ok(
exists('.search-advanced-options span:contains("admin")'),
'has "admin" pre-populated'
);
assert.equal(
find(".search-query").val(),
"none assigned:admin",
'has updated search term to "none assigned:admin"'
await visit("/search");
await fillIn(".search-query", "none");
await inSelector.expand();
await inSelector.selectRowByValue("unassigned");
assert.equal(
inSelector.header().label(),
"are unassigned",
'has "are unassigned" populated'
);
assert.equal(
find(".search-query").val(),
"none in:unassigned",
'has updated search term to "none in:unassinged"'
);
}
);
skip("update assigned to through advanced search ui", async (assert) => {
updateCurrentUser({ can_assign: true });
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 click(".search-advanced-options .autocomplete ul li a:first");
assert.ok(
exists('.search-advanced-options span:contains("admin")'),
'has "admin" pre-populated'
);
assert.equal(
find(".search-query").val(),
"none assigned:admin",
'has updated search term to "none assigned:admin"'
);
});
});
});

View File

@ -1,26 +1,23 @@
import selectKit from "helpers/select-kit-helper";
import { acceptance } from "helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { default as AssignedTopics } from "../fixtures/assigned-topics-fixtures";
acceptance("UnAssign/Re-assign from the topics list", {
loggedIn: true,
settings: {
assign_enabled: true,
assigns_user_url_path: "/",
},
pretend(server, helper) {
acceptance("UnAssign/Re-assign 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";
const assigns = AssignedTopics[messagesPath];
server.get(messagesPath, () => helper.response(assigns));
},
});
QUnit.test("Unassing/Re-assign options are visible", async (assert) => {
const options = selectKit(".assign-actions-dropdown");
await visit("/u/eviltrout/activity/assigned");
await options.expand();
assert.equal(find("li[data-value='unassign']").length, 1);
assert.equal(find("li[data-value='reassign']").length, 1);
});
test("Unassing/Re-assign options are visible", async (assert) => {
const options = selectKit(".assign-actions-dropdown");
await visit("/u/eviltrout/activity/assigned");
await options.expand();
assert.equal(find("li[data-value='unassign']").length, 1);
assert.equal(find("li[data-value='reassign']").length, 1);
});
});

View File

@ -1,4 +1,4 @@
import componentTest from "helpers/component-test";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("group-assigned-filter", { integration: true });