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
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:
@@ -0,0 +1,123 @@
|
||||
import * as assert from 'node:assert';
|
||||
import { after, beforeEach, describe, it, mock } from 'node:test';
|
||||
|
||||
import type { IApi } from '@rocket.chat/apps-engine/definition/api';
|
||||
|
||||
import { AppObjectRegistry } from '../../../AppObjectRegistry';
|
||||
import { AppAccessors } from '../mod';
|
||||
|
||||
// The senderFn echoes the request as the SuccessObject `result`, so a bridge call resolves to the
|
||||
// `{ method, params }` descriptor and the recorded spy shows exactly what was sent.
|
||||
const senderFn = (r: any) =>
|
||||
Promise.resolve({
|
||||
id: 'test',
|
||||
jsonrpc: '2.0',
|
||||
result: r,
|
||||
serialize() {
|
||||
return JSON.stringify(this);
|
||||
},
|
||||
});
|
||||
|
||||
describe('ConfigurationExtend/Modify + app settings (base-runtime, via AppResourceBridge)', () => {
|
||||
beforeEach(() => {
|
||||
AppObjectRegistry.clear();
|
||||
AppObjectRegistry.set('id', 'deno-test');
|
||||
if (!AppObjectRegistry.has('apiEndpoints')) {
|
||||
AppObjectRegistry.set('apiEndpoints', []);
|
||||
}
|
||||
});
|
||||
|
||||
after(() => {
|
||||
AppObjectRegistry.clear();
|
||||
});
|
||||
|
||||
it('provideSlashCommand stashes the instance and calls doProvideSlashCommand', async () => {
|
||||
const spy = mock.fn(senderFn);
|
||||
const configExtend = new AppAccessors(spy).getConfigurationExtend();
|
||||
|
||||
const command = { command: 'my-cmd', executor() {} } as any;
|
||||
await configExtend.slashCommands.provideSlashCommand(command);
|
||||
|
||||
assert.strictEqual(AppObjectRegistry.get('slashcommand:my-cmd'), command);
|
||||
assert.strictEqual((spy.mock.calls[0].arguments[0] as any).method, 'bridges:getAppResourceBridge:doProvideSlashCommand');
|
||||
assert.strictEqual((spy.mock.calls[0].arguments[0] as any).params[1], 'APP_ID');
|
||||
});
|
||||
|
||||
it('registerProcessors stashes each processor and calls doRegisterProcessors', async () => {
|
||||
const spy = mock.fn(senderFn);
|
||||
const configExtend = new AppAccessors(spy).getConfigurationExtend();
|
||||
|
||||
await configExtend.scheduler.registerProcessors([{ id: 'p1' } as any, { id: 'p2' } as any]);
|
||||
|
||||
assert.ok(AppObjectRegistry.get('scheduler:p1'));
|
||||
assert.ok(AppObjectRegistry.get('scheduler:p2'));
|
||||
assert.deepStrictEqual(spy.mock.calls[0].arguments, [
|
||||
{ method: 'bridges:getAppResourceBridge:doRegisterProcessors', params: [[{ id: 'p1' }, { id: 'p2' }], 'APP_ID'] },
|
||||
]);
|
||||
});
|
||||
|
||||
it('provideApi stashes endpoints, calls doProvideApi, and then doListApis', async () => {
|
||||
const spy = mock.fn(senderFn);
|
||||
const configExtend = new AppAccessors(spy).getConfigurationExtend();
|
||||
|
||||
const api = { endpoints: [{ path: 'hello', get() {} }] } as unknown as IApi;
|
||||
await configExtend.api.provideApi(api);
|
||||
|
||||
assert.ok(AppObjectRegistry.get('api:hello'));
|
||||
assert.strictEqual((spy.mock.calls[0].arguments[0] as any).method, 'bridges:getAppResourceBridge:doProvideApi');
|
||||
// _availableMethods is computed locally before sending
|
||||
assert.deepStrictEqual((spy.mock.calls[0].arguments[0] as any).params[0].endpoints[0]._availableMethods, ['get']);
|
||||
assert.strictEqual((spy.mock.calls[1].arguments[0] as any).method, 'bridges:getAppResourceBridge:doListApis');
|
||||
});
|
||||
|
||||
it('registerButton / provideSetting / externalComponents route to their bridge methods', async () => {
|
||||
const spy = mock.fn(senderFn);
|
||||
const configExtend = new AppAccessors(spy).getConfigurationExtend();
|
||||
|
||||
await configExtend.ui.registerButton({ actionId: 'b1' } as any);
|
||||
await configExtend.settings.provideSetting({ id: 's1' } as any);
|
||||
await configExtend.externalComponents.register({ name: 'c1' } as any);
|
||||
|
||||
assert.deepStrictEqual(
|
||||
spy.mock.calls.map((c) => (c.arguments[0] as any).method),
|
||||
[
|
||||
'bridges:getAppResourceBridge:doRegisterActionButton',
|
||||
'bridges:getAppResourceBridge:doProvideSetting',
|
||||
'bridges:getAppResourceBridge:doRegisterExternalComponent',
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
it('ConfigurationModify.slashCommands maps to modify/enable/disable bridge methods', async () => {
|
||||
const spy = mock.fn(senderFn);
|
||||
const configModify = new AppAccessors(spy).getConfigurationModify();
|
||||
|
||||
await configModify.slashCommands.modifySlashCommand({ command: 'c', executor() {} } as any);
|
||||
await configModify.slashCommands.enableSlashCommand('c');
|
||||
await configModify.slashCommands.disableSlashCommand('c');
|
||||
|
||||
assert.deepStrictEqual(
|
||||
spy.mock.calls.map((c) => (c.arguments[0] as any).method),
|
||||
[
|
||||
'bridges:getAppResourceBridge:doModifySlashCommand',
|
||||
'bridges:getAppResourceBridge:doEnableSlashCommand',
|
||||
'bridges:getAppResourceBridge:doDisableSlashCommand',
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
it('app-settings read/update go through the AppResourceBridge', async () => {
|
||||
const spy = mock.fn(senderFn);
|
||||
const accessors = new AppAccessors(spy);
|
||||
|
||||
accessors.getEnvironmentRead().getSettings().getById('s1');
|
||||
await accessors.getEnvironmentWrite().getSettings().updateValue('s1', 'v');
|
||||
|
||||
assert.deepStrictEqual(spy.mock.calls[0].arguments, [
|
||||
{ method: 'bridges:getAppResourceBridge:doGetSettingById', params: ['s1', 'APP_ID'] },
|
||||
]);
|
||||
assert.deepStrictEqual(spy.mock.calls[1].arguments, [
|
||||
{ method: 'bridges:getAppResourceBridge:doUpdateSettingValue', params: ['s1', 'v', 'APP_ID'] },
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user