A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
test(app): remove boot shell, ui and community unit tests
Hampus49d58c50a904
diff --git a/fluxer_app/src/app/BootShell.test.ts b/fluxer_app/src/app/BootShell.test.tsdeleted file mode 100644index e4258d8ed..000000000--- a/fluxer_app/src/app/BootShell.test.ts+++ /dev/null@@ -1,198 +0,0 @@-// @vitest-environment happy-dom-// SPDX-License-Identifier: AGPL-3.0-or-later--import {readFileSync} from 'node:fs';-import {resolve} from 'node:path';-import {SHELL_HINT_VERSION} from '@app/features/app/components/skeleton/ShellHint';-import type {ReactNode} from 'react';-import {afterEach, expect, test, vi} from 'vitest';--vi.mock('@lingui/core/macro', () => {- const descriptor = (value: unknown): unknown => (typeof value === 'string' ? {message: value} : value);- return {msg: descriptor, t: descriptor, plural: () => '', select: () => '', selectOrdinal: () => ''};-});-vi.mock('@lingui/react/macro', () => ({- Trans: ({children}: {children?: ReactNode}) => children ?? null,- useLingui: () => ({i18n: {_: (descriptor: {message?: string}) => descriptor.message ?? ''}}),-}));--const html = readFileSync(resolve(process.cwd(), 'index.html'), 'utf8');--function readBootScript(): string {- const body = html.slice(html.indexOf('<div id="root"></div>'));- const match = /<script[^>]*>([\s\S]*?)<\/script>/u.exec(body);- expect(match).not.toBeNull();- return match?.[1] ?? '';-}--interface ShellHintOverrides {- readonly [key: string]: unknown;-}--const ACCOUNT_KEY = 'https://one.example/api::100';--function desktopDMHint(overrides: ShellHintOverrides = {}): Record<string, unknown> {- return {- v: SHELL_HINT_VERSION,- t: Date.now(),- p: '/channels/@me',- a: ACCOUNT_KEY,- mo: 0,- ua: 0,- fs: 0,- sw: 320,- sv: 'dm',- ck: 'other',- cb: 1,- rf: 1,- rv: 1,- ru: [],- rti: 0,- ro: 0,- ri: [- [0, 0],- [0, 0],- [0, 0],- [0, 0],- ],- rgi: -1,- rbm: 15,- rbi: -1,- rs: 0,- gb: 0,- ga: 1778,- gn: 0,- gd: 0,- gm: 0,- sr: 6,- sam: 7,- ss: 1,- cid: '',- ch: 2,- ct: 0,- cnw: 0,- ctw: 0,- cda: -1,- cma: -1,- cfv: 1,- cst: 0,- cuv: 0,- ml: 0,- co: 4,- com: 2,- cdv: 0,- pc: 0,- pg: 16,- pf: 16,- ps: 16,- pa: 0,- pt: 56,- pv: 800,- nr: [],- vh: 0,- vc: 0,- mr: 0,- ms: 0,- mn: 0,- ...overrides,- };-}--function setViewportWidth(width: number): void {- Object.defineProperty(window, 'innerWidth', {value: width, configurable: true});- const matches = width >= 1024;- Object.defineProperty(window, 'matchMedia', {- value: (query: string) => ({matches: query.includes('1024') ? matches : false, media: query}),- configurable: true,- });-}--function failScript(): void {- const script = document.createElement('script');- document.body.appendChild(script);- script.dispatchEvent(new Event('error', {bubbles: false}));-}--const bootRoots: Array<HTMLElement> = [];--interface BootScriptOptions {- readonly signedIn?: boolean;- readonly storage?: Readonly<Record<string, string>>;-}--function runBootScript(- hint: Record<string, unknown> | null,- pathname = '/channels/@me',- {signedIn = true, storage = {}}: BootScriptOptions = {},-): HTMLElement | null {- document.body.innerHTML = '<div id="root"></div>';- window.history.pushState({}, '', pathname);- localStorage.clear();- if (signedIn) {- localStorage.setItem('fluxer:gateway:preboot:session', '1');- }- localStorage.setItem('fluxer:auth:active-account-key', ACCOUNT_KEY);- if (hint != null) {- localStorage.setItem('fluxer:ui:shell-hint', JSON.stringify(hint));- }- for (const [key, value] of Object.entries(storage)) {- localStorage.setItem(key, value);- }- const root = document.getElementById('root');- if (root != null) {- bootRoots.push(root);- }- new Function(readBootScript())();- return document.querySelector<HTMLElement>('#fluxer-boot-shell');-}--afterEach(async () => {- for (const root of bootRoots.splice(0)) {- root.replaceChildren(document.createElement('span'));- root.replaceChildren();- }- await Promise.resolve();- localStorage.clear();- document.body.innerHTML = '';- vi.useRealTimers();-});--test('a document script that never loads drops the boot shell because nothing else can mount the app', () => {- setViewportWidth(1400);-- expect(runBootScript(desktopDMHint())).not.toBeNull();-- failScript();-- expect(document.querySelector('#fluxer-boot-shell')).toBeNull();-});--test('the backstop removes a boot shell React never cleared', () => {- vi.useFakeTimers();- setViewportWidth(1400);-- expect(runBootScript(desktopDMHint())).not.toBeNull();-- vi.advanceTimersByTime(60_000);-- expect(document.querySelector('#fluxer-boot-shell')).toBeNull();-});--test('the error listener and the backstop stop existing once React has cleared the boot shell', async () => {- vi.useFakeTimers();- setViewportWidth(1400);-- expect(runBootScript(desktopDMHint())).not.toBeNull();-- document.getElementById('root')?.replaceChildren();- await Promise.resolve();-- const marker = document.createElement('div');- marker.id = 'fluxer-boot-shell';- document.body.appendChild(marker);-- failScript();- vi.advanceTimersByTime(60_000);-- expect(document.querySelector('#fluxer-boot-shell')).not.toBeNull();-});diff --git a/fluxer_app/src/features/channel/components/pickers/shared/useVirtualPickerGrid.test.tsx b/fluxer_app/src/features/channel/components/pickers/shared/useVirtualPickerGrid.test.tsxdeleted file mode 100644index c4e54e21a..000000000--- a/fluxer_app/src/features/channel/components/pickers/shared/useVirtualPickerGrid.test.tsx+++ /dev/null@@ -1,86 +0,0 @@-// @vitest-environment happy-dom-// SPDX-License-Identifier: AGPL-3.0-or-later--import {useVirtualPickerGrid} from '@app/features/channel/components/pickers/shared/useVirtualPickerGrid';-import type {ScrollerHandle} from '@app/features/ui/components/Scroller';-import {act} from 'react';-import {createRoot, type Root} from 'react-dom/client';-import {afterEach, beforeEach, expect, test, vi} from 'vitest';--type Row = {type: 'header'; category: string; index: number} | {type: 'items'; items: Array<string>; index: number};-const rows: Array<Row> = [- {type: 'header', category: 'guild', index: 0},- {type: 'items', items: ['first', 'second'], index: 1},-];-const getItems = (row: Row) => (row.type === 'header' ? null : row.items);-const scrollTo = vi.fn();-const revealRange = vi.fn();-const scrollerRef = {current: {scrollTo, revealRange} as unknown as ScrollerHandle};-const listMetrics = {origin: 10, viewportHeight: 100, gridWidth: 200};-let controller: ReturnType<typeof useVirtualPickerGrid<string, Row>>;-let root: Root;-let container: HTMLDivElement;--function Harness({rowHeightPx = 128, zoomLevel = 1}: {rowHeightPx?: number; zoomLevel?: number}) {- controller = useVirtualPickerGrid({- rows,- getItems,- rowOffsets: [0, 40, 40 + rowHeightPx],- scrollerRef,- scrollTop: 0,- rowHeightPx,- listMetrics,- leadRows: 2,- zoomLevel,- renderedCount: 2,- });- return null;-}--beforeEach(() => {- (globalThis as {IS_REACT_ACT_ENVIRONMENT?: boolean}).IS_REACT_ACT_ENVIRONMENT = true;- scrollTo.mockClear();- revealRange.mockClear();- container = document.createElement('div');- document.body.appendChild(container);- root = createRoot(container);- act(() => root.render(<Harness data-flx="channel.pickers.shared.use-virtual-picker-grid-test.harness" />));-});-afterEach(() => {- act(() => root.unmount());- container.remove();-});--test('keyboard selection skips headers and reveals the item using the measured list origin', () => {- act(() => controller.handleSelectionChange(0, 1, true));- expect(controller.hovered).toBe('second');- expect(controller.selectedRow).toBe(0);- expect(controller.selectAt(0, 0)).toBe('first');- expect(revealRange).toHaveBeenLastCalledWith({start: 50, end: 178});- controller.handleCategoryClick('guild');- expect(scrollTo).toHaveBeenCalledWith({to: 10});-});--test('zoom changes preserve selection and update its reveal height', () => {- act(() => controller.handleSelectionChange(0, 0, true));- act(() =>- root.render(- <Harness- rowHeightPx={256}- zoomLevel={2}- data-flx="channel.pickers.shared.use-virtual-picker-grid-test.harness--2"- />,- ),- );- expect(controller.hovered).toBe('first');- expect(revealRange).toHaveBeenLastCalledWith({start: 50, end: 306});-});--test('pointer hover updates selection without forcing a scroll', () => {- act(() => controller.handleHover('second', 0, 1));- expect(controller.selectedColumn).toBe(1);- expect(controller.shouldScrollOnSelection).toBe(false);- expect(revealRange).not.toHaveBeenCalled();- act(() => controller.handleHover(null));- expect(controller.hovered).toBeNull();-});diff --git a/fluxer_app/src/features/channel/state/ChannelFrecency.test.ts b/fluxer_app/src/features/channel/state/ChannelFrecency.test.tsdeleted file mode 100644index 29aee2093..000000000--- a/fluxer_app/src/features/channel/state/ChannelFrecency.test.ts+++ /dev/null@@ -1,186 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {Channel} from '@app/features/channel/models/Channel';-import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants';-import {observable, runInAction} from 'mobx';-import {describe, expect, it, vi} from 'vitest';--const GUILD = '1500000000000000000';-const CONTROL_GUILD = '1600000000000000000';-const channels = observable.map<string, Channel>();-const navigation = observable({guildId: null as string | null, channelId: null as string | null});-const mediaEngine = observable({guildId: null as string | null, channelId: null as string | null});-const initialization = observable({hasCompletedInitialLoad: true});-const activeGuildIds = observable.set<string>([GUILD]);--vi.mock('@app/features/app/state/RuntimeConfig', () => ({default: {localInstanceDomain: 'fluxer.test'}}));-vi.mock('@app/features/user/state/Users', () => ({default: {getUser: () => undefined, cacheUsers: () => {}}}));-vi.mock('@app/features/channel/state/Channels', () => ({- default: {getChannel: (id: string) => channels.get(id), getPrivateChannels: () => []},-}));-vi.mock('@app/features/guild/state/Guilds', () => ({default: {getGuild: () => undefined}}));-vi.mock('@app/features/threads/state/ThreadGuilds', () => ({- default: {- isActive: (id: string | null) => id !== null && activeGuildIds.has(id),- get guildIds() {- return Array.from(activeGuildIds);- },- },-}));-vi.mock('@app/features/app/state/Initialization', () => ({default: initialization}));-vi.mock('@app/features/navigation/state/Navigation', () => ({default: navigation}));-vi.mock('@app/features/voice/engine/MediaEngineFacade', () => ({default: mediaEngine}));-vi.mock('@app/features/user/state/SyncedField', () => ({makeSyncedField: async () => {}}));-vi.mock('@app/features/platform/utils/MobXPersistence', () => ({makePersistent: async () => {}}));--const {default: ChannelFrecency} = await import('@app/features/channel/state/ChannelFrecency');-await new Promise((resolve) => setTimeout(resolve, 0));--const TEXT = '1500000000000000001';-const THREAD = '1500000000000000010';--function load(id: string, type: number, parentId?: string, guildId = GUILD): void {- runInAction(() => channels.set(id, new Channel({id, guild_id: guildId, type, parent_id: parentId})));-}--function select(channelId: string, guildId = GUILD): void {- runInAction(() => {- navigation.guildId = guildId;- navigation.channelId = channelId;- });-}--describe('channel frecency selection', () => {- it('never records a thread id selected before its channel loads', () => {- select(THREAD);- expect(ChannelFrecency.useLog.has(THREAD)).toBe(false);- load(TEXT, ChannelTypes.GUILD_TEXT);- load(THREAD, ChannelTypes.PUBLIC_THREAD, TEXT);- expect(ChannelFrecency.useLog.has(THREAD)).toBe(false);- expect(ChannelFrecency.localUseLog.has(THREAD)).toBe(true);- expect(ChannelFrecency.scoreFor(THREAD)).toBeGreaterThan(0);- expect(ChannelFrecency.frequentIds).toContain(THREAD);- expect(ChannelFrecency.useLog.has(GUILD)).toBe(true);- expect(ChannelFrecency.localUseLog.has(GUILD)).toBe(false);- });-- it('records a guild channel once it loads after selection', () => {- runInAction(() => channels.delete(TEXT));- select(TEXT);- expect(ChannelFrecency.useLog.has(TEXT)).toBe(false);- load(TEXT, ChannelTypes.GUILD_TEXT);- expect(ChannelFrecency.useLog.has(TEXT)).toBe(true);- });-- it('records an unknown channel immediately outside thread guilds', () => {- const unknown = '1600000000000000001';- select(unknown, CONTROL_GUILD);- expect(ChannelFrecency.useLog.has(unknown)).toBe(true);- });-- it('defers an unknown channel selected before READY in a remembered thread guild', () => {- const lateGuild = '1700000000000000000';- const lateParent = '1700000000000000001';- const lateThread = '1700000000000000010';- runInAction(() => {- activeGuildIds.add(lateGuild);- });- runInAction(() => {- initialization.hasCompletedInitialLoad = false;- });- select(lateThread, lateGuild);- expect(ChannelFrecency.useLog.has(lateThread)).toBe(false);- runInAction(() => {- initialization.hasCompletedInitialLoad = true;- });- expect(ChannelFrecency.useLog.has(lateThread)).toBe(false);- load(lateParent, ChannelTypes.GUILD_TEXT, undefined, lateGuild);- load(lateThread, ChannelTypes.PUBLIC_THREAD, lateParent, lateGuild);- expect(ChannelFrecency.useLog.has(lateThread)).toBe(false);- expect(ChannelFrecency.localUseLog.has(lateThread)).toBe(true);- });-- it('records a control channel selected before READY synchronously', () => {- const controlChannel = '1600000000000000002';- runInAction(() => {- initialization.hasCompletedInitialLoad = false;- });- select(controlChannel, CONTROL_GUILD);- expect(ChannelFrecency.useLog.get(controlChannel)?.hitCount).toBe(1);- runInAction(() => {- initialization.hasCompletedInitialLoad = true;- });- expect(ChannelFrecency.useLog.get(controlChannel)?.hitCount).toBe(1);- });-- it('records a deferred selection once READY leaves its guild without threads', () => {- const formerGuild = '1800000000000000000';- const channel = '1800000000000000001';- runInAction(() => {- activeGuildIds.add(formerGuild);- });- runInAction(() => {- initialization.hasCompletedInitialLoad = false;- });- select(channel, formerGuild);- expect(ChannelFrecency.useLog.has(channel)).toBe(false);- load(channel, ChannelTypes.GUILD_TEXT, undefined, formerGuild);- runInAction(() => {- activeGuildIds.delete(formerGuild);- initialization.hasCompletedInitialLoad = true;- });- expect(ChannelFrecency.useLog.get(channel)?.hitCount).toBe(1);- });-- it('drops a deferred selection that stays unknown once READY leaves its guild without threads', () => {- const killedGuild = '1900000000000000000';- const purgedThread = '1900000000000000010';- runInAction(() => {- activeGuildIds.add(killedGuild);- });- runInAction(() => {- initialization.hasCompletedInitialLoad = false;- });- select(purgedThread, killedGuild);- runInAction(() => {- activeGuildIds.delete(killedGuild);- initialization.hasCompletedInitialLoad = true;- });- expect(ChannelFrecency.useLog.has(purgedThread)).toBe(false);- expect(ChannelFrecency.localUseLog.has(purgedThread)).toBe(false);- });-- it('drops deferred selections on logout', () => {- const queued = '1500000000000000021';- runInAction(() => {- initialization.hasCompletedInitialLoad = false;- });- select(queued);- expect(ChannelFrecency.useLog.has(queued)).toBe(false);- ChannelFrecency.handleLogout();- select(TEXT);- runInAction(() => {- activeGuildIds.delete(GUILD);- initialization.hasCompletedInitialLoad = true;- });- expect(ChannelFrecency.useLog.has(queued)).toBe(false);- runInAction(() => {- activeGuildIds.add(GUILD);- });- });-- it('records the channel queued before logout when the next session selects it', () => {- const queued = '1500000000000000022';- runInAction(() => {- initialization.hasCompletedInitialLoad = false;- });- select(queued);- ChannelFrecency.handleLogout();- runInAction(() => {- initialization.hasCompletedInitialLoad = true;- });- load(queued, ChannelTypes.GUILD_TEXT);- select(queued);- expect(ChannelFrecency.useLog.get(queued)?.hitCount).toBe(1);- });-});diff --git a/fluxer_app/src/features/devtools/commands/VoiceStateCommands.test.ts b/fluxer_app/src/features/devtools/commands/VoiceStateCommands.test.tsdeleted file mode 100644index dcea31287..000000000--- a/fluxer_app/src/features/devtools/commands/VoiceStateCommands.test.ts+++ /dev/null@@ -1,197 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {beforeEach, describe, expect, it, vi} from 'vitest';--const playSound = vi.fn();--const localVoiceState = {- selfMute: false,- selfDeaf: false,- getSelfMute: () => localVoiceState.selfMute,- getSelfDeaf: () => localVoiceState.selfDeaf,- updateSelfMute: (muted: boolean) => {- localVoiceState.selfMute = muted;- },- toggleSelfMute: () => {- if (localVoiceState.selfDeaf) {- localVoiceState.selfDeaf = false;- localVoiceState.selfMute = false;- return;- }- localVoiceState.selfMute = !localVoiceState.selfMute;- },-};--const permissionMuted = {active: false};-const microphoneFailureLatch = {active: false};--vi.mock('@app/features/input/state/InputKeybind', () => ({- default: {isPushToTalkEffective: () => true, pushToTalkHeld: true},-}));-const updateVoiceStateExplicit = vi.fn();-const gatewayVoiceStates: Record<- string,- {- guild_id: string;- channel_id: string;- self_mute: boolean;- self_deaf: boolean;- self_video: boolean;- self_stream: boolean;- }-> = {};--vi.mock('@app/features/gateway/transport/GatewaySessionPool', () => ({- default: {foregroundConnection: {socket: {updateVoiceStateExplicit}}},-}));-vi.mock('@app/features/ui/commands/SoundCommands', () => ({- playSound: (...args: Array<unknown>) => playSound(...args),-}));-vi.mock('@app/features/permissions/system/commands/MacPermissionsModalCommands', () => ({- handleMediaPermissionBlocked: () => undefined,-}));-vi.mock('@app/features/permissions/system/state/MediaPermission', () => ({- default: {- getMicrophonePermissionState: () => 'granted',- isMicrophoneGranted: () => true,- isMicrophoneExplicitlyDenied: () => false,- },-}));-vi.mock('@app/features/permissions/system/utils/NativePermissions', () => ({- ensureNativePermission: async () => 'granted',-}));-vi.mock('@app/features/ui/utils/NativeUtils', () => ({isDesktop: () => false}));-vi.mock('@app/features/voice/engine/MediaEngineFacade', () => ({- default: {- room: null,- guildId: '1',- channelId: '2',- connectionId: 'local',- getVoiceStateByConnectionId: (connectionId: string) => gatewayVoiceStates[connectionId] ?? null,- isMicrophoneFailureLatched: () => microphoneFailureLatch.active,- clearMicrophoneFailureLatch: () => {- microphoneFailureLatch.active = false;- },- getCurrentUserVoiceState: () => null,- syncLocalVoiceStateWithServer: () => undefined,- },-}));-vi.mock('@app/features/voice/state/LocalVoiceState', () => ({default: localVoiceState}));-vi.mock('@app/features/voice/utils/VoicePermissionUtils', () => ({- isVoicePermissionMuteActive: () => permissionMuted.active,-}));--const {bulkMuteConnections, getCurrentSelfMute, getSelfMuteForConnection, toggleSelfMute, toggleSelfMuteForConnection} =- await import('@app/features/devtools/commands/VoiceStateCommands');-const {SoundType} = await import('@app/features/notification/utils/SoundUtils');--describe('toggleSelfMute with push to talk enabled', () => {- beforeEach(() => {- localVoiceState.selfMute = false;- localVoiceState.selfDeaf = false;- permissionMuted.active = false;- microphoneFailureLatch.active = false;- playSound.mockClear();- });-- it('mutes and unmutes', async () => {- await toggleSelfMute(null);- expect(localVoiceState.selfMute).toBe(true);- expect(playSound).toHaveBeenLastCalledWith(SoundType.Mute);- await toggleSelfMute(null);- expect(localVoiceState.selfMute).toBe(false);- expect(playSound).toHaveBeenLastCalledWith(SoundType.Unmute);- });-- it('undeafens like voice activity mode', async () => {- localVoiceState.selfMute = true;- localVoiceState.selfDeaf = true;- await toggleSelfMute(null);- expect(localVoiceState.selfDeaf).toBe(false);- expect(localVoiceState.selfMute).toBe(false);- });-- it('keeps a permission-muted user muted', async () => {- localVoiceState.selfMute = true;- permissionMuted.active = true;- await toggleSelfMute(null);- expect(localVoiceState.selfMute).toBe(true);- });-});--describe('device-scoped self-mute with push to talk enabled', () => {- beforeEach(() => {- localVoiceState.selfMute = false;- localVoiceState.selfDeaf = false;- permissionMuted.active = false;- microphoneFailureLatch.active = false;- playSound.mockClear();- updateVoiceStateExplicit.mockClear();- const idle = {- guild_id: '1',- channel_id: '2',- self_mute: true,- self_deaf: false,- self_video: false,- self_stream: false,- };- gatewayVoiceStates.local = {...idle};- gatewayVoiceStates.other = {...idle, self_mute: false};- });-- it('reads the local device from local self-mute instead of the push-to-talk gateway value', () => {- expect(getSelfMuteForConnection('local')).toBe(false);- localVoiceState.selfMute = true;- gatewayVoiceStates.local.self_mute = false;- expect(getSelfMuteForConnection('local')).toBe(true);- expect(getSelfMuteForConnection('other')).toBe(false);- });-- it('toggles the local device through local self-mute without a direct gateway write', async () => {- await toggleSelfMuteForConnection('local');- expect(localVoiceState.selfMute).toBe(true);- expect(playSound).toHaveBeenLastCalledWith(SoundType.Mute);- await toggleSelfMuteForConnection('local');- expect(localVoiceState.selfMute).toBe(false);- expect(playSound).toHaveBeenLastCalledWith(SoundType.Unmute);- expect(updateVoiceStateExplicit).not.toHaveBeenCalled();- });-- it('toggles another device through the gateway without touching local self-mute', async () => {- await toggleSelfMuteForConnection('other');- expect(updateVoiceStateExplicit).toHaveBeenCalledTimes(1);- expect(updateVoiceStateExplicit).toHaveBeenLastCalledWith(- expect.objectContaining({connection_id: 'other', self_mute: true}),- );- expect(localVoiceState.selfMute).toBe(false);- });-- it('reports a latched microphone failure as self-muted and unmutes it on toggle', async () => {- microphoneFailureLatch.active = true;- expect(getCurrentSelfMute()).toBe(true);- expect(getSelfMuteForConnection('local')).toBe(true);- await toggleSelfMuteForConnection('local');- expect(microphoneFailureLatch.active).toBe(false);- expect(getCurrentSelfMute()).toBe(false);- expect(playSound).toHaveBeenLastCalledWith(SoundType.Unmute);- });-- it('bulk mutes the local device through local self-mute and other devices through the gateway', async () => {- await bulkMuteConnections(['local', 'other'], true);- expect(localVoiceState.selfMute).toBe(true);- expect(updateVoiceStateExplicit).toHaveBeenCalledTimes(1);- expect(updateVoiceStateExplicit).toHaveBeenLastCalledWith(- expect.objectContaining({connection_id: 'other', self_mute: true}),- );- updateVoiceStateExplicit.mockClear();- gatewayVoiceStates.other.self_mute = true;- microphoneFailureLatch.active = true;- await bulkMuteConnections(['local', 'other'], false);- expect(localVoiceState.selfMute).toBe(false);- expect(microphoneFailureLatch.active).toBe(false);- expect(updateVoiceStateExplicit).toHaveBeenCalledTimes(1);- expect(updateVoiceStateExplicit).toHaveBeenLastCalledWith(- expect.objectContaining({connection_id: 'other', self_mute: false}),- );- });-});diff --git a/fluxer_app/src/features/experiment/state/ExperimentAssignments.test.ts b/fluxer_app/src/features/experiment/state/ExperimentAssignments.test.tsdeleted file mode 100644index 6a0e00ca4..000000000--- a/fluxer_app/src/features/experiment/state/ExperimentAssignments.test.ts+++ /dev/null@@ -1,394 +0,0 @@-// @vitest-environment happy-dom-// SPDX-License-Identifier: AGPL-3.0-or-later--import type {RestResponse} from '@app/features/platform/types/TransportTypes';-import type {DomainMigrationAssignmentResponse} from '@fluxer/schema/src/domains/admin/DomainMigrationSchemas';-import {- type ExperimentAssignmentsResponse,- INERT_EXPERIMENT_ASSIGNMENTS_RESPONSE,- readDomainMigrationAssignment,-} from '@fluxer/schema/src/domains/experiment/ExperimentSchemas';-import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';--vi.mock('@app/features/platform/utils/AppLogger', () => ({- Logger: class {- debug = vi.fn();- info = vi.fn();- warn = vi.fn();- error = vi.fn();- },-}));--vi.mock('@app/features/platform/transport/RestTransport', () => ({- http: {get: vi.fn(), post: vi.fn()},-}));--const {http} = await import('@app/features/platform/transport/RestTransport');-const {ExperimentAssignments} = await import('@app/features/experiment/state/ExperimentAssignments');-const {ResettableStates} = await import('@app/features/app/state/ResettableStates');--const CANARY_ASSIGNMENT: DomainMigrationAssignmentResponse = {- enabled: true,-};--const CANARY_ENVELOPE: ExperimentAssignmentsResponse = {- poll_interval_seconds: 300,- poll_jitter_percent: 15,- assignments: {domain_migration: CANARY_ASSIGNMENT},-};--let visibility: DocumentVisibilityState = 'visible';--function reply(status: number, body: unknown, headers: Record<string, string> = {}): RestResponse<unknown> {- return {ok: status >= 200 && status < 300, status, statusText: '', headers, body};-}--function requestHeaders(index: number): Record<string, string> {- return vi.mocked(http.get).mock.calls[index]?.[1]?.headers ?? {};-}--function lastScheduledDelayMs(): number {- const call = vi.mocked(setTimeout).mock.calls.at(-1);- expect(call).toBeDefined();- return call![1]!;-}--function setVisibility(next: DocumentVisibilityState): void {- visibility = next;- document.dispatchEvent(new Event('visibilitychange'));-}--async function settle(): Promise<void> {- await vi.advanceTimersByTimeAsync(0);-}--function migrationEnabled(): boolean {- return readDomainMigrationAssignment(ExperimentAssignments.response).enabled;-}--function deferredReply(): {resolve: (response: RestResponse<unknown>) => void} {- let resolve!: (response: RestResponse<unknown>) => void;- const pending = new Promise<RestResponse<unknown>>((complete) => {- resolve = complete;- });- vi.mocked(http.get).mockReturnValueOnce(pending);- return {resolve};-}--async function adopt(response: ExperimentAssignmentsResponse): Promise<void> {- vi.mocked(http.get).mockResolvedValue(reply(200, response, {etag: 'W/"seed"'}));- ExperimentAssignments.start();- await settle();-}--beforeEach(() => {- visibility = 'visible';- Object.defineProperty(document, 'visibilityState', {configurable: true, get: () => visibility});- vi.useFakeTimers();- vi.spyOn(globalThis, 'setTimeout');- vi.spyOn(Math, 'random').mockReturnValue(0.5);- vi.mocked(http.get).mockReset();-});--afterEach(() => {- ExperimentAssignments.reset();- vi.restoreAllMocks();- vi.useRealTimers();-});--describe('ExperimentAssignments cold start', () => {- it('keeps the inert envelope when the endpoint is unreachable', async () => {- vi.mocked(http.get).mockRejectedValue(new Error('network unreachable'));- ExperimentAssignments.start();- await settle();- expect(ExperimentAssignments.response).toBe(INERT_EXPERIMENT_ASSIGNMENTS_RESPONSE);- expect(ExperimentAssignments.response.assignments.domain_migration).toBeUndefined();- });-- it('keeps the inert envelope while unauthenticated and retries later', async () => {- vi.mocked(http.get).mockResolvedValue(reply(401, {message: '401: Unauthorized'}));- ExperimentAssignments.start();- await settle();- expect(ExperimentAssignments.response).toBe(INERT_EXPERIMENT_ASSIGNMENTS_RESPONSE);- expect(lastScheduledDelayMs()).toBeLessThanOrEqual(690_000);- await vi.advanceTimersByTimeAsync(700_000);- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(2);- });-});--describe('ExperimentAssignments response handling', () => {- it('discards a malformed envelope and keeps the previous value', async () => {- await adopt(CANARY_ENVELOPE);- vi.mocked(http.get).mockResolvedValue(- reply(200, {- ...CANARY_ENVELOPE,- assignments: {domain_migration: {enabled: 'yes'}},- }),- );- await vi.advanceTimersByTimeAsync(400_000);- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(2);- expect(ExperimentAssignments.response).toEqual(CANARY_ENVELOPE);- });-- it('discards a partial envelope rather than merging it', async () => {- await adopt(CANARY_ENVELOPE);- vi.mocked(http.get).mockResolvedValue(reply(200, {assignments: {}}));- await vi.advanceTimersByTimeAsync(400_000);- expect(ExperimentAssignments.response).toEqual(CANARY_ENVELOPE);- });-- it('keeps the value and the stored etag across a 304', async () => {- vi.mocked(http.get).mockResolvedValueOnce(reply(200, CANARY_ENVELOPE, {etag: 'W/"v7"'}));- ExperimentAssignments.start();- await settle();- expect(requestHeaders(0)['If-None-Match']).toBeUndefined();- vi.mocked(http.get).mockResolvedValue(reply(304, undefined));- await vi.advanceTimersByTimeAsync(400_000);- expect(requestHeaders(1)['If-None-Match']).toBe('W/"v7"');- expect(ExperimentAssignments.response).toEqual(CANARY_ENVELOPE);- await vi.advanceTimersByTimeAsync(400_000);- expect(requestHeaders(2)['If-None-Match']).toBe('W/"v7"');- expect(ExperimentAssignments.response).toEqual(CANARY_ENVELOPE);- });-});--describe('ExperimentAssignments scheduling', () => {- it('never schedules a poll below half the minimum interval', async () => {- vi.spyOn(Math, 'random').mockReturnValue(0);- await adopt({...CANARY_ENVELOPE, poll_interval_seconds: 60, poll_jitter_percent: 50});- expect(lastScheduledDelayMs()).toBeGreaterThanOrEqual(30_000);- });-- it('clamps an out-of-range poll interval into the supported window', async () => {- vi.spyOn(Math, 'random').mockReturnValue(0.5);- await adopt({...CANARY_ENVELOPE, poll_interval_seconds: 1});- expect(lastScheduledDelayMs()).toBe(60_000);- ExperimentAssignments.reset();- await adopt({...CANARY_ENVELOPE, poll_interval_seconds: 999_999});- expect(lastScheduledDelayMs()).toBe(86_400_000);- });-- it('schedules one timer for repeated starts and cancels it on stop', async () => {- vi.mocked(http.get).mockResolvedValue(reply(200, CANARY_ENVELOPE, {etag: 'W/"v7"'}));- ExperimentAssignments.start();- await settle();- expect(vi.getTimerCount()).toBe(1);- ExperimentAssignments.start();- await settle();- expect(vi.getTimerCount()).toBe(1);- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(1);- ExperimentAssignments.stop();- expect(vi.getTimerCount()).toBe(0);- await vi.advanceTimersByTimeAsync(1_000_000);- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(1);- ExperimentAssignments.start();- await settle();- expect(vi.getTimerCount()).toBe(1);- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(2);- });-- it('grows the retry delay on failure and resets it on success', async () => {- vi.spyOn(Math, 'random').mockReturnValue(0.5);- vi.mocked(http.get).mockRejectedValue(new Error('network unreachable'));- ExperimentAssignments.start();- await settle();- expect(lastScheduledDelayMs()).toBe(600_000);- await vi.advanceTimersByTimeAsync(600_000);- expect(lastScheduledDelayMs()).toBe(1_200_000);- await vi.advanceTimersByTimeAsync(1_200_000);- expect(lastScheduledDelayMs()).toBe(1_200_000);- vi.mocked(http.get).mockResolvedValue(reply(200, CANARY_ENVELOPE, {etag: 'W/"v7"'}));- await vi.advanceTimersByTimeAsync(1_200_000);- expect(lastScheduledDelayMs()).toBe(300_000);- });-});--describe('ExperimentAssignments visibility', () => {- it('keeps polling while the document is hidden at four times the interval', async () => {- vi.spyOn(Math, 'random').mockReturnValue(0.5);- visibility = 'hidden';- vi.mocked(http.get).mockResolvedValue(reply(200, CANARY_ENVELOPE, {etag: 'W/"v7"'}));- ExperimentAssignments.start();- await settle();- expect(vi.mocked(http.get)).not.toHaveBeenCalled();- expect(lastScheduledDelayMs()).toBe(1_200_000);- await vi.advanceTimersByTimeAsync(1_200_000);- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(1);- expect(ExperimentAssignments.response).toEqual(CANARY_ENVELOPE);- expect(lastScheduledDelayMs()).toBe(1_200_000);- await vi.advanceTimersByTimeAsync(1_200_000);- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(2);- await vi.advanceTimersByTimeAsync(31_000);- setVisibility('visible');- await settle();- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(3);- expect(lastScheduledDelayMs()).toBe(300_000);- });-- it('collapses repeated visibility flips inside thirty seconds into one fetch', async () => {- visibility = 'hidden';- vi.mocked(http.get).mockResolvedValue(reply(200, CANARY_ENVELOPE, {etag: 'W/"v7"'}));- ExperimentAssignments.start();- await settle();- setVisibility('visible');- await settle();- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(1);- setVisibility('hidden');- await vi.advanceTimersByTimeAsync(29_000);- setVisibility('visible');- await settle();- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(1);- setVisibility('hidden');- await vi.advanceTimersByTimeAsync(2_000);- setVisibility('visible');- await settle();- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(2);- });-});--describe('ExperimentAssignments lifecycle', () => {- it.each(['stop', 'reset'] as const)(- 'aborts an active request on %s and starts a fresh request immediately',- async (method) => {- const stale = deferredReply();- ExperimentAssignments.start();- await settle();- const signal = vi.mocked(http.get).mock.calls[0]?.[1]?.signal;- expect(signal).toBeDefined();- expect(signal!.aborted).toBe(false);-- ExperimentAssignments[method]();- expect(signal!.aborted).toBe(true);- vi.mocked(http.get).mockResolvedValue(reply(200, CANARY_ENVELOPE, {etag: 'W/"fresh"'}));- ExperimentAssignments.start();- await settle();- expect(http.get).toHaveBeenCalledTimes(2);- expect(ExperimentAssignments.response).toEqual(CANARY_ENVELOPE);- expect(vi.getTimerCount()).toBe(1);-- stale.resolve(reply(200, INERT_EXPERIMENT_ASSIGNMENTS_RESPONSE, {etag: 'W/"stale"'}));- await settle();- expect(ExperimentAssignments.response).toEqual(CANARY_ENVELOPE);- expect(vi.getTimerCount()).toBe(1);- },- );-- it('keeps ownership of the replacement request when the stale request finishes first', async () => {- const stale = deferredReply();- ExperimentAssignments.start();- ExperimentAssignments.stop();- const replacement = deferredReply();- ExperimentAssignments.start();- const signal = vi.mocked(http.get).mock.calls[1]?.[1]?.signal;- expect(signal).toBeDefined();-- stale.resolve(reply(200, CANARY_ENVELOPE));- await settle();- await vi.advanceTimersByTimeAsync(31_000);- setVisibility('hidden');- setVisibility('visible');- await settle();- expect(http.get).toHaveBeenCalledTimes(2);- expect(signal!.aborted).toBe(false);-- ExperimentAssignments.stop();- expect(signal!.aborted).toBe(true);- replacement.resolve(reply(200, CANARY_ENVELOPE));- await settle();- expect(ExperimentAssignments.response).toBe(INERT_EXPERIMENT_ASSIGNMENTS_RESPONSE);- expect(vi.getTimerCount()).toBe(0);- });-- it('does not keep the etag or the backoff of the previous session across a reset', async () => {- vi.spyOn(Math, 'random').mockReturnValue(0.5);- await adopt(CANARY_ENVELOPE);- vi.mocked(http.get).mockResolvedValue(reply(500, {message: '500: Internal Server Error'}));- await vi.advanceTimersByTimeAsync(400_000);- expect(lastScheduledDelayMs()).toBe(600_000);- ExperimentAssignments.reset();- vi.mocked(http.get).mockResolvedValue(reply(200, CANARY_ENVELOPE, {etag: 'W/"fresh"'}));- ExperimentAssignments.start();- await settle();- expect(requestHeaders(2)['If-None-Match']).toBeUndefined();- expect(lastScheduledDelayMs()).toBe(300_000);- });-});--describe('ExperimentAssignments endpoint failures', () => {- it('backs off while the session is rejected', async () => {- vi.spyOn(Math, 'random').mockReturnValue(0.5);- await adopt(CANARY_ENVELOPE);- vi.mocked(http.get).mockResolvedValue(reply(401, {message: '401: Unauthorized'}));- await vi.advanceTimersByTimeAsync(300_000);- expect(lastScheduledDelayMs()).toBe(600_000);- await vi.advanceTimersByTimeAsync(600_000);- expect(lastScheduledDelayMs()).toBe(1_200_000);- await vi.advanceTimersByTimeAsync(1_200_000);- expect(lastScheduledDelayMs()).toBe(1_200_000);- expect(ExperimentAssignments.response).toEqual(CANARY_ENVELOPE);- });-- it('stops polling for the session after three consecutive 404s', async () => {- vi.spyOn(Math, 'random').mockReturnValue(0.5);- vi.mocked(http.get).mockResolvedValue(reply(404, {message: '404: Not Found'}));- ExperimentAssignments.start();- await settle();- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(1);- await vi.advanceTimersByTimeAsync(600_000);- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(2);- await vi.advanceTimersByTimeAsync(1_200_000);- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(3);- expect(vi.getTimerCount()).toBe(0);- await vi.advanceTimersByTimeAsync(10_000_000);- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(3);- ExperimentAssignments.start();- await settle();- setVisibility('visible');- await settle();- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(3);- expect(ExperimentAssignments.response).toBe(INERT_EXPERIMENT_ASSIGNMENTS_RESPONSE);- });-});--describe('ExperimentAssignments account transitions', () => {- it('clears the previous account assignments and etag on an account switch', async () => {- vi.mocked(http.get).mockResolvedValue(reply(200, CANARY_ENVELOPE, {etag: 'W/"a"'}));- ExperimentAssignments.start('a');- await settle();- expect(migrationEnabled()).toBe(true);- ResettableStates.prepareForAccountTransition('account-switch');- expect(ExperimentAssignments.response).toBe(INERT_EXPERIMENT_ASSIGNMENTS_RESPONSE);- expect(ExperimentAssignments.ownerId).toBeNull();- expect(vi.getTimerCount()).toBe(0);- vi.mocked(http.get).mockResolvedValue(reply(200, CANARY_ENVELOPE, {etag: 'W/"b"'}));- ExperimentAssignments.start('b');- await settle();- expect(ExperimentAssignments.ownerId).toBe('b');- expect(requestHeaders(1)['If-None-Match']).toBeUndefined();- });-- it('polls the next account after the previous instance disabled the endpoint', async () => {- vi.mocked(http.get).mockResolvedValue(reply(404, {message: '404: Not Found'}));- ExperimentAssignments.start('a');- await settle();- await vi.advanceTimersByTimeAsync(600_000);- await vi.advanceTimersByTimeAsync(1_200_000);- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(3);- ResettableStates.prepareForAccountTransition('account-switch');- vi.mocked(http.get).mockResolvedValue(reply(200, CANARY_ENVELOPE, {etag: 'W/"b"'}));- ExperimentAssignments.start('b');- await settle();- expect(vi.mocked(http.get)).toHaveBeenCalledTimes(4);- expect(migrationEnabled()).toBe(true);- });-- it('ignores a response for the previous account that lands after the switch', async () => {- const pending = deferredReply();- ExperimentAssignments.start('a');- await settle();- ResettableStates.prepareForAccountTransition('account-switch');- pending.resolve(reply(200, CANARY_ENVELOPE, {etag: 'W/"a"'}));- await settle();- expect(ExperimentAssignments.response).toBe(INERT_EXPERIMENT_ASSIGNMENTS_RESPONSE);- });-});diff --git a/fluxer_app/src/features/guild/hooks/useConfirmDeleteMyMessages.test.tsx b/fluxer_app/src/features/guild/hooks/useConfirmDeleteMyMessages.test.tsxdeleted file mode 100644index 2318d2aad..000000000--- a/fluxer_app/src/features/guild/hooks/useConfirmDeleteMyMessages.test.tsx+++ /dev/null@@ -1,80 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {useConfirmDeleteMyMessages} from '@app/features/guild/hooks/useConfirmDeleteMyMessages';-import {renderToStaticMarkup} from 'react-dom/server';-import {beforeEach, describe, expect, it, vi} from 'vitest';--const mocks = vi.hoisted(() => ({push: vi.fn(), toast: vi.fn(), error: vi.fn()}));-vi.mock('@lingui/react/macro', () => ({useLingui: () => ({i18n: {_: () => 'Delete my messages'}})}));-vi.mock('@app/features/platform/utils/AppLogger', () => ({- Logger: class {- error() {}- },-}));-vi.mock('@app/features/channel/utils/ChannelMessageDescriptors', () => ({- DELETE_MY_MESSAGES_DESCRIPTOR: {message: 'Delete my messages'},-}));-vi.mock('@app/features/app/components/dialogs/ConfirmModal', () => ({ConfirmModal: () => null}));-vi.mock('@app/features/app/components/alerts/GenericErrorModalCommands', () => ({showGenericErrorModal: mocks.error}));-vi.mock('@app/features/ui/commands/ModalCommands', () => ({- push: mocks.push,- modal: (render: () => unknown) => render,-}));-vi.mock('@app/features/ui/commands/ToastCommands', () => ({createToast: mocks.toast}));-let confirm: ReturnType<typeof useConfirmDeleteMyMessages>;-function Probe() {- confirm = useConfirmDeleteMyMessages();- return null;-}-beforeEach(() => {- vi.clearAllMocks();- renderToStaticMarkup(<Probe data-flx="guild.use-confirm-delete-my-messages-test.probe" />);-});-describe('message deletion confirmation', () => {- it('waits for confirmation and successful deletion before showing success', async () => {- let finish!: () => void;- const run = vi.fn(- () =>- new Promise<void>((resolve) => {- finish = resolve;- }),- );- confirm({- title: 'Delete?',- description: 'Cannot undo',- run,- dataFlx: 'guild.delete.confirm-modal',- toastText: 'Deleted',- errorTitle: 'Failed',- errorMessage: 'Try again',- });- expect(run).not.toHaveBeenCalled();- const modal = mocks.push.mock.calls[0][0]();- const pending = modal.props.onPrimary();- expect(run).toHaveBeenCalledOnce();- expect(mocks.toast).not.toHaveBeenCalled();- finish();- await pending;- expect(mocks.toast).toHaveBeenCalledWith({type: 'success', children: 'Deleted'});- });- it('defers the error modal until the confirmation dismisses', async () => {- const run = vi.fn().mockRejectedValue(new Error('server'));- confirm({- title: 'Delete?',- description: 'Cannot undo',- run,- dataFlx: 'channel.delete.confirm-modal',- toastText: 'Deleted',- errorTitle: 'Channel failure',- errorMessage: 'Try later',- });- await mocks.push.mock.calls[0][0]().props.onPrimary();- expect(mocks.toast).not.toHaveBeenCalled();- expect(mocks.error).toHaveBeenCalledWith({- title: 'Channel failure',- message: 'Try later',- dataFlx: 'channel.delete.generic-error-modal',- defer: true,- });- });-});diff --git a/fluxer_app/src/features/guild/state/GuildMatureContentAgree.test.ts b/fluxer_app/src/features/guild/state/GuildMatureContentAgree.test.tsdeleted file mode 100644index 9006ea97b..000000000--- a/fluxer_app/src/features/guild/state/GuildMatureContentAgree.test.ts+++ /dev/null@@ -1,80 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {Channel} from '@app/features/channel/models/Channel';-import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants';-import {ContentWarningLevel} from '@fluxer/constants/src/GuildConstants';-import type {Channel as WireChannel} from '@fluxer/schema/src/domains/channel/ChannelSchemas';-import {beforeEach, describe, expect, it, vi} from 'vitest';--const channels = new Map<string, Channel>();-const guild = {id: 'guild', nsfw: false, contentWarningLevel: ContentWarningLevel.INHERIT, contentWarningText: null};--vi.mock('@lingui/core/macro', () => ({msg: (descriptor: unknown) => descriptor}));-vi.mock('@app/features/app/state/RuntimeConfig', () => ({default: {localInstanceDomain: 'fluxer.test'}}));-vi.mock('@app/features/user/state/Users', () => ({- default: {- getUser: () => undefined,- cacheUsers: () => {},- getCurrentUser: () => ({matureContentAllowed: true, matureContentCheckComplete: true}),- },-}));-vi.mock('@app/features/channel/state/Channels', () => ({default: {getChannel: (id: string) => channels.get(id)}}));-vi.mock('@app/features/guild/state/Guilds', () => ({default: {getGuild: () => guild}}));-vi.mock('@app/features/app/state/GeoIP', () => ({default: {ageRestrictedGeos: []}}));-vi.mock('@app/features/devtools/state/DeveloperOptions', () => ({default: {mockMatureContentGateReason: 'none'}}));-vi.mock('@app/features/moderation/utils/MatureContentGeoUtils', () => ({- getEffectiveMatureContentGeoContext: () => ({countryCode: null, regionCode: null}),-}));-vi.mock('@app/features/user/state/SyncedField', () => ({makeSyncedField: async () => {}}));--const {default: GuildMatureContentAgree, MatureContentGateReason} = await import(- '@app/features/guild/state/GuildMatureContentAgree'-);--function put(channel: WireChannel): void {- channels.set(channel.id, new Channel(channel));-}--beforeEach(() => {- channels.clear();- GuildMatureContentAgree.revokeChannel('parent');- GuildMatureContentAgree.revokeChannel('forum');- GuildMatureContentAgree.revokeCategory('category');- put({id: 'category', guild_id: 'guild', type: ChannelTypes.GUILD_CATEGORY, nsfw_override: null});- put({id: 'parent', guild_id: 'guild', type: ChannelTypes.GUILD_TEXT, parent_id: 'category', nsfw_override: null});- put({id: 'thread', guild_id: 'guild', type: ChannelTypes.PUBLIC_THREAD, parent_id: 'parent'});-});--describe('GuildMatureContentAgree for threads', () => {- it('gates a thread whose parent is mature and records consent on the parent', () => {- put({id: 'parent', guild_id: 'guild', type: ChannelTypes.GUILD_TEXT, parent_id: 'category', nsfw_override: true});- expect(GuildMatureContentAgree.getGateReason({channelId: 'thread'})).toBe(MatureContentGateReason.CONSENT_REQUIRED);- const resolved = GuildMatureContentAgree.getResolvedContext({channelId: 'thread'});- expect(resolved.scope).toBe('channel');- expect(resolved.scopeId).toBe('parent');- GuildMatureContentAgree.agreeToChannel('thread');- expect(GuildMatureContentAgree.agreedChannelIds).toEqual(['parent']);- expect(GuildMatureContentAgree.getGateReason({channelId: 'thread'})).toBe(MatureContentGateReason.NONE);- });-- it('gates a thread under a mature category through its parent', () => {- put({id: 'category', guild_id: 'guild', type: ChannelTypes.GUILD_CATEGORY, nsfw_override: true});- const resolved = GuildMatureContentAgree.getResolvedContext({channelId: 'thread'});- expect(resolved.scope).toBe('category');- expect(resolved.scopeId).toBe('category');- expect(GuildMatureContentAgree.getGateReason({channelId: 'thread'})).toBe(MatureContentGateReason.CONSENT_REQUIRED);- GuildMatureContentAgree.agreeToCategory('category');- expect(GuildMatureContentAgree.getGateReason({channelId: 'thread'})).toBe(MatureContentGateReason.NONE);- });-- it('does not gate a thread in a safe parent', () => {- expect(GuildMatureContentAgree.getGateReason({channelId: 'thread'})).toBe(MatureContentGateReason.NONE);- });-- it('keeps forum agreements out of synced preferences', () => {- put({id: 'forum', guild_id: 'guild', type: ChannelTypes.GUILD_FORUM, nsfw_override: true});- GuildMatureContentAgree.agreeToChannel('forum');- expect(GuildMatureContentAgree.agreedChannelIds).toEqual([]);- expect(GuildMatureContentAgree.hasAgreedToChannel('forum')).toBe(true);- });-});diff --git a/fluxer_app/src/features/guild/utils/GuildAcronymUtils.test.ts b/fluxer_app/src/features/guild/utils/GuildAcronymUtils.test.tsdeleted file mode 100644index ae3099c6c..000000000--- a/fluxer_app/src/features/guild/utils/GuildAcronymUtils.test.ts+++ /dev/null@@ -1,73 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {- getGuildAcronym,- getGuildAcronymFontScale,- getGuildAcronymLength,-} from '@app/features/guild/utils/GuildAcronymUtils';-import {describe, expect, test} from 'vitest';--const ACRONYM_VECTORS: ReadonlyArray<readonly [name: string, acronym: string, length: number]> = [- ['Movies? We Like Movies', 'M?WLM', 5],- ['Movies Movies', 'MM', 2],- ['(Internal) Fluxer DevOps', '(I)FD', 5],- ['secret server', 'ss', 2],- ['Hampus server', 'Hs', 2],- ['Fluxer', 'F', 1],- [' Fluxer ', 'F', 1],- ['a b\tc\nd', 'abcd', 4],- ["Bob's Burgers", 'BB', 2],- ['Bob’s Burgers', 'BB', 2],- ["Bob's", "B's", 3],- ["Don't Panic", "D'tP", 4],- ['Area 51', 'A5', 2],- ['2024 Reunion', '2R', 2],- ['Rock-n-Roll', 'R-n-R', 5],- ['Spider-Man Fans', 'S-MF', 4],- ['snake_case_name', 's', 1],- ['C++ & Rust', 'C++&R', 5],- ['@everyone', '@e', 2],- ['!!!', '!!!', 3],- ['\u{1F3AE}\u{1F3B2}', '\u{1F3AE}\u{1F3B2}', 2],- ['\u{1F496}tes tes', '\u{1F496}tt', 3],- ['❤️love', '❤️l', 2],- ['\u{1F468}\u{1F469}\u{1F467} Family', '\u{1F468}\u{1F469}\u{1F467}F', 2],- ['\u{1F1F8}\u{1F1EA} Sweden', '\u{1F1F8}\u{1F1EA}S', 2],- ['1️⃣ One', '1️⃣O', 2],- ['日本語 サーバー', '日サ', 2],- ['原神交流群', '原', 1],- ['한국 서버', '한서', 2],- ['Привет Мир', 'ПМ', 2],- ['مرحبا بالعالم', 'مب', 2],- ['שלום עולם', 'שע', 2],- ['میخواهم بازی', 'مب', 2],- ['École Normale', 'ÉN', 2],- ['नमस्ते दुनिया', 'नदु', 2],- ['one two three four five six seven eight nine ten', 'ottffssent', 10],- ['', '', 0],- [' \t ', '', 0],-];--const FONT_SCALE_VECTORS: ReadonlyArray<readonly [length: number, fontSizePxAt48: number]> = [- [0, 18],- [1, 18],- [2, 18],- [3, 16],- [4, 14],- [5, 12],- [6, 10],- [10, 10],-];--describe('getGuildAcronym', () => {- test.each(ACRONYM_VECTORS)('%j -> %j', (name, acronym, length) => {- expect(getGuildAcronym(name)).toBe(acronym);- expect(getGuildAcronymLength(acronym)).toBe(length);- });-});--describe('getGuildAcronymFontScale', () => {- test.each(FONT_SCALE_VECTORS)('%i graphemes -> %ipx on a 48px icon', (length, fontSizePx) => {- expect(getGuildAcronymFontScale(length) * 48).toBeCloseTo(fontSizePx);- });-});diff --git a/fluxer_app/src/features/input/state/HoldSources.test.ts b/fluxer_app/src/features/input/state/HoldSources.test.tsdeleted file mode 100644index d65bd9d51..000000000--- a/fluxer_app/src/features/input/state/HoldSources.test.ts+++ /dev/null@@ -1,90 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {HoldSources} from '@app/features/input/state/HoldSources';-import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';--const RELEASE_DELAY_MS = 250;--describe('HoldSources', () => {- beforeEach(() => {- vi.useFakeTimers();- });-- afterEach(() => {- vi.useRealTimers();- });-- it('keeps push-to-talk open while a portal source is held after the DOM source is released, for example on window blur', () => {- const sources = new HoldSources(() => RELEASE_DELAY_MS);- const onReleased = vi.fn();- expect(sources.press('voice_push_to_talk', 'custom:a')).toBe(true);- expect(sources.press('voice_push_to_talk', 'portal:voice_push_to_talk')).toBe(false);- sources.release('voice_push_to_talk', 'custom:a', onReleased);- vi.advanceTimersByTime(RELEASE_DELAY_MS * 4);- expect(onReleased).not.toHaveBeenCalled();- sources.release('voice_push_to_talk', 'portal:voice_push_to_talk', onReleased);- vi.advanceTimersByTime(RELEASE_DELAY_MS - 1);- expect(onReleased).not.toHaveBeenCalled();- vi.advanceTimersByTime(1);- expect(onReleased).toHaveBeenCalledTimes(1);- });-- it('cancels the pending release when a source is pressed again', () => {- const sources = new HoldSources(() => RELEASE_DELAY_MS);- const onReleased = vi.fn();- sources.press('voice_push_to_talk', 'custom:a');- sources.release('voice_push_to_talk', 'custom:a', onReleased);- expect(sources.press('voice_push_to_talk_priority', 'custom:b')).toBe(true);- expect(sources.prioritySpeakerHeld).toBe(true);- vi.advanceTimersByTime(RELEASE_DELAY_MS * 4);- expect(onReleased).not.toHaveBeenCalled();- sources.release('voice_push_to_talk_priority', 'custom:b', onReleased);- expect(sources.prioritySpeakerHeld).toBe(false);- vi.advanceTimersByTime(RELEASE_DELAY_MS);- expect(onReleased).toHaveBeenCalledTimes(1);- });-- it('ignores releases for sources that were never pressed', () => {- const sources = new HoldSources(() => RELEASE_DELAY_MS);- const onReleased = vi.fn();- sources.release('voice_push_to_talk', 'custom:unknown', onReleased);- sources.release('voice_push_to_mute', 'custom:unknown', onReleased);- sources.press('voice_push_to_talk', 'custom:a');- sources.release('voice_push_to_talk', 'custom:unknown', onReleased);- vi.advanceTimersByTime(RELEASE_DELAY_MS * 4);- expect(onReleased).not.toHaveBeenCalled();- });-- it('clears held sources and the pending release on reset', () => {- const sources = new HoldSources(() => RELEASE_DELAY_MS);- const onReleased = vi.fn();- sources.press('voice_push_to_talk', 'custom:a');- sources.press('voice_push_to_talk', 'custom:b');- sources.release('voice_push_to_talk', 'custom:a', onReleased);- sources.release('voice_push_to_talk', 'custom:b', onReleased);- sources.resetPushToTalk();- vi.advanceTimersByTime(RELEASE_DELAY_MS * 4);- expect(onReleased).not.toHaveBeenCalled();- sources.press('voice_push_to_talk', 'custom:a');- sources.resetPushToTalk();- sources.release('voice_push_to_talk', 'custom:a', onReleased);- vi.advanceTimersByTime(RELEASE_DELAY_MS * 4);- expect(onReleased).not.toHaveBeenCalled();- expect(sources.press('voice_push_to_talk', 'custom:a')).toBe(true);- });-- it('releases push-to-mute immediately when its last source is released', () => {- const sources = new HoldSources(() => RELEASE_DELAY_MS);- const onReleased = vi.fn();- expect(sources.press('voice_push_to_mute', 'custom:a')).toBe(true);- expect(sources.press('voice_push_to_mute', 'gamepad:a')).toBe(false);- sources.release('voice_push_to_mute', 'custom:a', onReleased);- expect(onReleased).not.toHaveBeenCalled();- sources.release('voice_push_to_mute', 'gamepad:a', onReleased);- expect(onReleased).toHaveBeenCalledTimes(1);- sources.press('voice_push_to_mute', 'custom:a');- sources.resetPushToMute();- sources.release('voice_push_to_mute', 'custom:a', onReleased);- expect(onReleased).toHaveBeenCalledTimes(1);- });-});diff --git a/fluxer_app/src/features/theme/utils/InstanceBrandColors.test.ts b/fluxer_app/src/features/theme/utils/InstanceBrandColors.test.tsdeleted file mode 100644index aac6caeae..000000000--- a/fluxer_app/src/features/theme/utils/InstanceBrandColors.test.ts+++ /dev/null@@ -1,150 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {BRAND_PRESSED_RATIO, THEME_PALETTES} from '@app/features/theme/utils/ColorSystemPalette';-import {- contrastRatio,- FOREGROUND_BRAND_TINT_RATIO,- FOREGROUND_SELF_TINT_RATIO,- getInstanceBrandVariables,- hslToRgb,- MIN_TEXT_CONTRAST,- mixRgb,- resolveThemeSurface,- resolveThemeSurfaces,-} from '@app/features/theme/utils/InstanceBrandColors';-import {describe, expect, test} from 'vitest';--type Rgb = readonly [number, number, number];--const MIN_UI_CONTRAST = 3;-const THEMES = Object.keys(THEME_PALETTES);-const SATURATION_FACTORS = [1, 0.5, 0];-const NAMED_COLORS = [- '#ffffff',- '#f0f0f0',- '#ffff00',- '#00ff00',- '#00ffff',- '#ff00ff',- '#ff0000',- '#0000ff',- '#e53935',- '#4641d9',- '#7f7f7f',- '#000001',- '#0b1a3a',- '#ffd1dc',-];--function hex(rgb: Rgb): string {- return `#${rgb.map((channel) => Math.round(channel).toString(16).padStart(2, '0')).join('')}`;-}--function gridColors(): Array<string> {- const colors: Array<string> = [];- for (let hue = 0; hue < 360; hue += 30) {- for (const saturation of [100, 35]) {- for (const lightness of [3, 15, 30, 50, 70, 85, 97]) {- colors.push(hex(hslToRgb(hue, saturation, lightness)));- }- }- }- return colors;-}--function parseColor(value: string): Rgb {- const hsl = /^hsl\(([\d.]+), ([\d.]+)%, ([\d.]+)%\)$/.exec(value);- if (hsl) return hslToRgb(Number(hsl[1]), Number(hsl[2]), Number(hsl[3]));- const rgb = /^rgb\(([\d.]+), ([\d.]+), ([\d.]+)\)$/.exec(value);- if (rgb) return [Number(rgb[1]), Number(rgb[2]), Number(rgb[3])];- throw new Error(`Unparseable colour ${value}`);-}--function minContrast(foreground: Rgb, backgrounds: ReadonlyArray<Rgb>): number {- return Math.min(...backgrounds.map((background) => contrastRatio(foreground, background)));-}--function sameColor(first: Rgb, second: Rgb): boolean {- return first.every((channel, index) => Math.abs(channel - second[index]) < 0.01);-}--const COLORS = [...NAMED_COLORS, ...gridColors()];-const CASES = THEMES.flatMap((theme) =>- SATURATION_FACTORS.flatMap((saturationFactor) => COLORS.map((color) => ({theme, saturationFactor, color}))),-);--describe('getInstanceBrandVariables', () => {- test('rejects anything but a lowercase six digit hex colour', () => {- expect(getInstanceBrandVariables('#FFF', 'dark', 1)).toBeNull();- expect(getInstanceBrandVariables('red', 'dark', 1)).toBeNull();- });-- test('keeps the operator colour as the solid fill', () => {- expect(getInstanceBrandVariables('#ffff00', 'light', 1)?.['--instance-brand-primary']).toBe('hsl(60, 100%, 50%)');- expect(getInstanceBrandVariables('#e53935', 'dark', 0.5)?.['--instance-brand-primary']).toBe(- 'hsl(1.36, 38.6%, 55.29%)',- );- });-- test('treats an unknown theme like the dark root palette', () => {- expect(getInstanceBrandVariables('#ffff00', 'unknown', 1)).toEqual(getInstanceBrandVariables('#ffff00', 'dark', 1));- });-- test.each(CASES)(- '$color in $theme at saturation $saturationFactor meets contrast minimums',- ({theme, saturationFactor, color}) => {- const variables = getInstanceBrandVariables(color, theme, saturationFactor);- expect(variables).not.toBeNull();- const v = Object.fromEntries(- Object.entries(variables!).map(([name, value]) => [name.replace('--instance-', ''), parseColor(value)]),- );- const surfaces = resolveThemeSurfaces(theme, saturationFactor);- const stops = surfaces.slice(0, surfaces.length / 2);- const pressed = mixRgb(v['brand-primary'], v['brand-primary-shade'], BRAND_PRESSED_RATIO);- const solidFills = [v['brand-primary'], v['brand-secondary'], pressed];- expect(minContrast(v['text-on-brand-primary'], solidFills)).toBeGreaterThanOrEqual(MIN_TEXT_CONTRAST);- expect(minContrast(v['brand-primary-fill'], solidFills)).toBeGreaterThanOrEqual(MIN_TEXT_CONTRAST);- expect(contrastRatio(v['text-on-brand-primary-light'], v['brand-primary-light'])).toBeGreaterThanOrEqual(- MIN_TEXT_CONTRAST,- );- expect(contrastRatio(v['brand-primary-light-fill'], v['brand-primary-light'])).toBeGreaterThanOrEqual(- MIN_TEXT_CONTRAST,- );- for (const name of ['brand-primary-foreground', 'brand-primary-light']) {- const foreground = v[name];- const tinted = [- ...stops.map((stop) => mixRgb(foreground, stop, FOREGROUND_SELF_TINT_RATIO)),- ...stops.map((stop) => mixRgb(v['brand-primary'], stop, FOREGROUND_BRAND_TINT_RATIO)),- ];- expect(minContrast(foreground, surfaces)).toBeGreaterThanOrEqual(MIN_TEXT_CONTRAST);- expect(minContrast(foreground, tinted)).toBeGreaterThanOrEqual(MIN_TEXT_CONTRAST);- }- expect(minContrast(v['brand-tint-border'], surfaces)).toBeGreaterThanOrEqual(MIN_UI_CONTRAST);- expect(minContrast(v['text-on-brand-tint'], [v['brand-tint'], v['brand-tint-hover']])).toBeGreaterThanOrEqual(- MIN_TEXT_CONTRAST,- );- const tint = THEME_PALETTES[theme as keyof typeof THEME_PALETTES].brandTint;- const tintSurface = resolveThemeSurface(theme, tint.surface, saturationFactor);- const matchingRatio = (target: Rgb, max: number) =>- Array.from({length: max + 1}, (_, ratio) => max - ratio).find((ratio) =>- sameColor(target, mixRgb(v['brand-primary'], tintSurface, ratio)),- );- expect(matchingRatio(v['brand-tint'], tint.rest)).toBeDefined();- expect(matchingRatio(v['brand-tint-hover'], tint.hover)).toBeDefined();- },- );-- test('keeps the stylesheet tint ratios whenever the text already passes', () => {- const variables = getInstanceBrandVariables('#4641d9', 'dark', 1)!;- const surface = resolveThemeSurface('dark', THEME_PALETTES.dark.brandTint.surface, 1);- const primary = parseColor(variables['--instance-brand-primary']);- expect(sameColor(parseColor(variables['--instance-brand-tint']), mixRgb(primary, surface, 36))).toBe(true);- expect(sameColor(parseColor(variables['--instance-brand-tint-hover']), mixRgb(primary, surface, 48))).toBe(true);- });-- test('reads light text on the dark reaction tint even when the brand needs dark text', () => {- const variables = getInstanceBrandVariables('#e53935', 'dark', 1)!;- expect(variables['--instance-text-on-brand-primary']).toBe('rgb(0, 0, 0)');- expect(variables['--instance-text-on-brand-tint']).toBe('hsl(0, 0%, 98%)');- });-});diff --git a/fluxer_app/src/features/ui/components/form/ComboboxNumericInput.test.ts b/fluxer_app/src/features/ui/components/form/ComboboxNumericInput.test.tsdeleted file mode 100644index 84b84845a..000000000--- a/fluxer_app/src/features/ui/components/form/ComboboxNumericInput.test.ts+++ /dev/null@@ -1,36 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {parseNumericInput, resolveNearestNumericOption} from '@app/features/ui/components/form/ComboboxNumericInput';-import {describe, expect, it} from 'vitest';--const RELEASE_DELAY_OPTIONS = [20, 100, 250, 500, 1000, 1500, 2000].map((value) => ({- value,- label: new Intl.NumberFormat('en-US', {style: 'unit', unit: 'millisecond', unitDisplay: 'narrow'}).format(value),-}));--describe('parseNumericInput', () => {- it('reads grouped thousands in common locale formats', () => {- expect(parseNumericInput('1,000ms')).toBe(1000);- expect(parseNumericInput('1.500 ms')).toBe(1500);- expect(parseNumericInput('2 000 ms')).toBe(2000);- expect(parseNumericInput("1'000")).toBe(1000);- });-- it('keeps decimals', () => {- expect(parseNumericInput('1.5 s')).toBe(1.5);- expect(parseNumericInput('1,5 s')).toBe(1.5);- expect(parseNumericInput('250')).toBe(250);- });-- it('returns undefined without digits', () => {- expect(parseNumericInput('ms')).toBeUndefined();- });-});--describe('resolveNearestNumericOption', () => {- it('keeps release delays above 500 ms when the selected label is read back', () => {- for (const option of RELEASE_DELAY_OPTIONS) {- expect(resolveNearestNumericOption(option.label, RELEASE_DELAY_OPTIONS)).toBe(option.value);- }- });-});diff --git a/fluxer_app/src/features/ui/state/Idle.test.ts b/fluxer_app/src/features/ui/state/Idle.test.tsdeleted file mode 100644index 60ea1fea9..000000000--- a/fluxer_app/src/features/ui/state/Idle.test.ts+++ /dev/null@@ -1,95 +0,0 @@-// @vitest-environment happy-dom-// SPDX-License-Identifier: AGPL-3.0-or-later--import {StatusTypes} from '@fluxer/constants/src/StatusConstants';-import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';--const IDLE_THRESHOLD_PASSED_MS = 11 * 60 * 1000;--const mobileLayoutLoad = vi.hoisted(() => ({delayMs: 0}));--vi.mock('@app/features/ui/state/MobileLayout', async () => {- await vi.advanceTimersByTimeAsync(mobileLayoutLoad.delayMs);- return {default: {isMobileLayout: () => false}};-});--vi.mock('@app/features/user/state/CustomStatus', () => ({- customStatusToKey: () => 'none',- normalizeCustomStatus: () => null,- toGatewayCustomStatus: () => null,-}));--function hydratedOnlineSettings(afkTimeoutSeconds = 600) {- return {- status: StatusTypes.ONLINE,- isHydrated: () => true,- markSessionChanging: () => {},- getAfkTimeout: () => afkTimeoutSeconds,- getCustomStatus: () => null,- getStatusResetsAt: () => null,- getStatusResetsTo: () => null,- };-}--describe('Idle', () => {- beforeEach(() => {- vi.resetModules();- vi.useFakeTimers();- mobileLayoutLoad.delayMs = 0;- });-- afterEach(async () => {- const {default: Idle} = await import('@app/features/ui/state/Idle');- Idle.destroy();- vi.useRealTimers();- });-- it('flips idle on its own timer while LocalPresence is still loading', async () => {- mobileLayoutLoad.delayMs = IDLE_THRESHOLD_PASSED_MS;- const {default: LocalPresence} = await import('@app/features/presence/state/LocalPresence');- const {default: Idle} = await import('@app/features/ui/state/Idle');- expect(Idle.isIdle()).toBe(true);- expect(LocalPresence).toBeDefined();- });-- it('moves LocalPresence to idle and back to online with the idle state', async () => {- const {default: LocalPresence, setLocalPresenceUserSettings} = await import(- '@app/features/presence/state/LocalPresence'- );- const {default: Idle} = await import('@app/features/ui/state/Idle');- setLocalPresenceUserSettings(hydratedOnlineSettings());- LocalPresence.updatePresence();- await vi.advanceTimersByTimeAsync(0);- expect(LocalPresence.getStatus()).toBe(StatusTypes.ONLINE);-- await vi.advanceTimersByTimeAsync(IDLE_THRESHOLD_PASSED_MS);- expect(Idle.isIdle()).toBe(true);- expect(LocalPresence.getStatus()).toBe(StatusTypes.IDLE);- expect(LocalPresence.getPresence().since).toBeGreaterThan(0);-- Idle.recordActivity();- expect(Idle.isIdle()).toBe(false);- expect(LocalPresence.getStatus()).toBe(StatusTypes.ONLINE);- expect(LocalPresence.getPresence().since).toBe(0);- });-- it('reports afk once the user afk timeout passes', async () => {- const {default: LocalPresence, setLocalPresenceUserSettings} = await import(- '@app/features/presence/state/LocalPresence'- );- const {default: Idle} = await import('@app/features/ui/state/Idle');- setLocalPresenceUserSettings(hydratedOnlineSettings(60));- LocalPresence.updatePresence();- await vi.advanceTimersByTimeAsync(0);- expect(LocalPresence.getPresence().afk).toBe(false);-- await vi.advanceTimersByTimeAsync(45 * 1000);- expect(LocalPresence.getPresence().afk).toBe(false);-- await vi.advanceTimersByTimeAsync(45 * 1000);- expect(LocalPresence.getPresence().afk).toBe(true);-- Idle.recordActivity();- expect(LocalPresence.getPresence().afk).toBe(false);- });-});diff --git a/fluxer_app/src/features/ui/state/IdleWithoutWindow.test.ts b/fluxer_app/src/features/ui/state/IdleWithoutWindow.test.tsdeleted file mode 100644index 495bb778b..000000000--- a/fluxer_app/src/features/ui/state/IdleWithoutWindow.test.ts+++ /dev/null@@ -1,19 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {afterEach, expect, it, vi} from 'vitest';--afterEach(async () => {- const {default: Idle} = await import('@app/features/ui/state/Idle');- Idle.destroy();- vi.useRealTimers();-});--it('checks idle state on its timer when there is no window', async () => {- vi.useFakeTimers();- const {default: Idle} = await import('@app/features/ui/state/Idle');- expect(typeof window).toBe('undefined');-- await vi.advanceTimersByTimeAsync(11 * 60 * 1000);-- expect(Idle.isIdle()).toBe(true);-});