mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
REFACTOR: Test Memory Usage Fixes (#7769)
* Calling `Discourse.reset()` creates a new container We should run our de-initializers only after acceptance tests, since initializers are not run outside of acceptance tests anyway, and the container at this point can be passed properly to the `teardown()` method. * Remove `Discourse.reset` from tests This would cause a new container to be created which leaks many objects. * `updateCurrentUser` is more accurate than `replaceCurrentUser`
This commit is contained in:
parent
c3381b845b
commit
a8793d0d9a
|
@ -1,4 +1,4 @@
|
|||
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
||||
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
||||
import { displayPollBuilderButton } from "discourse/plugins/poll/helpers/display-poll-builder-button";
|
||||
import { clearPopupMenuOptionsCallback } from "discourse/controllers/composer";
|
||||
|
||||
|
@ -14,7 +14,7 @@ acceptance("Poll Builder - polls are disabled", {
|
|||
});
|
||||
|
||||
test("regular user - sufficient trust level", assert => {
|
||||
replaceCurrentUser({ staff: false, trust_level: 3 });
|
||||
updateCurrentUser({ staff: false, trust_level: 3 });
|
||||
|
||||
displayPollBuilderButton();
|
||||
|
||||
|
@ -27,7 +27,7 @@ test("regular user - sufficient trust level", assert => {
|
|||
});
|
||||
|
||||
test("regular user - insufficient trust level", assert => {
|
||||
replaceCurrentUser({ staff: false, trust_level: 1 });
|
||||
updateCurrentUser({ staff: false, trust_level: 1 });
|
||||
|
||||
displayPollBuilderButton();
|
||||
|
||||
|
@ -40,7 +40,7 @@ test("regular user - insufficient trust level", assert => {
|
|||
});
|
||||
|
||||
test("staff", assert => {
|
||||
replaceCurrentUser({ staff: true });
|
||||
updateCurrentUser({ staff: true });
|
||||
|
||||
displayPollBuilderButton();
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
||||
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
||||
import { displayPollBuilderButton } from "discourse/plugins/poll/helpers/display-poll-builder-button";
|
||||
import { clearPopupMenuOptionsCallback } from "discourse/controllers/composer";
|
||||
|
||||
|
@ -14,7 +14,7 @@ acceptance("Poll Builder - polls are enabled", {
|
|||
});
|
||||
|
||||
test("regular user - sufficient trust level", assert => {
|
||||
replaceCurrentUser({ staff: false, trust_level: 1 });
|
||||
updateCurrentUser({ staff: false, trust_level: 1 });
|
||||
|
||||
displayPollBuilderButton();
|
||||
|
||||
|
@ -27,7 +27,7 @@ test("regular user - sufficient trust level", assert => {
|
|||
});
|
||||
|
||||
test("regular user - insufficient trust level", assert => {
|
||||
replaceCurrentUser({ staff: false, trust_level: 0 });
|
||||
updateCurrentUser({ staff: false, trust_level: 0 });
|
||||
|
||||
displayPollBuilderButton();
|
||||
|
||||
|
@ -40,7 +40,7 @@ test("regular user - insufficient trust level", assert => {
|
|||
});
|
||||
|
||||
test("staff - with insufficient trust level", assert => {
|
||||
replaceCurrentUser({ staff: true, trust_level: 0 });
|
||||
updateCurrentUser({ staff: true, trust_level: 0 });
|
||||
|
||||
displayPollBuilderButton();
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import selectKit from "helpers/select-kit-helper";
|
||||
import { acceptance, logIn } from "helpers/qunit-helpers";
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Badges");
|
||||
acceptance("Badges", { loggedIn: true });
|
||||
|
||||
QUnit.test("Visit Badge Pages", async assert => {
|
||||
await visit("/badges");
|
||||
|
@ -17,10 +17,7 @@ QUnit.test("Visit Badge Pages", async assert => {
|
|||
});
|
||||
|
||||
QUnit.test("shows correct badge titles to choose from", async assert => {
|
||||
logIn();
|
||||
Discourse.reset();
|
||||
const availableBadgeTitles = selectKit(".select-kit");
|
||||
|
||||
await visit("/badges/50/custombadge");
|
||||
await availableBadgeTitles.expand();
|
||||
assert.ok(availableBadgeTitles.rowByIndex(1).name() === "CustomBadge");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import selectKit from "helpers/select-kit-helper";
|
||||
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
||||
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
||||
import { _clearSnapshots } from "select-kit/components/composer-actions";
|
||||
import { toggleCheckDraftPopup } from "discourse/controllers/composer";
|
||||
|
||||
|
@ -305,7 +305,7 @@ QUnit.test("replying to post - toggle_topic_bump", async assert => {
|
|||
QUnit.test("replying to post as staff", async assert => {
|
||||
const composerActions = selectKit(".composer-actions");
|
||||
|
||||
replaceCurrentUser({ staff: true, admin: false });
|
||||
updateCurrentUser({ staff: true, admin: false });
|
||||
await visit("/t/internationalization-localization/280");
|
||||
await click("article#post_3 button.reply");
|
||||
await composerActions.expand();
|
||||
|
@ -317,7 +317,7 @@ QUnit.test("replying to post as staff", async assert => {
|
|||
QUnit.test("replying to post as TL3 user", async assert => {
|
||||
const composerActions = selectKit(".composer-actions");
|
||||
|
||||
replaceCurrentUser({ staff: false, admin: false, trust_level: 3 });
|
||||
updateCurrentUser({ staff: false, admin: false, trust_level: 3 });
|
||||
await visit("/t/internationalization-localization/280");
|
||||
await click("article#post_3 button.reply");
|
||||
await composerActions.expand();
|
||||
|
@ -335,7 +335,7 @@ QUnit.test("replying to post as TL3 user", async assert => {
|
|||
QUnit.test("replying to post as TL4 user", async assert => {
|
||||
const composerActions = selectKit(".composer-actions");
|
||||
|
||||
replaceCurrentUser({ staff: false, admin: false, trust_level: 4 });
|
||||
updateCurrentUser({ staff: false, admin: false, trust_level: 4 });
|
||||
await visit("/t/internationalization-localization/280");
|
||||
await click("article#post_3 button.reply");
|
||||
await composerActions.expand();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
||||
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Composer topic featured links", {
|
||||
loggedIn: true,
|
||||
|
@ -156,7 +156,7 @@ acceptance("Composer topic featured links when uncategorized is not allowed", {
|
|||
});
|
||||
|
||||
QUnit.test("Pasting a link enables the text input area", async assert => {
|
||||
replaceCurrentUser({ admin: false, staff: false, trust_level: 1 });
|
||||
updateCurrentUser({ admin: false, staff: false, trust_level: 1 });
|
||||
|
||||
await visit("/");
|
||||
await click("#create-topic");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import selectKit from "helpers/select-kit-helper";
|
||||
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
||||
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Composer and uncategorized is not allowed", {
|
||||
loggedIn: true,
|
||||
|
@ -18,7 +18,7 @@ acceptance("Composer and uncategorized is not allowed", {
|
|||
});
|
||||
|
||||
QUnit.test("Disable body until category is selected", async assert => {
|
||||
replaceCurrentUser({ admin: false, staff: false, trust_level: 1 });
|
||||
updateCurrentUser({ admin: false, staff: false, trust_level: 1 });
|
||||
|
||||
await visit("/");
|
||||
await click("#create-topic");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
||||
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Email Disabled Banner", {
|
||||
loggedIn: true
|
||||
|
@ -26,7 +26,7 @@ QUnit.test("shows banner when required", async assert => {
|
|||
"alert is displayed when email disabled for non-staff"
|
||||
);
|
||||
|
||||
replaceCurrentUser({ staff: true, moderator: true });
|
||||
updateCurrentUser({ staff: true, moderator: true });
|
||||
await visit("/");
|
||||
assert.ok(
|
||||
exists(".alert-emails-disabled"),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
||||
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Enforce Second Factor", {
|
||||
loggedIn: true
|
||||
|
@ -27,7 +27,7 @@ QUnit.test("as an admin", async assert => {
|
|||
});
|
||||
|
||||
QUnit.test("as a user", async assert => {
|
||||
replaceCurrentUser({ staff: false, admin: false });
|
||||
updateCurrentUser({ staff: false, admin: false });
|
||||
|
||||
await visit("/u/eviltrout/preferences/second-factor");
|
||||
Discourse.SiteSettings.enforce_second_factor = "all";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { acceptance, logIn, replaceCurrentUser } from "helpers/qunit-helpers";
|
||||
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Group Members");
|
||||
|
||||
|
@ -23,10 +23,10 @@ QUnit.test("Viewing Members as anon user", async assert => {
|
|||
);
|
||||
});
|
||||
|
||||
acceptance("Group Members", { loggedIn: true });
|
||||
|
||||
QUnit.test("Viewing Members as a group owner", async assert => {
|
||||
logIn();
|
||||
Discourse.reset();
|
||||
replaceCurrentUser({ admin: false, staff: false });
|
||||
updateCurrentUser({ admin: false, staff: false });
|
||||
|
||||
await visit("/g/discourse");
|
||||
await click(".group-members-add");
|
||||
|
@ -39,9 +39,6 @@ QUnit.test("Viewing Members as a group owner", async assert => {
|
|||
});
|
||||
|
||||
QUnit.test("Viewing Members as an admin user", async assert => {
|
||||
logIn();
|
||||
Discourse.reset();
|
||||
|
||||
await visit("/g/discourse");
|
||||
|
||||
assert.ok(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
||||
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Managing Group Interaction Settings", {
|
||||
loggedIn: true,
|
||||
|
@ -42,7 +42,7 @@ QUnit.test("As an admin", async assert => {
|
|||
});
|
||||
|
||||
QUnit.test("As a group owner", async assert => {
|
||||
replaceCurrentUser({ admin: false, staff: false });
|
||||
updateCurrentUser({ admin: false, staff: false });
|
||||
await visit("/g/discourse/manage/interaction");
|
||||
|
||||
assert.equal(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
||||
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Managing Group Membership", {
|
||||
loggedIn: true
|
||||
|
@ -68,7 +68,7 @@ QUnit.test("As an admin", async assert => {
|
|||
});
|
||||
|
||||
QUnit.test("As a group owner", async assert => {
|
||||
replaceCurrentUser({ staff: false, admin: false });
|
||||
updateCurrentUser({ staff: false, admin: false });
|
||||
|
||||
await visit("/g/discourse/manage/membership");
|
||||
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
import { acceptance, logIn, replaceCurrentUser } from "helpers/qunit-helpers";
|
||||
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Managing Group Profile");
|
||||
QUnit.test("As an anonymous user", async assert => {
|
||||
await visit("/g/discourse/manage/profile");
|
||||
|
||||
assert.ok(
|
||||
count(".group-members tr") > 0,
|
||||
"it should redirect to members page for an anonymous user"
|
||||
);
|
||||
});
|
||||
|
||||
acceptance("Managing Group Profile", { loggedIn: true });
|
||||
|
||||
QUnit.test("As an admin", async assert => {
|
||||
logIn();
|
||||
Discourse.reset();
|
||||
|
||||
await visit("/g/discourse/manage/profile");
|
||||
|
||||
assert.ok(
|
||||
|
@ -27,9 +34,7 @@ QUnit.test("As an admin", async assert => {
|
|||
});
|
||||
|
||||
QUnit.test("As a group owner", async assert => {
|
||||
logIn();
|
||||
Discourse.reset();
|
||||
replaceCurrentUser({ staff: false, admin: false });
|
||||
updateCurrentUser({ staff: false, admin: false });
|
||||
|
||||
await visit("/g/discourse/manage/profile");
|
||||
|
||||
|
@ -39,12 +44,3 @@ QUnit.test("As a group owner", async assert => {
|
|||
"it should not display group name input"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("As an anonymous user", async assert => {
|
||||
await visit("/g/discourse/manage/profile");
|
||||
|
||||
assert.ok(
|
||||
count(".group-members tr") > 0,
|
||||
"it should redirect to members page for an anonymous user"
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import selectKit from "helpers/select-kit-helper";
|
||||
import { acceptance, logIn } from "helpers/qunit-helpers";
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Group", {
|
||||
let groupArgs = {
|
||||
settings: {
|
||||
enable_group_directory: true
|
||||
},
|
||||
|
@ -12,7 +12,9 @@ acceptance("Group", {
|
|||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
acceptance("Group", groupArgs);
|
||||
|
||||
const response = object => {
|
||||
return [200, { "Content-Type": "application/json" }, object];
|
||||
|
@ -90,10 +92,9 @@ QUnit.test("Anonymous Viewing Automatic Group", async assert => {
|
|||
);
|
||||
});
|
||||
|
||||
QUnit.test("User Viewing Group", async assert => {
|
||||
logIn();
|
||||
Discourse.reset();
|
||||
acceptance("Group", Object.assign({ loggedIn: true }, groupArgs));
|
||||
|
||||
QUnit.test("User Viewing Group", async assert => {
|
||||
await visit("/g");
|
||||
await click(".group-index-request");
|
||||
|
||||
|
@ -138,11 +139,7 @@ QUnit.test(
|
|||
return response({ topic_list: { topics: [] } });
|
||||
});
|
||||
|
||||
logIn();
|
||||
Discourse.reset();
|
||||
|
||||
await visit("/g/discourse");
|
||||
|
||||
await click(".nav-pills li a[title='Messages']");
|
||||
|
||||
assert.equal(
|
||||
|
@ -238,9 +235,6 @@ QUnit.test("Admin viewing group messages", async assert => {
|
|||
});
|
||||
});
|
||||
|
||||
logIn();
|
||||
Discourse.reset();
|
||||
|
||||
await visit("/g/discourse");
|
||||
await click(".nav-pills li a[title='Messages']");
|
||||
|
||||
|
@ -254,9 +248,6 @@ QUnit.test("Admin viewing group messages", async assert => {
|
|||
});
|
||||
|
||||
QUnit.test("Admin Viewing Group", async assert => {
|
||||
logIn();
|
||||
Discourse.reset();
|
||||
|
||||
await visit("/g/discourse");
|
||||
|
||||
assert.ok(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { acceptance, logIn } from "helpers/qunit-helpers";
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("New Group");
|
||||
|
||||
|
@ -12,12 +12,10 @@ QUnit.test("As an anon user", async assert => {
|
|||
);
|
||||
});
|
||||
|
||||
acceptance("New Group", { loggedIn: true });
|
||||
|
||||
QUnit.test("Creating a new group", async assert => {
|
||||
logIn();
|
||||
Discourse.reset();
|
||||
|
||||
await visit("/g");
|
||||
|
||||
await click(".groups-header-new");
|
||||
|
||||
assert.equal(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { acceptance, logIn } from "helpers/qunit-helpers";
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("New Message");
|
||||
|
||||
|
@ -10,10 +10,8 @@ QUnit.test("accessing new-message route when logged out", async assert => {
|
|||
assert.ok(exists(".modal.login-modal"), "it shows the login modal");
|
||||
});
|
||||
|
||||
acceptance("New Message", { loggedIn: true });
|
||||
QUnit.test("accessing new-message route when logged in", async assert => {
|
||||
logIn();
|
||||
Discourse.reset();
|
||||
|
||||
await visit(
|
||||
"/new-message?username=charlie&title=message%20title&body=message%20body"
|
||||
);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import selectKit from "helpers/select-kit-helper";
|
||||
import { acceptance, logIn } from "helpers/qunit-helpers";
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("New Topic");
|
||||
|
||||
|
@ -9,10 +9,8 @@ QUnit.test("accessing new-topic route when logged out", async assert => {
|
|||
assert.ok(exists(".modal.login-modal"), "it shows the login modal");
|
||||
});
|
||||
|
||||
acceptance("New Topic", { loggedIn: true });
|
||||
QUnit.test("accessing new-topic route when logged in", async assert => {
|
||||
logIn();
|
||||
Discourse.reset();
|
||||
|
||||
await visit("/new-topic?title=topic%20title&body=topic%20body&category=bug");
|
||||
|
||||
assert.ok(exists(".composer-fields"), "it opens composer");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { acceptance, logIn, replaceCurrentUser } from "helpers/qunit-helpers";
|
||||
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
||||
import DiscoveryFixtures from "fixtures/discovery_fixtures";
|
||||
|
||||
acceptance("Redirect to Top", {
|
||||
|
@ -12,13 +12,12 @@ acceptance("Redirect to Top", {
|
|||
server.get("/top/all.json", () => {
|
||||
return helper.response(DiscoveryFixtures["/latest.json"]);
|
||||
});
|
||||
}
|
||||
},
|
||||
loggedIn: true
|
||||
});
|
||||
|
||||
QUnit.test("redirects categories to weekly top", async assert => {
|
||||
logIn();
|
||||
|
||||
replaceCurrentUser({
|
||||
updateCurrentUser({
|
||||
should_be_redirected_to_top: true,
|
||||
redirected_to_top: {
|
||||
period: "weekly",
|
||||
|
@ -31,9 +30,7 @@ QUnit.test("redirects categories to weekly top", async assert => {
|
|||
});
|
||||
|
||||
QUnit.test("redirects latest to monthly top", async assert => {
|
||||
logIn();
|
||||
|
||||
replaceCurrentUser({
|
||||
updateCurrentUser({
|
||||
should_be_redirected_to_top: true,
|
||||
redirected_to_top: {
|
||||
period: "monthly",
|
||||
|
@ -46,9 +43,7 @@ QUnit.test("redirects latest to monthly top", async assert => {
|
|||
});
|
||||
|
||||
QUnit.test("redirects root to All top", async assert => {
|
||||
logIn();
|
||||
|
||||
replaceCurrentUser({
|
||||
updateCurrentUser({
|
||||
should_be_redirected_to_top: true,
|
||||
redirected_to_top: {
|
||||
period: null,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import selectKit from "helpers/select-kit-helper";
|
||||
import { acceptance, logIn } from "helpers/qunit-helpers";
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
|
||||
const emptySearchContextCallbacks = [];
|
||||
|
||||
acceptance("Search", {
|
||||
let searchArgs = {
|
||||
pretend(server) {
|
||||
server.handledRequest = (verb, path, request) => {
|
||||
if (request.queryParams["search_context[type]"] === undefined) {
|
||||
|
@ -13,7 +13,9 @@ acceptance("Search", {
|
|||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
acceptance("Search", searchArgs);
|
||||
|
||||
QUnit.test("search", async assert => {
|
||||
await visit("/");
|
||||
|
@ -136,11 +138,11 @@ QUnit.test("Right filters are shown to anonymous users", async assert => {
|
|||
assert.notOk(exists(".search-advanced-options .in-seen"));
|
||||
});
|
||||
|
||||
acceptance("Search", Object.assign({ loggedIn: true, searchArgs }));
|
||||
|
||||
QUnit.test("Right filters are shown to logged-in users", async assert => {
|
||||
const inSelector = selectKit(".select-kit#in");
|
||||
|
||||
logIn();
|
||||
Discourse.reset();
|
||||
await visit("/search?expanded=true");
|
||||
|
||||
await inSelector.expand();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { replaceCurrentUser, acceptance } from "helpers/qunit-helpers";
|
||||
import { updateCurrentUser, acceptance } from "helpers/qunit-helpers";
|
||||
acceptance("Tags", { loggedIn: true });
|
||||
|
||||
QUnit.test("list the tags", async assert => {
|
||||
|
@ -156,7 +156,7 @@ test("new topic button is not available for staff-only tags", async assert => {
|
|||
}
|
||||
]);
|
||||
|
||||
replaceCurrentUser({ staff: false });
|
||||
updateCurrentUser({ staff: false });
|
||||
|
||||
await visit("/tags/regular-tag");
|
||||
assert.ok(find("#create-topic:disabled").length === 0);
|
||||
|
@ -164,7 +164,7 @@ test("new topic button is not available for staff-only tags", async assert => {
|
|||
await visit("/tags/staff-only-tag");
|
||||
assert.ok(find("#create-topic:disabled").length === 1);
|
||||
|
||||
replaceCurrentUser({ staff: true });
|
||||
updateCurrentUser({ staff: true });
|
||||
|
||||
await visit("/tags/regular-tag");
|
||||
assert.ok(find("#create-topic:disabled").length === 0);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import selectKit from "helpers/select-kit-helper";
|
||||
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
||||
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Topic - Edit timer", {
|
||||
loggedIn: true,
|
||||
|
@ -20,7 +20,7 @@ acceptance("Topic - Edit timer", {
|
|||
});
|
||||
|
||||
QUnit.test("default", async assert => {
|
||||
replaceCurrentUser({ admin: true, staff: true, canManageTopic: true });
|
||||
updateCurrentUser({ admin: true, staff: true, canManageTopic: true });
|
||||
const timerType = selectKit(".select-kit.timer-type");
|
||||
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
||||
|
||||
|
@ -41,7 +41,7 @@ QUnit.test("default", async assert => {
|
|||
});
|
||||
|
||||
QUnit.test("autoclose - specific time", async assert => {
|
||||
replaceCurrentUser({ admin: true, staff: true, canManageTopic: true });
|
||||
updateCurrentUser({ admin: true, staff: true, canManageTopic: true });
|
||||
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
||||
|
||||
await visit("/t/internationalization-localization");
|
||||
|
@ -62,7 +62,7 @@ QUnit.test("autoclose - specific time", async assert => {
|
|||
});
|
||||
|
||||
QUnit.test("autoclose", async assert => {
|
||||
replaceCurrentUser({ admin: true, staff: true, canManageTopic: true });
|
||||
updateCurrentUser({ admin: true, staff: true, canManageTopic: true });
|
||||
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
||||
|
||||
await visit("/t/internationalization-localization");
|
||||
|
@ -117,7 +117,7 @@ QUnit.test("autoclose", async assert => {
|
|||
});
|
||||
|
||||
QUnit.test("close temporarily", async assert => {
|
||||
replaceCurrentUser({ admin: true, staff: true, canManageTopic: true });
|
||||
updateCurrentUser({ admin: true, staff: true, canManageTopic: true });
|
||||
const timerType = selectKit(".select-kit.timer-type");
|
||||
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
||||
|
||||
|
@ -159,7 +159,7 @@ QUnit.test("close temporarily", async assert => {
|
|||
});
|
||||
|
||||
QUnit.test("schedule", async assert => {
|
||||
replaceCurrentUser({ admin: true, staff: true, canManageTopic: true });
|
||||
updateCurrentUser({ admin: true, staff: true, canManageTopic: true });
|
||||
const timerType = selectKit(".select-kit.timer-type");
|
||||
const categoryChooser = selectKit(".modal-body .category-chooser");
|
||||
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
||||
|
@ -194,7 +194,7 @@ QUnit.test("schedule", async assert => {
|
|||
});
|
||||
|
||||
QUnit.test("TL4 can't auto-delete", async assert => {
|
||||
replaceCurrentUser({ staff: false, trust_level: 4 });
|
||||
updateCurrentUser({ staff: false, trust_level: 4 });
|
||||
|
||||
await visit("/t/internationalization-localization");
|
||||
await click(".toggle-admin-menu");
|
||||
|
@ -208,7 +208,7 @@ QUnit.test("TL4 can't auto-delete", async assert => {
|
|||
});
|
||||
|
||||
QUnit.test("auto delete", async assert => {
|
||||
replaceCurrentUser({ admin: true, staff: true, canManageTopic: true });
|
||||
updateCurrentUser({ admin: true, staff: true, canManageTopic: true });
|
||||
const timerType = selectKit(".select-kit.timer-type");
|
||||
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
||||
|
||||
|
@ -238,7 +238,7 @@ QUnit.test("auto delete", async assert => {
|
|||
QUnit.test(
|
||||
"Manually closing before the timer will clear the status text",
|
||||
async assert => {
|
||||
replaceCurrentUser({ admin: true, staff: true, canManageTopic: true });
|
||||
updateCurrentUser({ admin: true, staff: true, canManageTopic: true });
|
||||
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
||||
|
||||
await visit("/t/internationalization-localization");
|
||||
|
|
|
@ -24,12 +24,11 @@ export function currentUser() {
|
|||
);
|
||||
}
|
||||
|
||||
export function replaceCurrentUser(properties) {
|
||||
const user = Discourse.User.current();
|
||||
user.setProperties(properties);
|
||||
Discourse.User.resetCurrent(user);
|
||||
export function updateCurrentUser(properties) {
|
||||
Discourse.User.current().setProperties(properties);
|
||||
}
|
||||
|
||||
// Note: do not use this in acceptance tests. Use `loggedIn: true` instead
|
||||
export function logIn() {
|
||||
Discourse.User.resetCurrent(currentUser());
|
||||
}
|
||||
|
@ -130,6 +129,14 @@ export function acceptance(name, options) {
|
|||
resetWidgetCleanCallbacks();
|
||||
resetOneboxCache();
|
||||
resetCustomPostMessageCallbacks();
|
||||
Discourse._runInitializer("instanceInitializers", function(
|
||||
initName,
|
||||
initializer
|
||||
) {
|
||||
if (initializer && initializer.teardown) {
|
||||
initializer.teardown(Discourse.__container__);
|
||||
}
|
||||
});
|
||||
Discourse.reset();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { logIn, replaceCurrentUser } from "helpers/qunit-helpers";
|
||||
import { logIn, updateCurrentUser } from "helpers/qunit-helpers";
|
||||
|
||||
QUnit.module("lib:discourse");
|
||||
|
||||
|
@ -59,7 +59,7 @@ QUnit.test("title counts are updated correctly", assert => {
|
|||
);
|
||||
|
||||
logIn();
|
||||
replaceCurrentUser({ dynamic_favicon: false });
|
||||
updateCurrentUser({ dynamic_favicon: false });
|
||||
|
||||
Discourse.set("hasFocus", true);
|
||||
Discourse.set("hasFocus", false);
|
||||
|
|
|
@ -169,15 +169,6 @@ QUnit.testDone(function() {
|
|||
});
|
||||
});
|
||||
|
||||
Discourse._runInitializer("instanceInitializers", function(
|
||||
name,
|
||||
initializer
|
||||
) {
|
||||
if (initializer && initializer.teardown) {
|
||||
initializer.teardown();
|
||||
}
|
||||
});
|
||||
|
||||
window.MessageBus.unsubscribe("*");
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user