@sprucelabs/spruce-test-fixtures 66.0.20 → 66.0.22
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 +24 -24
@@ -25,7 +25,7 @@ class LocationFixture {
|
|
25
25
|
constructor(options) {
|
26
26
|
this.locationCounter = 0;
|
27
27
|
this.people = options.people;
|
28
|
-
this.
|
28
|
+
this.organizations = options.organizations;
|
29
29
|
this.roles = options.roles;
|
30
30
|
}
|
31
31
|
seedDemoLocation(values) {
|
@@ -34,12 +34,12 @@ class LocationFixture {
|
|
34
34
|
const { client } = yield this.people.loginAsDemoPerson((_a = values === null || values === void 0 ? void 0 : values.phone) !== null && _a !== void 0 ? _a : undefined);
|
35
35
|
let _d = values !== null && values !== void 0 ? values : {}, { organizationId: orgId } = _d, rest = __rest(_d, ["organizationId"]);
|
36
36
|
if (!orgId) {
|
37
|
-
const last = yield this.
|
37
|
+
const last = yield this.organizations.getNewestOrganization((_b = values === null || values === void 0 ? void 0 : values.phone) !== null && _b !== void 0 ? _b : undefined);
|
38
38
|
if (last) {
|
39
39
|
orgId = last.id;
|
40
40
|
}
|
41
41
|
else {
|
42
|
-
const org = yield this.
|
42
|
+
const org = yield this.organizations.seedDemoOrganization({
|
43
43
|
name: 'Org to support seed location',
|
44
44
|
phone: (_c = values === null || values === void 0 ? void 0 : values.phone) !== null && _c !== void 0 ? _c : undefined,
|
45
45
|
});
|
@@ -83,7 +83,7 @@ class LocationFixture {
|
|
83
83
|
var _a;
|
84
84
|
const { client } = yield this.people.loginAsDemoPerson();
|
85
85
|
if (!organizationId) {
|
86
|
-
const org = yield this.
|
86
|
+
const org = yield this.organizations.getNewestOrganization();
|
87
87
|
assert.isTruthy(org, `You gotta @seed('locations', 1) before you can get the newest location.`);
|
88
88
|
organizationId = org.id;
|
89
89
|
}
|
@@ -105,7 +105,7 @@ class LocationFixture {
|
|
105
105
|
return __awaiter(this, void 0, void 0, function* () {
|
106
106
|
const { client } = yield this.people.loginAsDemoPerson();
|
107
107
|
if (!organizationId) {
|
108
|
-
const org = yield this.
|
108
|
+
const org = yield this.organizations.getNewestOrganization();
|
109
109
|
if (!org) {
|
110
110
|
throw new Error(`You have to @seed('organizations',1) before you can list locations.`);
|
111
111
|
}
|
@@ -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;
|
@@ -71,34 +71,50 @@ class MercuryFixture {
|
|
71
71
|
return promise;
|
72
72
|
});
|
73
73
|
}
|
74
|
+
static clearContractCache() {
|
75
|
+
this.contractsByCwd = {};
|
76
|
+
}
|
74
77
|
static setDefaultContractToLocalEventsIfExist(cwd) {
|
78
|
+
if (cwd in this.contractsByCwd) {
|
79
|
+
MercuryFixture.setDefaultContract(this.contractsByCwd[cwd]);
|
80
|
+
return;
|
81
|
+
}
|
82
|
+
let contract;
|
83
|
+
const shouldImport = MercuryFixture.shouldAutoImportContracts &&
|
84
|
+
diskUtil.doesBuiltHashSprucePathExist(cwd);
|
85
|
+
if (shouldImport) {
|
86
|
+
contract = this.loadEventContract(cwd);
|
87
|
+
}
|
88
|
+
else {
|
89
|
+
contract = coreEventContracts[0];
|
90
|
+
}
|
91
|
+
this.contractsByCwd[cwd] = contract;
|
92
|
+
if (contract) {
|
93
|
+
MercuryFixture.setDefaultContract(contract);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
static loadEventContract(cwd) {
|
75
97
|
var _a;
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
contracts = [...contracts, ...coreEventContracts];
|
83
|
-
}
|
84
|
-
const combined = eventContractUtil.unifyContracts(contracts);
|
85
|
-
if (combined) {
|
86
|
-
MercuryFixture.setDefaultContract(combined);
|
87
|
-
}
|
98
|
+
let contract;
|
99
|
+
try {
|
100
|
+
const combinedContract = eventDiskUtil.resolveCombinedEventsContractFile(cwd);
|
101
|
+
let contracts = require(combinedContract).default;
|
102
|
+
if (this.shouldMixinCoreEventContractWhenImportingLocal) {
|
103
|
+
contracts = [...contracts, ...coreEventContracts];
|
88
104
|
}
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
105
|
+
contract = eventContractUtil.unifyContracts(contracts);
|
106
|
+
}
|
107
|
+
catch (err) {
|
108
|
+
//since we default to the
|
109
|
+
if (((_a = err.options) === null || _a === void 0 ? void 0 : _a.code) === 'EVENT_CONTRACTS_NOT_SYNCED') {
|
110
|
+
contract = coreEventContracts[0];
|
111
|
+
}
|
112
|
+
else {
|
95
113
|
throw new Error('Mixing in local event contracts failed. Original error:\n\n' +
|
96
114
|
err.stack);
|
97
115
|
}
|
98
116
|
}
|
99
|
-
|
100
|
-
MercuryFixture.setDefaultContract(coreEventContracts[0]);
|
101
|
-
}
|
117
|
+
return contract;
|
102
118
|
}
|
103
119
|
static setDefaultContract(contract) {
|
104
120
|
var _a;
|
@@ -129,7 +145,6 @@ class MercuryFixture {
|
|
129
145
|
}
|
130
146
|
static beforeEach(cwd) {
|
131
147
|
return __awaiter(this, void 0, void 0, function* () {
|
132
|
-
var _a;
|
133
148
|
if (this.originalHost) {
|
134
149
|
process.env.HOST = this.originalHost;
|
135
150
|
}
|
@@ -144,17 +159,25 @@ class MercuryFixture {
|
|
144
159
|
}
|
145
160
|
this.setDefaultContractToLocalEventsIfExist(cwd);
|
146
161
|
try {
|
147
|
-
const
|
148
|
-
const namespace = (_a = auth.getCurrentSkill()) === null || _a === void 0 ? void 0 : _a.slug;
|
162
|
+
const namespace = this.getCurrentSkillsNamespace(cwd);
|
149
163
|
if (namespace) {
|
150
164
|
MercuryTestClient.setNamespacesThatMustBeHandledLocally([
|
151
165
|
namespace,
|
152
166
|
]);
|
153
167
|
}
|
154
168
|
}
|
155
|
-
catch (
|
169
|
+
catch (_a) { }
|
156
170
|
});
|
157
171
|
}
|
172
|
+
static getCurrentSkillsNamespace(cwd) {
|
173
|
+
var _a;
|
174
|
+
if (!(cwd in this.namespacesByCwd)) {
|
175
|
+
const auth = AuthService.Auth(cwd);
|
176
|
+
const namespace = (_a = auth.getCurrentSkill()) === null || _a === void 0 ? void 0 : _a.slug;
|
177
|
+
this.namespacesByCwd[cwd] = namespace;
|
178
|
+
}
|
179
|
+
return this.namespacesByCwd[cwd];
|
180
|
+
}
|
158
181
|
static setShouldRequireLocalListeners(shouldRequireLocal) {
|
159
182
|
this.shouldRequireLocalListeners = shouldRequireLocal;
|
160
183
|
MercuryTestClient.setShouldRequireLocalListeners(shouldRequireLocal);
|
@@ -170,4 +193,6 @@ MercuryFixture.shouldAutoImportContracts = true;
|
|
170
193
|
MercuryFixture.shouldMixinCoreEventContractWhenImportingLocal = false;
|
171
194
|
MercuryFixture.shouldAutomaticallyClearDefaultClient = true;
|
172
195
|
MercuryFixture.shouldRequireLocalListeners = true;
|
196
|
+
MercuryFixture.contractsByCwd = {};
|
197
|
+
MercuryFixture.namespacesByCwd = {};
|
173
198
|
export 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;
|
@@ -21,6 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
21
21
|
import { formatPhoneNumber, SchemaError } from '@sprucelabs/schema';
|
22
22
|
import dotenv from 'dotenv';
|
23
23
|
import generateRandomName from './generateRandomName.js';
|
24
|
+
import MercuryFixture from './MercuryFixture.js';
|
24
25
|
dotenv.config();
|
25
26
|
export default class PersonFixture {
|
26
27
|
constructor(options) {
|
@@ -51,16 +52,27 @@ export default class PersonFixture {
|
|
51
52
|
}
|
52
53
|
loginAsDemoPerson(phone) {
|
53
54
|
return __awaiter(this, void 0, void 0, function* () {
|
54
|
-
var _a, _b, _c;
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
var _a, _b, _c, _d, _e;
|
56
|
+
let phoneFormated = phone ? formatPhoneNumber(phone) : undefined;
|
57
|
+
const defaultClient = MercuryFixture.getDefaultClient();
|
58
|
+
const isDefaultClient = defaultClient &&
|
59
|
+
(!phone || ((_b = (_a = defaultClient === null || defaultClient === void 0 ? void 0 : defaultClient.auth) === null || _a === void 0 ? void 0 : _a.person) === null || _b === void 0 ? void 0 : _b.phone) === phoneFormated);
|
60
|
+
if (isDefaultClient) {
|
61
|
+
return {
|
62
|
+
client: defaultClient,
|
63
|
+
person: defaultClient.auth.person,
|
64
|
+
token: defaultClient.auth.token,
|
65
|
+
};
|
66
|
+
}
|
67
|
+
const isFirstLoggedIn = this.firstLoggedIn &&
|
68
|
+
(!phone || phoneFormated === this.firstLoggedIn.person.phone);
|
69
|
+
if (isFirstLoggedIn) {
|
70
|
+
return this.firstLoggedIn;
|
59
71
|
}
|
60
72
|
const client = (yield this.connectToApi({
|
61
73
|
shouldReUseClient: !phone,
|
62
74
|
}));
|
63
|
-
if ((
|
75
|
+
if ((_c = client.auth) === null || _c === void 0 ? void 0 : _c.person) {
|
64
76
|
return {
|
65
77
|
client,
|
66
78
|
person: client.auth.person,
|
@@ -77,7 +89,7 @@ export default class PersonFixture {
|
|
77
89
|
}
|
78
90
|
const formattedPhone = formatPhoneNumber(p);
|
79
91
|
//@ts-ignore
|
80
|
-
if (((
|
92
|
+
if (((_e = (_d = client.auth) === null || _d === void 0 ? void 0 : _d.person) === null || _e === void 0 ? void 0 : _e.phone) === formattedPhone) {
|
81
93
|
return {
|
82
94
|
client,
|
83
95
|
person: client.auth.person,
|
@@ -93,8 +105,10 @@ export default class PersonFixture {
|
|
93
105
|
});
|
94
106
|
//@ts-ignore
|
95
107
|
client.auth = { person, token };
|
96
|
-
this.
|
97
|
-
|
108
|
+
if (!this.firstLoggedIn) {
|
109
|
+
this.firstLoggedIn = { person, client, token };
|
110
|
+
}
|
111
|
+
return { person, client, token };
|
98
112
|
});
|
99
113
|
}
|
100
114
|
destroy() {
|
@@ -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 {};
|
@@ -12,13 +12,13 @@ import { eventResponseUtil } from '@sprucelabs/spruce-event-utils';
|
|
12
12
|
import { assert } from '@sprucelabs/test-utils';
|
13
13
|
export default class RoleFixture {
|
14
14
|
constructor(options) {
|
15
|
-
this.
|
15
|
+
this.people = options.people;
|
16
16
|
this.getNewestOrgHandler = options.getNewestOrg;
|
17
17
|
}
|
18
18
|
listRoles(options) {
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
20
20
|
let { organizationId, locationId, personId, phone, shouldIncludeMetaRoles, } = options !== null && options !== void 0 ? options : {};
|
21
|
-
const { client } = yield this.
|
21
|
+
const { client } = yield this.people.loginAsDemoPerson(phone);
|
22
22
|
if (!organizationId && !locationId) {
|
23
23
|
const latest = yield this.getNewestOrgHandler();
|
24
24
|
organizationId = latest === null || latest === void 0 ? void 0 : latest.id;
|
@@ -48,7 +48,7 @@ export default class RoleFixture {
|
|
48
48
|
addRoleToPerson(options) {
|
49
49
|
return __awaiter(this, void 0, void 0, function* () {
|
50
50
|
const { personId, organizationId, locationId, roleBase, phone } = options;
|
51
|
-
const { client } = yield this.
|
51
|
+
const { client } = yield this.people.loginAsDemoPerson(phone);
|
52
52
|
const match = yield this.getFirstRoleWithBase({
|
53
53
|
organizationId,
|
54
54
|
phone,
|
@@ -74,7 +74,7 @@ export default class RoleFixture {
|
|
74
74
|
removeRoleFromPerson(options) {
|
75
75
|
return __awaiter(this, void 0, void 0, function* () {
|
76
76
|
const { phone, organizationId: orgId, personId, roleBase, locationId, } = options;
|
77
|
-
const { client } = yield this.
|
77
|
+
const { client } = yield this.people.loginAsDemoPerson(phone);
|
78
78
|
const role = yield this.getFirstRoleWithBase({
|
79
79
|
phone,
|
80
80
|
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>;
|
@@ -24,12 +24,12 @@ export default class SkillFixture {
|
|
24
24
|
this.skills = [];
|
25
25
|
this.skillCounter = process.pid;
|
26
26
|
this.connectToApi = options.connectToApi;
|
27
|
-
this.
|
27
|
+
this.people = options.people;
|
28
28
|
}
|
29
29
|
seedDemoSkill(options) {
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
31
31
|
const _a = options !== null && options !== void 0 ? options : {}, { creatorPhone } = _a, values = __rest(_a, ["creatorPhone"]);
|
32
|
-
const { client } = yield this.
|
32
|
+
const { client } = yield this.people.loginAsDemoPerson(creatorPhone);
|
33
33
|
const [{ skill }] = yield client.emitAndFlattenResponses('register-skill::v2020_12_25', {
|
34
34
|
payload: Object.assign({ slug: this.generateSkillSlug(), name: this.generateSkillName() }, values),
|
35
35
|
});
|
@@ -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;
|
@@ -29,7 +29,7 @@ class ViewFixture {
|
|
29
29
|
this.shouldAutomaticallyResetAuthenticator = shouldReset;
|
30
30
|
}
|
31
31
|
constructor(options) {
|
32
|
-
const { connectToApi, people, fixtureFactory, vcDir, cwd, namespace, proxyDecorator, permissions, } = options;
|
32
|
+
const { connectToApi, people, organizations: orgs, locations, fixtureFactory, vcDir, cwd, namespace, proxyDecorator, permissions, } = options;
|
33
33
|
this.connectToApi = connectToApi;
|
34
34
|
this.people = people;
|
35
35
|
this.vcDir =
|
@@ -37,18 +37,20 @@ class ViewFixture {
|
|
37
37
|
this.controllerMap = options === null || options === void 0 ? void 0 : options.controllerMap;
|
38
38
|
this.namespace = namespace;
|
39
39
|
this.proxyDecorator = proxyDecorator;
|
40
|
-
this.
|
41
|
-
|
42
|
-
|
40
|
+
this.organizations =
|
41
|
+
orgs !== null && orgs !== void 0 ? orgs : fixtureFactory.Fixture('organization', {
|
42
|
+
people: this.people,
|
43
|
+
});
|
43
44
|
this.permissions = permissions;
|
44
45
|
if (!ViewFixture.device) {
|
45
46
|
ViewFixture.device = new SpyDevice();
|
46
47
|
}
|
47
48
|
this.locale = new LocaleImpl();
|
48
|
-
this.locations =
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
this.locations =
|
50
|
+
locations !== null && locations !== void 0 ? locations : fixtureFactory.Fixture('location', {
|
51
|
+
people: this.people,
|
52
|
+
organizations: this.organizations,
|
53
|
+
});
|
52
54
|
}
|
53
55
|
addPlugin(name, plugin) {
|
54
56
|
this.getFactory().addPlugin(name, plugin);
|
@@ -256,7 +258,7 @@ class ViewFixture {
|
|
256
258
|
getScope() {
|
257
259
|
if (!ViewFixture.scope) {
|
258
260
|
ViewFixture.scope = new SpyScope({
|
259
|
-
organizationFixture: this.
|
261
|
+
organizationFixture: this.organizations,
|
260
262
|
locationFixture: this.locations,
|
261
263
|
});
|
262
264
|
}
|