snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s

This commit is contained in:
upstream-mirror
2026-09-16 01:21:02 +05:00
commit 30810eecd7
10161 changed files with 987110 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import { ModalContext } from '@rocket.chat/ui-contexts';
import type { ContextType, ReactNode } from 'react';
import { useContext, useMemo } from 'react';
import { action } from 'storybook/actions';
const logAction = action('ModalContext');
export type ModalContextMockProps = {
children: ReactNode;
};
const ModalContextMock = ({ children }: ModalContextMockProps) => {
const context = useContext(ModalContext);
const value = useMemo(
(): ContextType<typeof ModalContext> =>
context?.modal
? {
modal: {
...context.modal,
setModal: (modal): void => {
logAction('setModal', modal);
},
},
currentModal: context.currentModal,
}
: undefined,
[context],
);
return <ModalContext.Provider value={value}>{children}</ModalContext.Provider>;
};
export default ModalContextMock;

View File

@@ -0,0 +1,34 @@
import { RouterContext } from '@rocket.chat/ui-contexts';
import type { ContextType, ReactNode } from 'react';
import { useContext, useMemo } from 'react';
import { action } from 'storybook/actions';
const logAction = action('RouterContext');
export type RouterContextMockProps = {
children: ReactNode;
};
// Ensure Meteor settings are defined
window.__meteor_runtime_config__ = {
ROOT_URL: 'http://localhost:3000',
ROOT_URL_PATH_PREFIX: '',
};
const RouterContextMock = ({ children }: RouterContextMockProps) => {
const parent = useContext(RouterContext);
const value = useMemo(
(): ContextType<typeof RouterContext> => ({
...parent,
navigate: (...args): void => {
logAction('navigate', ...args);
},
}),
[parent],
);
return <RouterContext.Provider value={value}>{children}</RouterContext.Provider>;
};
export default RouterContextMock;

View File

@@ -0,0 +1,184 @@
import type { Serialized } from '@rocket.chat/core-typings';
import type { ServerMethodName, ServerMethodParameters, ServerMethodReturn } from '@rocket.chat/ddp-client';
import type { Method, OperationParams, OperationResult, PathFor, PathPattern } from '@rocket.chat/rest-typings';
import type { UploadResult } from '@rocket.chat/ui-contexts';
import { ServerContext } from '@rocket.chat/ui-contexts';
import type { ContextType, ReactNode } from 'react';
import { useContext, useMemo } from 'react';
import { action } from 'storybook/actions';
const logAction = action('ServerContext');
const randomDelay = (): Promise<UploadResult> => new Promise((resolve) => setTimeout(resolve, Math.random() * 1000));
const uploadToEndpoint = (endpoint: PathFor<'POST'>, formData: any): Promise<UploadResult> =>
Promise.resolve(logAction('uploadToEndpoint', endpoint, formData)).then(randomDelay);
const getStream = (
streamName: string,
options: {
retransmit?: boolean | undefined;
retransmitToSelf?: boolean | undefined;
} = {},
): (<TEvent extends unknown[]>(eventName: string, callback: (...event: TEvent) => void) => () => void) => {
logAction('getStream', streamName, options);
return (eventName: string, callback: () => void): (() => void) => {
const subId = Math.random().toString(16).slice(2);
logAction('getStream.subscribe', streamName, eventName, subId);
randomDelay().then(() => callback());
return (): void => {
logAction('getStream.unsubscribe', streamName, eventName, subId);
};
};
};
type Operations = {
[
TOperation in Method extends infer TMethod
? TMethod extends Method
? PathPattern extends infer TPathPattern
? TPathPattern extends PathPattern
? {
id: `${TMethod} ${TPathPattern extends `/${string}` ? TPathPattern : `/v1/${TPathPattern}`}`;
fn: (
params: void extends OperationParams<TMethod, TPathPattern> ? void : OperationParams<TMethod, TPathPattern>,
) => Promise<
void extends OperationResult<TMethod, TPathPattern> ? Serialized<OperationResult<TMethod, TPathPattern>> : void
>;
}
: never
: never
: never
: never as TOperation['id']
]: TOperation['fn'];
};
export type ServerContextMockProps = Omit<Partial<ContextType<typeof ServerContext>>, 'callEndpoint' | 'callMethod'> & {
children: ReactNode;
baseURL?: string | URL;
callEndpoint?: {
[TOperationID in keyof Operations]?: Operations[TOperationID] | 'infinite' | 'errored';
};
callMethod?: {
[TMethodName in ServerMethodName]?:
((...args: ServerMethodParameters<TMethodName>) => Promise<ServerMethodReturn<TMethodName>>) | 'infinite' | 'errored';
};
};
const ServerContextMock = ({ children, baseURL, callEndpoint = {}, callMethod = {}, ...overrides }: ServerContextMockProps) => {
const parent = useContext(ServerContext);
const value = useMemo((): ContextType<typeof ServerContext> => {
type ServerContextValue = ContextType<typeof ServerContext>;
const absoluteURL: ServerContextValue['absoluteUrl'] = (path): string => {
logAction('absoluteUrl', path);
try {
return new URL(path, baseURL).toString();
} catch (e) {
return path;
}
};
const mockedEndpoints = Object.entries(callEndpoint).map(
([operationID, handler]): {
match: (method: string, path: string) => boolean;
handler: ((params: any) => Promise<unknown>) | 'infinite' | 'errored' | undefined;
} => {
const [_method, _pathPattern] = operationID.split(' ');
return {
match: (method: string, pathPattern: string): boolean => _method === method && _pathPattern === pathPattern,
handler: handler as any,
};
},
);
const _callEndpoint: ServerContextValue['callEndpoint'] = async <TMethod extends Method, TPathPattern extends PathPattern>({
method,
pathPattern,
params,
}: {
method: TMethod;
pathPattern: TPathPattern;
params: OperationParams<TMethod, TPathPattern>;
}): Promise<Serialized<OperationResult<TMethod, TPathPattern>>> => {
const mockedEndpoint = mockedEndpoints.find((endpoint) => endpoint.match(method, pathPattern));
const handler = mockedEndpoint?.handler;
if (!handler) {
logAction('callEndpoint (undefined)', method, pathPattern, params);
return undefined as any;
}
if (handler === 'infinite') {
logAction('callEndpoint (infinite)', method, pathPattern, params);
return new Promise(() => undefined);
}
if (handler === 'errored') {
logAction('callEndpoint (errored)', method, pathPattern, params);
throw new Error(`${method} ${pathPattern} failed`);
}
logAction('callEndpoint (intercepted)', method, pathPattern, params);
return handler(params) as Promise<Serialized<OperationResult<TMethod, TPathPattern>>>;
};
const _callMethod: ServerContextValue['callMethod'] = async <MethodName extends ServerMethodName>(
methodName: MethodName,
...args: ServerMethodParameters<MethodName>
): Promise<ServerMethodReturn<MethodName>> => {
const handler = callMethod[methodName];
if (!handler) {
logAction('callMethod (undefined)', methodName, ...args);
return undefined as any;
}
if (handler === 'infinite') {
logAction('callMethod (infinite)', methodName, ...args);
return new Promise<any>(() => undefined);
}
if (handler === 'errored') {
logAction('callMethod (errored)', methodName, ...args);
throw new Error(`${methodName} failed`);
}
logAction('callMethod (intercepted)', methodName, ...args);
return handler(...args);
};
return {
...parent,
info: {
version: 'x.y.z',
build: {
platform: 'storybook',
arch: 'storybook cpu',
cpus: 1,
date: new Date().toLocaleDateString(),
nodeVersion: 'lts',
osRelease: 'x',
freeMemory: 639 * 1024,
totalMemory: 640 * 1024,
},
commit: {},
marketplaceApiVersion: 'x.y.z',
},
absoluteUrl: absoluteURL,
callEndpoint: _callEndpoint,
callMethod: _callMethod,
uploadToEndpoint,
getStream,
getStreamAll: () => () => () => undefined,
...overrides,
};
}, [baseURL, callEndpoint, callMethod, overrides, parent]);
return <ServerContext.Provider value={value}>{children}</ServerContext.Provider>;
};
export default ServerContextMock;

View File

@@ -0,0 +1,67 @@
import type { TranslationKey } from '@rocket.chat/ui-contexts';
import { TranslationContext } from '@rocket.chat/ui-contexts';
import i18next from 'i18next';
import type { ContextType, ReactNode } from 'react';
import { useContext, useMemo } from 'react';
export type TranslationContextMockProps = {
children: ReactNode;
};
const TranslationContextMock = ({ children }: TranslationContextMockProps) => {
const parent = useContext(TranslationContext);
const value = useMemo<ContextType<typeof TranslationContext>>(() => {
i18next.init({
fallbackLng: 'en',
defaultNS: 'project',
resources: {
en: {
project: require('../../../packages/rocketchat-i18n/i18n/en.i18n.json'),
},
},
interpolation: {
prefix: '__',
suffix: '__',
},
initImmediate: false,
});
const translate = (key: string, ...replaces: unknown[]): string => {
if (typeof replaces[0] === 'object' && replaces[0] !== null) {
const [options] = replaces;
return i18next.t(key, options);
}
if (replaces.length === 0) {
return i18next.t(key);
}
return i18next.t(key, {
postProcess: 'sprintf',
sprintf: replaces,
});
};
translate.has = (key: string | undefined): key is TranslationKey => !!key && i18next.exists(key);
return {
...parent,
languages: [
{
name: 'English',
en: 'English',
ogName: 'English',
key: 'en',
},
],
language: 'en',
translate,
loadLanguage: async (): Promise<void> => undefined,
};
}, [parent]);
return <TranslationContext.Provider value={value}>{children}</TranslationContext.Provider>;
};
export default TranslationContextMock;