mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-08 22:51:30 -07:00
fix 2 test failures due to chat type notification
This commit is contained in:
@@ -3,6 +3,7 @@ import { beforeAll, beforeEach, describe, expect, it } from 'vitest'
|
|||||||
|
|
||||||
import '../../chat.app'
|
import '../../chat.app'
|
||||||
|
|
||||||
|
import { NotificationType } from '../../../../notify/src/notification-types'
|
||||||
import {
|
import {
|
||||||
ChatModerationState,
|
ChatModerationState,
|
||||||
getMessage,
|
getMessage,
|
||||||
@@ -721,7 +722,7 @@ describe('ChatMessageReceived push', () => {
|
|||||||
/** The stubbed hub (see vitest.config.ts) records what it was sent. */
|
/** The stubbed hub (see vitest.config.ts) records what it was sent. */
|
||||||
interface SentNotification {
|
interface SentNotification {
|
||||||
playerId: number
|
playerId: number
|
||||||
notificationType: number
|
notificationType: NotificationType
|
||||||
data: Record<string, unknown>
|
data: Record<string, unknown>
|
||||||
}
|
}
|
||||||
const hub = env.RECFLARE_NOTIFICATIONS_HUB as unknown as {
|
const hub = env.RECFLARE_NOTIFICATIONS_HUB as unknown as {
|
||||||
@@ -759,8 +760,9 @@ describe('ChatMessageReceived push', () => {
|
|||||||
|
|
||||||
const sent = await hub.getByName('global').takeSent()
|
const sent = await hub.getByName('global').takeSent()
|
||||||
expect(sent.map((n) => n.playerId).sort((a, b) => a - b)).toEqual([caller, 886002, 886003])
|
expect(sent.map((n) => n.playerId).sort((a, b) => a - b)).toEqual([caller, 886002, 886003])
|
||||||
// NotificationType.ChatMessageReceived
|
expect(
|
||||||
expect(sent.every((n) => n.notificationType === 90)).toBe(true)
|
sent.every((n) => n.notificationType === NotificationType.ChatMessageReceived)
|
||||||
|
).toBe(true)
|
||||||
expect(sent[0]!.data).toEqual({
|
expect(sent[0]!.data).toEqual({
|
||||||
chatMessageId: chatThread.latestMessage.chatMessageId,
|
chatMessageId: chatThread.latestMessage.chatMessageId,
|
||||||
chatThreadId: chatThread.chatThreadId,
|
chatThreadId: chatThread.chatThreadId,
|
||||||
@@ -982,7 +984,9 @@ describe('POST /thread/:id', () => {
|
|||||||
it('pushes ChatMessageReceived to every member', async () => {
|
it('pushes ChatMessageReceived to every member', async () => {
|
||||||
const hub = env.RECFLARE_NOTIFICATIONS_HUB as unknown as {
|
const hub = env.RECFLARE_NOTIFICATIONS_HUB as unknown as {
|
||||||
getByName(name: string): {
|
getByName(name: string): {
|
||||||
takeSent(): Promise<Array<{ playerId: number; notificationType: number }>>
|
takeSent(): Promise<
|
||||||
|
Array<{ playerId: number; notificationType: NotificationType }>
|
||||||
|
>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const caller = 889005
|
const caller = 889005
|
||||||
@@ -992,7 +996,9 @@ describe('POST /thread/:id', () => {
|
|||||||
await send(caller, `/thread/${chatThreadId}`)
|
await send(caller, `/thread/${chatThreadId}`)
|
||||||
const sent = await hub.getByName('global').takeSent()
|
const sent = await hub.getByName('global').takeSent()
|
||||||
expect(sent.map((n) => n.playerId).sort((a, b) => a - b)).toEqual([caller, 889006])
|
expect(sent.map((n) => n.playerId).sort((a, b) => a - b)).toEqual([caller, 889006])
|
||||||
expect(sent.every((n) => n.notificationType === 90)).toBe(true)
|
expect(
|
||||||
|
sent.every((n) => n.notificationType === NotificationType.ChatMessageReceived)
|
||||||
|
).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('reports invalid arguments for blank contents without storing anything', async () => {
|
it('reports invalid arguments for blank contents without storing anything', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user