mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 05:25:40 +09:00
test(app): remove useless frontend tests (#2819)
This commit is contained in:
1 parent
ed9528834d
commit
deac653a9e
341 files changed
-62758
No files matched your search
@@ -1,94 +0,0 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {
|
||||
type AutoAckWindowConditions,
|
||||
createAutoAckWindowSnapshot,
|
||||
selectAutoAckWindowCommands,
|
||||
transitionAutoAckWindowSnapshot,
|
||||
} from '@app/features/notification/state/NotificationAutoAckStateMachine';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
|
||||
function conditions(overrides: Partial<AutoAckWindowConditions> = {}): AutoAckWindowConditions {
|
||||
return {
|
||||
channelId: null,
|
||||
isAtBottom: false,
|
||||
canAutoAck: false,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function transition(overrides: Partial<AutoAckWindowConditions>) {
|
||||
return transitionAutoAckWindowSnapshot(createAutoAckWindowSnapshot(), {
|
||||
type: 'autoAck.conditionsChanged',
|
||||
conditions: conditions(overrides),
|
||||
});
|
||||
}
|
||||
|
||||
describe('autoAckWindowStateMachine', () => {
|
||||
it('does not emit commands when there is no selected channel', () => {
|
||||
const snapshot = transition({});
|
||||
expect(snapshot.value).toBe('noChannel');
|
||||
expect(selectAutoAckWindowCommands(snapshot)).toEqual([]);
|
||||
});
|
||||
|
||||
it('enables automatic ack only when the channel is visible at bottom', () => {
|
||||
const snapshot = transition({channelId: 'channel-1', isAtBottom: true, canAutoAck: true});
|
||||
|
||||
expect(snapshot.value).toBe('enabled');
|
||||
expect(selectAutoAckWindowCommands(snapshot)).toEqual([{type: 'enable', channelId: 'channel-1'}]);
|
||||
});
|
||||
|
||||
it('disables the current channel when auto-ack conditions fail', () => {
|
||||
const snapshot = transition({channelId: 'channel-1', isAtBottom: false, canAutoAck: true});
|
||||
|
||||
expect(snapshot.value).toBe('disabled');
|
||||
expect(selectAutoAckWindowCommands(snapshot)).toEqual([{type: 'disable', channelId: 'channel-1'}]);
|
||||
});
|
||||
|
||||
it('disables the previous channel before enabling a new channel', () => {
|
||||
const firstSnapshot = transition({channelId: 'channel-1', isAtBottom: true, canAutoAck: true});
|
||||
const secondSnapshot = transitionAutoAckWindowSnapshot(firstSnapshot, {
|
||||
type: 'autoAck.conditionsChanged',
|
||||
conditions: conditions({channelId: 'channel-2', isAtBottom: true, canAutoAck: true}),
|
||||
});
|
||||
|
||||
expect(secondSnapshot.value).toBe('enabled');
|
||||
expect(selectAutoAckWindowCommands(secondSnapshot)).toEqual([
|
||||
{type: 'disable', channelId: 'channel-1'},
|
||||
{type: 'enable', channelId: 'channel-2'},
|
||||
]);
|
||||
});
|
||||
|
||||
it('disables the previous channel when selection clears', () => {
|
||||
const firstSnapshot = transition({channelId: 'channel-1', isAtBottom: true, canAutoAck: true});
|
||||
const secondSnapshot = transitionAutoAckWindowSnapshot(firstSnapshot, {
|
||||
type: 'autoAck.conditionsChanged',
|
||||
conditions: conditions({channelId: null}),
|
||||
});
|
||||
|
||||
expect(secondSnapshot.value).toBe('noChannel');
|
||||
expect(selectAutoAckWindowCommands(secondSnapshot)).toEqual([{type: 'disable', channelId: 'channel-1'}]);
|
||||
});
|
||||
|
||||
it('disables automatic ack while the media viewer suppresses auto-ack', () => {
|
||||
const enabledSnapshot = transition({channelId: 'channel-1', isAtBottom: true, canAutoAck: true});
|
||||
const viewerOpenSnapshot = transitionAutoAckWindowSnapshot(enabledSnapshot, {
|
||||
type: 'autoAck.conditionsChanged',
|
||||
conditions: conditions({channelId: 'channel-1', isAtBottom: true, canAutoAck: false}),
|
||||
});
|
||||
|
||||
expect(viewerOpenSnapshot.value).toBe('disabled');
|
||||
expect(selectAutoAckWindowCommands(viewerOpenSnapshot)).toEqual([{type: 'disable', channelId: 'channel-1'}]);
|
||||
});
|
||||
|
||||
it('re-enables automatic ack at the bottom once the media viewer no longer suppresses it', () => {
|
||||
const viewerOpenSnapshot = transition({channelId: 'channel-1', isAtBottom: true, canAutoAck: false});
|
||||
const viewerClosedSnapshot = transitionAutoAckWindowSnapshot(viewerOpenSnapshot, {
|
||||
type: 'autoAck.conditionsChanged',
|
||||
conditions: conditions({channelId: 'channel-1', isAtBottom: true, canAutoAck: true}),
|
||||
});
|
||||
|
||||
expect(viewerClosedSnapshot.value).toBe('enabled');
|
||||
expect(selectAutoAckWindowCommands(viewerClosedSnapshot)).toEqual([{type: 'enable', channelId: 'channel-1'}]);
|
||||
});
|
||||
});
|
||||
@@ -1,72 +0,0 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {
|
||||
getDirectCallFullscreenScopeKey,
|
||||
isTextChatVisibleForAutoAck,
|
||||
isVoiceCallFullscreenScopeForChannel,
|
||||
} from '@app/features/notification/utils/AutoAckVisibility';
|
||||
import {getGuildVoiceCallExpansionKey} from '@app/features/voice/state/CompactVoiceCallHeight';
|
||||
import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
|
||||
describe('isTextChatVisibleForAutoAck', () => {
|
||||
it('allows normal text channels to auto-ack when no fullscreen call view is active', () => {
|
||||
expect(
|
||||
isTextChatVisibleForAutoAck({
|
||||
channelId: 'text-1',
|
||||
channelType: ChannelTypes.GUILD_TEXT,
|
||||
isGuildVoiceCallExpanded: true,
|
||||
activeVoiceCallFullscreenScopeKey: null,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
it('blocks guild voice auto-ack while the call view has hidden chat', () => {
|
||||
expect(
|
||||
isTextChatVisibleForAutoAck({
|
||||
channelId: 'voice-1',
|
||||
channelType: ChannelTypes.GUILD_VOICE,
|
||||
isGuildVoiceCallExpanded: true,
|
||||
activeVoiceCallFullscreenScopeKey: null,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
it('allows guild voice auto-ack when chat is visible', () => {
|
||||
expect(
|
||||
isTextChatVisibleForAutoAck({
|
||||
channelId: 'voice-1',
|
||||
channelType: ChannelTypes.GUILD_VOICE,
|
||||
isGuildVoiceCallExpanded: false,
|
||||
activeVoiceCallFullscreenScopeKey: null,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
it('blocks auto-ack when the selected channel is in a fullscreen call view', () => {
|
||||
expect(
|
||||
isTextChatVisibleForAutoAck({
|
||||
channelId: 'voice-1',
|
||||
channelType: ChannelTypes.GUILD_VOICE,
|
||||
isGuildVoiceCallExpanded: false,
|
||||
activeVoiceCallFullscreenScopeKey: getGuildVoiceCallExpansionKey('voice-1'),
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(
|
||||
isTextChatVisibleForAutoAck({
|
||||
channelId: 'dm-1',
|
||||
channelType: ChannelTypes.DM,
|
||||
isGuildVoiceCallExpanded: false,
|
||||
activeVoiceCallFullscreenScopeKey: getDirectCallFullscreenScopeKey('dm-1'),
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
it('ignores fullscreen call scopes for other channels', () => {
|
||||
expect(isVoiceCallFullscreenScopeForChannel('voice-1', getGuildVoiceCallExpansionKey('voice-2'))).toBe(false);
|
||||
expect(
|
||||
isTextChatVisibleForAutoAck({
|
||||
channelId: 'voice-1',
|
||||
channelType: ChannelTypes.GUILD_VOICE,
|
||||
isGuildVoiceCallExpanded: false,
|
||||
activeVoiceCallFullscreenScopeKey: getGuildVoiceCallExpansionKey('voice-2'),
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,39 +0,0 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {
|
||||
type MentionFilters,
|
||||
messageMatchesMentionTypeFilters,
|
||||
} from '@app/features/notification/utils/MentionFeedFilters';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
|
||||
const DIRECT_ONLY = {mention_everyone: false, mention_roles: []};
|
||||
const EVERYONE_ONLY = {mention_everyone: true, mention_roles: []};
|
||||
const ROLE_ONLY = {mention_everyone: false, mention_roles: ['10']};
|
||||
const EVERYONE_AND_ROLE = {mention_everyone: true, mention_roles: ['10']};
|
||||
|
||||
function filters(overrides: Partial<MentionFilters>): MentionFilters {
|
||||
return {
|
||||
includeEveryone: true,
|
||||
includeRoles: true,
|
||||
includeGuilds: true,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe('messageMatchesMentionTypeFilters', () => {
|
||||
it('keeps direct user mentions regardless of mass mention filters', () => {
|
||||
expect(messageMatchesMentionTypeFilters(DIRECT_ONLY, filters({includeEveryone: false, includeRoles: false}))).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
it('excludes role mentions when role mentions are disabled', () => {
|
||||
expect(messageMatchesMentionTypeFilters(ROLE_ONLY, filters({includeRoles: false}))).toBe(false);
|
||||
});
|
||||
it('excludes everyone mentions when everyone mentions are disabled', () => {
|
||||
expect(messageMatchesMentionTypeFilters(EVERYONE_ONLY, filters({includeEveryone: false}))).toBe(false);
|
||||
});
|
||||
it('excludes mixed mass mentions when either matching mass mention type is disabled', () => {
|
||||
expect(messageMatchesMentionTypeFilters(EVERYONE_AND_ROLE, filters({includeEveryone: false}))).toBe(false);
|
||||
expect(messageMatchesMentionTypeFilters(EVERYONE_AND_ROLE, filters({includeRoles: false}))).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user