mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: correctly check for disabled notifications, tab and is idle (#27127)
This commit reuses the existing codepath in desktop-notifications and make it available to use to chat. primaryTab was too hard to test if not impossible in this service test, however isIdle and disabled notifications are correctly tested.
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { test } from "qunit";
|
||||
import {
|
||||
disable,
|
||||
init,
|
||||
resetIdle,
|
||||
setLastAction,
|
||||
} from "discourse/lib/desktop-notifications";
|
||||
import {
|
||||
acceptance,
|
||||
updateCurrentUser,
|
||||
@@ -44,6 +50,13 @@ acceptance(
|
||||
});
|
||||
|
||||
updateCurrentUser({ chat_sound: "ding" });
|
||||
|
||||
init(
|
||||
this.container.lookup("service:message-bus"),
|
||||
this.container.lookup("service:app-events")
|
||||
);
|
||||
|
||||
setLastAction(moment().subtract(1, "hour").valueOf());
|
||||
});
|
||||
|
||||
needs.user();
|
||||
@@ -115,5 +128,19 @@ acceptance(
|
||||
|
||||
assert.deepEqual(await this.subject.play(channel), false);
|
||||
});
|
||||
|
||||
test("not idle", async function (assert) {
|
||||
const channel = buildDirectMessageChannel(getOwner(this));
|
||||
resetIdle();
|
||||
|
||||
assert.deepEqual(await this.subject.play(channel), false);
|
||||
});
|
||||
|
||||
test("notifications disabled", async function (assert) {
|
||||
const channel = buildDirectMessageChannel(getOwner(this));
|
||||
disable();
|
||||
|
||||
assert.deepEqual(await this.subject.play(channel), false);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user