@sprucelabs/spruce-test-fixtures 66.0.19 → 66.0.21
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/FakerTracker.d.ts +41 -0
- package/build/FakerTracker.js +56 -0
- package/build/esm/FakerTracker.d.ts +41 -0
- package/build/esm/FakerTracker.js +54 -0
- package/build/esm/tests/AbstractSpruceFixtureTest.d.ts +68 -27
- package/build/esm/tests/AbstractSpruceFixtureTest.js +256 -103
- package/build/esm/tests/decorators/fake.d.ts +11 -11
- package/build/esm/tests/decorators/fake.js +151 -173
- package/build/esm/tests/decorators/install.js +7 -4
- package/build/esm/tests/decorators/login.js +18 -18
- package/build/esm/tests/decorators/seed.js +34 -40
- package/build/esm/tests/fixtures/FixtureFactory.d.ts +2 -1
- package/build/esm/tests/fixtures/FixtureFactory.js +38 -35
- package/build/esm/tests/fixtures/FixtureWarehourse.d.ts +56 -0
- package/build/esm/tests/fixtures/FixtureWarehourse.js +165 -0
- package/build/esm/tests/fixtures/LocationFixture.d.ts +5 -5
- package/build/esm/tests/fixtures/LocationFixture.js +5 -5
- package/build/esm/tests/fixtures/MercuryFixture.d.ts +5 -0
- package/build/esm/tests/fixtures/MercuryFixture.js +50 -25
- package/build/esm/tests/fixtures/OrganizationFixture.d.ts +4 -4
- package/build/esm/tests/fixtures/PersonFixture.d.ts +2 -2
- package/build/esm/tests/fixtures/PersonFixture.js +23 -9
- package/build/esm/tests/fixtures/RoleFixture.d.ts +4 -4
- package/build/esm/tests/fixtures/RoleFixture.js +4 -4
- package/build/esm/tests/fixtures/SeedFixture.d.ts +13 -13
- package/build/esm/tests/fixtures/SkillFixture.d.ts +2 -2
- package/build/esm/tests/fixtures/SkillFixture.js +2 -2
- package/build/esm/tests/fixtures/SpyScope.d.ts +2 -2
- package/build/esm/tests/fixtures/ViewFixture.d.ts +7 -3
- package/build/esm/tests/fixtures/ViewFixture.js +11 -9
- package/build/tests/AbstractSpruceFixtureTest.d.ts +68 -27
- package/build/tests/AbstractSpruceFixtureTest.js +243 -98
- package/build/tests/decorators/fake.d.ts +11 -11
- package/build/tests/decorators/fake.js +151 -171
- package/build/tests/decorators/install.js +9 -3
- package/build/tests/decorators/login.js +20 -17
- package/build/tests/decorators/seed.js +34 -38
- package/build/tests/fixtures/FixtureFactory.d.ts +2 -1
- package/build/tests/fixtures/FixtureFactory.js +37 -35
- package/build/tests/fixtures/FixtureWarehourse.d.ts +56 -0
- package/build/tests/fixtures/FixtureWarehourse.js +170 -0
- package/build/tests/fixtures/LocationFixture.d.ts +5 -5
- package/build/tests/fixtures/LocationFixture.js +5 -5
- package/build/tests/fixtures/MercuryFixture.d.ts +5 -0
- package/build/tests/fixtures/MercuryFixture.js +48 -23
- package/build/tests/fixtures/OrganizationFixture.d.ts +4 -4
- package/build/tests/fixtures/PersonFixture.d.ts +2 -2
- package/build/tests/fixtures/PersonFixture.js +20 -6
- package/build/tests/fixtures/RoleFixture.d.ts +4 -4
- package/build/tests/fixtures/RoleFixture.js +4 -4
- package/build/tests/fixtures/SeedFixture.d.ts +13 -13
- package/build/tests/fixtures/SkillFixture.d.ts +2 -2
- package/build/tests/fixtures/SkillFixture.js +2 -2
- package/build/tests/fixtures/SpyScope.d.ts +2 -2
- package/build/tests/fixtures/ViewFixture.d.ts +7 -3
- package/build/tests/fixtures/ViewFixture.js +13 -9
- package/package.json +25 -25
@@ -7,19 +7,19 @@ class LocationFixture {
|
|
7
7
|
constructor(options) {
|
8
8
|
this.locationCounter = 0;
|
9
9
|
this.people = options.people;
|
10
|
-
this.
|
10
|
+
this.organizations = options.organizations;
|
11
11
|
this.roles = options.roles;
|
12
12
|
}
|
13
13
|
async seedDemoLocation(values) {
|
14
14
|
const { client } = await this.people.loginAsDemoPerson(values?.phone ?? undefined);
|
15
15
|
let { organizationId: orgId, ...rest } = values ?? {};
|
16
16
|
if (!orgId) {
|
17
|
-
const last = await this.
|
17
|
+
const last = await this.organizations.getNewestOrganization(values?.phone ?? undefined);
|
18
18
|
if (last) {
|
19
19
|
orgId = last.id;
|
20
20
|
}
|
21
21
|
else {
|
22
|
-
const org = await this.
|
22
|
+
const org = await this.organizations.seedDemoOrganization({
|
23
23
|
name: 'Org to support seed location',
|
24
24
|
phone: values?.phone ?? undefined,
|
25
25
|
});
|
@@ -64,7 +64,7 @@ class LocationFixture {
|
|
64
64
|
async getNewestLocation(organizationId) {
|
65
65
|
const { client } = await this.people.loginAsDemoPerson();
|
66
66
|
if (!organizationId) {
|
67
|
-
const org = await this.
|
67
|
+
const org = await this.organizations.getNewestOrganization();
|
68
68
|
test_utils_1.assert.isTruthy(org, `You gotta @seed('locations', 1) before you can get the newest location.`);
|
69
69
|
organizationId = org.id;
|
70
70
|
}
|
@@ -84,7 +84,7 @@ class LocationFixture {
|
|
84
84
|
async listLocations(organizationId) {
|
85
85
|
const { client } = await this.people.loginAsDemoPerson();
|
86
86
|
if (!organizationId) {
|
87
|
-
const org = await this.
|
87
|
+
const org = await this.organizations.getNewestOrganization();
|
88
88
|
if (!org) {
|
89
89
|
throw new Error(`You have to @seed('organizations',1) before you can list locations.`);
|
90
90
|
}
|
@@ -10,18 +10,23 @@ export default class MercuryFixture {
|
|
10
10
|
private static defaultClient?;
|
11
11
|
private static shouldAutomaticallyClearDefaultClient;
|
12
12
|
private static shouldRequireLocalListeners;
|
13
|
+
private static contractsByCwd;
|
14
|
+
private static namespacesByCwd;
|
13
15
|
static setDefaultClient(client: MercuryClient): void;
|
14
16
|
static clearDefaultClient(): void;
|
15
17
|
static getDefaultClient(): MercuryClient | undefined;
|
16
18
|
static setShouldAutomaticallyClearDefaultClient(shouldClear: boolean): void;
|
17
19
|
constructor(cwd: string);
|
18
20
|
connectToApi(options?: TestConnectionOptions): Promise<MercuryClient>;
|
21
|
+
static clearContractCache(): void;
|
19
22
|
static setDefaultContractToLocalEventsIfExist(cwd: string): void;
|
23
|
+
private static loadEventContract;
|
20
24
|
private static setDefaultContract;
|
21
25
|
getConnectFactory(): TestConnectFactory;
|
22
26
|
destroy(): Promise<void>;
|
23
27
|
static beforeAll(): void;
|
24
28
|
static beforeEach(cwd: string): Promise<void>;
|
29
|
+
private static getCurrentSkillsNamespace;
|
25
30
|
static setShouldRequireLocalListeners(shouldRequireLocal: boolean): void;
|
26
31
|
static setShouldMixinCoreEventContractsWhenImportingLocal(shouldMixin: boolean): void;
|
27
32
|
static setShouldAutoImportContracts(shouldImport: boolean): void;
|
@@ -61,33 +61,49 @@ class MercuryFixture {
|
|
61
61
|
this.clientPromises.push(promise);
|
62
62
|
return promise;
|
63
63
|
}
|
64
|
+
static clearContractCache() {
|
65
|
+
this.contractsByCwd = {};
|
66
|
+
}
|
64
67
|
static setDefaultContractToLocalEventsIfExist(cwd) {
|
65
|
-
if (
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
68
|
+
if (cwd in this.contractsByCwd) {
|
69
|
+
MercuryFixture.setDefaultContract(this.contractsByCwd[cwd]);
|
70
|
+
return;
|
71
|
+
}
|
72
|
+
let contract;
|
73
|
+
const shouldImport = MercuryFixture.shouldAutoImportContracts &&
|
74
|
+
spruce_skill_utils_1.diskUtil.doesBuiltHashSprucePathExist(cwd);
|
75
|
+
if (shouldImport) {
|
76
|
+
contract = this.loadEventContract(cwd);
|
77
|
+
}
|
78
|
+
else {
|
79
|
+
contract = mercury_core_events_1.coreEventContracts[0];
|
80
|
+
}
|
81
|
+
this.contractsByCwd[cwd] = contract;
|
82
|
+
if (contract) {
|
83
|
+
MercuryFixture.setDefaultContract(contract);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
static loadEventContract(cwd) {
|
87
|
+
let contract;
|
88
|
+
try {
|
89
|
+
const combinedContract = spruce_event_utils_1.eventDiskUtil.resolveCombinedEventsContractFile(cwd);
|
90
|
+
let contracts = require(combinedContract).default;
|
91
|
+
if (this.shouldMixinCoreEventContractWhenImportingLocal) {
|
92
|
+
contracts = [...contracts, ...mercury_core_events_1.coreEventContracts];
|
93
|
+
}
|
94
|
+
contract = spruce_event_utils_1.eventContractUtil.unifyContracts(contracts);
|
95
|
+
}
|
96
|
+
catch (err) {
|
97
|
+
//since we default to the
|
98
|
+
if (err.options?.code === 'EVENT_CONTRACTS_NOT_SYNCED') {
|
99
|
+
contract = mercury_core_events_1.coreEventContracts[0];
|
77
100
|
}
|
78
|
-
|
79
|
-
//since we default to the
|
80
|
-
if (err.options?.code === 'EVENT_CONTRACTS_NOT_SYNCED') {
|
81
|
-
MercuryFixture.setDefaultContract(mercury_core_events_1.coreEventContracts[0]);
|
82
|
-
return;
|
83
|
-
}
|
101
|
+
else {
|
84
102
|
throw new Error('Mixing in local event contracts failed. Original error:\n\n' +
|
85
103
|
err.stack);
|
86
104
|
}
|
87
105
|
}
|
88
|
-
|
89
|
-
MercuryFixture.setDefaultContract(mercury_core_events_1.coreEventContracts[0]);
|
90
|
-
}
|
106
|
+
return contract;
|
91
107
|
}
|
92
108
|
static setDefaultContract(contract) {
|
93
109
|
//@ts-ignore
|
@@ -127,8 +143,7 @@ class MercuryFixture {
|
|
127
143
|
}
|
128
144
|
this.setDefaultContractToLocalEventsIfExist(cwd);
|
129
145
|
try {
|
130
|
-
const
|
131
|
-
const namespace = auth.getCurrentSkill()?.slug;
|
146
|
+
const namespace = this.getCurrentSkillsNamespace(cwd);
|
132
147
|
if (namespace) {
|
133
148
|
mercury_client_1.MercuryTestClient.setNamespacesThatMustBeHandledLocally([
|
134
149
|
namespace,
|
@@ -137,6 +152,14 @@ class MercuryFixture {
|
|
137
152
|
}
|
138
153
|
catch { }
|
139
154
|
}
|
155
|
+
static getCurrentSkillsNamespace(cwd) {
|
156
|
+
if (!(cwd in this.namespacesByCwd)) {
|
157
|
+
const auth = spruce_skill_utils_1.AuthService.Auth(cwd);
|
158
|
+
const namespace = auth.getCurrentSkill()?.slug;
|
159
|
+
this.namespacesByCwd[cwd] = namespace;
|
160
|
+
}
|
161
|
+
return this.namespacesByCwd[cwd];
|
162
|
+
}
|
140
163
|
static setShouldRequireLocalListeners(shouldRequireLocal) {
|
141
164
|
this.shouldRequireLocalListeners = shouldRequireLocal;
|
142
165
|
mercury_client_1.MercuryTestClient.setShouldRequireLocalListeners(shouldRequireLocal);
|
@@ -152,4 +175,6 @@ MercuryFixture.shouldAutoImportContracts = true;
|
|
152
175
|
MercuryFixture.shouldMixinCoreEventContractWhenImportingLocal = false;
|
153
176
|
MercuryFixture.shouldAutomaticallyClearDefaultClient = true;
|
154
177
|
MercuryFixture.shouldRequireLocalListeners = true;
|
178
|
+
MercuryFixture.contractsByCwd = {};
|
179
|
+
MercuryFixture.namespacesByCwd = {};
|
155
180
|
exports.default = MercuryFixture;
|
@@ -14,12 +14,12 @@ export default class OrganizationFixture {
|
|
14
14
|
seedDemoOrganization(values?: Partial<Omit<SpruceSchemas.Mercury.v2020_12_25.CreateOrgEmitPayload, 'slug'>> & {
|
15
15
|
phone?: string;
|
16
16
|
slug?: string;
|
17
|
-
}): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false>>, "id" | "address" | "
|
18
|
-
getOrganizationById(id: string): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false>>, "id" | "address" | "
|
17
|
+
}): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false>>, "id" | "address" | "dateCreated" | "name" | "slug" | "dateDeleted" | "isPublic">>;
|
18
|
+
getOrganizationById(id: string): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false>>, "id" | "address" | "dateCreated" | "name" | "slug" | "dateDeleted" | "isPublic">>;
|
19
19
|
updateOrganization(id: string, values: SpruceSchemas.Mercury.v2020_12_25.UpdateOrgEmitPayload & {
|
20
20
|
phone?: string;
|
21
21
|
}): Promise<void>;
|
22
|
-
getNewestOrganization(phone?: string): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false>>, "id" | "address" | "
|
22
|
+
getNewestOrganization(phone?: string): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false>>, "id" | "address" | "dateCreated" | "name" | "slug" | "dateDeleted" | "isPublic"> | null>;
|
23
23
|
private generateOrgSlug;
|
24
24
|
installSkill(skillId: string, orgId: string, shouldNotifySkillOfInstall?: boolean): Promise<void>;
|
25
25
|
isPartOfOrg(options: {
|
@@ -46,6 +46,6 @@ export default class OrganizationFixture {
|
|
46
46
|
shouldNotifySkillOfInstall?: boolean;
|
47
47
|
}): Promise<void>;
|
48
48
|
deleteAllOrganizations(phone?: string): Promise<void>;
|
49
|
-
listOrganizations(phone?: string): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false>>, "id" | "address" | "
|
49
|
+
listOrganizations(phone?: string): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false>>, "id" | "address" | "dateCreated" | "name" | "slug" | "dateDeleted" | "isPublic">[]>;
|
50
50
|
destroy(): Promise<void>;
|
51
51
|
}
|
@@ -7,7 +7,7 @@ type ClientPromise = ReturnType<Factory>;
|
|
7
7
|
type Client = ClientPromise extends PromiseLike<infer C> ? C : ClientPromise;
|
8
8
|
export default class PersonFixture {
|
9
9
|
private connectToApi;
|
10
|
-
private
|
10
|
+
private firstLoggedIn?;
|
11
11
|
constructor(options: {
|
12
12
|
connectToApi: Factory;
|
13
13
|
});
|
@@ -18,7 +18,7 @@ export default class PersonFixture {
|
|
18
18
|
roleBases?: string[];
|
19
19
|
roleIds?: string[];
|
20
20
|
shouldIncludePrivateFields?: boolean;
|
21
|
-
}): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Mercury.v2020_12_25.ListPersonSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Mercury.v2020_12_25.ListPersonSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Mercury.v2020_12_25.ListPersonSchema, false>>, "id" | "phone" | "
|
21
|
+
}): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Mercury.v2020_12_25.ListPersonSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Mercury.v2020_12_25.ListPersonSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Mercury.v2020_12_25.ListPersonSchema, false>>, "id" | "phone" | "firstName" | "lastName" | "casualName" | "timezone" | "username" | "avatar" | "dateCreated" | "dateUpdated" | "dateScrambled" | "macAddress" | "roleIds">[]>;
|
22
22
|
generateRandomName(client: MercuryClient): Promise<{
|
23
23
|
firstName: string;
|
24
24
|
lastName: string;
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const schema_1 = require("@sprucelabs/schema");
|
7
7
|
const dotenv_1 = __importDefault(require("dotenv"));
|
8
8
|
const generateRandomName_1 = __importDefault(require("./generateRandomName"));
|
9
|
+
const MercuryFixture_1 = __importDefault(require("./MercuryFixture"));
|
9
10
|
dotenv_1.default.config();
|
10
11
|
class PersonFixture {
|
11
12
|
constructor(options) {
|
@@ -33,10 +34,21 @@ class PersonFixture {
|
|
33
34
|
return { ...person, ...values };
|
34
35
|
}
|
35
36
|
async loginAsDemoPerson(phone) {
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
let phoneFormated = phone ? (0, schema_1.formatPhoneNumber)(phone) : undefined;
|
38
|
+
const defaultClient = MercuryFixture_1.default.getDefaultClient();
|
39
|
+
const isDefaultClient = defaultClient &&
|
40
|
+
(!phone || defaultClient?.auth?.person?.phone === phoneFormated);
|
41
|
+
if (isDefaultClient) {
|
42
|
+
return {
|
43
|
+
client: defaultClient,
|
44
|
+
person: defaultClient.auth.person,
|
45
|
+
token: defaultClient.auth.token,
|
46
|
+
};
|
47
|
+
}
|
48
|
+
const isFirstLoggedIn = this.firstLoggedIn &&
|
49
|
+
(!phone || phoneFormated === this.firstLoggedIn.person.phone);
|
50
|
+
if (isFirstLoggedIn) {
|
51
|
+
return this.firstLoggedIn;
|
40
52
|
}
|
41
53
|
const client = (await this.connectToApi({
|
42
54
|
shouldReUseClient: !phone,
|
@@ -74,8 +86,10 @@ class PersonFixture {
|
|
74
86
|
});
|
75
87
|
//@ts-ignore
|
76
88
|
client.auth = { person, token };
|
77
|
-
this.
|
78
|
-
|
89
|
+
if (!this.firstLoggedIn) {
|
90
|
+
this.firstLoggedIn = { person, client, token };
|
91
|
+
}
|
92
|
+
return { person, client, token };
|
79
93
|
}
|
80
94
|
async destroy() { }
|
81
95
|
}
|
@@ -2,7 +2,7 @@ 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
|
-
private
|
5
|
+
private people;
|
6
6
|
private getNewestOrgHandler;
|
7
7
|
constructor(options: {
|
8
8
|
people: PersonFixture;
|
@@ -14,7 +14,7 @@ export default class RoleFixture {
|
|
14
14
|
personId?: string;
|
15
15
|
phone?: string;
|
16
16
|
shouldIncludeMetaRoles?: boolean;
|
17
|
-
}): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema, false>>, "id" | "
|
17
|
+
}): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema, false>>, "id" | "organizationId" | "target" | "dateCreated" | "name" | "description" | "dateDeleted" | "isPublic" | "base" | "isMeta">[]>;
|
18
18
|
addRoleToPerson(options: {
|
19
19
|
personId: string;
|
20
20
|
organizationId: string;
|
@@ -34,11 +34,11 @@ export default class RoleFixture {
|
|
34
34
|
organizationId: string;
|
35
35
|
base: string;
|
36
36
|
phone?: string;
|
37
|
-
}): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema, false>>, "id" | "
|
37
|
+
}): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema, false>>, "id" | "organizationId" | "target" | "dateCreated" | "name" | "description" | "dateDeleted" | "isPublic" | "base" | "isMeta">>;
|
38
38
|
getFirstRoleWithBase(options: {
|
39
39
|
organizationId: string;
|
40
40
|
base: string;
|
41
41
|
phone?: string;
|
42
|
-
}): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema, false>>, "id" | "
|
42
|
+
}): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Mercury.v2020_12_25.ListRoleSchema, false>>, "id" | "organizationId" | "target" | "dateCreated" | "name" | "description" | "dateDeleted" | "isPublic" | "base" | "isMeta">>;
|
43
43
|
}
|
44
44
|
export {};
|
@@ -5,12 +5,12 @@ const spruce_event_utils_1 = require("@sprucelabs/spruce-event-utils");
|
|
5
5
|
const test_utils_1 = require("@sprucelabs/test-utils");
|
6
6
|
class RoleFixture {
|
7
7
|
constructor(options) {
|
8
|
-
this.
|
8
|
+
this.people = options.people;
|
9
9
|
this.getNewestOrgHandler = options.getNewestOrg;
|
10
10
|
}
|
11
11
|
async listRoles(options) {
|
12
12
|
let { organizationId, locationId, personId, phone, shouldIncludeMetaRoles, } = options ?? {};
|
13
|
-
const { client } = await this.
|
13
|
+
const { client } = await this.people.loginAsDemoPerson(phone);
|
14
14
|
if (!organizationId && !locationId) {
|
15
15
|
const latest = await this.getNewestOrgHandler();
|
16
16
|
organizationId = latest?.id;
|
@@ -38,7 +38,7 @@ class RoleFixture {
|
|
38
38
|
}
|
39
39
|
async addRoleToPerson(options) {
|
40
40
|
const { personId, organizationId, locationId, roleBase, phone } = options;
|
41
|
-
const { client } = await this.
|
41
|
+
const { client } = await this.people.loginAsDemoPerson(phone);
|
42
42
|
const match = await this.getFirstRoleWithBase({
|
43
43
|
organizationId,
|
44
44
|
phone,
|
@@ -62,7 +62,7 @@ class RoleFixture {
|
|
62
62
|
}
|
63
63
|
async removeRoleFromPerson(options) {
|
64
64
|
const { phone, organizationId: orgId, personId, roleBase, locationId, } = options;
|
65
|
-
const { client } = await this.
|
65
|
+
const { client } = await this.people.loginAsDemoPerson(phone);
|
66
66
|
const role = await this.getFirstRoleWithBase({
|
67
67
|
phone,
|
68
68
|
base: roleBase,
|
@@ -2,18 +2,6 @@ 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
|
-
type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
|
6
|
-
export interface SeedLocationOptions {
|
7
|
-
totalLocations: number;
|
8
|
-
organizationId?: string;
|
9
|
-
phone?: string;
|
10
|
-
totalGuests?: number;
|
11
|
-
totalTeammates?: number;
|
12
|
-
totalManagers?: number;
|
13
|
-
totalOwners?: number;
|
14
|
-
totalGroupManagers?: number;
|
15
|
-
startingPhone?: string;
|
16
|
-
}
|
17
5
|
export default class SeedFixture {
|
18
6
|
private organizations;
|
19
7
|
private locations;
|
@@ -49,7 +37,7 @@ export default class SeedFixture {
|
|
49
37
|
managers: Person[];
|
50
38
|
groupManagers: Person[];
|
51
39
|
owners: Person[];
|
52
|
-
locations: Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Spruce.v2020_07_22.LocationSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Spruce.v2020_07_22.LocationSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Spruce.v2020_07_22.LocationSchema, false>>, "id" | "address" | "phone" | "
|
40
|
+
locations: Pick<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Spruce.v2020_07_22.LocationSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Spruce.v2020_07_22.LocationSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Spruce.v2020_07_22.LocationSchema, false>>, "id" | "address" | "phone" | "organizationId" | "timezone" | "dateCreated" | "dateUpdated" | "name" | "slug" | "dateDeleted" | "num" | "isPublic">[];
|
53
41
|
}>;
|
54
42
|
seedPeople(options: Omit<SeedLocationOptions, 'totalLocations'> & {
|
55
43
|
locationId?: string;
|
@@ -64,4 +52,16 @@ export default class SeedFixture {
|
|
64
52
|
private seedPeopleWithRole;
|
65
53
|
resetAccount(phone?: string): Promise<void>;
|
66
54
|
}
|
55
|
+
type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
|
56
|
+
export interface SeedLocationOptions {
|
57
|
+
totalLocations: number;
|
58
|
+
organizationId?: string;
|
59
|
+
phone?: string;
|
60
|
+
totalGuests?: number;
|
61
|
+
totalTeammates?: number;
|
62
|
+
totalManagers?: number;
|
63
|
+
totalOwners?: number;
|
64
|
+
totalGroupManagers?: number;
|
65
|
+
startingPhone?: string;
|
66
|
+
}
|
67
67
|
export {};
|
@@ -11,12 +11,12 @@ export interface SeedDemoSkillValues {
|
|
11
11
|
creatorPhone?: string;
|
12
12
|
}
|
13
13
|
export default class SkillFixture {
|
14
|
-
private
|
14
|
+
private people;
|
15
15
|
private connectToApi;
|
16
16
|
private skills;
|
17
17
|
private skillCounter;
|
18
18
|
constructor(options: {
|
19
|
-
|
19
|
+
people: PersonFixture;
|
20
20
|
connectToApi: Factory;
|
21
21
|
});
|
22
22
|
seedDemoSkill(options?: SeedDemoSkillValues): Promise<SpruceSchemas.Spruce.v2020_07_22.Skill>;
|
@@ -6,11 +6,11 @@ class SkillFixture {
|
|
6
6
|
this.skills = [];
|
7
7
|
this.skillCounter = process.pid;
|
8
8
|
this.connectToApi = options.connectToApi;
|
9
|
-
this.
|
9
|
+
this.people = options.people;
|
10
10
|
}
|
11
11
|
async seedDemoSkill(options) {
|
12
12
|
const { creatorPhone, ...values } = options ?? {};
|
13
|
-
const { client } = await this.
|
13
|
+
const { client } = await this.people.loginAsDemoPerson(creatorPhone);
|
14
14
|
const [{ skill }] = await client.emitAndFlattenResponses('register-skill::v2020_12_25', {
|
15
15
|
payload: {
|
16
16
|
slug: this.generateSkillSlug(),
|
@@ -12,12 +12,12 @@ export default class SpyScope implements Scope {
|
|
12
12
|
organizationFixture: OrganizationFixture;
|
13
13
|
locationFixture: LocationFixture;
|
14
14
|
});
|
15
|
-
getCurrentOrganization(): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false>>, "id" | "address" | "
|
15
|
+
getCurrentOrganization(): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.Spruce.v2020_07_22.OrganizationSchema, false>>, "id" | "address" | "dateCreated" | "name" | "slug" | "dateDeleted" | "isPublic"> | null>;
|
16
16
|
private assertScopedByOrg;
|
17
17
|
setCurrentOrganization(id: string | null): void;
|
18
18
|
setFlags(flags: ScopeFlag[]): void;
|
19
19
|
getFlags(): ScopeFlag[];
|
20
|
-
getCurrentLocation(): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.Spruce.v2020_07_22.LocationSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.Spruce.v2020_07_22.LocationSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.Spruce.v2020_07_22.LocationSchema, false>>, "id" | "address" | "phone" | "
|
20
|
+
getCurrentLocation(): Promise<Pick<import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.Spruce.v2020_07_22.LocationSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.Spruce.v2020_07_22.LocationSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/heartwood-view-controllers").SpruceSchemas.Spruce.v2020_07_22.LocationSchema, false>>, "id" | "address" | "phone" | "organizationId" | "timezone" | "dateCreated" | "dateUpdated" | "name" | "slug" | "dateDeleted" | "num" | "isPublic"> | null>;
|
21
21
|
private assertScopedToCurrentLocation;
|
22
22
|
setCurrentLocation(id: string | null): void;
|
23
23
|
clearSession(): void;
|
@@ -9,6 +9,8 @@ import { ArgsFromSvc } from '../../types/view.types';
|
|
9
9
|
import TestRouter from '../routers/TestRouter';
|
10
10
|
import SpyViewControllerFactory from '../SpyViewControllerFactory';
|
11
11
|
import FixtureFactory from './FixtureFactory';
|
12
|
+
import LocationFixture from './LocationFixture';
|
13
|
+
import OrganizationFixture from './OrganizationFixture';
|
12
14
|
import PermissionFixture from './PermissionFixture';
|
13
15
|
import PersonFixture from './PersonFixture';
|
14
16
|
import SpyAuthenticator from './SpyAuthenticator';
|
@@ -22,13 +24,13 @@ export default class ViewFixture {
|
|
22
24
|
private static scope?;
|
23
25
|
private static shouldAutomaticallyResetAuthenticator;
|
24
26
|
private static viewClient?;
|
27
|
+
protected people: PersonFixture;
|
28
|
+
protected organizations: OrganizationFixture;
|
29
|
+
protected locations: LocationFixture;
|
25
30
|
protected vcDir: string;
|
26
31
|
private controllerMap?;
|
27
32
|
private connectToApi;
|
28
33
|
private namespace;
|
29
|
-
private people;
|
30
|
-
private orgs;
|
31
|
-
private locations;
|
32
34
|
private proxyDecorator;
|
33
35
|
private locale;
|
34
36
|
private permissions;
|
@@ -38,6 +40,8 @@ export default class ViewFixture {
|
|
38
40
|
constructor(options: {
|
39
41
|
connectToApi: Factory;
|
40
42
|
people: PersonFixture;
|
43
|
+
organizations?: OrganizationFixture;
|
44
|
+
locations?: LocationFixture;
|
41
45
|
fixtureFactory: FixtureFactory;
|
42
46
|
vcDir?: string;
|
43
47
|
cwd?: string;
|
@@ -25,7 +25,7 @@ class ViewFixture {
|
|
25
25
|
this.shouldAutomaticallyResetAuthenticator = shouldReset;
|
26
26
|
}
|
27
27
|
constructor(options) {
|
28
|
-
const { connectToApi, people, fixtureFactory, vcDir, cwd, namespace, proxyDecorator, permissions, } = options;
|
28
|
+
const { connectToApi, people, organizations: orgs, locations, fixtureFactory, vcDir, cwd, namespace, proxyDecorator, permissions, } = options;
|
29
29
|
this.connectToApi = connectToApi;
|
30
30
|
this.people = people;
|
31
31
|
this.vcDir =
|
@@ -33,18 +33,22 @@ class ViewFixture {
|
|
33
33
|
this.controllerMap = options?.controllerMap;
|
34
34
|
this.namespace = namespace;
|
35
35
|
this.proxyDecorator = proxyDecorator;
|
36
|
-
this.
|
37
|
-
|
38
|
-
|
36
|
+
this.organizations =
|
37
|
+
orgs ??
|
38
|
+
fixtureFactory.Fixture('organization', {
|
39
|
+
people: this.people,
|
40
|
+
});
|
39
41
|
this.permissions = permissions;
|
40
42
|
if (!ViewFixture.device) {
|
41
43
|
ViewFixture.device = new heartwood_view_controllers_1.SpyDevice();
|
42
44
|
}
|
43
45
|
this.locale = new calendar_utils_1.LocaleImpl();
|
44
|
-
this.locations =
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
this.locations =
|
47
|
+
locations ??
|
48
|
+
fixtureFactory.Fixture('location', {
|
49
|
+
people: this.people,
|
50
|
+
organizations: this.organizations,
|
51
|
+
});
|
48
52
|
}
|
49
53
|
addPlugin(name, plugin) {
|
50
54
|
this.getFactory().addPlugin(name, plugin);
|
@@ -246,7 +250,7 @@ class ViewFixture {
|
|
246
250
|
getScope() {
|
247
251
|
if (!ViewFixture.scope) {
|
248
252
|
ViewFixture.scope = new SpyScope_1.default({
|
249
|
-
organizationFixture: this.
|
253
|
+
organizationFixture: this.organizations,
|
250
254
|
locationFixture: this.locations,
|
251
255
|
});
|
252
256
|
}
|
package/package.json
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
"@sprucelabs/spruce-test-fixtures"
|
14
14
|
]
|
15
15
|
},
|
16
|
-
"version": "66.0.
|
16
|
+
"version": "66.0.21",
|
17
17
|
"files": [
|
18
18
|
"build/**/*",
|
19
19
|
"!build/__tests__",
|
@@ -52,7 +52,7 @@
|
|
52
52
|
"lint": "eslint --cache '**/*.ts'",
|
53
53
|
"rebuild": "cd .. && yarn rebuild",
|
54
54
|
"resolve-paths.lint": "yarn run build.resolve-paths ; yarn run lint",
|
55
|
-
"test": "jest",
|
55
|
+
"test": "jest --detectOpenHandles --forceExit --verbose",
|
56
56
|
"post.watch.build": "yarn run build.copy-files && yarn run build.resolve-paths",
|
57
57
|
"spruce.upgrade": "spruce upgrade",
|
58
58
|
"watch.build.dev": "tsc-watch --sourceMap --onCompilationComplete 'yarn run post.watch.build'",
|
@@ -61,45 +61,45 @@
|
|
61
61
|
"lint.tsc": "tsc -p . --noEmit"
|
62
62
|
},
|
63
63
|
"dependencies": {
|
64
|
-
"@sprucelabs/data-stores": "^28.5.
|
65
|
-
"@sprucelabs/error": "^6.0.
|
66
|
-
"@sprucelabs/heartwood-view-controllers": "^117.2.
|
67
|
-
"@sprucelabs/mercury-client": "^42.0.
|
68
|
-
"@sprucelabs/mercury-core-events": "^26.0.
|
69
|
-
"@sprucelabs/mercury-event-emitter": "^42.0.
|
70
|
-
"@sprucelabs/schema": "^31.0.
|
71
|
-
"@sprucelabs/spruce-core-schemas": "^40.1.
|
72
|
-
"@sprucelabs/spruce-event-utils": "^40.2.
|
73
|
-
"@sprucelabs/spruce-permission-utils": "^12.0.
|
74
|
-
"@sprucelabs/spruce-skill-booter": "^66.0.
|
75
|
-
"@sprucelabs/spruce-skill-utils": "^31.2.
|
76
|
-
"@sprucelabs/test-utils": "^5.
|
64
|
+
"@sprucelabs/data-stores": "^28.5.63",
|
65
|
+
"@sprucelabs/error": "^6.0.580",
|
66
|
+
"@sprucelabs/heartwood-view-controllers": "^117.2.8",
|
67
|
+
"@sprucelabs/mercury-client": "^42.0.734",
|
68
|
+
"@sprucelabs/mercury-core-events": "^26.0.15",
|
69
|
+
"@sprucelabs/mercury-event-emitter": "^42.0.734",
|
70
|
+
"@sprucelabs/schema": "^31.0.52",
|
71
|
+
"@sprucelabs/spruce-core-schemas": "^40.1.641",
|
72
|
+
"@sprucelabs/spruce-event-utils": "^40.2.38",
|
73
|
+
"@sprucelabs/spruce-permission-utils": "^12.0.33",
|
74
|
+
"@sprucelabs/spruce-skill-booter": "^66.0.21",
|
75
|
+
"@sprucelabs/spruce-skill-utils": "^31.2.55",
|
76
|
+
"@sprucelabs/test-utils": "^5.5.11",
|
77
77
|
"dotenv": "^16.4.7",
|
78
78
|
"unique-names-generator": "^4.7.1"
|
79
79
|
},
|
80
80
|
"devDependencies": {
|
81
|
-
"@sprucelabs/esm-postbuild": "^6.0.
|
82
|
-
"@sprucelabs/jest-json-reporter": "^8.0.
|
83
|
-
"@sprucelabs/mercury-types": "^47.2.
|
84
|
-
"@sprucelabs/resolve-path-aliases": "^2.0.
|
81
|
+
"@sprucelabs/esm-postbuild": "^6.0.549",
|
82
|
+
"@sprucelabs/jest-json-reporter": "^8.0.581",
|
83
|
+
"@sprucelabs/mercury-types": "^47.2.34",
|
84
|
+
"@sprucelabs/resolve-path-aliases": "^2.0.533",
|
85
85
|
"@sprucelabs/semantic-release": "^5.0.2",
|
86
|
-
"@sprucelabs/test": "^9.0.
|
86
|
+
"@sprucelabs/test": "^9.0.73",
|
87
87
|
"@types/node": "17.0.5",
|
88
88
|
"calendar-utils": "^0.11.0",
|
89
89
|
"chokidar-cli": "^3.0.0",
|
90
|
-
"eslint": "^9.
|
90
|
+
"eslint": "^9.21.0",
|
91
91
|
"eslint-config-spruce": "^11.2.26",
|
92
92
|
"jest": "^29.7.0",
|
93
93
|
"jest-circus": "^29.7.0",
|
94
|
-
"prettier": "^3.5.
|
94
|
+
"prettier": "^3.5.2",
|
95
95
|
"ts-node": "^10.9.2",
|
96
96
|
"tsc-watch": "^6.2.1",
|
97
97
|
"tsconfig-paths": "^4.2.0",
|
98
98
|
"typescript": "^5.7.3"
|
99
99
|
},
|
100
100
|
"jest": {
|
101
|
-
"maxWorkers":
|
102
|
-
"testTimeout":
|
101
|
+
"maxWorkers": 1,
|
102
|
+
"testTimeout": 1200000,
|
103
103
|
"testEnvironment": "node",
|
104
104
|
"testPathIgnorePatterns": [
|
105
105
|
"<rootDir>/tmp/",
|
@@ -114,5 +114,5 @@
|
|
114
114
|
"^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
|
115
115
|
}
|
116
116
|
},
|
117
|
-
"gitHead": "
|
117
|
+
"gitHead": "41fa5f59edf353050ca0dbabd950dc0f23ee7651"
|
118
118
|
}
|