mirror of
https://github.com/discourse/discourse.git
synced 2025-02-23 04:55:00 +00:00
DEV: Add test to check if user tips are saved once (#19084)
Before 35980ad56eea2204ffef37d2ba55030f48091835, hidden user tips used to be saved everytime when User.hideUserTipForever was called.
This commit is contained in:
parent
0f36fcdecd
commit
3ec7b2a769
@ -447,18 +447,21 @@ const User = RestModel.extend({
|
||||
type: "PUT",
|
||||
})
|
||||
.then((result) => {
|
||||
this.set("bio_excerpt", result.user.bio_excerpt);
|
||||
const userProps = getProperties(
|
||||
result.user.user_option || this.user_option,
|
||||
"enable_quoting",
|
||||
"enable_defer",
|
||||
"external_links_in_new_tab",
|
||||
"dynamic_favicon",
|
||||
"seen_popups",
|
||||
"skip_new_user_tips"
|
||||
);
|
||||
User.current()?.setProperties(userProps);
|
||||
this.setProperties(updatedState);
|
||||
this.setProperties(getProperties(result.user, "bio_excerpt"));
|
||||
if (User.current() === this && result.user.user_option) {
|
||||
this.setProperties(
|
||||
getProperties(
|
||||
result.user.user_option,
|
||||
"enable_quoting",
|
||||
"enable_defer",
|
||||
"external_links_in_new_tab",
|
||||
"dynamic_favicon",
|
||||
"seen_popups",
|
||||
"skip_new_user_tips"
|
||||
)
|
||||
);
|
||||
}
|
||||
return result;
|
||||
})
|
||||
.finally(() => {
|
||||
|
@ -4,6 +4,8 @@ import User from "discourse/models/user";
|
||||
import PreloadStore from "discourse/lib/preload-store";
|
||||
import sinon from "sinon";
|
||||
import { settled } from "@ember/test-helpers";
|
||||
import Site from "discourse/models/site";
|
||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
|
||||
module("Unit | Model | user", function () {
|
||||
test("staff", function (assert) {
|
||||
@ -179,4 +181,27 @@ module("Unit | Model | user", function () {
|
||||
"_clearStatusTimerId wasn't set"
|
||||
);
|
||||
});
|
||||
|
||||
test("hideUserTipForever() makes a single request", async function (assert) {
|
||||
Site.current().set("user_tips", { first_notification: 1 });
|
||||
const user = User.create({ username: "test" });
|
||||
|
||||
let requestsCount = 0;
|
||||
pretender.put("/u/test.json", () => {
|
||||
requestsCount += 1;
|
||||
return response(200, {
|
||||
user: {
|
||||
user_option: {
|
||||
seen_popups: [1],
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
await user.hideUserTipForever("first_notification");
|
||||
assert.strictEqual(requestsCount, 1);
|
||||
|
||||
await user.hideUserTipForever("first_notification");
|
||||
assert.strictEqual(requestsCount, 1);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user