A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
test(app): remove the app vitest config and micro-benchmarks
Hampusdfe3f61a07bf
diff --git a/fluxer_app/src/features/channel/components/ChannelMessageStreamUtils.bench.ts b/fluxer_app/src/features/channel/components/ChannelMessageStreamUtils.bench.tsdeleted file mode 100644index afb1447a1..000000000--- a/fluxer_app/src/features/channel/components/ChannelMessageStreamUtils.bench.ts+++ /dev/null@@ -1,42 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {getUnreadDividerBeforeMessageId} from '@app/features/channel/components/ChannelMessageStreamUtils';-import type {Message} from '@app/features/messaging/models/MessagingMessage';-import type {ChannelStreamItem} from '@app/features/messaging/utils/MessageGroupingUtils';-import {test} from 'vitest';--const GROUP_ITEMS = Array.from(- {length: 100},- (_value, index): ChannelStreamItem => ({- type: 'MESSAGE',- content: {- id: `message-${index}`,- } as Message,- groupId: 'group-1',- showUnreadDividerBefore: index === 74,- }),-);--const GROUPS = Array.from({length: 1_000}, (_value, groupIndex) =>- GROUP_ITEMS.map(- (item, itemIndex): ChannelStreamItem => ({- ...item,- content: {- id: `message-${groupIndex}-${itemIndex}`,- } as Message,- showUnreadDividerBefore: itemIndex === groupIndex % GROUP_ITEMS.length,- }),- ),-);--test('ChannelMessageStreamUtils benchmarks', async ({bench}) => {- await bench('find unread divider id across 1k pending render groups', () => {- let hits = 0;- for (const group of GROUPS) {- if (getUnreadDividerBeforeMessageId(group) !== null) {- hits += 1;- }- }- (globalThis as {__channelMessageStreamBenchSink?: number}).__channelMessageStreamBenchSink = hits;- }).run();-});diff --git a/fluxer_app/src/features/channel/components/MessageAttachmentUtils.bench.ts b/fluxer_app/src/features/channel/components/MessageAttachmentUtils.bench.tsdeleted file mode 100644index 1779bdcb7..000000000--- a/fluxer_app/src/features/channel/components/MessageAttachmentUtils.bench.ts+++ /dev/null@@ -1,37 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {splitMediaAndFileAttachments} from '@app/features/channel/components/MessageAttachmentUtils';-import type {MessageAttachment} from '@fluxer/schema/src/domains/message/MessageResponseSchemas';-import {test} from 'vitest';--const CONTENT_TYPES = [- 'image/png',- 'image/jpeg',- 'video/mp4',- 'application/pdf',- 'audio/mpeg',- 'image/webp',- 'text/plain',-] as const;--const ATTACHMENTS = Array.from({length: 500}, (_value, index): MessageAttachment => {- const contentType = CONTENT_TYPES[index % CONTENT_TYPES.length];- const isVisual = contentType.startsWith('image/') || contentType.startsWith('video/');- return {- id: `attachment-${index}`,- filename: `file-${index}`,- size: 1024 + index,- url: `https://cdn.example.test/${index}`,- proxy_url: `https://cdn.example.test/${index}`,- content_type: contentType,- width: isVisual ? 640 + (index % 100) : 0,- height: isVisual ? 360 + (index % 100) : 0,- flags: 0,- };-});--test('MessageAttachmentUtils benchmarks', async ({bench}) => {- await bench('split 500 mixed media and file attachments', () => {- splitMediaAndFileAttachments(ATTACHMENTS);- }).run();-});diff --git a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerGridData.bench.ts b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerGridData.bench.tsdeleted file mode 100644index 7c476fb0f..000000000--- a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerGridData.bench.ts+++ /dev/null@@ -1,103 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {buildGifPickerGridData} from '@app/features/channel/components/pickers/gif/GifPickerGridData';-import {test} from 'vitest';--function gif(index: number, width = 200 + (index % 80), height = 120 + (index % 160)) {- return {- id: `gif-${index}`,- slug: `gif-${index}`,- provider: 'klipy',- title: `GIF ${index}`,- url: `https://example.test/gif-${index}`,- src: `https://cdn.example.test/gif-${index}.webp`,- proxy_src: `https://proxy.example.test/gif-${index}.webp`,- width,- height,- media: {},- };-}--const GIFS = Array.from({length: 500}, (_, index) => gif(index));-const FAVORITE_GIFS = Array.from({length: 500}, (_, index) => ({- url: `https://example.test/favorite-${index}`,- proxy_url: `https://proxy.example.test/favorite-${index}.webp`,- width: 220,- height: 140 + (index % 120),- content_type: 'image/gif',- placeholder: null,- media: {- webp: {- src: `https://cdn.example.test/favorite-${index}.webp`,- proxy_src: `https://proxy.example.test/favorite-${index}.webp`,- width: 220,- height: 140 + (index % 120),- },- },-}));-const FEATURED = {- gifs: [gif(0)],- categories: Array.from({length: 100}, (_, index) => ({- name: `category-${index}`,- src: `https://cdn.example.test/category-${index}.webp`,- proxy_src: `https://proxy.example.test/category-${index}.webp`,- gif: index % 3 === 0 ? gif(index) : null,- })),-};-const FAVORITE_MEMES = Array.from({length: 100}, (_, index) => ({- contentType: index % 2 === 0 ? 'video/mp4' : 'image/png',- url: `https://cdn.example.test/meme-${index}.mp4`,-}));--test('GifPickerGridData benchmarks', async ({bench}) => {- await bench('builds 500 GIF result items', () => {- buildGifPickerGridData({- surface: 'results',- loading: false,- columns: 4,- provider: 'klipy',- featured: FEATURED,- gifs: GIFS,- favoriteGifs: FAVORITE_GIFS,- favoriteMemes: FAVORITE_MEMES,- useSavedMediaForGifFavorites: false,- featuredFavoritePreviewSeed: 0.42,- favoriteTitle: 'Favorites',- trendingTitle: 'Trending',- });- }).run();-- await bench('builds 500 favorite GIF items', () => {- buildGifPickerGridData({- surface: 'favorites',- loading: false,- columns: 4,- provider: 'klipy',- featured: FEATURED,- gifs: GIFS,- favoriteGifs: FAVORITE_GIFS,- favoriteMemes: FAVORITE_MEMES,- useSavedMediaForGifFavorites: false,- featuredFavoritePreviewSeed: 0.42,- favoriteTitle: 'Favorites',- trendingTitle: 'Trending',- });- }).run();-- await bench('builds featured categories and preview tiles', () => {- buildGifPickerGridData({- surface: 'featured',- loading: false,- columns: 4,- provider: 'klipy',- featured: FEATURED,- gifs: GIFS,- favoriteGifs: FAVORITE_GIFS,- favoriteMemes: FAVORITE_MEMES,- useSavedMediaForGifFavorites: true,- featuredFavoritePreviewSeed: 0.42,- favoriteTitle: 'Favorites',- trendingTitle: 'Trending',- });- }).run();-});diff --git a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout.bench.ts b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout.bench.tsdeleted file mode 100644index 204dc7937..000000000--- a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout.bench.ts+++ /dev/null@@ -1,19 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {buildGifPickerLoadingSkeletonLayout} from '@app/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout';-import {test} from 'vitest';--const VIEWPORTS = [- {viewportWidth: 360, viewportHeight: 480},- {viewportWidth: 436, viewportHeight: 640},- {viewportWidth: 720, viewportHeight: 720},- {viewportWidth: 960, viewportHeight: 840},-] as const;--test('GifPickerLoadingSkeletonGridLayout benchmarks', async ({bench}) => {- await bench('builds deterministic masonry skeleton layouts for common picker sizes', () => {- for (const viewport of VIEWPORTS) {- buildGifPickerLoadingSkeletonLayout(viewport);- }- }).run();-});diff --git a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerStateMachine.bench.ts b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerStateMachine.bench.tsdeleted file mode 100644index 43cbb1dac..000000000--- a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerStateMachine.bench.ts+++ /dev/null@@ -1,123 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {- createGifPickerRequestId,- createGifPickerSnapshot,- selectGifPickerModel,- transitionGifPickerSnapshot,-} from '@app/features/channel/components/pickers/gif/GifPickerStateMachine';-import {test} from 'vitest';--const SEARCH_TERMS = Array.from({length: 1_000}, (_, index) => `query-${index}`);--test('GifPickerStateMachine benchmarks', async ({bench}) => {- await bench('coalesces 1k search term transitions while preserving the visible surface', () => {- let snapshot = createGifPickerSnapshot();- snapshot = transitionGifPickerSnapshot(snapshot, {- type: 'gifPicker.featuredSucceeded',- requestId: createGifPickerRequestId(1),- hasContent: true,- });- for (const term of SEARCH_TERMS) {- snapshot = transitionGifPickerSnapshot(snapshot, {- type: 'gifPicker.searchTermChanged',- term,- });- }- selectGifPickerModel(snapshot);- }).run();-- await bench('rejects 1k stale search completions', () => {- let snapshot = createGifPickerSnapshot();- for (let index = 0; index < SEARCH_TERMS.length; index += 1) {- const term = SEARCH_TERMS[index];- const requestId = createGifPickerRequestId(index + 1);- snapshot = transitionGifPickerSnapshot(snapshot, {- type: 'gifPicker.searchTermChanged',- term,- });- snapshot = transitionGifPickerSnapshot(snapshot, {- type: 'gifPicker.searchRequested',- requestId,- term,- showLoadingSkeleton: false,- });- }- for (let index = 0; index < SEARCH_TERMS.length - 1; index += 1) {- snapshot = transitionGifPickerSnapshot(snapshot, {- type: 'gifPicker.searchSucceeded',- requestId: createGifPickerRequestId(index + 1),- term: SEARCH_TERMS[index],- resultCount: 24,- });- }- selectGifPickerModel(snapshot);- }).run();-- await bench('commits latest search result after a fast query burst', () => {- let snapshot = createGifPickerSnapshot();- for (let index = 0; index < SEARCH_TERMS.length; index += 1) {- const term = SEARCH_TERMS[index];- const requestId = createGifPickerRequestId(index + 1);- snapshot = transitionGifPickerSnapshot(snapshot, {- type: 'gifPicker.searchTermChanged',- term,- });- snapshot = transitionGifPickerSnapshot(snapshot, {- type: 'gifPicker.searchRequested',- requestId,- term,- showLoadingSkeleton: false,- });- }- snapshot = transitionGifPickerSnapshot(snapshot, {- type: 'gifPicker.searchSucceeded',- requestId: createGifPickerRequestId(SEARCH_TERMS.length),- term: SEARCH_TERMS[SEARCH_TERMS.length - 1],- resultCount: 24,- });- selectGifPickerModel(snapshot);- }).run();-- await bench('rejects 1k stale skeleton timer events before showing the active one', () => {- const activeRequestId = createGifPickerRequestId(SEARCH_TERMS.length + 1);- let snapshot = createGifPickerSnapshot();- snapshot = transitionGifPickerSnapshot(snapshot, {- type: 'gifPicker.searchTermChanged',- term: 'active',- });- snapshot = transitionGifPickerSnapshot(snapshot, {- type: 'gifPicker.searchRequested',- requestId: activeRequestId,- term: 'active',- showLoadingSkeleton: false,- });- for (let index = 0; index < SEARCH_TERMS.length; index += 1) {- snapshot = transitionGifPickerSnapshot(snapshot, {- type: 'gifPicker.loadingSkeletonElapsed',- requestId: createGifPickerRequestId(index + 1),- kind: 'search',- term: SEARCH_TERMS[index],- });- }- snapshot = transitionGifPickerSnapshot(snapshot, {- type: 'gifPicker.loadingSkeletonElapsed',- requestId: activeRequestId,- kind: 'search',- term: 'active',- });- selectGifPickerModel(snapshot);- }).run();-- await bench('opens 1k cached category snapshots without entering loading', () => {- let snapshot = createGifPickerSnapshot();- for (const term of SEARCH_TERMS) {- snapshot = transitionGifPickerSnapshot(snapshot, {- type: 'gifPicker.categoryCacheOpened',- term,- resultCount: 24,- });- }- selectGifPickerModel(snapshot);- }).run();-});diff --git a/fluxer_app/src/features/member/utils/MemberListRangeUtils.bench.ts b/fluxer_app/src/features/member/utils/MemberListRangeUtils.bench.tsdeleted file mode 100644index 741608583..000000000--- a/fluxer_app/src/features/member/utils/MemberListRangeUtils.bench.ts+++ /dev/null@@ -1,64 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {- areNormalizedMemberListRangesCovered,- areNormalizedMemberListRangesEqual,- buildMemberListRangeWindow,- buildMemberListRenderWindow,- normalizeMemberListRanges,-} from '@app/features/member/utils/MemberListRangeUtils';-import {test} from 'vitest';--const ROW_HEIGHT = 44;-const VIEWPORT_HEIGHT = ROW_HEIGHT * 18;-const LARGE_TOTAL_ROWS = 100_000;-const SCROLL_OFFSETS = Array.from({length: 1_000}, (_, index) => ((index * 997) % LARGE_TOTAL_ROWS) * ROW_HEIGHT);-const OVERLAPPING_RANGES = Array.from({length: 1_000}, (_, index): [number, number] => {- const start = (index * 37) % 20_000;- return [start, start + ((index * 13) % 150)];-});-const COVERING_RANGES = Array.from({length: 1_000}, (_, index): [number, number] => [index * 100, index * 100 + 99]);-const INNER_RANGES = Array.from({length: 1_000}, (_, index): [number, number] => [index * 100 + 25, index * 100 + 75]);-const COVERING_RANGES_COPY = COVERING_RANGES.map((range): [number, number] => [range[0], range[1]]);-const NORMALIZED_COVERING_RANGES = normalizeMemberListRanges(COVERING_RANGES);-const NORMALIZED_COVERING_RANGES_COPY = normalizeMemberListRanges(COVERING_RANGES_COPY);-const NORMALIZED_INNER_RANGES = normalizeMemberListRanges(INNER_RANGES);--test('MemberListRangeUtils benchmarks', async ({bench}) => {- await bench('normalize 1k mixed overlapping ranges', () => {- normalizeMemberListRanges(OVERLAPPING_RANGES);- }).run();-- await bench('build subscription windows while fast scrolling', () => {- for (const scrollTop of SCROLL_OFFSETS) {- buildMemberListRangeWindow({- scrollTop,- clientHeight: VIEWPORT_HEIGHT,- rowHeight: ROW_HEIGHT,- bufferRows: 12,- overscanPages: 0,- totalRows: LARGE_TOTAL_ROWS,- });- }- }).run();-- await bench('build render windows while fast scrolling', () => {- for (const scrollTop of SCROLL_OFFSETS) {- buildMemberListRenderWindow({- scrollTop,- clientHeight: VIEWPORT_HEIGHT,- rowHeight: ROW_HEIGHT,- bufferRows: 6,- totalRows: LARGE_TOTAL_ROWS,- });- }- }).run();-- await bench('normalized coverage checks without re-normalizing', () => {- areNormalizedMemberListRangesCovered(NORMALIZED_INNER_RANGES, NORMALIZED_COVERING_RANGES);- }).run();-- await bench('normalized range equality without re-normalizing', () => {- areNormalizedMemberListRangesEqual(NORMALIZED_COVERING_RANGES, NORMALIZED_COVERING_RANGES_COPY);- }).run();-});diff --git a/fluxer_app/src/features/messaging/components/markdown/MarkdownRendering.bench.ts b/fluxer_app/src/features/messaging/components/markdown/MarkdownRendering.bench.tsdeleted file mode 100644index de263ae64..000000000--- a/fluxer_app/src/features/messaging/components/markdown/MarkdownRendering.bench.ts+++ /dev/null@@ -1,66 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import type {MarkdownParseOptions} from '@app/features/messaging/components/markdown/renderers/RendererTypes';-import {MarkdownContext} from '@app/features/messaging/components/markdown/renderers/RendererTypes';-import {parseMarkdownContent as parse} from '@app/features/messaging/utils/markdown/MarkdownParseCache';-import type {Node} from '@app/features/messaging/utils/markdown/parser/Nodes';-import {test} from 'vitest';--const SIMPLE_CONTENT = 'hello **world** with <@1234567890> and https://fluxer.app';-const RICH_CONTENT = [- '# Release notes',- 'This is **bold**, *italic*, __underlined__, ~~removed~~, and ||spoilered||.',- '> [!WARNING]',- '> Check `inline code` and a larger block:',- '```ts',- 'const value = 42;',- 'console.log(value);',- '```',- '- first item',- '- second item with <#1500157798955385456>',- '| name | value |',- '| --- | ---: |',- '| one | 1 |',-].join('\n');-const RENDER_OPTIONS = {- context: MarkdownContext.STANDARD_WITHOUT_JUMBO,- channelId: 'channel-1',-} satisfies MarkdownParseOptions;-const SIMPLE_AST = parse({content: SIMPLE_CONTENT, context: MarkdownContext.STANDARD_WITHOUT_JUMBO}).nodes;-const RICH_AST = parse({content: RICH_CONTENT, context: MarkdownContext.STANDARD_WITHOUT_JUMBO}).nodes;-let missSerial = 0;--test('Markdown rendering benchmarks', async ({bench}) => {- await bench('parse cache hit for simple message content', () => {- parse({content: SIMPLE_CONTENT, context: MarkdownContext.STANDARD_WITHOUT_JUMBO});- }).run();-- await bench('parse cache miss for rich message content', () => {- missSerial += 1;- parse({content: `${RICH_CONTENT}\n${missSerial}`, context: MarkdownContext.STANDARD_WITHOUT_JUMBO});- }).run();-- await bench('render simple parsed markdown AST to React nodes', () => {- let count = 0;- for (const node of SIMPLE_AST) {- count += node.type.length;- }- (globalThis as {__markdownRenderBenchSink?: number}).__markdownRenderBenchSink = count + RENDER_OPTIONS.context;- }).run();-- await bench('walk rich parsed markdown AST for render preparation', () => {- let count = 0;- const stack = [...RICH_AST];- while (stack.length > 0) {- const node = stack.pop()!;- count += node.type.length;- const children = (node as {children?: Array<Node>}).children;- if (children) {- for (const child of children) {- stack.push(child);- }- }- }- (globalThis as {__markdownRenderBenchSink?: number}).__markdownRenderBenchSink = count + RENDER_OPTIONS.context;- }).run();-});diff --git a/fluxer_app/src/features/messaging/state/ReactionStateMachine.bench.ts b/fluxer_app/src/features/messaging/state/ReactionStateMachine.bench.tsdeleted file mode 100644index 89851296e..000000000--- a/fluxer_app/src/features/messaging/state/ReactionStateMachine.bench.ts+++ /dev/null@@ -1,63 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {emptyMap, mapToReactions, transitionReactionMap} from '@app/features/messaging/state/ReactionStateMachine';-import type {ReactionEmoji} from '@app/features/messaging/utils/ReactionUtils';-import {test} from 'vitest';--const EMOJIS: Array<ReactionEmoji> = Array.from({length: 32}, (_value, index) => ({- id: index % 3 === 0 ? `emoji-${index}` : undefined,- name: index % 3 === 0 ? `custom_${index}` : ['π₯', 'β€οΈ', 'π', 'π'][index % 4],-}));--test('ReactionStateMachine benchmarks', async ({bench}) => {- await bench('apply 1k reaction add/remove transitions for visible messages', () => {- let map = emptyMap();- for (let index = 0; index < 1_000; index += 1) {- const emoji = EMOJIS[index % EMOJIS.length];- const userId = `user-${index % 250}`;- map = transitionReactionMap(- map,- {- type: 'reaction.add',- emoji,- userId,- isCurrentUser: userId === 'me',- },- 'me',- );- if (index % 4 === 0) {- map = transitionReactionMap(- map,- {- type: 'reaction.remove',- emoji,- userId,- isCurrentUser: false,- },- 'me',- );- }- }- mapToReactions(map);- }).run();-- await bench('hydrate 500-message reaction payload shape', () => {- let map = emptyMap();- for (let index = 0; index < 500; index += 1) {- map = transitionReactionMap(- map,- {- type: 'reaction.hydrate',- currentUserId: 'me',- reactions: EMOJIS.slice(0, 8).map((emoji, reactionIndex) => ({- emoji,- count: 1 + ((index + reactionIndex) % 50),- me: reactionIndex === index % 8 ? true : undefined,- })),- },- 'me',- );- }- mapToReactions(map);- }).run();-});diff --git a/fluxer_app/src/features/messaging/utils/MessagePaginationUtils.bench.ts b/fluxer_app/src/features/messaging/utils/MessagePaginationUtils.bench.tsdeleted file mode 100644index 7f119b746..000000000--- a/fluxer_app/src/features/messaging/utils/MessagePaginationUtils.bench.ts+++ /dev/null@@ -1,32 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {- calculateAroundPaginationState,- getAroundWindowCounts,-} from '@app/features/messaging/utils/MessagePaginationUtils';-import {test} from 'vitest';--const PAGINATION_INPUTS = Array.from({length: 100_000}, (_value, index) => ({- limit: 50 + (index % 25),- messageCount: 25 + (index % 100),- targetIndex: index % 50,- newestFetchedMessageId: index % 3 === 0 ? 'latest' : `${index}`,- knownLatestMessageId: 'latest',-}));--test('MessagePaginationUtils benchmarks', async ({bench}) => {- await bench('calculate 100k around pagination states', () => {- for (const input of PAGINATION_INPUTS) {- calculateAroundPaginationState(input);- }- }).run();-- await bench('calculate 100k around window counts', () => {- let total = 0;- for (let index = 0; index < 100_000; index += 1) {- const {newer, older} = getAroundWindowCounts(index % 100);- total += newer + older;- }- (globalThis as {__messagePaginationBenchSink?: number}).__messagePaginationBenchSink = total;- }).run();-});diff --git a/fluxer_app/vitest.config.ts b/fluxer_app/vitest.config.tsdeleted file mode 100644index c0b7c360e..000000000--- a/fluxer_app/vitest.config.ts+++ /dev/null@@ -1,28 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {defineConfig} from 'vitest/config';--export default defineConfig({- resolve: {tsconfigPaths: true},- oxc: {- jsx: {runtime: 'automatic', importSource: 'react'},- },- test: {- globals: true,- environment: 'node',- testTimeout: 30_000,- hookTimeout: 30_000,- setupFiles: ['./vitest.setup.ts'],- env: {- PUBLIC_BUILD_VERSION: process.env.PUBLIC_BUILD_VERSION ?? 'dev',- PUBLIC_RELEASE_CHANNEL: process.env.PUBLIC_RELEASE_CHANNEL ?? 'development',- },- include: ['src/**/*.{test,spec}.{ts,tsx}'],- exclude: ['node_modules', 'dist'],- server: {- deps: {- inline: [/livekit-client/, /@livekit\//],- },- },- },-});diff --git a/fluxer_app/vitest.setup.ts b/fluxer_app/vitest.setup.tsdeleted file mode 100644index 1333a7b68..000000000--- a/fluxer_app/vitest.setup.ts+++ /dev/null@@ -1,35 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import 'fake-indexeddb/auto';--interface TestLockManager {- request<Result>(name: string, operation: () => Promise<Result>): Promise<Result>;-}--function createTestLockManager(): TestLockManager {- const tails = new Map<string, Promise<void>>();- return {- request<Result>(name: string, operation: () => Promise<Result>): Promise<Result> {- const result = (tails.get(name) ?? Promise.resolve()).then(operation);- const tail = result.then(- () => undefined,- () => undefined,- );- tails.set(name, tail);- void tail.then(() => {- if (tails.get(name) === tail) {- tails.delete(name);- }- });- return result;- },- };-}--if (typeof window !== 'undefined' && window.localStorage === undefined && typeof Storage === 'function') {- Object.defineProperty(window, 'localStorage', {value: new Storage(), configurable: true, writable: true});-}--if (typeof navigator !== 'undefined' && navigator.locks == null) {- Object.defineProperty(navigator, 'locks', {value: createTestLockManager(), configurable: true, writable: true});-}