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,28 @@
import type { ReactNode } from 'react';
import { ChatContext } from '../../../client/views/room/contexts/ChatContext';
import { createFakeSubscription } from '../data';
export type FakeChatProviderProps = {
children?: ReactNode;
};
const FakeChatProvider = ({ children }: FakeChatProviderProps) => {
return (
<ChatContext.Provider
value={
{
data: {
getSubscriptionFromMessage: async () => {
return createFakeSubscription();
},
},
} as any
}
>
{children}
</ChatContext.Provider>
);
};
export default FakeChatProvider;

View File

@@ -0,0 +1,37 @@
import { faker } from '@faker-js/faker';
import type { IRoom, ISubscription } from '@rocket.chat/core-typings';
import type { ReactNode } from 'react';
import { useMemo } from 'react';
import { RoomContext } from '../../../client/views/room/contexts/RoomContext';
import { createFakeRoom, createFakeSubscription } from '../data';
export type FakeRoomProviderProps = {
children?: ReactNode;
roomOverrides?: Partial<IRoom>;
subscriptionOverrides?: Partial<ISubscription>;
};
const FakeRoomProvider = ({ children, roomOverrides, subscriptionOverrides }: FakeRoomProviderProps) => {
return (
<RoomContext.Provider
value={useMemo(() => {
const room = createFakeRoom(roomOverrides);
const subscription = createFakeSubscription(subscriptionOverrides);
return {
rid: room._id,
room,
hasMoreNextMessages: faker.datatype.boolean(),
hasMorePreviousMessages: faker.datatype.boolean(),
isLoadingMoreMessages: faker.datatype.boolean(),
subscription,
};
}, [roomOverrides, subscriptionOverrides])}
>
{children}
</RoomContext.Provider>
);
};
export default FakeRoomProvider;

View File

@@ -0,0 +1,22 @@
import { ModalContext } from '@rocket.chat/ui-contexts';
import type { ContextType, ReactNode } from 'react';
import { useMemo } from 'react';
export type ModalContextMockProps = {
children: ReactNode;
};
const ModalContextMock = ({ children }: ModalContextMockProps) => {
const value = useMemo(
() => ({
modal: {
setModal: (): void => undefined,
},
}),
[],
);
return <ModalContext.Provider value={value as unknown as ContextType<typeof ModalContext>}>{children}</ModalContext.Provider>;
};
export default ModalContextMock;

View File

@@ -0,0 +1,119 @@
import type { To, SearchParameters, LocationPathname, LocationSearch } from '@rocket.chat/ui-contexts';
import { RouterContext } from '@rocket.chat/ui-contexts';
import { compile } from 'path-to-regexp';
import { useRef, useMemo } from 'react';
import type { MutableRefObject, ReactNode } from 'react';
const encodeSearchParameters = (searchParameters: SearchParameters) => {
const search = new URLSearchParams();
for (const [key, value] of Object.entries(searchParameters)) {
search.append(key, value);
}
const searchString = search.toString();
return searchString ? (`?${searchString}` as `?${LocationSearch}`) : '';
};
const buildRoutePath = (to: To): LocationPathname | `${LocationPathname}?${LocationSearch}` => {
if (typeof to === 'string') {
return to;
}
if ('pathname' in to) {
const { pathname, search = {} } = to;
return (pathname + encodeSearchParameters(search)) as LocationPathname | `${LocationPathname}?${LocationSearch}`;
}
if ('pattern' in to) {
const { pattern, params = {}, search = {} } = to;
return (compile(pattern, { encode: encodeURIComponent })(params) + encodeSearchParameters(search)) as
LocationPathname | `${LocationPathname}?${LocationSearch}`;
}
if ('name' in to) {
const { name, params = {}, search = {} } = to;
switch (name) {
case 'audit-home':
return `/audit${encodeSearchParameters(search)}`;
case 'audit-log':
return `/audit-log${encodeSearchParameters(search)}`;
case 'marketplace':
return `/marketplace/${params.context}/${params.page}${encodeSearchParameters(search)}`;
}
return (compile(name, { encode: encodeURIComponent })(params) + encodeSearchParameters(search)) as
LocationPathname | `${LocationPathname}?${LocationSearch}`;
}
throw new Error('Invalid route');
};
export type RouterContextMockProps = {
children?: ReactNode;
navigate?: (toOrDelta: number | To) => void;
currentPath?: MutableRefObject<string | undefined>;
searchParameters?: Record<string, any>;
routeParameters?: Record<string, any>;
};
const RouterContextMock = ({ children, navigate, currentPath, searchParameters = {}, routeParameters = {} }: RouterContextMockProps) => {
const history = useRef<{ stack: To[]; index: number }>({ stack: ['/'], index: 0 });
if (currentPath) {
currentPath.current = buildRoutePath(history.current.stack[history.current.index]);
}
return (
<RouterContext.Provider
value={useMemo(() => {
return {
subscribeToRouteChange: () => () => undefined,
getLocationPathname: () => '/',
getLocationSearch: () => '',
getLocationHash: () => '',
getRouteParameters: () => routeParameters,
getSearchParameters: () => searchParameters,
getRouteName: () => 'home',
getPreviousRouteName: () => undefined,
buildRoutePath,
navigate:
navigate ??
((toOrDelta: number | To) => {
if (typeof toOrDelta === 'number') {
history.current.index += toOrDelta;
if (history.current.index < 0) {
history.current.index = 0;
}
if (history.current.index >= history.current.stack.length) {
history.current.index = history.current.stack.length - 1;
}
return;
}
history.current.stack = history.current.stack.slice(0, history.current.index + 1);
history.current.stack.push(toOrDelta);
history.current.index = history.current.stack.length - 1;
if (currentPath) {
currentPath.current = buildRoutePath(history.current.stack[history.current.index]);
}
}),
defineRoutes: () => () => undefined,
getRoomRoute: () => ({ path: '/' }),
};
}, [currentPath, navigate, routeParameters, searchParameters])}
>
{children}
</RouterContext.Provider>
);
};
export default RouterContextMock;

View File

@@ -0,0 +1,91 @@
import type { Serialized } from '@rocket.chat/core-typings';
import type { Method, PathPattern, OperationParams, UrlParams, OperationResult } from '@rocket.chat/rest-typings';
import type { EndpointFunction, ServerContextValue } from '@rocket.chat/ui-contexts';
import { ServerContext } from '@rocket.chat/ui-contexts';
import { useMemo } from 'react';
import type { ContextType, ReactNode } from 'react';
type RegisterEndpoint = <TMethod extends Method, TPathPattern extends PathPattern>(
method: TMethod,
pathPattern: TPathPattern,
endpoint: EndpointFunction<TMethod, TPathPattern>,
) => void;
type CallEndpoint = <TMethod extends Method, TPathPattern extends PathPattern>(args: {
method: TMethod;
pathPattern: TPathPattern;
keys: UrlParams<TPathPattern>;
params: OperationParams<TMethod, TPathPattern>;
}) => Promise<Serialized<OperationResult<TMethod, TPathPattern>>>;
// this function should be used to create a new instance of `callEndpoint` to be passed to the `ServerProviderMock`
// as the second parameter, it returns a function that can be used to register endpoint mocks
// the rest should be self-explanatory, just rely on the types.
export const makeCallEndpoint = (): [CallEndpoint, RegisterEndpoint] => {
const endpoints = new Map<`${Method}/${PathPattern}`, (params: any) => Promise<unknown>>();
const getEndpoint = <TMethod extends Method, TPathPattern extends PathPattern>(
method: TMethod,
pathPattern: TPathPattern,
): EndpointFunction<TMethod, TPathPattern> => {
const endpoint = endpoints.get(`${method}/${pathPattern}`);
if (!endpoint) {
throw new Error('Endpoint not implemented');
}
return endpoint as EndpointFunction<TMethod, TPathPattern>;
};
const registerEndpoint: RegisterEndpoint = (method, pathPattern, endpoint) => {
endpoints.set(`${method}/${pathPattern}`, endpoint);
};
const callEndpoint: CallEndpoint = (args) => {
const endpoint = getEndpoint(args.method, args.pathPattern);
if (!endpoint) {
throw new Error('Endpoint not implemented');
}
return endpoint(args.params);
};
return [callEndpoint, registerEndpoint];
};
const absoluteUrl = () => ''; // to be implemented
const uploadToEndpoint = async () => {
throw new Error('not implemented');
}; // to be implemented
const getStream = () => () => () => undefined; // to be implemented
const getStreamAll = () => () => () => undefined; // to be implemented
const callEndpoint = () => {
throw new Error('not implemented');
}; // to be implemented
const writeStream = () => undefined; // to be implemented
const contextValue: ServerContextValue = {
connected: true,
status: 'connected',
retryCount: 0,
info: undefined,
absoluteUrl,
// callMethod,
callEndpoint,
uploadToEndpoint,
getStream,
getStreamAll,
reconnect: () => undefined,
disconnect: () => undefined,
writeStream,
};
export type ServerProviderMockProps = {
children?: ReactNode;
callEndpoint?: ContextType<typeof ServerContext>['callEndpoint'];
};
const ServerProviderMock = ({ children, callEndpoint }: ServerProviderMockProps) => {
const value = useMemo(() => ({ ...contextValue, callEndpoint: callEndpoint ?? contextValue.callEndpoint }), [callEndpoint]);
return <ServerContext.Provider value={value}>{children}</ServerContext.Provider>;
};
export default ServerProviderMock;

View File

@@ -0,0 +1,47 @@
import { AppClientManager } from '@rocket.chat/apps/dist/client/AppClientManager';
import { AppsEngineUIHost } from '@rocket.chat/apps/dist/client/AppsEngineUIHost';
import type { IExternalComponentRoomInfo } from '@rocket.chat/apps/dist/client/definition/IExternalComponentRoomInfo';
import type { ReactNode } from 'react';
import { AppsContext, type IAppsOrchestrator } from '../../../client/contexts/AppsContext';
import { createFakeExternalComponentRoomInfo, createFakeExternalComponentUserInfo } from '../data';
class MockedAppsEngineUIHost extends AppsEngineUIHost {
public async getClientRoomInfo(): Promise<IExternalComponentRoomInfo> {
return createFakeExternalComponentRoomInfo();
}
public async getClientUserInfo() {
return createFakeExternalComponentUserInfo();
}
}
class MockedAppClientManager extends AppClientManager {}
export const mockAppsOrchestrator = () => {
const appsEngineUIHost = new MockedAppsEngineUIHost();
const manager = new MockedAppClientManager(appsEngineUIHost);
const orchestrator: IAppsOrchestrator = {
load: () => Promise.resolve(),
getAppClientManager: () => manager,
handleError: () => undefined,
getInstalledApps: async () => [],
getAppsFromMarketplace: async () => ({ apps: [] }),
getAppsOnBundle: async () => [],
getApp: () => Promise.reject(new Error('not implemented')),
setAppSettings: async () => undefined,
installApp: () => Promise.reject(new Error('not implemented')),
updateApp: () => Promise.reject(new Error('not implemented')),
buildExternalUrl: () => Promise.reject(new Error('not implemented')),
buildExternalAppRequest: () => Promise.reject(new Error('not implemented')),
buildIncompatibleExternalUrl: () => Promise.reject(new Error('not implemented')),
getCategories: () => Promise.reject(new Error('not implemented')),
};
return orchestrator;
};
export const mockedAppsContext = (children: ReactNode) => (
<AppsContext.Provider value={mockAppsOrchestrator()}>{children}</AppsContext.Provider>
);

View File

@@ -0,0 +1,57 @@
import { jest } from '@jest/globals';
export const Meteor = {
loginWithSamlToken: jest.fn((_token, callback: () => void) => callback()),
connection: {
_stream: { on: jest.fn() },
},
_localStorage: {
getItem: jest.fn(),
setItem: jest.fn(),
},
users: {},
userId: () => 'uid',
_SynchronousQueue: class _SynchronousQueue {
drain = jest.fn();
},
_runFresh: jest.fn(),
_isPromise: jest.fn(() => false),
defer: jest.fn((fn: () => void) => queueMicrotask(fn)),
};
export const Mongo = {
Collection: class Collection {
_collection = {
_docs: {},
};
find = jest.fn(() => ({
fetch: jest.fn(() => []),
observe: jest.fn(),
}));
findOne = jest.fn();
update = jest.fn();
},
};
export const Accounts = {
onLogin: jest.fn(),
onLogout: jest.fn(),
};
export const Tracker = { autorun: jest.fn() };
export const ReactiveVar = class ReactiveVar {};
export const EJSON = {
isBinary: jest.fn(() => false),
clone: jest.fn((obj) => obj),
equals: jest.fn((a, b) => JSON.stringify(a) === JSON.stringify(b)),
};
export const DDPCommon = {
parseDDP: jest.fn((msg: string) => JSON.parse(msg)),
stringifyDDP: jest.fn((msg: unknown) => JSON.stringify(msg)),
};

View File

@@ -0,0 +1,37 @@
import { mockAppRoot } from '@rocket.chat/mock-providers';
export const createRenteionPolicySettingsMock = ({
enabled = true,
filesOnly = false,
doNotPrunePinned = false,
appliesToChannels = false,
TTLChannels = 60000,
appliesToGroups = false,
TTLGroups = 60000,
appliesToDMs = false,
TTLDMs = 60000,
precision = '0',
advancedPrecision = false,
advancedPrecisionCron = '*/30 * * * *',
} = {}) => {
return mockAppRoot()
.withTranslations('en', 'core', {
RetentionPolicy_RoomWarning_NextRunDate: '{{maxAge}} {{nextRunDate}}',
RetentionPolicy_RoomWarning_Unpinned_NextRunDate: 'Unpinned {{maxAge}} {{nextRunDate}}',
RetentionPolicy_RoomWarning_FilesOnly_NextRunDate: 'FilesOnly {{maxAge}} {{nextRunDate}}',
RetentionPolicy_RoomWarning_UnpinnedFilesOnly_NextRunDate: 'UnpinnedFilesOnly {{maxAge}} {{nextRunDate}}',
})
.withSetting('RetentionPolicy_Enabled', enabled)
.withSetting('RetentionPolicy_FilesOnly', filesOnly)
.withSetting('RetentionPolicy_DoNotPrunePinned', doNotPrunePinned)
.withSetting('RetentionPolicy_AppliesToChannels', appliesToChannels)
.withSetting('RetentionPolicy_TTL_Channels', TTLChannels)
.withSetting('RetentionPolicy_AppliesToGroups', appliesToGroups)
.withSetting('RetentionPolicy_TTL_Groups', TTLGroups)
.withSetting('RetentionPolicy_AppliesToDMs', appliesToDMs)
.withSetting('RetentionPolicy_TTL_DMs', TTLDMs)
.withSetting('RetentionPolicy_Precision', precision)
.withSetting('RetentionPolicy_Advanced_Precision', advancedPrecision)
.withSetting('RetentionPolicy_Advanced_Precision_Cron', advancedPrecisionCron)
.build();
};