mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 14:12:10 +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:

committed by
Joffrey JAFFEUX

parent
c3381b845b
commit
a8793d0d9a
@ -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();
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user