import { AutumnDBSession, testUtils as autumndbTestUtils, Contract, LinkContract } from 'autumndb'; import { Worker } from '.'; import { ActionDefinition, PluginDefinition } from './plugin'; import { Action, ActionRequestContract, Map } from './types'; /** * Context that can be used in tests against the worker. */ export interface TestContext extends autumndbTestUtils.TestContext { actor: string; dequeue: (times?: number) => Promise; worker: Worker; adminUserId: string; actionLibrary: Map; flush: (session: AutumnDBSession) => Promise; flushAll: (session: AutumnDBSession) => Promise; waitForMatch: (query: any, times?: number) => Promise; processAction: (session: AutumnDBSession, action: any) => Promise; createEvent: (actor: string, session: AutumnDBSession, target: Contract, body: string, type: string) => Promise; createLinkThroughWorker: (actor: string, session: AutumnDBSession, fromContract: Contract, toContract: Contract, verb: string, inverseVerb: string) => Promise; createContract: (actor: string, session: AutumnDBSession, type: string, name: string | null, data: any, markers?: any) => Promise; createSupportThread: (actor: string, session: AutumnDBSession, name: string | null, data: any, markers?: any) => Promise; createMessage: (actor: string, session: AutumnDBSession, target: Contract, body: string) => Promise; createWhisper: (actor: string, session: AutumnDBSession, target: Contract, body: string) => Promise; } /** * Options accepted by `newContext`. */ export interface NewContextOptions extends autumndbTestUtils.NewContextOptions { /** * Set of plugins needed to run tests. */ plugins?: PluginDefinition[]; actions?: ActionDefinition[]; } /** * Create a new `TestContext` with an initialized worker. */ export declare const newContext: (options?: NewContextOptions) => Promise; /** * Deinitialize the worker. */ export declare const destroyContext: (context: TestContext) => Promise; interface Variation { name: string; combination: any[]; } export declare const tailSort: ((contract: Contract) => unknown)[]; /** * @summary Get the different variations for a given sequence * @function * * @param sequence * @param options * @returns */ export declare function getVariations(sequence: any, options: any): Variation[]; /** * @summary Tasks to be executed before all translate tests * @function * * @param context - test context */ export declare function translateBeforeAll(context: TestContext): Promise; /** * @summary Tasks to be executed after each translate test * @function * * @param context - test context */ export declare function translateAfterEach(context: TestContext): Promise; /** * @summary Tasks to be executed after all translate tests * @function */ export declare function translateAfterAll(): void; /** * Simulate a webhook against a nocked endpoint and check * translate results against expected values. * * @param context - test context * @param testCase - test case * @param options - test options */ export declare function webhookScenario(context: TestContext, testCase: { steps: any[]; prepareEvent: (event: any) => Promise; offset: number; headIndex: number; original: any[]; ignoreUpdateEvents: boolean; expected: any; name: string; variant: string; }, options: { source: string; baseUrl: string | RegExp; uriPath: RegExp; basePath: string; isAuthorized: (request: any) => any; head?: { ignore: { [key: string]: string[]; }; }; }): Promise; export {};