@sprucelabs/spruce-test-fixtures 52.1.4 → 52.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/.spruce/errors/options.types.d.ts +1 -1
- package/build/ClientProxyDecorator.d.ts +1 -1
- package/build/__tests__/behavioral/DummyStore.d.ts +1 -1
- package/build/__tests__/support/FakeThemeManager.d.ts +1 -1
- package/build/__tests__/test.types.d.ts +1 -1
- package/build/__tests__/testDirsAndFiles/one-good-store-skill/build/stores/Good.store.d.ts +1 -1
- package/build/esm/.spruce/errors/options.types.d.ts +1 -1
- package/build/esm/ClientProxyDecorator.d.ts +1 -1
- package/build/esm/__tests__/behavioral/DummyStore.d.ts +1 -1
- package/build/esm/__tests__/support/FakeThemeManager.d.ts +1 -1
- package/build/esm/__tests__/test.types.d.ts +1 -1
- package/build/esm/__tests__/testDirsAndFiles/one-good-store-skill/build/stores/Good.store.d.ts +1 -1
- package/build/esm/tests/AbstractSpruceFixtureTest.d.ts +4 -4
- package/build/esm/tests/decorators/fake.d.ts +3 -3
- package/build/esm/tests/decorators/login.d.ts +1 -1
- package/build/esm/tests/decorators/seed.d.ts +4 -4
- package/build/esm/tests/eventFaker.d.ts +3 -3
- package/build/esm/tests/fixtures/MercuryFixture.js +12 -12
- package/build/esm/tests/fixtures/PersonFixture.d.ts +4 -4
- package/build/esm/tests/fixtures/RoleFixture.d.ts +1 -1
- package/build/esm/tests/fixtures/SeedFixture.d.ts +1 -1
- package/build/esm/tests/fixtures/SkillFixture.d.ts +3 -3
- package/build/esm/tests/fixtures/ViewFixture.d.ts +2 -2
- package/build/esm/tests/fixtures/ViewFixture.js +6 -6
- package/build/esm/tests/routers/TestRouter.d.ts +1 -1
- package/build/esm/tests/routers/TestRouter.js +3 -3
- package/build/esm/types/fixture.types.d.ts +6 -6
- package/build/esm/types/view.types.d.ts +1 -1
- package/build/esm/utilities/SpyMapUtil.d.ts +1 -1
- package/build/tests/AbstractSpruceFixtureTest.d.ts +4 -4
- package/build/tests/decorators/fake.d.ts +3 -3
- package/build/tests/decorators/login.d.ts +1 -1
- package/build/tests/decorators/seed.d.ts +4 -4
- package/build/tests/eventFaker.d.ts +3 -3
- package/build/tests/fixtures/MercuryFixture.js +12 -12
- package/build/tests/fixtures/PersonFixture.d.ts +4 -4
- package/build/tests/fixtures/RoleFixture.d.ts +1 -1
- package/build/tests/fixtures/SeedFixture.d.ts +1 -1
- package/build/tests/fixtures/SkillFixture.d.ts +3 -3
- package/build/tests/fixtures/ViewFixture.d.ts +2 -2
- package/build/tests/fixtures/ViewFixture.js +6 -6
- package/build/tests/routers/TestRouter.d.ts +1 -1
- package/build/tests/routers/TestRouter.js +3 -3
- package/build/types/fixture.types.d.ts +6 -6
- package/build/types/view.types.d.ts +1 -1
- package/build/utilities/SpyMapUtil.d.ts +1 -1
- package/package.json +17 -17
|
@@ -24,5 +24,5 @@ export interface InvalidFixtureErrorOptions extends SpruceErrors.SpruceTestFixtu
|
|
|
24
24
|
export interface FakeEventErrorErrorOptions extends SpruceErrors.SpruceTestFixtures.FakeEventError, ISpruceErrorOptions {
|
|
25
25
|
code: 'FAKE_EVENT_ERROR';
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
type ErrorOptions = UnknownViewControllerErrorErrorOptions | SkillNotFoundErrorOptions | ScopeRequirementsNotMetErrorOptions | NotFoundErrorOptions | InvalidViewControllerErrorOptions | InvalidTargetErrorOptions | InvalidFixtureErrorOptions | FakeEventErrorErrorOptions;
|
|
28
28
|
export default ErrorOptions;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
2
|
-
export
|
|
2
|
+
export type TokenGenerator = () => undefined | string | Promise<string | undefined>;
|
|
3
3
|
export default class ClientProxyDecorator {
|
|
4
4
|
private static instance?;
|
|
5
5
|
private proxyTokenGenerator?;
|
|
@@ -9,7 +9,7 @@ declare const dummySchema: {
|
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
type DummySchema = typeof dummySchema;
|
|
13
13
|
export declare class DummyStore extends AbstractStore<DummySchema> {
|
|
14
14
|
name: string;
|
|
15
15
|
protected collectionName: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SpruceSchemas, ThemeManager } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
-
|
|
2
|
+
type Theme = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Theme;
|
|
3
3
|
export default class FakeThemeManager implements ThemeManager {
|
|
4
4
|
private theme;
|
|
5
5
|
setTheme(theme: Theme): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
2
|
-
export
|
|
2
|
+
export type Organization = SpruceSchemas.Spruce.v2020_07_22.Organization;
|
|
@@ -24,5 +24,5 @@ export interface InvalidFixtureErrorOptions extends SpruceErrors.SpruceTestFixtu
|
|
|
24
24
|
export interface FakeEventErrorErrorOptions extends SpruceErrors.SpruceTestFixtures.FakeEventError, ISpruceErrorOptions {
|
|
25
25
|
code: 'FAKE_EVENT_ERROR';
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
type ErrorOptions = UnknownViewControllerErrorErrorOptions | SkillNotFoundErrorOptions | ScopeRequirementsNotMetErrorOptions | NotFoundErrorOptions | InvalidViewControllerErrorOptions | InvalidTargetErrorOptions | InvalidFixtureErrorOptions | FakeEventErrorErrorOptions;
|
|
28
28
|
export default ErrorOptions;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
2
|
-
export
|
|
2
|
+
export type TokenGenerator = () => undefined | string | Promise<string | undefined>;
|
|
3
3
|
export default class ClientProxyDecorator {
|
|
4
4
|
private static instance?;
|
|
5
5
|
private proxyTokenGenerator?;
|
|
@@ -9,7 +9,7 @@ declare const dummySchema: {
|
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
type DummySchema = typeof dummySchema;
|
|
13
13
|
export declare class DummyStore extends AbstractStore<DummySchema> {
|
|
14
14
|
name: string;
|
|
15
15
|
protected collectionName: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SpruceSchemas, ThemeManager } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
-
|
|
2
|
+
type Theme = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Theme;
|
|
3
3
|
export default class FakeThemeManager implements ThemeManager {
|
|
4
4
|
private theme;
|
|
5
5
|
setTheme(theme: Theme): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
2
|
-
export
|
|
2
|
+
export type Organization = SpruceSchemas.Spruce.v2020_07_22.Organization;
|
|
@@ -12,10 +12,10 @@ import SeedFixture from './fixtures/SeedFixture';
|
|
|
12
12
|
import SkillFixture from './fixtures/SkillFixture';
|
|
13
13
|
import StoreFixture from './fixtures/StoreFixture';
|
|
14
14
|
import ViewFixture from './fixtures/ViewFixture';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
|
|
16
|
+
type Role = SpruceSchemas.Spruce.v2020_07_22.Role;
|
|
17
|
+
type Skill = SpruceSchemas.Spruce.v2020_07_22.Skill;
|
|
18
|
+
type Organization = SpruceSchemas.Spruce.v2020_07_22.Organization;
|
|
19
19
|
export default abstract class AbstractSpruceFixtureTest extends AbstractSkillTest {
|
|
20
20
|
static fakedPerson: Person;
|
|
21
21
|
static fakedClient: MercuryClient;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
2
2
|
import { SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
3
3
|
import { CoreSeedTarget } from './seed';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
|
|
5
|
+
type Skill = SpruceSchemas.Spruce.v2020_07_22.Skill;
|
|
6
6
|
/** @ts-ignore */
|
|
7
|
-
|
|
7
|
+
type Client = MercuryClient;
|
|
8
8
|
interface ClassWithFakes {
|
|
9
9
|
fakedOwners?: Person[];
|
|
10
10
|
fakedTeammates?: Person[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
2
2
|
import { SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
3
|
-
|
|
3
|
+
type Client = MercuryClient;
|
|
4
4
|
declare function login(phone: string): (Class: any) => void;
|
|
5
5
|
declare namespace login {
|
|
6
6
|
var getClient: () => Client;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { StoreName } from '@sprucelabs/data-stores';
|
|
2
2
|
import { EMPLOYED_BASE_ROLES, GUEST_BASE_ROLES } from '@sprucelabs/spruce-core-schemas';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
3
|
+
type EMPLOYED = typeof EMPLOYED_BASE_ROLES;
|
|
4
|
+
type GUEST = typeof GUEST_BASE_ROLES;
|
|
5
|
+
export type CoreSeedTarget = 'organizations' | 'locations' | `${EMPLOYED[number]['slug']}s` | `${GUEST[number]['slug']}s`;
|
|
6
|
+
type SeedTarget = CoreSeedTarget | StoreName;
|
|
7
7
|
declare function seed(storeName: SeedTarget, totalToSeed?: number, ...params: any[]): (Class: any, key: string, descriptor: any) => void;
|
|
8
8
|
declare namespace seed {
|
|
9
9
|
var disableResettingTestClient: () => void;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SkillEventContract } from '@sprucelabs/mercury-types';
|
|
2
2
|
import { SchemaValues } from '@sprucelabs/schema';
|
|
3
3
|
/** @ts-ignore */
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type Fqen = keyof SkillEventContract['eventSignatures'];
|
|
5
|
+
type TargetAndPayload<E extends Fqen> = SchemaValues<
|
|
6
6
|
/** @ts-ignore */
|
|
7
7
|
SkillEventContract['eventSignatures'][E]['emitPayloadSchema']>;
|
|
8
|
-
|
|
8
|
+
type Response<E extends Fqen> = SchemaValues<
|
|
9
9
|
/** @ts-ignore> */
|
|
10
10
|
SkillEventContract['eventSignatures'][E]['responsePayloadSchema']>;
|
|
11
11
|
declare const eventFaker: {
|
|
@@ -18,18 +18,6 @@ const env = require('dotenv');
|
|
|
18
18
|
env.config();
|
|
19
19
|
const TEST_HOST = (_a = process.env.TEST_HOST) !== null && _a !== void 0 ? _a : process.env.HOST;
|
|
20
20
|
export default class MercuryFixture {
|
|
21
|
-
constructor(cwd) {
|
|
22
|
-
this.clientPromises = [];
|
|
23
|
-
this.cwd = cwd;
|
|
24
|
-
if (!this.cwd) {
|
|
25
|
-
throw new SchemaError({
|
|
26
|
-
code: 'MISSING_PARAMETERS',
|
|
27
|
-
friendlyMessage: 'Mercury fixture needs cwd.',
|
|
28
|
-
parameters: ['options.cwd'],
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
this.connectToApi = this.connectToApi.bind(this);
|
|
32
|
-
}
|
|
33
21
|
static setDefaultClient(client) {
|
|
34
22
|
//@ts-ignore
|
|
35
23
|
client.shouldDestroy = this.shouldAutomaticallyClearDefaultClient;
|
|
@@ -44,6 +32,18 @@ export default class MercuryFixture {
|
|
|
44
32
|
static setShouldAutomaticallyClearDefaultClient(shouldClear) {
|
|
45
33
|
this.shouldAutomaticallyClearDefaultClient = shouldClear;
|
|
46
34
|
}
|
|
35
|
+
constructor(cwd) {
|
|
36
|
+
this.clientPromises = [];
|
|
37
|
+
this.cwd = cwd;
|
|
38
|
+
if (!this.cwd) {
|
|
39
|
+
throw new SchemaError({
|
|
40
|
+
code: 'MISSING_PARAMETERS',
|
|
41
|
+
friendlyMessage: 'Mercury fixture needs cwd.',
|
|
42
|
+
parameters: ['options.cwd'],
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
this.connectToApi = this.connectToApi.bind(this);
|
|
46
|
+
}
|
|
47
47
|
connectToApi(options) {
|
|
48
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
49
|
const shouldReUseClient = (options === null || options === void 0 ? void 0 : options.shouldReUseClient) !== false;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
2
2
|
import { SpruceSchemas } from '@sprucelabs/spruce-core-schemas';
|
|
3
3
|
import { TestConnectFactory } from '../../types/fixture.types';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
|
|
5
|
+
type Factory = TestConnectFactory;
|
|
6
|
+
type ClientPromise = ReturnType<Factory>;
|
|
7
|
+
type Client = ClientPromise extends PromiseLike<infer C> ? C : ClientPromise;
|
|
8
8
|
export default class PersonFixture {
|
|
9
9
|
private connectToApi;
|
|
10
10
|
private lastLoggedIn?;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
2
2
|
import PersonFixture from './PersonFixture';
|
|
3
|
-
|
|
3
|
+
type GetNewestOrgHandler = () => Promise<SpruceSchemas.Spruce.v2020_07_22.Organization | null>;
|
|
4
4
|
export default class RoleFixture {
|
|
5
5
|
private personFixture;
|
|
6
6
|
private getNewestOrgHandler;
|
|
@@ -2,7 +2,7 @@ import { SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
|
2
2
|
import LocationFixture from './LocationFixture';
|
|
3
3
|
import OrganizationFixture from './OrganizationFixture';
|
|
4
4
|
import PersonFixture from './PersonFixture';
|
|
5
|
-
|
|
5
|
+
type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
|
|
6
6
|
export interface SeedLocationOptions {
|
|
7
7
|
totalLocations: number;
|
|
8
8
|
organizationId?: string;
|
|
@@ -2,9 +2,9 @@ import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
|
2
2
|
import { SpruceSchemas } from '@sprucelabs/spruce-core-schemas';
|
|
3
3
|
import { TestConnectFactory } from '../../types/fixture.types';
|
|
4
4
|
import PersonFixture from './PersonFixture';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type Skill = SpruceSchemas.Spruce.v2020_07_22.Skill;
|
|
6
|
+
type Factory = TestConnectFactory;
|
|
7
|
+
type Client = MercuryClient;
|
|
8
8
|
export interface SeedDemoSkillValues {
|
|
9
9
|
name?: string;
|
|
10
10
|
slug?: string;
|
|
@@ -11,8 +11,8 @@ import SpyAuthorizer from '../SpyAuthorizer';
|
|
|
11
11
|
import FixtureFactory from './FixtureFactory';
|
|
12
12
|
import PersonFixture from './PersonFixture';
|
|
13
13
|
import SpyScope from './SpyScope';
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
type Factory = TestConnectFactory;
|
|
15
|
+
type Client = MercuryClient;
|
|
16
16
|
export default class ViewFixture {
|
|
17
17
|
private static vcFactory?;
|
|
18
18
|
private static loggedInPersonProxyTokens;
|
|
@@ -20,6 +20,12 @@ import TestRouter from '../routers/TestRouter.js';
|
|
|
20
20
|
import SpyAuthorizer from '../SpyAuthorizer.js';
|
|
21
21
|
import SpyScope from './SpyScope.js';
|
|
22
22
|
export default class ViewFixture {
|
|
23
|
+
static lockProxyCacheForPerson(id) {
|
|
24
|
+
this.dontResetProxyTokenForPersonId = id;
|
|
25
|
+
}
|
|
26
|
+
static setShouldAutomaticallyResetAuth(shouldReset) {
|
|
27
|
+
this.shouldAutomaticallyResetAuthenticator = shouldReset;
|
|
28
|
+
}
|
|
23
29
|
constructor(options) {
|
|
24
30
|
var _a, _b;
|
|
25
31
|
this.connectToApi = options.connectToApi;
|
|
@@ -38,12 +44,6 @@ export default class ViewFixture {
|
|
|
38
44
|
organizations: this.orgs,
|
|
39
45
|
});
|
|
40
46
|
}
|
|
41
|
-
static lockProxyCacheForPerson(id) {
|
|
42
|
-
this.dontResetProxyTokenForPersonId = id;
|
|
43
|
-
}
|
|
44
|
-
static setShouldAutomaticallyResetAuth(shouldReset) {
|
|
45
|
-
this.shouldAutomaticallyResetAuthenticator = shouldReset;
|
|
46
|
-
}
|
|
47
47
|
getFactory() {
|
|
48
48
|
return ViewFixture.getSharedFactory({
|
|
49
49
|
namespace: this.namespace,
|
|
@@ -10,7 +10,7 @@ declare const contract: {
|
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
type Contract = typeof contract;
|
|
14
14
|
export default class TestRouter extends AbstractEventEmitter<Contract> implements Router, MercuryEventEmitter<Contract> {
|
|
15
15
|
private vcFactory;
|
|
16
16
|
private presentVc?;
|
|
@@ -21,6 +21,9 @@ const contract = buildEventContract({
|
|
|
21
21
|
},
|
|
22
22
|
});
|
|
23
23
|
export default class TestRouter extends AbstractEventEmitter {
|
|
24
|
+
static setShouldThrowWhenRedirectingToBadSvc(shouldThrow) {
|
|
25
|
+
this.shouldThrowWhenRedirectingToBadSvc = shouldThrow;
|
|
26
|
+
}
|
|
24
27
|
constructor(options) {
|
|
25
28
|
super(contract);
|
|
26
29
|
this.themes = new FakeThemeManager();
|
|
@@ -28,9 +31,6 @@ export default class TestRouter extends AbstractEventEmitter {
|
|
|
28
31
|
this.scope = options.scope;
|
|
29
32
|
this.locale = options.locale;
|
|
30
33
|
}
|
|
31
|
-
static setShouldThrowWhenRedirectingToBadSvc(shouldThrow) {
|
|
32
|
-
this.shouldThrowWhenRedirectingToBadSvc = shouldThrow;
|
|
33
|
-
}
|
|
34
34
|
static setShouldLoadDestinationVc(shouldLoad) {
|
|
35
35
|
this.shouldLoadDestinationVc = shouldLoad;
|
|
36
36
|
}
|
|
@@ -14,8 +14,8 @@ import ViewFixture from '../tests/fixtures/ViewFixture';
|
|
|
14
14
|
export interface TestConnectionOptions {
|
|
15
15
|
shouldReUseClient?: boolean;
|
|
16
16
|
}
|
|
17
|
-
export
|
|
18
|
-
export
|
|
17
|
+
export type ConnectOptions = TestConnectionOptions & ConnectionOptions;
|
|
18
|
+
export type TestConnectFactory = (options?: ConnectOptions) => Promise<MercuryClient>;
|
|
19
19
|
export interface FixtureClassMap {
|
|
20
20
|
person: typeof PersonFixture;
|
|
21
21
|
organization: typeof OrganizationFixture;
|
|
@@ -28,14 +28,14 @@ export interface FixtureClassMap {
|
|
|
28
28
|
role: typeof RoleFixture;
|
|
29
29
|
seed: typeof SeedFixture;
|
|
30
30
|
}
|
|
31
|
-
export
|
|
32
|
-
export
|
|
31
|
+
export type RoleBase = NonNullable<SpruceSchemas.Spruce.v2020_07_22.Role['base']>;
|
|
32
|
+
export type FixtureMap = {
|
|
33
33
|
[K in keyof FixtureClassMap]: InstanceType<FixtureClassMap[K]>;
|
|
34
34
|
};
|
|
35
|
-
export
|
|
35
|
+
export type FixtureConstructorOptionsMap = {
|
|
36
36
|
[K in keyof FixtureClassMap]: ConstructorParameters<FixtureClassMap[K]>[0];
|
|
37
37
|
};
|
|
38
|
-
export
|
|
38
|
+
export type FixtureName = keyof FixtureMap;
|
|
39
39
|
declare module '@sprucelabs/heartwood-view-controllers/build/types/heartwood.types' {
|
|
40
40
|
interface SkillViewControllerMap {
|
|
41
41
|
'heartwood.root': FakeSkillViewController;
|
|
@@ -9,7 +9,7 @@ export interface ViewHealthCheckItem extends HealthCheckItem {
|
|
|
9
9
|
viewControllers: HealthCheckView[];
|
|
10
10
|
skillViewControllers: HealthCheckView[];
|
|
11
11
|
}
|
|
12
|
-
export
|
|
12
|
+
export type ArgsFromSvc<T> = T extends SkillViewController<infer R> ? R : Record<string, any>;
|
|
13
13
|
declare module '@sprucelabs/spruce-skill-utils/build/types/skill.types' {
|
|
14
14
|
interface HealthCheckResults {
|
|
15
15
|
view?: ViewHealthCheckItem;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MapUtil, OpenNavigationOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
-
export
|
|
2
|
+
export type SpyMapUtil = MapUtil & {
|
|
3
3
|
lastOpenNavigationOptions: OpenNavigationOptions | undefined;
|
|
4
4
|
};
|
|
5
5
|
declare const spyMapUtil: SpyMapUtil;
|
|
@@ -12,10 +12,10 @@ import SeedFixture from './fixtures/SeedFixture';
|
|
|
12
12
|
import SkillFixture from './fixtures/SkillFixture';
|
|
13
13
|
import StoreFixture from './fixtures/StoreFixture';
|
|
14
14
|
import ViewFixture from './fixtures/ViewFixture';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
|
|
16
|
+
type Role = SpruceSchemas.Spruce.v2020_07_22.Role;
|
|
17
|
+
type Skill = SpruceSchemas.Spruce.v2020_07_22.Skill;
|
|
18
|
+
type Organization = SpruceSchemas.Spruce.v2020_07_22.Organization;
|
|
19
19
|
export default abstract class AbstractSpruceFixtureTest extends AbstractSkillTest {
|
|
20
20
|
static fakedPerson: Person;
|
|
21
21
|
static fakedClient: MercuryClient;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
2
2
|
import { SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
3
3
|
import { CoreSeedTarget } from './seed';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
|
|
5
|
+
type Skill = SpruceSchemas.Spruce.v2020_07_22.Skill;
|
|
6
6
|
/** @ts-ignore */
|
|
7
|
-
|
|
7
|
+
type Client = MercuryClient;
|
|
8
8
|
interface ClassWithFakes {
|
|
9
9
|
fakedOwners?: Person[];
|
|
10
10
|
fakedTeammates?: Person[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
2
2
|
import { SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
3
|
-
|
|
3
|
+
type Client = MercuryClient;
|
|
4
4
|
declare function login(phone: string): (Class: any) => void;
|
|
5
5
|
declare namespace login {
|
|
6
6
|
var getClient: () => Client;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { StoreName } from '@sprucelabs/data-stores';
|
|
2
2
|
import { EMPLOYED_BASE_ROLES, GUEST_BASE_ROLES } from '@sprucelabs/spruce-core-schemas';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
3
|
+
type EMPLOYED = typeof EMPLOYED_BASE_ROLES;
|
|
4
|
+
type GUEST = typeof GUEST_BASE_ROLES;
|
|
5
|
+
export type CoreSeedTarget = 'organizations' | 'locations' | `${EMPLOYED[number]['slug']}s` | `${GUEST[number]['slug']}s`;
|
|
6
|
+
type SeedTarget = CoreSeedTarget | StoreName;
|
|
7
7
|
declare function seed(storeName: SeedTarget, totalToSeed?: number, ...params: any[]): (Class: any, key: string, descriptor: any) => void;
|
|
8
8
|
declare namespace seed {
|
|
9
9
|
var disableResettingTestClient: () => void;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SkillEventContract } from '@sprucelabs/mercury-types';
|
|
2
2
|
import { SchemaValues } from '@sprucelabs/schema';
|
|
3
3
|
/** @ts-ignore */
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type Fqen = keyof SkillEventContract['eventSignatures'];
|
|
5
|
+
type TargetAndPayload<E extends Fqen> = SchemaValues<
|
|
6
6
|
/** @ts-ignore */
|
|
7
7
|
SkillEventContract['eventSignatures'][E]['emitPayloadSchema']>;
|
|
8
|
-
|
|
8
|
+
type Response<E extends Fqen> = SchemaValues<
|
|
9
9
|
/** @ts-ignore> */
|
|
10
10
|
SkillEventContract['eventSignatures'][E]['responsePayloadSchema']>;
|
|
11
11
|
declare const eventFaker: {
|
|
@@ -11,18 +11,6 @@ const env = require('dotenv');
|
|
|
11
11
|
env.config();
|
|
12
12
|
const TEST_HOST = (_a = process.env.TEST_HOST) !== null && _a !== void 0 ? _a : process.env.HOST;
|
|
13
13
|
class MercuryFixture {
|
|
14
|
-
constructor(cwd) {
|
|
15
|
-
this.clientPromises = [];
|
|
16
|
-
this.cwd = cwd;
|
|
17
|
-
if (!this.cwd) {
|
|
18
|
-
throw new schema_1.SchemaError({
|
|
19
|
-
code: 'MISSING_PARAMETERS',
|
|
20
|
-
friendlyMessage: 'Mercury fixture needs cwd.',
|
|
21
|
-
parameters: ['options.cwd'],
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
this.connectToApi = this.connectToApi.bind(this);
|
|
25
|
-
}
|
|
26
14
|
static setDefaultClient(client) {
|
|
27
15
|
//@ts-ignore
|
|
28
16
|
client.shouldDestroy = this.shouldAutomaticallyClearDefaultClient;
|
|
@@ -37,6 +25,18 @@ class MercuryFixture {
|
|
|
37
25
|
static setShouldAutomaticallyClearDefaultClient(shouldClear) {
|
|
38
26
|
this.shouldAutomaticallyClearDefaultClient = shouldClear;
|
|
39
27
|
}
|
|
28
|
+
constructor(cwd) {
|
|
29
|
+
this.clientPromises = [];
|
|
30
|
+
this.cwd = cwd;
|
|
31
|
+
if (!this.cwd) {
|
|
32
|
+
throw new schema_1.SchemaError({
|
|
33
|
+
code: 'MISSING_PARAMETERS',
|
|
34
|
+
friendlyMessage: 'Mercury fixture needs cwd.',
|
|
35
|
+
parameters: ['options.cwd'],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
this.connectToApi = this.connectToApi.bind(this);
|
|
39
|
+
}
|
|
40
40
|
async connectToApi(options) {
|
|
41
41
|
const shouldReUseClient = (options === null || options === void 0 ? void 0 : options.shouldReUseClient) !== false;
|
|
42
42
|
if (shouldReUseClient && MercuryFixture.defaultClient) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
2
2
|
import { SpruceSchemas } from '@sprucelabs/spruce-core-schemas';
|
|
3
3
|
import { TestConnectFactory } from '../../types/fixture.types';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
|
|
5
|
+
type Factory = TestConnectFactory;
|
|
6
|
+
type ClientPromise = ReturnType<Factory>;
|
|
7
|
+
type Client = ClientPromise extends PromiseLike<infer C> ? C : ClientPromise;
|
|
8
8
|
export default class PersonFixture {
|
|
9
9
|
private connectToApi;
|
|
10
10
|
private lastLoggedIn?;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
2
2
|
import PersonFixture from './PersonFixture';
|
|
3
|
-
|
|
3
|
+
type GetNewestOrgHandler = () => Promise<SpruceSchemas.Spruce.v2020_07_22.Organization | null>;
|
|
4
4
|
export default class RoleFixture {
|
|
5
5
|
private personFixture;
|
|
6
6
|
private getNewestOrgHandler;
|
|
@@ -2,7 +2,7 @@ import { SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
|
2
2
|
import LocationFixture from './LocationFixture';
|
|
3
3
|
import OrganizationFixture from './OrganizationFixture';
|
|
4
4
|
import PersonFixture from './PersonFixture';
|
|
5
|
-
|
|
5
|
+
type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
|
|
6
6
|
export interface SeedLocationOptions {
|
|
7
7
|
totalLocations: number;
|
|
8
8
|
organizationId?: string;
|
|
@@ -2,9 +2,9 @@ import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
|
2
2
|
import { SpruceSchemas } from '@sprucelabs/spruce-core-schemas';
|
|
3
3
|
import { TestConnectFactory } from '../../types/fixture.types';
|
|
4
4
|
import PersonFixture from './PersonFixture';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type Skill = SpruceSchemas.Spruce.v2020_07_22.Skill;
|
|
6
|
+
type Factory = TestConnectFactory;
|
|
7
|
+
type Client = MercuryClient;
|
|
8
8
|
export interface SeedDemoSkillValues {
|
|
9
9
|
name?: string;
|
|
10
10
|
slug?: string;
|
|
@@ -11,8 +11,8 @@ import SpyAuthorizer from '../SpyAuthorizer';
|
|
|
11
11
|
import FixtureFactory from './FixtureFactory';
|
|
12
12
|
import PersonFixture from './PersonFixture';
|
|
13
13
|
import SpyScope from './SpyScope';
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
type Factory = TestConnectFactory;
|
|
15
|
+
type Client = MercuryClient;
|
|
16
16
|
export default class ViewFixture {
|
|
17
17
|
private static vcFactory?;
|
|
18
18
|
private static loggedInPersonProxyTokens;
|
|
@@ -16,6 +16,12 @@ const TestRouter_1 = __importDefault(require("../routers/TestRouter"));
|
|
|
16
16
|
const SpyAuthorizer_1 = __importDefault(require("../SpyAuthorizer"));
|
|
17
17
|
const SpyScope_1 = __importDefault(require("./SpyScope"));
|
|
18
18
|
class ViewFixture {
|
|
19
|
+
static lockProxyCacheForPerson(id) {
|
|
20
|
+
this.dontResetProxyTokenForPersonId = id;
|
|
21
|
+
}
|
|
22
|
+
static setShouldAutomaticallyResetAuth(shouldReset) {
|
|
23
|
+
this.shouldAutomaticallyResetAuthenticator = shouldReset;
|
|
24
|
+
}
|
|
19
25
|
constructor(options) {
|
|
20
26
|
var _a, _b;
|
|
21
27
|
this.connectToApi = options.connectToApi;
|
|
@@ -34,12 +40,6 @@ class ViewFixture {
|
|
|
34
40
|
organizations: this.orgs,
|
|
35
41
|
});
|
|
36
42
|
}
|
|
37
|
-
static lockProxyCacheForPerson(id) {
|
|
38
|
-
this.dontResetProxyTokenForPersonId = id;
|
|
39
|
-
}
|
|
40
|
-
static setShouldAutomaticallyResetAuth(shouldReset) {
|
|
41
|
-
this.shouldAutomaticallyResetAuthenticator = shouldReset;
|
|
42
|
-
}
|
|
43
43
|
getFactory() {
|
|
44
44
|
return ViewFixture.getSharedFactory({
|
|
45
45
|
namespace: this.namespace,
|
|
@@ -10,7 +10,7 @@ declare const contract: {
|
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
type Contract = typeof contract;
|
|
14
14
|
export default class TestRouter extends AbstractEventEmitter<Contract> implements Router, MercuryEventEmitter<Contract> {
|
|
15
15
|
private vcFactory;
|
|
16
16
|
private presentVc?;
|
|
@@ -17,6 +17,9 @@ const contract = (0, mercury_types_1.buildEventContract)({
|
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
19
|
class TestRouter extends mercury_event_emitter_1.AbstractEventEmitter {
|
|
20
|
+
static setShouldThrowWhenRedirectingToBadSvc(shouldThrow) {
|
|
21
|
+
this.shouldThrowWhenRedirectingToBadSvc = shouldThrow;
|
|
22
|
+
}
|
|
20
23
|
constructor(options) {
|
|
21
24
|
super(contract);
|
|
22
25
|
this.themes = new FakeThemeManager_1.default();
|
|
@@ -24,9 +27,6 @@ class TestRouter extends mercury_event_emitter_1.AbstractEventEmitter {
|
|
|
24
27
|
this.scope = options.scope;
|
|
25
28
|
this.locale = options.locale;
|
|
26
29
|
}
|
|
27
|
-
static setShouldThrowWhenRedirectingToBadSvc(shouldThrow) {
|
|
28
|
-
this.shouldThrowWhenRedirectingToBadSvc = shouldThrow;
|
|
29
|
-
}
|
|
30
30
|
static setShouldLoadDestinationVc(shouldLoad) {
|
|
31
31
|
this.shouldLoadDestinationVc = shouldLoad;
|
|
32
32
|
}
|
|
@@ -14,8 +14,8 @@ import ViewFixture from '../tests/fixtures/ViewFixture';
|
|
|
14
14
|
export interface TestConnectionOptions {
|
|
15
15
|
shouldReUseClient?: boolean;
|
|
16
16
|
}
|
|
17
|
-
export
|
|
18
|
-
export
|
|
17
|
+
export type ConnectOptions = TestConnectionOptions & ConnectionOptions;
|
|
18
|
+
export type TestConnectFactory = (options?: ConnectOptions) => Promise<MercuryClient>;
|
|
19
19
|
export interface FixtureClassMap {
|
|
20
20
|
person: typeof PersonFixture;
|
|
21
21
|
organization: typeof OrganizationFixture;
|
|
@@ -28,14 +28,14 @@ export interface FixtureClassMap {
|
|
|
28
28
|
role: typeof RoleFixture;
|
|
29
29
|
seed: typeof SeedFixture;
|
|
30
30
|
}
|
|
31
|
-
export
|
|
32
|
-
export
|
|
31
|
+
export type RoleBase = NonNullable<SpruceSchemas.Spruce.v2020_07_22.Role['base']>;
|
|
32
|
+
export type FixtureMap = {
|
|
33
33
|
[K in keyof FixtureClassMap]: InstanceType<FixtureClassMap[K]>;
|
|
34
34
|
};
|
|
35
|
-
export
|
|
35
|
+
export type FixtureConstructorOptionsMap = {
|
|
36
36
|
[K in keyof FixtureClassMap]: ConstructorParameters<FixtureClassMap[K]>[0];
|
|
37
37
|
};
|
|
38
|
-
export
|
|
38
|
+
export type FixtureName = keyof FixtureMap;
|
|
39
39
|
declare module '@sprucelabs/heartwood-view-controllers/build/types/heartwood.types' {
|
|
40
40
|
interface SkillViewControllerMap {
|
|
41
41
|
'heartwood.root': FakeSkillViewController;
|
|
@@ -9,7 +9,7 @@ export interface ViewHealthCheckItem extends HealthCheckItem {
|
|
|
9
9
|
viewControllers: HealthCheckView[];
|
|
10
10
|
skillViewControllers: HealthCheckView[];
|
|
11
11
|
}
|
|
12
|
-
export
|
|
12
|
+
export type ArgsFromSvc<T> = T extends SkillViewController<infer R> ? R : Record<string, any>;
|
|
13
13
|
declare module '@sprucelabs/spruce-skill-utils/build/types/skill.types' {
|
|
14
14
|
interface HealthCheckResults {
|
|
15
15
|
view?: ViewHealthCheckItem;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MapUtil, OpenNavigationOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
-
export
|
|
2
|
+
export type SpyMapUtil = MapUtil & {
|
|
3
3
|
lastOpenNavigationOptions: OpenNavigationOptions | undefined;
|
|
4
4
|
};
|
|
5
5
|
declare const spyMapUtil: SpyMapUtil;
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@sprucelabs/spruce-test-fixtures"
|
|
14
14
|
]
|
|
15
15
|
},
|
|
16
|
-
"version": "52.1
|
|
16
|
+
"version": "52.2.1",
|
|
17
17
|
"files": [
|
|
18
18
|
"build/**/*",
|
|
19
19
|
"!build/__tests__",
|
|
@@ -63,28 +63,28 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@sprucelabs/data-stores": "^19.0.54",
|
|
66
|
-
"@sprucelabs/error": "^5.0.
|
|
67
|
-
"@sprucelabs/heartwood-view-controllers": "^98.1
|
|
66
|
+
"@sprucelabs/error": "^5.0.541",
|
|
67
|
+
"@sprucelabs/heartwood-view-controllers": "^98.2.1",
|
|
68
68
|
"@sprucelabs/mercury-client": "^34.0.49",
|
|
69
|
-
"@sprucelabs/mercury-core-events": "^15.0.
|
|
69
|
+
"@sprucelabs/mercury-core-events": "^15.0.71",
|
|
70
70
|
"@sprucelabs/mercury-event-emitter": "^34.0.49",
|
|
71
|
-
"@sprucelabs/schema": "^28.5.
|
|
72
|
-
"@sprucelabs/spruce-core-schemas": "^35.1.
|
|
73
|
-
"@sprucelabs/spruce-event-utils": "^29.1.
|
|
74
|
-
"@sprucelabs/spruce-skill-booter": "^52.1
|
|
75
|
-
"@sprucelabs/spruce-skill-utils": "^28.0.
|
|
76
|
-
"@sprucelabs/test-utils": "^3.2.
|
|
71
|
+
"@sprucelabs/schema": "^28.5.68",
|
|
72
|
+
"@sprucelabs/spruce-core-schemas": "^35.1.57",
|
|
73
|
+
"@sprucelabs/spruce-event-utils": "^29.1.59",
|
|
74
|
+
"@sprucelabs/spruce-skill-booter": "^52.2.1",
|
|
75
|
+
"@sprucelabs/spruce-skill-utils": "^28.0.52",
|
|
76
|
+
"@sprucelabs/test-utils": "^3.2.56",
|
|
77
77
|
"dotenv": "^16.0.3",
|
|
78
78
|
"unique-names-generator": "^4.7.1"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@sprucelabs/esm-postbuild": "^2.0.
|
|
82
|
-
"@sprucelabs/jest-json-reporter": "^6.0.
|
|
81
|
+
"@sprucelabs/esm-postbuild": "^2.0.32",
|
|
82
|
+
"@sprucelabs/jest-json-reporter": "^6.0.520",
|
|
83
83
|
"@sprucelabs/jest-sheets-reporter": "^2.0.21",
|
|
84
|
-
"@sprucelabs/mercury-types": "^37.0.
|
|
85
|
-
"@sprucelabs/resolve-path-aliases": "^1.1.
|
|
84
|
+
"@sprucelabs/mercury-types": "^37.0.59",
|
|
85
|
+
"@sprucelabs/resolve-path-aliases": "^1.1.130",
|
|
86
86
|
"@sprucelabs/semantic-release": "^4.0.8",
|
|
87
|
-
"@sprucelabs/test": "^7.7.
|
|
87
|
+
"@sprucelabs/test": "^7.7.387",
|
|
88
88
|
"@types/node": "17.0.5",
|
|
89
89
|
"calendar-utils": "^0.10.4",
|
|
90
90
|
"chokidar-cli": "^3.0.0",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"ts-node": "^10.9.1",
|
|
98
98
|
"tsc-watch": "^5.0.3",
|
|
99
99
|
"tsconfig-paths": "^4.1.0",
|
|
100
|
-
"typescript": "^4.
|
|
100
|
+
"typescript": "^4.9.3"
|
|
101
101
|
},
|
|
102
102
|
"jest": {
|
|
103
103
|
"maxWorkers": 2,
|
|
@@ -131,5 +131,5 @@
|
|
|
131
131
|
]
|
|
132
132
|
]
|
|
133
133
|
},
|
|
134
|
-
"gitHead": "
|
|
134
|
+
"gitHead": "56da03b1b421ee9de13d6a66d98dcb90f2a8943a"
|
|
135
135
|
}
|