This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/acceptance/user-card-test.js
Jarek Radosz 6662101208
DEV: Fix a test leak (#15135)
The leak was introduced in #11722 and a test was added that relied on it in #14563

This PR fixes the leak (bookmarks-test), fixes the test that relied on it (fast-edit-test), and repleces some ad-hoc code with cloneJSON helper (other files)
2021-11-30 13:45:26 +11:00

29 lines
1.1 KiB
JavaScript

import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
import { click, visit } from "@ember/test-helpers";
import User from "discourse/models/user";
import { test } from "qunit";
import userFixtures from "discourse/tests/fixtures/user-fixtures";
import { cloneJSON } from "discourse-common/lib/object";
acceptance("User Card - Show Local Time", function (needs) {
needs.user();
needs.settings({ display_local_time_in_user_card: true });
needs.pretender((server, helper) => {
const cardResponse = cloneJSON(userFixtures["/u/charlie/card.json"]);
delete cardResponse.user.timezone;
server.get("/u/charlie/card.json", () => helper.response(cardResponse));
});
test("user card local time - does not update timezone for another user", async function (assert) {
User.current().changeTimezone("Australia/Brisbane");
await visit("/t/internationalization-localization/280");
await click('a[data-user-card="charlie"]');
assert.not(
exists(".user-card .local-time"),
"it does not show the local time if the user card returns a null/undefined timezone for another user"
);
});
});