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
Code scanning - action / CodeQL-Build (push) Failing after 2s
Auto-close duplicate issues / auto-close-duplicates (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
Code scanning - action / CodeQL-Build (push) Failing after 2s
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
This commit is contained in:
2
packages/apps/tests/test-data/README.md
Normal file
2
packages/apps/tests/test-data/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# What is this folder?
|
||||
This contains data, classes, and implementations of pieces that the user of this package would have to implement.
|
||||
BIN
packages/apps/tests/test-data/apps/hello-world-test_0.0.1.zip
Normal file
BIN
packages/apps/tests/test-data/apps/hello-world-test_0.0.1.zip
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
packages/apps/tests/test-data/apps/testing-app_0.0.8.zip
Normal file
BIN
packages/apps/tests/test-data/apps/testing-app_0.0.8.zip
Normal file
Binary file not shown.
29
packages/apps/tests/test-data/bridges/OAuthAppsBridge.ts
Normal file
29
packages/apps/tests/test-data/bridges/OAuthAppsBridge.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import type { IOAuthApp, IOAuthAppParams } from '@rocket.chat/apps-engine/definition/accessors/IOAuthApp';
|
||||
|
||||
import { OAuthAppsBridge } from '../../../src/server/bridges/OAuthAppsBridge';
|
||||
|
||||
export class TestOAuthAppsBridge extends OAuthAppsBridge {
|
||||
protected create(oAuthApp: IOAuthAppParams, appId: string): Promise<string> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
protected getById(id: string, appId: string): Promise<IOAuthApp> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
protected getByName(name: string, appId: string): Promise<Array<IOAuthApp>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
protected update(oAuthApp: IOAuthAppParams, id: string, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
protected delete(id: string, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
protected purge(appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
26
packages/apps/tests/test-data/bridges/activationBridge.ts
Normal file
26
packages/apps/tests/test-data/bridges/activationBridge.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import type { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus';
|
||||
|
||||
import type { ProxiedApp } from '../../../src/server/ProxiedApp';
|
||||
import { AppActivationBridge } from '../../../src/server/bridges';
|
||||
|
||||
export class TestsActivationBridge extends AppActivationBridge {
|
||||
public async appAdded(app: ProxiedApp): Promise<void> {
|
||||
console.log(`The App ${app.getName()} (${app.getID()}) has been added.`);
|
||||
}
|
||||
|
||||
public async appUpdated(app: ProxiedApp): Promise<void> {
|
||||
console.log(`The App ${app.getName()} (${app.getID()}) has been updated.`);
|
||||
}
|
||||
|
||||
public async appRemoved(app: ProxiedApp): Promise<void> {
|
||||
console.log(`The App ${app.getName()} (${app.getID()}) has been removed.`);
|
||||
}
|
||||
|
||||
public async appStatusChanged(app: ProxiedApp, status: AppStatus): Promise<void> {
|
||||
console.log(`The App ${app.getName()} (${app.getID()}) status has changed to: ${status}`);
|
||||
}
|
||||
|
||||
protected async actionsChanged(): Promise<void> {
|
||||
console.log('The actions have changed.');
|
||||
}
|
||||
}
|
||||
38
packages/apps/tests/test-data/bridges/apiBridge.ts
Normal file
38
packages/apps/tests/test-data/bridges/apiBridge.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import type { IApi } from '@rocket.chat/apps-engine/definition/api';
|
||||
|
||||
import { ApiBridge } from '../../../src/server/bridges';
|
||||
import type { AppApi } from '../../../src/server/managers/AppApi';
|
||||
import { TestData } from '../utilities';
|
||||
|
||||
export class TestsApiBridge extends ApiBridge {
|
||||
public apis: Map<string, Map<string, IApi>>;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.apis = new Map<string, Map<string, IApi>>();
|
||||
this.apis.set('appId', new Map<string, IApi>());
|
||||
this.apis.get('appId').set('it-exists', TestData.getApi('it-exists'));
|
||||
}
|
||||
|
||||
public async registerApi(api: AppApi, appId: string): Promise<void> {
|
||||
if (!this.apis.has(appId)) {
|
||||
this.apis.set(appId, new Map<string, IApi>());
|
||||
}
|
||||
|
||||
if (this.apis.get(appId)) {
|
||||
api.api.endpoints.forEach((endpoint) => {
|
||||
if (this.apis.get(appId).has(endpoint.path)) {
|
||||
throw new Error(`Api "${api.endpoint.path}" has already been registered for app ${appId}.`);
|
||||
}
|
||||
});
|
||||
|
||||
api.api.endpoints.forEach((endpoint) => {
|
||||
this.apis.get(appId).set(api.endpoint.path, api.api);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public async unregisterApis(appId: string): Promise<void> {
|
||||
this.apis.delete(appId);
|
||||
}
|
||||
}
|
||||
255
packages/apps/tests/test-data/bridges/appBridges.ts
Normal file
255
packages/apps/tests/test-data/bridges/appBridges.ts
Normal file
@@ -0,0 +1,255 @@
|
||||
import { TestOAuthAppsBridge } from './OAuthAppsBridge';
|
||||
import { TestsActivationBridge } from './activationBridge';
|
||||
import { TestsApiBridge } from './apiBridge';
|
||||
import { TestsAppDetailChangesBridge } from './appDetailChanges';
|
||||
import { TestAppCloudWorkspaceBridge } from './cloudBridge';
|
||||
import { TestsCommandBridge } from './commandBridge';
|
||||
import { TestContactBridge } from './contactBridge';
|
||||
import { TestsEmailBridge } from './emailBridge';
|
||||
import { TestsEnvironmentalVariableBridge } from './environmentalVariableBridge';
|
||||
import { TestExperimentalBridge } from './experimentalBridge';
|
||||
import { TestsHttpBridge } from './httpBridge';
|
||||
import { TestsInternalBridge } from './internalBridge';
|
||||
import { TestsInternalFederationBridge } from './internalFederationBridge';
|
||||
import { TestLivechatBridge } from './livechatBridge';
|
||||
import { TestsMessageBridge } from './messageBridge';
|
||||
import { TestsModerationBridge } from './moderationBridge';
|
||||
import { TestOutboundCommunicationBridge } from './outboundComms';
|
||||
import { TestsPersisBridge } from './persisBridge';
|
||||
import { TestsRoleBridge } from './roleBridge';
|
||||
import { TestsRoomBridge } from './roomBridge';
|
||||
import { TestSchedulerBridge } from './schedulerBridge';
|
||||
import { TestsServerSettingBridge } from './serverSettingBridge';
|
||||
import { TestsThreadBridge } from './threadBridge';
|
||||
import { TestsUiIntegrationBridge } from './uiIntegrationBridge';
|
||||
import { TestUploadBridge } from './uploadBridge';
|
||||
import { TestsUserBridge } from './userBridge';
|
||||
import { TestsVideoConferenceBridge } from './videoConferenceBridge';
|
||||
import { AppBridges } from '../../../src/server/bridges';
|
||||
import type {
|
||||
AppActivationBridge,
|
||||
AppDetailChangesBridge,
|
||||
ContactBridge,
|
||||
EnvironmentalVariableBridge,
|
||||
ExperimentalBridge,
|
||||
HttpBridge,
|
||||
IInternalBridge,
|
||||
IListenerBridge,
|
||||
LivechatBridge,
|
||||
MessageBridge,
|
||||
ModerationBridge,
|
||||
OutboundMessageBridge,
|
||||
PersistenceBridge,
|
||||
RoleBridge,
|
||||
RoomBridge,
|
||||
SchedulerBridge,
|
||||
ServerSettingBridge,
|
||||
UiInteractionBridge,
|
||||
UploadBridge,
|
||||
UserBridge,
|
||||
VideoConferenceBridge,
|
||||
} from '../../../src/server/bridges';
|
||||
import type { CloudWorkspaceBridge } from '../../../src/server/bridges/CloudWorkspaceBridge';
|
||||
import type { EmailBridge } from '../../../src/server/bridges/EmailBridge';
|
||||
import type { IInternalFederationBridge } from '../../../src/server/bridges/IInternalFederationBridge';
|
||||
import type { OAuthAppsBridge } from '../../../src/server/bridges/OAuthAppsBridge';
|
||||
import type { ThreadBridge } from '../../../src/server/bridges/ThreadBridge';
|
||||
|
||||
export class TestsAppBridges extends AppBridges {
|
||||
private readonly appDetails: TestsAppDetailChangesBridge;
|
||||
|
||||
private readonly cmdBridge: TestsCommandBridge;
|
||||
|
||||
private readonly apiBridge: TestsApiBridge;
|
||||
|
||||
private readonly setsBridge: TestsServerSettingBridge;
|
||||
|
||||
private readonly envBridge: TestsEnvironmentalVariableBridge;
|
||||
|
||||
private readonly rlActBridge: TestsActivationBridge;
|
||||
|
||||
private readonly msgBridge: TestsMessageBridge;
|
||||
|
||||
private readonly moderationBridge: TestsModerationBridge;
|
||||
|
||||
private readonly persisBridge: TestsPersisBridge;
|
||||
|
||||
private readonly roleBridge: TestsRoleBridge;
|
||||
|
||||
private readonly roomBridge: TestsRoomBridge;
|
||||
|
||||
private readonly internalBridge: TestsInternalBridge;
|
||||
|
||||
private readonly userBridge: TestsUserBridge;
|
||||
|
||||
private readonly httpBridge: TestsHttpBridge;
|
||||
|
||||
private readonly livechatBridge: TestLivechatBridge;
|
||||
|
||||
private readonly uploadBridge: TestUploadBridge;
|
||||
|
||||
private readonly emailBridge: EmailBridge;
|
||||
|
||||
private readonly contactBridge: ContactBridge;
|
||||
|
||||
private readonly uiIntegrationBridge: TestsUiIntegrationBridge;
|
||||
|
||||
private readonly schedulerBridge: TestSchedulerBridge;
|
||||
|
||||
private readonly cloudWorkspaceBridge: TestAppCloudWorkspaceBridge;
|
||||
|
||||
private readonly videoConfBridge: TestsVideoConferenceBridge;
|
||||
|
||||
private readonly oauthBridge: OAuthAppsBridge;
|
||||
|
||||
private readonly internalFederationBridge: IInternalFederationBridge;
|
||||
|
||||
private readonly threadBridge: ThreadBridge;
|
||||
|
||||
private readonly outboundCommsBridge: TestOutboundCommunicationBridge;
|
||||
|
||||
private readonly experimentalBridge: TestExperimentalBridge;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.appDetails = new TestsAppDetailChangesBridge();
|
||||
this.cmdBridge = new TestsCommandBridge();
|
||||
this.apiBridge = new TestsApiBridge();
|
||||
this.setsBridge = new TestsServerSettingBridge();
|
||||
this.envBridge = new TestsEnvironmentalVariableBridge();
|
||||
this.rlActBridge = new TestsActivationBridge();
|
||||
this.msgBridge = new TestsMessageBridge();
|
||||
this.moderationBridge = new TestsModerationBridge();
|
||||
this.persisBridge = new TestsPersisBridge();
|
||||
this.roleBridge = new TestsRoleBridge();
|
||||
this.roomBridge = new TestsRoomBridge();
|
||||
this.internalBridge = new TestsInternalBridge();
|
||||
this.userBridge = new TestsUserBridge();
|
||||
this.httpBridge = new TestsHttpBridge();
|
||||
this.livechatBridge = new TestLivechatBridge();
|
||||
this.uploadBridge = new TestUploadBridge();
|
||||
this.uiIntegrationBridge = new TestsUiIntegrationBridge();
|
||||
this.schedulerBridge = new TestSchedulerBridge();
|
||||
this.cloudWorkspaceBridge = new TestAppCloudWorkspaceBridge();
|
||||
this.videoConfBridge = new TestsVideoConferenceBridge();
|
||||
this.oauthBridge = new TestOAuthAppsBridge();
|
||||
this.internalFederationBridge = new TestsInternalFederationBridge();
|
||||
this.threadBridge = new TestsThreadBridge();
|
||||
this.emailBridge = new TestsEmailBridge();
|
||||
this.contactBridge = new TestContactBridge();
|
||||
this.outboundCommsBridge = new TestOutboundCommunicationBridge();
|
||||
this.experimentalBridge = new TestExperimentalBridge();
|
||||
}
|
||||
|
||||
public getCommandBridge(): TestsCommandBridge {
|
||||
return this.cmdBridge;
|
||||
}
|
||||
|
||||
public getApiBridge(): TestsApiBridge {
|
||||
return this.apiBridge;
|
||||
}
|
||||
|
||||
public getServerSettingBridge(): ServerSettingBridge {
|
||||
return this.setsBridge;
|
||||
}
|
||||
|
||||
public getEnvironmentalVariableBridge(): EnvironmentalVariableBridge {
|
||||
return this.envBridge;
|
||||
}
|
||||
|
||||
public getAppDetailChangesBridge(): AppDetailChangesBridge {
|
||||
return this.appDetails;
|
||||
}
|
||||
|
||||
public getHttpBridge(): HttpBridge {
|
||||
return this.httpBridge;
|
||||
}
|
||||
|
||||
public getListenerBridge(): IListenerBridge {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public getMessageBridge(): MessageBridge {
|
||||
return this.msgBridge;
|
||||
}
|
||||
|
||||
public getModerationBridge(): ModerationBridge {
|
||||
return this.moderationBridge;
|
||||
}
|
||||
|
||||
public getPersistenceBridge(): PersistenceBridge {
|
||||
return this.persisBridge;
|
||||
}
|
||||
|
||||
public getAppActivationBridge(): AppActivationBridge {
|
||||
return this.rlActBridge;
|
||||
}
|
||||
|
||||
public getThreadBridge(): ThreadBridge {
|
||||
return this.threadBridge;
|
||||
}
|
||||
|
||||
public getRoleBridge(): RoleBridge {
|
||||
return this.roleBridge;
|
||||
}
|
||||
|
||||
public getRoomBridge(): RoomBridge {
|
||||
return this.roomBridge;
|
||||
}
|
||||
|
||||
public getInternalBridge(): IInternalBridge {
|
||||
return this.internalBridge;
|
||||
}
|
||||
|
||||
public getUserBridge(): UserBridge {
|
||||
return this.userBridge;
|
||||
}
|
||||
|
||||
public getLivechatBridge(): LivechatBridge {
|
||||
return this.livechatBridge;
|
||||
}
|
||||
|
||||
public getEmailBridge(): EmailBridge {
|
||||
return this.emailBridge;
|
||||
}
|
||||
|
||||
public getUploadBridge(): UploadBridge {
|
||||
return this.uploadBridge;
|
||||
}
|
||||
|
||||
public getUiInteractionBridge(): UiInteractionBridge {
|
||||
return this.uiIntegrationBridge;
|
||||
}
|
||||
|
||||
public getSchedulerBridge(): SchedulerBridge {
|
||||
return this.schedulerBridge;
|
||||
}
|
||||
|
||||
public getCloudWorkspaceBridge(): CloudWorkspaceBridge {
|
||||
return this.cloudWorkspaceBridge;
|
||||
}
|
||||
|
||||
public getVideoConferenceBridge(): VideoConferenceBridge {
|
||||
return this.videoConfBridge;
|
||||
}
|
||||
|
||||
public getOAuthAppsBridge(): OAuthAppsBridge {
|
||||
return this.oauthBridge;
|
||||
}
|
||||
|
||||
public getInternalFederationBridge(): IInternalFederationBridge {
|
||||
return this.internalFederationBridge;
|
||||
}
|
||||
|
||||
public getContactBridge(): ContactBridge {
|
||||
return this.contactBridge;
|
||||
}
|
||||
|
||||
public getOutboundMessageBridge(): OutboundMessageBridge {
|
||||
return this.outboundCommsBridge;
|
||||
}
|
||||
|
||||
public getExperimentalBridge(): ExperimentalBridge {
|
||||
return this.experimentalBridge;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings';
|
||||
|
||||
import { AppDetailChangesBridge } from '../../../src/server/bridges';
|
||||
|
||||
export class TestsAppDetailChangesBridge extends AppDetailChangesBridge {
|
||||
public onAppSettingsChange(appId: string, setting: ISetting): void {}
|
||||
}
|
||||
16
packages/apps/tests/test-data/bridges/cloudBridge.ts
Normal file
16
packages/apps/tests/test-data/bridges/cloudBridge.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { IWorkspaceToken } from '@rocket.chat/apps-engine/definition/cloud/IWorkspaceToken';
|
||||
|
||||
import { CloudWorkspaceBridge } from '../../../src/server/bridges/CloudWorkspaceBridge';
|
||||
|
||||
export class TestAppCloudWorkspaceBridge extends CloudWorkspaceBridge {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public async getWorkspaceToken(scope: string, appId: string): Promise<IWorkspaceToken> {
|
||||
return {
|
||||
token: 'mock-workspace-token',
|
||||
expiresAt: new Date(Date.now() + 10000),
|
||||
};
|
||||
}
|
||||
}
|
||||
42
packages/apps/tests/test-data/bridges/commandBridge.ts
Normal file
42
packages/apps/tests/test-data/bridges/commandBridge.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import type { IHttp, IModify, IPersistence, IRead } from '@rocket.chat/apps-engine/definition/accessors';
|
||||
import type { ISlashCommand, SlashCommandContext } from '@rocket.chat/apps-engine/definition/slashcommands';
|
||||
|
||||
import { CommandBridge } from '../../../src/server/bridges';
|
||||
import { TestData } from '../utilities';
|
||||
|
||||
export class TestsCommandBridge extends CommandBridge {
|
||||
public commands: Map<string, (context: SlashCommandContext, read: IRead, modify: IModify, http: IHttp, persis: IPersistence) => void>;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.commands = new Map<
|
||||
string,
|
||||
(context: SlashCommandContext, read: IRead, modify: IModify, http: IHttp, persis: IPersistence) => void
|
||||
>();
|
||||
this.commands.set('it-exists', TestData.getSlashCommand('it-exists').executor);
|
||||
}
|
||||
|
||||
public async doesCommandExist(command: string, appId: string): Promise<boolean> {
|
||||
return this.commands.has(command);
|
||||
}
|
||||
|
||||
public async enableCommand(command: string, appId: string): Promise<void> {}
|
||||
|
||||
public async disableCommand(command: string, appId: string): Promise<void> {}
|
||||
|
||||
public async modifyCommand(command: ISlashCommand, appId: string): Promise<void> {}
|
||||
|
||||
public restoreCommand(comand: string, appId: string): void {}
|
||||
|
||||
public async registerCommand(command: ISlashCommand, appId: string): Promise<void> {
|
||||
if (this.commands.has(command.command)) {
|
||||
throw new Error(`Command "${command.command}" has already been registered.`);
|
||||
}
|
||||
|
||||
this.commands.set(command.command, command.executor);
|
||||
}
|
||||
|
||||
public async unregisterCommand(command: string, appId: string): Promise<void> {
|
||||
this.commands.delete(command);
|
||||
}
|
||||
}
|
||||
23
packages/apps/tests/test-data/bridges/contactBridge.ts
Normal file
23
packages/apps/tests/test-data/bridges/contactBridge.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { ILivechatContact } from '@rocket.chat/apps-engine/definition/livechat';
|
||||
|
||||
import { ContactBridge } from '../../../src/server/bridges';
|
||||
|
||||
export class TestContactBridge extends ContactBridge {
|
||||
protected addContactEmail(contactId: ILivechatContact['_id'], email: string, appId: string): Promise<ILivechatContact> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
protected getById(id: ILivechatContact['_id']): Promise<ILivechatContact> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
protected verifyContact(verifyContactChannelParams: {
|
||||
contactId: string;
|
||||
field: string;
|
||||
value: string;
|
||||
visitorId: string;
|
||||
roomId: string;
|
||||
}): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
9
packages/apps/tests/test-data/bridges/emailBridge.ts
Normal file
9
packages/apps/tests/test-data/bridges/emailBridge.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { IEmail } from '@rocket.chat/apps-engine/definition/email';
|
||||
|
||||
import { EmailBridge } from '../../../src/server/bridges/EmailBridge';
|
||||
|
||||
export class TestsEmailBridge extends EmailBridge {
|
||||
protected sendEmail(email: IEmail, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { EnvironmentalVariableBridge } from '../../../src/server/bridges/EnvironmentalVariableBridge';
|
||||
|
||||
export class TestsEnvironmentalVariableBridge extends EnvironmentalVariableBridge {
|
||||
public getValueByName(envVarName: string, appId: string): Promise<string> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public isReadable(envVarName: string, appId: string): Promise<boolean> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public isSet(envVarName: string, appId: string): Promise<boolean> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import { ExperimentalBridge } from '../../../src/server/bridges';
|
||||
|
||||
export class TestExperimentalBridge extends ExperimentalBridge {}
|
||||
16
packages/apps/tests/test-data/bridges/httpBridge.ts
Normal file
16
packages/apps/tests/test-data/bridges/httpBridge.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { IHttpResponse } from '@rocket.chat/apps-engine/definition/accessors';
|
||||
|
||||
import type { IHttpBridgeRequestInfo } from '../../../src/server/bridges';
|
||||
import { HttpBridge } from '../../../src/server/bridges';
|
||||
|
||||
export class TestsHttpBridge extends HttpBridge {
|
||||
public call(info: IHttpBridgeRequestInfo): Promise<IHttpResponse> {
|
||||
return Promise.resolve({
|
||||
url: info.url,
|
||||
method: info.method,
|
||||
statusCode: 200,
|
||||
headers: info.request.headers,
|
||||
content: info.request.content,
|
||||
});
|
||||
}
|
||||
}
|
||||
17
packages/apps/tests/test-data/bridges/internalBridge.ts
Normal file
17
packages/apps/tests/test-data/bridges/internalBridge.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings';
|
||||
|
||||
import type { IInternalBridge } from '../../../src/server/bridges';
|
||||
|
||||
export class TestsInternalBridge implements IInternalBridge {
|
||||
public doGetUsernamesOfRoomByIdSync(roomId: string): Array<string> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public doGetUsernamesOfRoomById(roomId: string): Promise<Array<string>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public doGetWorkspacePublicKey(): Promise<ISetting> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { IInternalFederationBridge } from '../../../src/server/bridges';
|
||||
|
||||
export class TestsInternalFederationBridge implements IInternalFederationBridge {
|
||||
public async getPrivateKey(): Promise<string> {
|
||||
return 'fake_private-key';
|
||||
}
|
||||
|
||||
public async getPublicKey(): Promise<string> {
|
||||
return 'fake_public-key';
|
||||
}
|
||||
}
|
||||
124
packages/apps/tests/test-data/bridges/livechatBridge.ts
Normal file
124
packages/apps/tests/test-data/bridges/livechatBridge.ts
Normal file
@@ -0,0 +1,124 @@
|
||||
import type { IExtraRoomParams } from '@rocket.chat/apps-engine/definition/accessors/ILivechatCreator';
|
||||
import type {
|
||||
IDepartment,
|
||||
IVisitorExternalIdentifier,
|
||||
ILivechatMessage,
|
||||
ILivechatRoom,
|
||||
ILivechatTransferData,
|
||||
IVisitor,
|
||||
ResolveVisitorContactData,
|
||||
} from '@rocket.chat/apps-engine/definition/livechat';
|
||||
import type { IMessage } from '@rocket.chat/apps-engine/definition/messages';
|
||||
import type { IUser } from '@rocket.chat/apps-engine/definition/users';
|
||||
|
||||
import { LivechatBridge } from '../../../src/server/bridges/LivechatBridge';
|
||||
|
||||
export class TestLivechatBridge extends LivechatBridge {
|
||||
public findDepartmentsEnabledWithAgents(appId: string): Promise<Array<IDepartment>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public isOnline(departmentId?: string): boolean {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public isOnlineAsync(departmentId?: string): Promise<boolean> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public createMessage(message: ILivechatMessage, appId: string): Promise<string> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public getMessageById(messageId: string, appId: string): Promise<ILivechatMessage> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public updateMessage(message: ILivechatMessage, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public createVisitor(visitor: IVisitor, appId: string): Promise<string> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public createAndReturnVisitor(visitor: IVisitor, appId: string): Promise<IVisitor | undefined> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public transferVisitor(visitor: IVisitor, transferData: ILivechatTransferData, appId: string): Promise<boolean> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public findVisitors(query: object, appId: string): Promise<Array<IVisitor>> {
|
||||
console.warn('The method AppLivechatBridge.findVisitors is deprecated. Please consider using its alternatives');
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public findVisitorById(id: string, appId: string): Promise<IVisitor | undefined> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public findVisitorByEmail(email: string, appId: string): Promise<IVisitor | undefined> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public findVisitorByToken(token: string, appId: string): Promise<IVisitor | undefined> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public findVisitorByPhoneNumber(phoneNumber: string, appId: string): Promise<IVisitor | undefined> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public resolveVisitor(
|
||||
externalId: IVisitorExternalIdentifier,
|
||||
contactData: ResolveVisitorContactData | undefined,
|
||||
appId: string,
|
||||
): Promise<IVisitor | undefined> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public updateVisitorExternalId(
|
||||
visitorId: string,
|
||||
externalId: Omit<IVisitorExternalIdentifier, 'appId'>,
|
||||
appId: string,
|
||||
): Promise<IVisitor | undefined> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public createRoom(visitor: IVisitor, agent: IUser, appId: string, extraParams?: IExtraRoomParams): Promise<ILivechatRoom> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public closeRoom(room: ILivechatRoom, comment: string, closer: IUser | undefined, appId: string): Promise<boolean> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public findRooms(visitor: IVisitor, departmentId: string | null, appId: string): Promise<Array<ILivechatRoom>> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public findOpenRoomsByAgentId(agentId: string, appId: string): Promise<ILivechatRoom[]> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public countOpenRoomsByAgentId(agentId: string, appId: string): Promise<number> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public findDepartmentByIdOrName(value: string, appId: string): Promise<IDepartment | undefined> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public _fetchLivechatRoomMessages(appId: string, roomId: string): Promise<Array<IMessage>> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public setCustomFields(
|
||||
data: { token: IVisitor['token']; key: string; value: string; overwrite: boolean },
|
||||
appId: string,
|
||||
): Promise<number> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
}
|
||||
44
packages/apps/tests/test-data/bridges/messageBridge.ts
Normal file
44
packages/apps/tests/test-data/bridges/messageBridge.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import type { IMessage, Reaction } from '@rocket.chat/apps-engine/definition/messages';
|
||||
import type { IRoom } from '@rocket.chat/apps-engine/definition/rooms';
|
||||
import type { IUser } from '@rocket.chat/apps-engine/definition/users';
|
||||
|
||||
import { MessageBridge } from '../../../src/server/bridges';
|
||||
import type { ITypingDescriptor } from '../../../src/server/bridges/MessageBridge';
|
||||
|
||||
export class TestsMessageBridge extends MessageBridge {
|
||||
public create(message: IMessage, appId: string): Promise<string> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public getById(messageId: string, appId: string): Promise<IMessage> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public update(message: IMessage, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public notifyUser(user: IUser, message: IMessage, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public notifyRoom(room: IRoom, message: IMessage, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public delete(message: IMessage, user: IUser, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public typing(options: ITypingDescriptor): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public addReaction(_messageId: string, _userId: string, _reaction: Reaction): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public removeReaction(_messageId: string, _userId: string, _reaction: Reaction): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
18
packages/apps/tests/test-data/bridges/moderationBridge.ts
Normal file
18
packages/apps/tests/test-data/bridges/moderationBridge.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { IMessage } from '@rocket.chat/apps-engine/definition/messages';
|
||||
import type { IUser } from '@rocket.chat/apps-engine/definition/users';
|
||||
|
||||
import { ModerationBridge } from '../../../src/server/bridges';
|
||||
|
||||
export class TestsModerationBridge extends ModerationBridge {
|
||||
public report(messageId: string, description: string, userId: string, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public dismissReportsByMessageId(messageId: IMessage['id'], reason: string, action: string, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public dismissReportsByUserId(userId: IUser['id'], reason: string, action: string, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
21
packages/apps/tests/test-data/bridges/outboundComms.ts
Normal file
21
packages/apps/tests/test-data/bridges/outboundComms.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import type {
|
||||
IOutboundEmailMessageProvider,
|
||||
IOutboundMessageProviders,
|
||||
IOutboundPhoneMessageProvider,
|
||||
} from '@rocket.chat/apps-engine/definition/outboundCommunication';
|
||||
|
||||
import { OutboundMessageBridge } from '../../../src/server/bridges';
|
||||
|
||||
export class TestOutboundCommunicationBridge extends OutboundMessageBridge {
|
||||
protected async registerPhoneProvider(provider: IOutboundPhoneMessageProvider, appId: string): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
protected async registerEmailProvider(provider: IOutboundEmailMessageProvider, appId: string): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
protected async unRegisterProvider(provider: IOutboundMessageProviders, appId: string): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
46
packages/apps/tests/test-data/bridges/persisBridge.ts
Normal file
46
packages/apps/tests/test-data/bridges/persisBridge.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import type { RocketChatAssociationRecord } from '@rocket.chat/apps-engine/definition/metadata';
|
||||
|
||||
import { PersistenceBridge } from '../../../src/server/bridges';
|
||||
|
||||
export class TestsPersisBridge extends PersistenceBridge {
|
||||
public purge(appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public create(data: any, appId: string): Promise<string> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public createWithAssociations(data: object, associations: Array<RocketChatAssociationRecord>, appId: string): Promise<string> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public readById(id: string, appId: string): Promise<object> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public readByAssociations(associations: Array<RocketChatAssociationRecord>, appId: string): Promise<Array<object>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public remove(id: string, appId: string): Promise<object> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public removeByAssociations(associations: Array<RocketChatAssociationRecord>, appId: string): Promise<Array<object>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public update(id: string, data: object, upsert: boolean, appId: string): Promise<string> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public updateByAssociations(
|
||||
associations: Array<RocketChatAssociationRecord>,
|
||||
data: object,
|
||||
upsert: boolean,
|
||||
appId: string,
|
||||
): Promise<string> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
}
|
||||
13
packages/apps/tests/test-data/bridges/roleBridge.ts
Normal file
13
packages/apps/tests/test-data/bridges/roleBridge.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { IRole } from '@rocket.chat/apps-engine/definition/roles';
|
||||
|
||||
import { RoleBridge } from '../../../src/server/bridges';
|
||||
|
||||
export class TestsRoleBridge extends RoleBridge {
|
||||
public getOneByIdOrName(idOrName: IRole['id'] | IRole['name'], appId: string): Promise<IRole | null> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public getCustomRoles(appId: string): Promise<Array<IRole>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
81
packages/apps/tests/test-data/bridges/roomBridge.ts
Normal file
81
packages/apps/tests/test-data/bridges/roomBridge.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import type { IMessage, IMessageRaw } from '@rocket.chat/apps-engine/definition/messages';
|
||||
import type { IRoom } from '@rocket.chat/apps-engine/definition/rooms';
|
||||
import type { IRoomRaw } from '@rocket.chat/apps-engine/definition/rooms/IRoomRaw';
|
||||
import type { IUser } from '@rocket.chat/apps-engine/definition/users';
|
||||
|
||||
import { RoomBridge } from '../../../src/server/bridges';
|
||||
import type { GetMessagesOptions, GetRoomsOptions, GetRoomsFilters } from '../../../src/server/bridges/RoomBridge';
|
||||
|
||||
export class TestsRoomBridge extends RoomBridge {
|
||||
public create(room: IRoom, members: Array<string>, appId: string): Promise<string> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public getById(roomId: string, appId: string): Promise<IRoom> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public getCreatorById(roomId: string, appId: string): Promise<IUser> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public getByName(roomName: string, appId: string): Promise<IRoom> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public getCreatorByName(roomName: string, appId: string): Promise<IUser> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public getDirectByUsernames(username: Array<string>, appId: string): Promise<IRoom> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public getMembers(roomName: string, appId: string): Promise<Array<IUser>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public getAllRooms(filter: GetRoomsFilters, options: GetRoomsOptions, appId: string): Promise<IRoomRaw[]> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public getMessages(roomId: string, options: GetMessagesOptions, appId: string): Promise<IMessageRaw[]> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public update(room: IRoom, members: Array<string>, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public createDiscussion(room: IRoom, parentMessage: IMessage, reply: string, members: Array<string>, appId: string): Promise<string> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public delete(roomId: string, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public getLeaders(roomId: string, appId: string): Promise<Array<IUser>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public getModerators(roomId: string, appId: string): Promise<Array<IUser>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public getOwners(roomId: string, appId: string): Promise<Array<IUser>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public removeUsers(roomId: string, usernames: string[], appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public getUnreadByUser(roomId: string, uid: string, options: GetMessagesOptions, appId: string): Promise<IMessageRaw[]> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
protected getUserUnreadMessageCount(roomId: string, uid: string, appId: string): Promise<number> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
25
packages/apps/tests/test-data/bridges/schedulerBridge.ts
Normal file
25
packages/apps/tests/test-data/bridges/schedulerBridge.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { IOnetimeSchedule, IProcessor, IRecurringSchedule } from '@rocket.chat/apps-engine/definition/scheduler';
|
||||
|
||||
import { SchedulerBridge } from '../../../src/server/bridges';
|
||||
|
||||
export class TestSchedulerBridge extends SchedulerBridge {
|
||||
public async registerProcessors(processors: Array<IProcessor>, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public async scheduleOnce(job: IOnetimeSchedule, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public async scheduleRecurring(job: IRecurringSchedule, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public async cancelJob(jobId: string, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public async cancelAllJobs(appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
42
packages/apps/tests/test-data/bridges/serverSettingBridge.ts
Normal file
42
packages/apps/tests/test-data/bridges/serverSettingBridge.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { SettingType, type ISetting } from '@rocket.chat/apps-engine/definition/settings';
|
||||
|
||||
import { ServerSettingBridge } from '../../../src/server/bridges';
|
||||
|
||||
export class TestsServerSettingBridge extends ServerSettingBridge {
|
||||
public getAll(appId: string): Promise<Array<ISetting>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public getOneById(id: string, appId: string): Promise<ISetting> {
|
||||
return Promise.resolve({
|
||||
id,
|
||||
packageValue: 'packageValue',
|
||||
value: 'value',
|
||||
i18nLabel: 'i18nLabel',
|
||||
i18nDescription: 'i18nDescription',
|
||||
required: true,
|
||||
public: true,
|
||||
type: SettingType.STRING,
|
||||
});
|
||||
}
|
||||
|
||||
public hideGroup(name: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public hideSetting(id: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public isReadableById(id: string, appId: string): Promise<boolean> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public updateOne(setting: ISetting, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public incrementValue(id: ISetting['id'], value: number, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
9
packages/apps/tests/test-data/bridges/threadBridge.ts
Normal file
9
packages/apps/tests/test-data/bridges/threadBridge.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { IMessage } from '@rocket.chat/apps-engine/definition/messages';
|
||||
|
||||
import { ThreadBridge } from '../../../src/server/bridges/ThreadBridge';
|
||||
|
||||
export class TestsThreadBridge extends ThreadBridge {
|
||||
public getById(messageId: string, appId: string): Promise<Array<IMessage>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
10
packages/apps/tests/test-data/bridges/uiIntegrationBridge.ts
Normal file
10
packages/apps/tests/test-data/bridges/uiIntegrationBridge.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { IUIKitInteractionParam } from '@rocket.chat/apps-engine/definition/accessors/IUIController';
|
||||
import type { IUser } from '@rocket.chat/apps-engine/definition/users';
|
||||
|
||||
import { UiInteractionBridge } from '../../../src/server/bridges';
|
||||
|
||||
export class TestsUiIntegrationBridge extends UiInteractionBridge {
|
||||
public async notifyUser(user: IUser, interaction: IUIKitInteractionParam, appId: string) {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
18
packages/apps/tests/test-data/bridges/uploadBridge.ts
Normal file
18
packages/apps/tests/test-data/bridges/uploadBridge.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { IUpload } from '@rocket.chat/apps-engine/definition/uploads';
|
||||
import type { IUploadDetails } from '@rocket.chat/apps-engine/definition/uploads/IUploadDetails';
|
||||
|
||||
import { UploadBridge } from '../../../src/server/bridges/UploadBridge';
|
||||
|
||||
export class TestUploadBridge extends UploadBridge {
|
||||
public getById(id: string, appId: string): Promise<IUpload> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public getBuffer(upload: IUpload, appId: string): Promise<Buffer> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public createUpload(details: IUploadDetails, buffer: Buffer, appId: string): Promise<IUpload> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
}
|
||||
61
packages/apps/tests/test-data/bridges/userBridge.ts
Normal file
61
packages/apps/tests/test-data/bridges/userBridge.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import type { IUser, UserType } from '@rocket.chat/apps-engine/definition/users';
|
||||
|
||||
import { UserBridge } from '../../../src/server/bridges';
|
||||
|
||||
export class TestsUserBridge extends UserBridge {
|
||||
public getById(id: string, appId: string): Promise<IUser> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public getByUsername(username: string, appId: string): Promise<IUser> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public create(user: Partial<IUser>): Promise<string> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public getActiveUserCount(): Promise<number> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public remove(user: IUser, appId: string): Promise<boolean> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public getAppUser(appId?: string): Promise<IUser> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public async update(user: IUser, updates: Partial<IUser>, appId: string): Promise<boolean> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public async deleteUsersCreatedByApp(appId: string, type: UserType.BOT): Promise<boolean> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
protected getUserUnreadMessageCount(uid: string, appId: string): Promise<number> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
protected getUserRoomIds(userId: string, appId: string): Promise<string[]> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
protected deactivate(userId: IUser['id'], confirmRelinquish: boolean, appId: string): Promise<boolean> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
protected setActiveState(
|
||||
userId: IUser['id'],
|
||||
state: Pick<IUser, 'statusDefault' | 'statusSource' | 'statusText' | 'statusExpiresAt' | 'statusId'>,
|
||||
appId: string,
|
||||
): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
protected endActiveState(userId: IUser['id'], appId: string, statusId?: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import type { IVideoConfProvider } from '@rocket.chat/apps-engine/definition/videoConfProviders';
|
||||
import type { VideoConference, AppVideoConference } from '@rocket.chat/apps-engine/definition/videoConferences';
|
||||
|
||||
import { VideoConferenceBridge } from '../../../src/server/bridges';
|
||||
|
||||
export class TestsVideoConferenceBridge extends VideoConferenceBridge {
|
||||
public getById(callId: string, appId: string): Promise<VideoConference> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public create(call: AppVideoConference, appId: string): Promise<string> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
public update(call: VideoConference, appId: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
protected registerProvider(info: IVideoConfProvider, appId: string): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
protected unRegisterProvider(info: IVideoConfProvider, appId: string): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
5
packages/apps/tests/test-data/misc/fake-library-file.d.ts
vendored
Normal file
5
packages/apps/tests/test-data/misc/fake-library-file.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export declare class FakeLibraryClass {
|
||||
startWork(): boolean;
|
||||
|
||||
stopWorking(): boolean;
|
||||
}
|
||||
20
packages/apps/tests/test-data/storage/TestSourceStorage.ts
Normal file
20
packages/apps/tests/test-data/storage/TestSourceStorage.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { IAppStorageItem } from '../../../src/server/storage';
|
||||
import { AppSourceStorage } from '../../../src/server/storage';
|
||||
|
||||
export class TestSourceStorage extends AppSourceStorage {
|
||||
public async store(item: IAppStorageItem, zip: Buffer): Promise<string> {
|
||||
return 'app_package_path';
|
||||
}
|
||||
|
||||
public async fetch(item: IAppStorageItem): Promise<Buffer> {
|
||||
return Buffer.from('buffer');
|
||||
}
|
||||
|
||||
public async update(item: IAppStorageItem, zip: Buffer): Promise<string> {
|
||||
return 'updated_path';
|
||||
}
|
||||
|
||||
public async remove(item: IAppStorageItem): Promise<void> {
|
||||
// yup
|
||||
}
|
||||
}
|
||||
28
packages/apps/tests/test-data/storage/logStorage.ts
Normal file
28
packages/apps/tests/test-data/storage/logStorage.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import type { ILoggerStorageEntry } from '../../../src/server/logging';
|
||||
import type { IAppLogStorageFindOptions } from '../../../src/server/storage';
|
||||
import { AppLogStorage } from '../../../src/server/storage';
|
||||
|
||||
export class TestsAppLogStorage extends AppLogStorage {
|
||||
constructor() {
|
||||
super('nothing');
|
||||
}
|
||||
|
||||
public findPaginated(
|
||||
query: { [field: string]: any },
|
||||
options?: IAppLogStorageFindOptions,
|
||||
): Promise<{ logs: ILoggerStorageEntry[]; total: number }> {
|
||||
return Promise.resolve({ logs: [], total: 0 });
|
||||
}
|
||||
|
||||
public storeEntries(logEntry: ILoggerStorageEntry): Promise<ILoggerStorageEntry> {
|
||||
return Promise.resolve({} as ILoggerStorageEntry);
|
||||
}
|
||||
|
||||
public getEntriesFor(appId: string): Promise<Array<ILoggerStorageEntry>> {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
public removeEntriesFor(appId: string): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
110
packages/apps/tests/test-data/storage/storage.ts
Normal file
110
packages/apps/tests/test-data/storage/storage.ts
Normal file
@@ -0,0 +1,110 @@
|
||||
import type { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus';
|
||||
import type { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata';
|
||||
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings';
|
||||
|
||||
import type { IMarketplaceInfo } from '../../../src/server/marketplace';
|
||||
import type { IAppStorageItem } from '../../../src/server/storage';
|
||||
import { AppMetadataStorage } from '../../../src/server/storage';
|
||||
import { AppInstallationSource } from '../../../src/server/storage/IAppStorageItem';
|
||||
|
||||
export class TestsAppStorage extends AppMetadataStorage {
|
||||
private db = new Map<string, IAppStorageItem>();
|
||||
|
||||
constructor() {
|
||||
super('in-memory');
|
||||
}
|
||||
|
||||
public create(item: IAppStorageItem): Promise<IAppStorageItem> {
|
||||
for (const [id, value] of this.db) {
|
||||
if (id === item.id || item.info.nameSlug === value.info.nameSlug) {
|
||||
return Promise.reject(new Error('App already exists.'));
|
||||
}
|
||||
}
|
||||
|
||||
const stored = { ...item, _id: item._id ?? item.id, createdAt: new Date(), updatedAt: new Date() };
|
||||
this.db.set(stored.id, stored);
|
||||
return Promise.resolve(stored);
|
||||
}
|
||||
|
||||
public retrieveOne(id: string): Promise<IAppStorageItem | null> {
|
||||
return Promise.resolve(this.db.get(id) ?? null);
|
||||
}
|
||||
|
||||
public retrieveAll(): Promise<Map<string, IAppStorageItem>> {
|
||||
return Promise.resolve(new Map(this.db));
|
||||
}
|
||||
|
||||
public retrieveAllPrivate(): Promise<Map<string, IAppStorageItem>> {
|
||||
const items = new Map<string, IAppStorageItem>();
|
||||
for (const [id, item] of this.db) {
|
||||
if (item.installationSource === AppInstallationSource.PRIVATE) {
|
||||
items.set(id, item);
|
||||
}
|
||||
}
|
||||
return Promise.resolve(items);
|
||||
}
|
||||
|
||||
public clear(): void {
|
||||
this.db.clear();
|
||||
}
|
||||
|
||||
public remove(id: string): Promise<{ success: boolean }> {
|
||||
this.db.delete(id);
|
||||
return Promise.resolve({ success: true });
|
||||
}
|
||||
|
||||
public updatePartialAndReturnDocument(
|
||||
item: Partial<IAppStorageItem>,
|
||||
_options?: { unsetPermissionsGranted?: boolean },
|
||||
): Promise<IAppStorageItem> {
|
||||
const lookupId = item.id ?? item._id;
|
||||
if (!lookupId) {
|
||||
return Promise.reject(new Error('Cannot update: item has no id.'));
|
||||
}
|
||||
|
||||
const existing = this.db.get(lookupId);
|
||||
if (!existing) {
|
||||
return Promise.reject(new Error(`App not found: ${lookupId}`));
|
||||
}
|
||||
|
||||
const updated = { ...existing, ...item, updatedAt: new Date() };
|
||||
this.db.set(updated.id, updated);
|
||||
return Promise.resolve(updated);
|
||||
}
|
||||
|
||||
public updateStatus(id: string, status: AppStatus): Promise<boolean> {
|
||||
const existing = this.db.get(id);
|
||||
if (!existing) {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
this.db.set(id, { ...existing, status, updatedAt: new Date() });
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public updateSetting(id: string, setting: ISetting): Promise<boolean> {
|
||||
const existing = this.db.get(id);
|
||||
if (!existing) {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
this.db.set(id, { ...existing, settings: { ...existing.settings, [setting.id]: setting }, updatedAt: new Date() });
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public updateAppInfo(id: string, info: IAppInfo): Promise<boolean> {
|
||||
const existing = this.db.get(id);
|
||||
if (!existing) {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
this.db.set(id, { ...existing, info, updatedAt: new Date() });
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public updateMarketplaceInfo(id: string, marketplaceInfo: IMarketplaceInfo[]): Promise<boolean> {
|
||||
const existing = this.db.get(id);
|
||||
if (!existing) {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
this.db.set(id, { ...existing, marketplaceInfo, updatedAt: new Date() });
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
729
packages/apps/tests/test-data/utilities.ts
Normal file
729
packages/apps/tests/test-data/utilities.ts
Normal file
@@ -0,0 +1,729 @@
|
||||
import * as os from 'node:os';
|
||||
|
||||
import { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus';
|
||||
import type { IHttp, IModify, IPersistence, IRead } from '@rocket.chat/apps-engine/definition/accessors';
|
||||
import { HttpStatusCode } from '@rocket.chat/apps-engine/definition/accessors';
|
||||
import type { IApi, IApiRequest, IApiResponse } from '@rocket.chat/apps-engine/definition/api';
|
||||
import { ApiSecurity, ApiVisibility } from '@rocket.chat/apps-engine/definition/api';
|
||||
import type { IApiEndpointInfo } from '@rocket.chat/apps-engine/definition/api/IApiEndpointInfo';
|
||||
import type { IMessage, IMessageAttachment, IMessageRaw } from '@rocket.chat/apps-engine/definition/messages';
|
||||
import type {
|
||||
IOutboundEmailMessageProvider,
|
||||
IOutboundMessage,
|
||||
IOutboundPhoneMessageProvider,
|
||||
ProviderMetadata,
|
||||
} from '@rocket.chat/apps-engine/definition/outboundCommunication';
|
||||
import type { IRoom } from '@rocket.chat/apps-engine/definition/rooms';
|
||||
import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
|
||||
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings';
|
||||
import { SettingType } from '@rocket.chat/apps-engine/definition/settings';
|
||||
import type {
|
||||
ISlashCommand,
|
||||
ISlashCommandPreview,
|
||||
ISlashCommandPreviewItem,
|
||||
SlashCommandContext,
|
||||
} from '@rocket.chat/apps-engine/definition/slashcommands';
|
||||
import type { IUser } from '@rocket.chat/apps-engine/definition/users';
|
||||
import { UserStatusConnection, UserType } from '@rocket.chat/apps-engine/definition/users';
|
||||
import type {
|
||||
IVideoConferenceOptions,
|
||||
IVideoConfProvider,
|
||||
VideoConfData,
|
||||
VideoConfDataExtended,
|
||||
} from '@rocket.chat/apps-engine/definition/videoConfProviders';
|
||||
import type { AppVideoConference } from '@rocket.chat/apps-engine/definition/videoConferences/AppVideoConference';
|
||||
import type { VideoConference } from '@rocket.chat/apps-engine/definition/videoConferences/IVideoConference';
|
||||
import { VideoConferenceStatus } from '@rocket.chat/apps-engine/definition/videoConferences/IVideoConference';
|
||||
import type { IVideoConferenceUser } from '@rocket.chat/apps-engine/definition/videoConferences/IVideoConferenceUser';
|
||||
|
||||
import { TestsAppBridges } from './bridges/appBridges';
|
||||
import { TestSourceStorage } from './storage/TestSourceStorage';
|
||||
import { TestsAppLogStorage } from './storage/logStorage';
|
||||
import { TestsAppStorage } from './storage/storage';
|
||||
import type { AppOutboundCommunicationProviderManager } from '../../server/managers/AppOutboundCommunicationProviderManager';
|
||||
import type { AppManager } from '../../src/server/AppManager';
|
||||
import { ProxiedApp } from '../../src/server/ProxiedApp';
|
||||
import type { AppBridges } from '../../src/server/bridges';
|
||||
import { AppResourceBridge } from '../../src/server/bridges/AppResourceBridge';
|
||||
import { AppPackageParser } from '../../src/server/compiler';
|
||||
import type {
|
||||
AppExternalComponentManager,
|
||||
AppSchedulerManager,
|
||||
AppSettingsManager,
|
||||
AppSlashCommandManager,
|
||||
AppVideoConfProviderManager,
|
||||
} from '../../src/server/managers';
|
||||
import type { AppRuntimeManager } from '../../src/server/managers/AppRuntimeManager';
|
||||
import type { UIActionButtonManager } from '../../src/server/managers/UIActionButtonManager';
|
||||
import type { IMarketplaceInfo, IMarketplaceSubscriptionInfo } from '../../src/server/marketplace';
|
||||
import { MarketplacePurchaseType } from '../../src/server/marketplace/MarketplacePurchaseType';
|
||||
import { MarketplaceSubscriptionStatus } from '../../src/server/marketplace/MarketplaceSubscriptionStatus';
|
||||
import { MarketplaceSubscriptionType } from '../../src/server/marketplace/MarketplaceSubscriptionType';
|
||||
import type { IRuntimeController } from '../../src/server/runtime/IRuntimeController';
|
||||
import type { AppLogStorage, AppMetadataStorage, AppSourceStorage, IAppStorageItem } from '../../src/server/storage';
|
||||
import { AppInstallationSource } from '../../src/server/storage/IAppStorageItem';
|
||||
|
||||
export class TestInfastructureSetup {
|
||||
private appStorage: TestsAppStorage;
|
||||
|
||||
private logStorage: TestsAppLogStorage;
|
||||
|
||||
private bridges: TestsAppBridges;
|
||||
|
||||
private sourceStorage: TestSourceStorage;
|
||||
|
||||
private appManager: AppManager;
|
||||
|
||||
private runtimeManager: AppRuntimeManager;
|
||||
|
||||
constructor() {
|
||||
this.appStorage = new TestsAppStorage();
|
||||
this.logStorage = new TestsAppLogStorage();
|
||||
this.bridges = new TestsAppBridges();
|
||||
this.sourceStorage = new TestSourceStorage();
|
||||
this.runtimeManager = {
|
||||
startRuntimeForApp: async () => {
|
||||
return TestData.getMockRuntimeController('test');
|
||||
},
|
||||
runInSandbox: async () => {
|
||||
return {} as unknown as Promise<unknown>;
|
||||
},
|
||||
stopRuntime: () => {},
|
||||
} as unknown as AppRuntimeManager;
|
||||
|
||||
this.appManager = {
|
||||
getParser() {
|
||||
if (!this.parser) {
|
||||
this.parser = new AppPackageParser();
|
||||
}
|
||||
|
||||
return this.parser;
|
||||
},
|
||||
getBridges: () => {
|
||||
return this.bridges as AppBridges;
|
||||
},
|
||||
getCommandManager() {
|
||||
return {} as AppSlashCommandManager;
|
||||
},
|
||||
getExternalComponentManager() {
|
||||
return {} as AppExternalComponentManager;
|
||||
},
|
||||
getOneById(appId: string): ProxiedApp {
|
||||
return appId === 'failMePlease'
|
||||
? undefined
|
||||
: TestData.getMockApp({ info: { id: appId, name: 'testing' } } as IAppStorageItem, this);
|
||||
},
|
||||
getLogStorage(): AppLogStorage {
|
||||
return new TestsAppLogStorage();
|
||||
},
|
||||
getSchedulerManager() {
|
||||
return {} as AppSchedulerManager;
|
||||
},
|
||||
getUIActionButtonManager() {
|
||||
return {} as UIActionButtonManager;
|
||||
},
|
||||
getVideoConfProviderManager() {
|
||||
return {} as AppVideoConfProviderManager;
|
||||
},
|
||||
getOutboundCommunicationProviderManager() {
|
||||
return {} as AppOutboundCommunicationProviderManager;
|
||||
},
|
||||
getSettingsManager() {
|
||||
return {} as AppSettingsManager;
|
||||
},
|
||||
getAppResourceBridge() {
|
||||
return new AppResourceBridge(this as unknown as AppManager);
|
||||
},
|
||||
getRuntime: () => {
|
||||
return this.runtimeManager;
|
||||
},
|
||||
getTempFilePath: this.getTempFilePath,
|
||||
} as unknown as AppManager;
|
||||
}
|
||||
|
||||
public getTempFilePath(): string {
|
||||
return os.tmpdir();
|
||||
}
|
||||
|
||||
public getAppStorage(): AppMetadataStorage {
|
||||
return this.appStorage;
|
||||
}
|
||||
|
||||
public getLogStorage(): AppLogStorage {
|
||||
return this.logStorage;
|
||||
}
|
||||
|
||||
public getAppBridges(): AppBridges {
|
||||
return this.bridges;
|
||||
}
|
||||
|
||||
public getSourceStorage(): AppSourceStorage {
|
||||
return this.sourceStorage;
|
||||
}
|
||||
|
||||
public getMockManager(): AppManager {
|
||||
return this.appManager;
|
||||
}
|
||||
}
|
||||
|
||||
const date = new Date();
|
||||
|
||||
const DEFAULT_ATTACHMENT = {
|
||||
color: '#00b2b2',
|
||||
collapsed: false,
|
||||
text: 'Just an attachment that is used for testing',
|
||||
timestampLink: 'https://google.com/',
|
||||
thumbnailUrl: 'https://avatars0.githubusercontent.com/u/850391?s=88&v=4',
|
||||
author: {
|
||||
name: 'Author Name',
|
||||
link: 'https://github.com/graywolf336',
|
||||
icon: 'https://avatars0.githubusercontent.com/u/850391?s=88&v=4',
|
||||
},
|
||||
title: {
|
||||
value: 'Attachment Title',
|
||||
link: 'https://github.com/RocketChat',
|
||||
displayDownloadLink: false,
|
||||
},
|
||||
imageUrl: 'https://rocket.chat/images/default/logo.svg',
|
||||
audioUrl: 'http://www.w3schools.com/tags/horse.mp3',
|
||||
videoUrl: 'http://www.w3schools.com/tags/movie.mp4',
|
||||
fields: [
|
||||
{
|
||||
short: true,
|
||||
title: 'Test',
|
||||
value: 'Testing out something or other',
|
||||
},
|
||||
{
|
||||
short: true,
|
||||
title: 'Another Test',
|
||||
value: '[Link](https://google.com/) something and this and that.',
|
||||
},
|
||||
],
|
||||
};
|
||||
export class TestData {
|
||||
public static getDate(): Date {
|
||||
return date;
|
||||
}
|
||||
|
||||
public static getSetting(id?: string): ISetting {
|
||||
return {
|
||||
id: id || 'testing',
|
||||
type: SettingType.STRING,
|
||||
packageValue: 'The packageValue',
|
||||
required: false,
|
||||
public: false,
|
||||
i18nLabel: 'Testing',
|
||||
};
|
||||
}
|
||||
|
||||
public static getUser(id?: string, username?: string): IUser {
|
||||
return {
|
||||
id: id || 'BBxwgCBzLeMC6esTb',
|
||||
username: username || 'testing-user',
|
||||
name: 'Testing User',
|
||||
emails: [],
|
||||
type: UserType.USER,
|
||||
isEnabled: true,
|
||||
roles: ['admin'],
|
||||
status: 'online',
|
||||
statusConnection: UserStatusConnection.ONLINE,
|
||||
utcOffset: -5,
|
||||
createdAt: date,
|
||||
updatedAt: new Date(),
|
||||
lastLoginAt: new Date(),
|
||||
};
|
||||
}
|
||||
|
||||
public static getRoom(id?: string, slugifiedName?: string): IRoom {
|
||||
return {
|
||||
id: id || 'bTse6CMeLzBCgwxBB',
|
||||
slugifiedName: slugifiedName || 'testing-room',
|
||||
displayName: 'Testing Room',
|
||||
type: RoomType.CHANNEL,
|
||||
creator: TestData.getUser(),
|
||||
usernames: [TestData.getUser().username],
|
||||
isDefault: true,
|
||||
isReadOnly: false,
|
||||
displaySystemMessages: true,
|
||||
messageCount: 145,
|
||||
createdAt: date,
|
||||
updatedAt: new Date(),
|
||||
lastModifiedAt: new Date(),
|
||||
};
|
||||
}
|
||||
|
||||
public static getMessage(id?: string, text?: string): IMessage {
|
||||
return {
|
||||
id: id || '4bShvoOXqB',
|
||||
room: TestData.getRoom(),
|
||||
sender: TestData.getUser(),
|
||||
text: 'This is just a test, do not be alarmed',
|
||||
createdAt: date,
|
||||
updatedAt: new Date(),
|
||||
editor: TestData.getUser(),
|
||||
editedAt: new Date(),
|
||||
emoji: ':see_no_evil:',
|
||||
avatarUrl: 'https://avatars0.githubusercontent.com/u/850391?s=88&v=4',
|
||||
alias: 'Testing Bot',
|
||||
attachments: [this.createAttachment()],
|
||||
};
|
||||
}
|
||||
|
||||
public static getMessageRaw(id?: string, text?: string): IMessageRaw {
|
||||
const editorUser = TestData.getUser();
|
||||
const senderUser = TestData.getUser();
|
||||
|
||||
return {
|
||||
id: id || '4bShvoOXqB',
|
||||
roomId: TestData.getRoom().id,
|
||||
sender: {
|
||||
_id: senderUser.id,
|
||||
username: senderUser.username,
|
||||
name: senderUser?.name,
|
||||
},
|
||||
text: text || 'This is just a test, do not be alarmed',
|
||||
createdAt: date,
|
||||
updatedAt: new Date(),
|
||||
editor: {
|
||||
_id: editorUser.id,
|
||||
username: editorUser.username,
|
||||
},
|
||||
editedAt: new Date(),
|
||||
emoji: ':see_no_evil:',
|
||||
avatarUrl: 'https://avatars0.githubusercontent.com/u/850391?s=88&v=4',
|
||||
alias: 'Testing Bot',
|
||||
attachments: [this.createAttachment()],
|
||||
};
|
||||
}
|
||||
|
||||
private static createAttachment(attachment?: IMessageAttachment): IMessageAttachment {
|
||||
attachment = attachment || DEFAULT_ATTACHMENT;
|
||||
return {
|
||||
timestamp: new Date(),
|
||||
...attachment,
|
||||
};
|
||||
}
|
||||
|
||||
public static getSlashCommand(command?: string): ISlashCommand {
|
||||
return {
|
||||
command: command || 'testing-cmd',
|
||||
i18nParamsExample: 'justATest',
|
||||
i18nDescription: 'justATest_Description',
|
||||
permission: 'create-c',
|
||||
providesPreview: true,
|
||||
executor: (context: SlashCommandContext, read: IRead, modify: IModify, http: IHttp, persis: IPersistence): Promise<void> => {
|
||||
return Promise.resolve();
|
||||
},
|
||||
previewer: (
|
||||
context: SlashCommandContext,
|
||||
read: IRead,
|
||||
modify: IModify,
|
||||
http: IHttp,
|
||||
persis: IPersistence,
|
||||
): Promise<ISlashCommandPreview> => {
|
||||
return Promise.resolve({
|
||||
i18nTitle: 'my i18nTitle',
|
||||
items: [],
|
||||
} as ISlashCommandPreview);
|
||||
},
|
||||
executePreviewItem: (
|
||||
item: ISlashCommandPreviewItem,
|
||||
context: SlashCommandContext,
|
||||
read: IRead,
|
||||
modify: IModify,
|
||||
http: IHttp,
|
||||
persis: IPersistence,
|
||||
): Promise<void> => {
|
||||
return Promise.resolve();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public static getApi(
|
||||
path = 'testing-path',
|
||||
visibility: ApiVisibility = ApiVisibility.PUBLIC,
|
||||
security: ApiSecurity = ApiSecurity.UNSECURE,
|
||||
): IApi {
|
||||
return {
|
||||
visibility,
|
||||
security,
|
||||
endpoints: [
|
||||
{
|
||||
path,
|
||||
// The move to the Deno runtime now requires us to manually set what methods are available
|
||||
_availableMethods: ['get'],
|
||||
get(
|
||||
request: IApiRequest,
|
||||
endpoint: IApiEndpointInfo,
|
||||
read: IRead,
|
||||
modify: IModify,
|
||||
http: IHttp,
|
||||
persis: IPersistence,
|
||||
): Promise<IApiResponse> {
|
||||
return Promise.resolve({
|
||||
status: HttpStatusCode.OK,
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
public static getVideoConfProvider(name = 'test'): IVideoConfProvider {
|
||||
return {
|
||||
name,
|
||||
|
||||
async generateUrl(call: VideoConfData): Promise<string> {
|
||||
return `${name}/${call._id}`;
|
||||
},
|
||||
|
||||
async customizeUrl(
|
||||
call: VideoConfDataExtended,
|
||||
user: IVideoConferenceUser | undefined,
|
||||
options: IVideoConferenceOptions,
|
||||
): Promise<string> {
|
||||
return `${name}/${call._id}#${user ? user.username : ''}`;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public static getInvalidConfProvider(name = 'invalid'): IVideoConfProvider {
|
||||
return {
|
||||
name,
|
||||
|
||||
async isFullyConfigured(): Promise<boolean> {
|
||||
return false;
|
||||
},
|
||||
|
||||
async generateUrl(call: VideoConfData): Promise<string> {
|
||||
return ``;
|
||||
},
|
||||
|
||||
async customizeUrl(
|
||||
call: VideoConfDataExtended,
|
||||
user: IVideoConferenceUser | undefined,
|
||||
options: IVideoConferenceOptions,
|
||||
): Promise<string> {
|
||||
return ``;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public static getFullVideoConfProvider(name = 'test'): IVideoConfProvider {
|
||||
return {
|
||||
name,
|
||||
|
||||
capabilities: {
|
||||
mic: true,
|
||||
cam: true,
|
||||
title: true,
|
||||
},
|
||||
|
||||
async isFullyConfigured(): Promise<boolean> {
|
||||
return true;
|
||||
},
|
||||
|
||||
async generateUrl(call: VideoConfData): Promise<string> {
|
||||
return `${name}/${call._id}`;
|
||||
},
|
||||
|
||||
async customizeUrl(
|
||||
call: VideoConfDataExtended,
|
||||
user: IVideoConferenceUser | undefined,
|
||||
options: IVideoConferenceOptions,
|
||||
): Promise<string> {
|
||||
return `${name}/${call._id}#${user ? user.username : ''}`;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public static getVideoConferenceUser(): IVideoConferenceUser {
|
||||
return {
|
||||
_id: 'callerId',
|
||||
username: 'caller',
|
||||
name: 'John Caller',
|
||||
};
|
||||
}
|
||||
|
||||
public static getVideoConfData(): VideoConfData {
|
||||
return {
|
||||
_id: 'first-call',
|
||||
type: 'videoconference',
|
||||
rid: 'roomId',
|
||||
createdBy: this.getVideoConferenceUser(),
|
||||
title: 'Test Call',
|
||||
};
|
||||
}
|
||||
|
||||
public static getVideoConfDataExtended(providerName = 'test'): VideoConfDataExtended {
|
||||
return {
|
||||
...this.getVideoConfData(),
|
||||
url: '${providerName}/first-call',
|
||||
};
|
||||
}
|
||||
|
||||
public static getAppVideoConference(): AppVideoConference {
|
||||
return {
|
||||
rid: 'roomId',
|
||||
createdBy: 'userId',
|
||||
title: 'Video Conference',
|
||||
providerName: 'test',
|
||||
};
|
||||
}
|
||||
|
||||
public static getVideoConference(): VideoConference {
|
||||
return {
|
||||
_id: 'first-call',
|
||||
_updatedAt: new Date(),
|
||||
type: 'videoconference',
|
||||
rid: 'roomId',
|
||||
users: [
|
||||
{
|
||||
_id: 'johnId',
|
||||
name: 'John Doe',
|
||||
username: 'mrdoe',
|
||||
ts: new Date(),
|
||||
},
|
||||
{
|
||||
_id: 'janeId',
|
||||
name: 'Jane Doe',
|
||||
username: 'msdoe',
|
||||
ts: new Date(),
|
||||
},
|
||||
],
|
||||
status: VideoConferenceStatus.STARTED,
|
||||
messages: {
|
||||
started: 'messageId',
|
||||
},
|
||||
url: 'video-conf/first-call',
|
||||
createdBy: {
|
||||
_id: 'johnId',
|
||||
name: 'John Doe',
|
||||
username: 'mrdoe',
|
||||
},
|
||||
createdAt: new Date(),
|
||||
title: 'Video Conference',
|
||||
anonymousUsers: 0,
|
||||
providerName: 'test',
|
||||
};
|
||||
}
|
||||
|
||||
public static getOutboundPhoneMessageProvider(name = 'Test Phone Provider'): IOutboundPhoneMessageProvider {
|
||||
return {
|
||||
type: 'phone',
|
||||
appId: `${name}-app-id`,
|
||||
name,
|
||||
supportsTemplates: true,
|
||||
documentationUrl: 'https://rocket.chat',
|
||||
sendOutboundMessage: async (message): Promise<void> => {
|
||||
console.log('Sending message', message);
|
||||
},
|
||||
getProviderMetadata: async (): Promise<ProviderMetadata> => {
|
||||
return {} as ProviderMetadata;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public static getOutboundEmailMessageProvider(name = 'Test Email Provider'): IOutboundEmailMessageProvider {
|
||||
return {
|
||||
type: 'email',
|
||||
appId: `${name}-app-id`,
|
||||
name,
|
||||
supportsTemplates: true,
|
||||
documentationUrl: 'https://rocket.chat',
|
||||
sendOutboundMessage: async (message): Promise<void> => {
|
||||
console.log('Sending message', message);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public static getOutboundMessage(): IOutboundMessage {
|
||||
return {
|
||||
to: '+123456789',
|
||||
type: 'template',
|
||||
templateProviderPhoneNumber: '+123456789',
|
||||
agentId: 'agent-id',
|
||||
departmentId: 'department-id',
|
||||
template: {
|
||||
name: 'template-name',
|
||||
language: {
|
||||
code: 'en',
|
||||
policy: 'deterministic',
|
||||
},
|
||||
components: [
|
||||
{
|
||||
type: 'body',
|
||||
parameters: [
|
||||
{
|
||||
type: 'text',
|
||||
text: 'Sample text',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
namespace: 'template-namespace',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public static getOAuthApp(isToCreate: boolean) {
|
||||
const OAuthApp = {
|
||||
_id: '4526fcab-b068-4dcc-b208-4fff599165b0',
|
||||
name: 'name-test',
|
||||
active: true,
|
||||
clientId: 'clientId-test',
|
||||
clientSecret: 'clientSecret-test',
|
||||
redirectUri: 'redirectUri-test',
|
||||
appId: 'app-123',
|
||||
_createdAt: '2022-07-11T14:30:48.937Z',
|
||||
_createdBy: {
|
||||
_id: 'Em5TQwMD4P7AmTs73',
|
||||
username: 'testa.bot',
|
||||
},
|
||||
_updatedAt: '2022-07-11T14:30:48.937Z',
|
||||
};
|
||||
|
||||
if (isToCreate) {
|
||||
delete OAuthApp._id;
|
||||
delete OAuthApp._createdAt;
|
||||
delete OAuthApp._createdBy;
|
||||
delete OAuthApp._updatedAt;
|
||||
delete OAuthApp.appId;
|
||||
}
|
||||
return OAuthApp;
|
||||
}
|
||||
|
||||
public static getMockRuntimeController(id: string): IRuntimeController {
|
||||
const mock = {
|
||||
getStatus: () => Promise.resolve(AppStatus.AUTO_ENABLED),
|
||||
sendRequest: () => Promise.resolve(undefined),
|
||||
setupApp: () => Promise.resolve(),
|
||||
stopApp: () => Promise.resolve(),
|
||||
getAppId: () => id,
|
||||
on: () => mock,
|
||||
once: () => mock,
|
||||
off: () => mock,
|
||||
emit: () => true,
|
||||
addListener: () => mock,
|
||||
removeListener: () => mock,
|
||||
removeAllListeners: () => mock,
|
||||
setMaxListeners: () => mock,
|
||||
getMaxListeners: () => 10,
|
||||
listeners: () => [],
|
||||
rawListeners: () => [],
|
||||
listenerCount: () => 0,
|
||||
prependListener: () => mock,
|
||||
prependOnceListener: () => mock,
|
||||
eventNames: () => [],
|
||||
} as IRuntimeController;
|
||||
|
||||
return mock;
|
||||
}
|
||||
|
||||
public static getMockApp(storageItem: Partial<IAppStorageItem>, manager: AppManager): ProxiedApp {
|
||||
const { id, name } = storageItem.info || { id: 'test-app', name: 'Test App' };
|
||||
|
||||
return new ProxiedApp(
|
||||
manager,
|
||||
{ id, status: AppStatus.AUTO_ENABLED, info: { id, name }, ...storageItem } as IAppStorageItem,
|
||||
TestData.getMockRuntimeController(id),
|
||||
);
|
||||
}
|
||||
|
||||
public static getMarketplaceSubscriptionInfo(overrides: Partial<IMarketplaceSubscriptionInfo> = {}): IMarketplaceSubscriptionInfo {
|
||||
return {
|
||||
seats: 10,
|
||||
maxSeats: 100,
|
||||
startDate: '2023-01-01',
|
||||
periodEnd: '2023-12-31',
|
||||
isSubscripbedViaBundle: false,
|
||||
typeOf: MarketplaceSubscriptionType.SubscriptionTypeApp,
|
||||
status: MarketplaceSubscriptionStatus.PurchaseSubscriptionStatusActive,
|
||||
license: {
|
||||
license: 'encrypted-license-data',
|
||||
version: 1,
|
||||
expireDate: new Date('2023-01-01'),
|
||||
},
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
public static getMarketplaceInfo(overrides: Partial<IMarketplaceInfo> = {}): IMarketplaceInfo {
|
||||
return {
|
||||
id: 'test-app',
|
||||
name: 'Test App',
|
||||
nameSlug: 'test-app',
|
||||
version: '1.0.0',
|
||||
description: 'Test app',
|
||||
author: { name: 'Test Author', support: 'https://test.com', homepage: 'https://test.com' },
|
||||
permissions: [],
|
||||
requiredApiVersion: '1.0.0',
|
||||
classFile: 'main.js',
|
||||
iconFile: 'icon.png',
|
||||
implements: [],
|
||||
categories: [],
|
||||
status: 'active',
|
||||
isVisible: true,
|
||||
isPurchased: false,
|
||||
isSubscribed: false,
|
||||
isBundled: false,
|
||||
createdDate: '2023-01-01',
|
||||
modifiedDate: '2023-01-01',
|
||||
price: 0,
|
||||
purchaseType: MarketplacePurchaseType.PurchaseTypeSubscription,
|
||||
subscriptionInfo: TestData.getMarketplaceSubscriptionInfo(),
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
public static getAppStorageItem(overrides: Partial<IAppStorageItem> = {}): IAppStorageItem {
|
||||
return {
|
||||
id: 'test-app',
|
||||
status: AppStatus.AUTO_ENABLED,
|
||||
info: {
|
||||
id: 'test-app',
|
||||
name: 'Test App',
|
||||
nameSlug: 'test-app',
|
||||
version: '1.0.0',
|
||||
description: 'Test app',
|
||||
author: { name: 'Test Author', support: 'https://test.com', homepage: 'https://test.com' },
|
||||
permissions: [],
|
||||
requiredApiVersion: '1.0.0',
|
||||
classFile: 'main.js',
|
||||
iconFile: 'icon.png',
|
||||
implements: [],
|
||||
},
|
||||
marketplaceInfo: [TestData.getMarketplaceInfo()],
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
installationSource: AppInstallationSource.MARKETPLACE,
|
||||
languageContent: {},
|
||||
settings: {},
|
||||
implemented: {},
|
||||
signature: 'default-signature',
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
public static getAppsOverview(subscriptionInfo?: IMarketplaceSubscriptionInfo): Array<{ latest: IMarketplaceInfo }> {
|
||||
return [
|
||||
{
|
||||
latest: TestData.getMarketplaceInfo({
|
||||
subscriptionInfo: subscriptionInfo || TestData.getMarketplaceSubscriptionInfo(),
|
||||
}),
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
export class SimpleClass {
|
||||
private readonly world: string;
|
||||
|
||||
constructor(world = 'Earith') {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public getWorld(): string {
|
||||
return this.world;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user