Alan Guo Xiang Tan 37dc162554
DEV: Rewrite broken tests
Mocking time in Ruby land doesn't translate to the browser
2025-10-15 15:17:49 +08:00

45 lines
1.2 KiB
JavaScript

import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { acceptance, fakeTime } from "discourse/tests/helpers/qunit-helpers";
acceptance("DiscourseRewind | rewind tab", function (needs) {
needs.user();
needs.settings({ discourse_rewind_enabled: true });
test("shows the tab in january", async function (assert) {
const clock = fakeTime("2022-01-10 12:00:00", null, false);
await visit("/my/activity");
assert
.dom(".user-nav__activity-rewind")
.exists("rewind tab is visible in January");
clock.restore();
});
test("shows the tab in december", async function (assert) {
const clock = fakeTime("2022-12-05 12:00:00", null, false);
await visit("/my/activity");
assert
.dom(".user-nav__activity-rewind")
.exists("rewind tab is visible in December");
clock.restore();
});
test("doesn't show the tab in november", async function (assert) {
const clock = fakeTime("2022-11-24 12:00:00", null, false);
await visit("/my/activity");
assert
.dom(".user-nav__activity-rewind")
.doesNotExist("rewind tab is not visible in November");
clock.restore();
});
});