@sprucelabs/spruce-test-fixtures 44.2.13 → 44.2.16
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/ClientProxyDecorator.js +2 -1
- package/build/esm/ClientProxyDecorator.js +2 -1
- package/build/esm/tests/AbstractSpruceFixtureTest.d.ts +1 -1
- package/build/esm/tests/decorators/fake.js +37 -28
- package/build/esm/tests/fixtures/PersonFixture.js +1 -1
- package/build/esm/tests/fixtures/ViewFixture.d.ts +1 -1
- package/build/tests/AbstractSpruceFixtureTest.d.ts +1 -1
- package/build/tests/decorators/fake.js +35 -28
- package/build/tests/fixtures/PersonFixture.js +1 -1
- package/build/tests/fixtures/ViewFixture.d.ts +1 -1
- package/package.json +6 -6
|
@@ -22,7 +22,7 @@ class ClientProxyDecorator {
|
|
|
22
22
|
delete this.instance;
|
|
23
23
|
}
|
|
24
24
|
decorateEmitToPassProxyToken(client, token) {
|
|
25
|
-
const newClient = Object.assign(Object.assign({}, client), {
|
|
25
|
+
const newClient = Object.assign(Object.assign({}, client), { proxyToken: token,
|
|
26
26
|
//@ts-ignore
|
|
27
27
|
emit: async (eventName, targetAndPayload, cb) => {
|
|
28
28
|
let builtTp = await this.mixinProxyToken(token, targetAndPayload);
|
|
@@ -34,6 +34,7 @@ class ClientProxyDecorator {
|
|
|
34
34
|
return client.emitAndFlattenResponses(eventName, builtTp, cb);
|
|
35
35
|
} });
|
|
36
36
|
spruce_skill_utils_1.functionDelegationUtil.delegateFunctionCalls(newClient, client);
|
|
37
|
+
newClient.getProxyToken = () => token;
|
|
37
38
|
return newClient;
|
|
38
39
|
}
|
|
39
40
|
async mixinProxyToken(token, targetAndPayload) {
|
|
@@ -29,7 +29,7 @@ export default class ClientProxyDecorator {
|
|
|
29
29
|
delete this.instance;
|
|
30
30
|
}
|
|
31
31
|
decorateEmitToPassProxyToken(client, token) {
|
|
32
|
-
const newClient = Object.assign(Object.assign({}, client), {
|
|
32
|
+
const newClient = Object.assign(Object.assign({}, client), { proxyToken: token,
|
|
33
33
|
//@ts-ignore
|
|
34
34
|
emit: (eventName, targetAndPayload, cb) => __awaiter(this, void 0, void 0, function* () {
|
|
35
35
|
let builtTp = yield this.mixinProxyToken(token, targetAndPayload);
|
|
@@ -41,6 +41,7 @@ export default class ClientProxyDecorator {
|
|
|
41
41
|
return client.emitAndFlattenResponses(eventName, builtTp, cb);
|
|
42
42
|
}) });
|
|
43
43
|
functionDelegationUtil.delegateFunctionCalls(newClient, client);
|
|
44
|
+
newClient.getProxyToken = () => token;
|
|
44
45
|
return newClient;
|
|
45
46
|
}
|
|
46
47
|
mixinProxyToken(token, targetAndPayload) {
|
|
@@ -16,7 +16,7 @@ declare type Role = SpruceSchemas.Spruce.v2020_07_22.Role;
|
|
|
16
16
|
declare type Skill = SpruceSchemas.Spruce.v2020_07_22.Skill;
|
|
17
17
|
declare type Organization = SpruceSchemas.Spruce.v2020_07_22.Organization;
|
|
18
18
|
export default abstract class AbstractSpruceFixtureTest extends AbstractSkillTest {
|
|
19
|
-
static
|
|
19
|
+
static fakedPerson: Person;
|
|
20
20
|
static fakedPeople: Person[];
|
|
21
21
|
static fakedTeammates: Person[];
|
|
22
22
|
static fakedOwners: Person[];
|
|
@@ -39,7 +39,8 @@ const strategies = {
|
|
|
39
39
|
groupManagers: buildSeeder('groupManagers'),
|
|
40
40
|
owners: buildSeeder('owners'),
|
|
41
41
|
};
|
|
42
|
-
function
|
|
42
|
+
function resetFakedRecords(Class) {
|
|
43
|
+
var _a, _b, _c;
|
|
43
44
|
if (shouldSkipNextReset) {
|
|
44
45
|
shouldSkipNextReset = false;
|
|
45
46
|
return;
|
|
@@ -54,10 +55,12 @@ function resetFakes(Class) {
|
|
|
54
55
|
Class.fakedGroupManagers = [];
|
|
55
56
|
Class.fakedGuests = [];
|
|
56
57
|
Class.fakedRoles = [];
|
|
57
|
-
Class.fakedPeople = [];
|
|
58
|
+
Class.fakedPeople = ((_a = Class.fakedPeople) === null || _a === void 0 ? void 0 : _a[0]) ? [Class.fakedPeople[0]] : [];
|
|
58
59
|
Class.fakedSkills = [];
|
|
59
|
-
Class.fakedTokens = [];
|
|
60
|
-
Class.fakedProxyTokens = []
|
|
60
|
+
Class.fakedTokens = ((_b = Class.fakedTokens) === null || _b === void 0 ? void 0 : _b[0]) ? [Class.fakedTokens[0]] : [];
|
|
61
|
+
Class.fakedProxyTokens = ((_c = Class.fakedProxyTokens) === null || _c === void 0 ? void 0 : _c[0])
|
|
62
|
+
? [Class.fakedProxyTokens[0]]
|
|
63
|
+
: [];
|
|
61
64
|
}
|
|
62
65
|
export default function fake(target, total) {
|
|
63
66
|
assertOptions({ target, total }, ['target', 'total']);
|
|
@@ -66,7 +69,7 @@ export default function fake(target, total) {
|
|
|
66
69
|
const Class = TestClass;
|
|
67
70
|
const bound = (_b = (_a = descriptor === null || descriptor === void 0 ? void 0 : descriptor.value) === null || _a === void 0 ? void 0 : _a.bind) === null || _b === void 0 ? void 0 : _b.call(_a, Class);
|
|
68
71
|
descriptor.value = (...args) => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
assert.isTruthy(Class.
|
|
72
|
+
assert.isTruthy(Class.fakedPerson, `You gotta @faker.login(...) before you can create fake '${target}'!`);
|
|
70
73
|
const strategy = strategies[target];
|
|
71
74
|
assert.isTruthy(strategy, `Faking ${target} is not ready yet!`);
|
|
72
75
|
yield (strategy === null || strategy === void 0 ? void 0 : strategy(Class, total));
|
|
@@ -77,6 +80,7 @@ export default function fake(target, total) {
|
|
|
77
80
|
fake.login = (phone = '555-000-0000') => {
|
|
78
81
|
assert.isTruthy(phone, `You need to pass a phone to 'faker.login(...)'`);
|
|
79
82
|
assert.isTrue(isValidNumber(phone), `'${phone}' is not a valid phone. Try something like: 555-000-0000`);
|
|
83
|
+
MercuryFixture.setShouldAutomaticallyClearDefaultClient(false);
|
|
80
84
|
MercuryTestClient.setShouldRequireLocalListeners(true);
|
|
81
85
|
MercuryClientFactory.setIsTestMode(true);
|
|
82
86
|
seed.disableResettingTestClient();
|
|
@@ -95,28 +99,26 @@ fake.login = (phone = '555-000-0000') => {
|
|
|
95
99
|
MercuryFixture.beforeEach = (...args) => __awaiter(this, void 0, void 0, function* () {
|
|
96
100
|
//@ts-ignore
|
|
97
101
|
yield old(...args);
|
|
98
|
-
yield
|
|
99
|
-
MercuryFixture.setDefaultClient(Class.fakedOwnerClient);
|
|
102
|
+
yield setupFakeListeners(Class);
|
|
100
103
|
});
|
|
101
104
|
}
|
|
102
105
|
Class.beforeAll = () => __awaiter(this, void 0, void 0, function* () {
|
|
103
106
|
yield (beforeAll === null || beforeAll === void 0 ? void 0 : beforeAll());
|
|
104
|
-
|
|
105
|
-
yield
|
|
107
|
+
resetFakedRecords(Class);
|
|
108
|
+
yield setupFakeListeners(Class);
|
|
106
109
|
yield login(Class, phone);
|
|
107
|
-
MercuryFixture.setDefaultClient(Class.
|
|
110
|
+
MercuryFixture.setDefaultClient(Class.fakedClient);
|
|
108
111
|
});
|
|
109
112
|
Class.afterEach = () => __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
yield
|
|
113
|
+
yield setupFakeListeners(Class);
|
|
111
114
|
yield (afterEach === null || afterEach === void 0 ? void 0 : afterEach());
|
|
112
115
|
});
|
|
113
116
|
Class.beforeEach = () => __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
|
|
115
|
-
|
|
117
|
+
resetFakedRecords(Class);
|
|
118
|
+
yield setupFakeListeners(Class);
|
|
116
119
|
if (!TestClass.cwd) {
|
|
117
120
|
return;
|
|
118
121
|
}
|
|
119
|
-
yield login(Class, phone);
|
|
120
122
|
shouldPassHookCalls && (yield (beforeEach === null || beforeEach === void 0 ? void 0 : beforeEach()));
|
|
121
123
|
});
|
|
122
124
|
};
|
|
@@ -129,6 +131,18 @@ fake.getPerson = () => {
|
|
|
129
131
|
return fake.getClient().auth.person;
|
|
130
132
|
};
|
|
131
133
|
function login(Class, phone) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
const { person, client } = yield loginUsingViewsFallingBackToPeople(Class, phone);
|
|
136
|
+
if (!person.firstName) {
|
|
137
|
+
givePersonName(person);
|
|
138
|
+
}
|
|
139
|
+
//@ts-ignore
|
|
140
|
+
client.auth.person = person;
|
|
141
|
+
Class.fakedClient = client;
|
|
142
|
+
Class.fakedPerson = person;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function loginUsingViewsFallingBackToPeople(Class, phone) {
|
|
132
146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
133
147
|
let person;
|
|
134
148
|
let client;
|
|
@@ -142,13 +156,8 @@ function login(Class, phone) {
|
|
|
142
156
|
person = p;
|
|
143
157
|
client = c;
|
|
144
158
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
Class.fakedPeople = [person];
|
|
149
|
-
Class.fakedOwners = [person];
|
|
150
|
-
Class.fakedOwner = person;
|
|
151
|
-
Class.fakedOwnerClient = client;
|
|
159
|
+
yield client.registerProxyToken();
|
|
160
|
+
return { person: Class.fakedPeople.find((p) => p.id === person.id), client };
|
|
152
161
|
});
|
|
153
162
|
}
|
|
154
163
|
function givePersonName(person) {
|
|
@@ -157,7 +166,7 @@ function givePersonName(person) {
|
|
|
157
166
|
person.firstName = names.firstName;
|
|
158
167
|
person.lastName = names.lastName;
|
|
159
168
|
}
|
|
160
|
-
function
|
|
169
|
+
function setupFakeListeners(Class) {
|
|
161
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
162
171
|
yield Promise.all([
|
|
163
172
|
fakeSkillLifecycleEvents(Class),
|
|
@@ -389,7 +398,7 @@ function fakeCreateLocation(Class) {
|
|
|
389
398
|
addPersonAsRoleToLocationOrOrg({
|
|
390
399
|
Class,
|
|
391
400
|
roleId: role.id,
|
|
392
|
-
person: Class.
|
|
401
|
+
person: Class.fakedPerson,
|
|
393
402
|
locationId: location.id,
|
|
394
403
|
});
|
|
395
404
|
}
|
|
@@ -410,7 +419,7 @@ function fakeCreateOrganization(Class) {
|
|
|
410
419
|
Class,
|
|
411
420
|
organizationId: organization.id,
|
|
412
421
|
roleId: roles.find((r) => r.base === 'owner').id,
|
|
413
|
-
person: Class.
|
|
422
|
+
person: Class.fakedPerson,
|
|
414
423
|
});
|
|
415
424
|
return {
|
|
416
425
|
organization,
|
|
@@ -441,7 +450,7 @@ function fakeSkillLifecycleEvents(Class) {
|
|
|
441
450
|
process.env.SKILL_API_KEY = process.env.SKILL_API_KEY || generateId();
|
|
442
451
|
yield eventFaker.on('register-skill::v2020_12_25', ({ payload }) => {
|
|
443
452
|
var _a;
|
|
444
|
-
const skill = Object.assign(Object.assign({ apiKey: generateId(), creators: [{ personId: Class.
|
|
453
|
+
const skill = Object.assign(Object.assign({ apiKey: generateId(), creators: [{ personId: Class.fakedPerson.id }], dateCreated: new Date().getTime(), id: generateId() }, payload), { slug: (_a = payload.slug) !== null && _a !== void 0 ? _a : generateId() });
|
|
445
454
|
Class.fakedSkills.unshift(skill);
|
|
446
455
|
return {
|
|
447
456
|
skill,
|
|
@@ -593,8 +602,8 @@ function fakeAuthenticationEvents(Class) {
|
|
|
593
602
|
let person = Class.fakedPeople.find((p) => p.phone === formattedPhone);
|
|
594
603
|
if (!person) {
|
|
595
604
|
person =
|
|
596
|
-
((_a = Class.
|
|
597
|
-
? Class.
|
|
605
|
+
((_a = Class.fakedPerson) === null || _a === void 0 ? void 0 : _a.phone) === formattedPhone
|
|
606
|
+
? Class.fakedPerson
|
|
598
607
|
: {
|
|
599
608
|
id: generateId(),
|
|
600
609
|
casualName: 'friend',
|
|
@@ -659,7 +668,7 @@ function fakeAuthenticationEvents(Class) {
|
|
|
659
668
|
}
|
|
660
669
|
const person = getPersonById(Class, match.personId);
|
|
661
670
|
return {
|
|
662
|
-
type: '
|
|
671
|
+
type: 'authenticated',
|
|
663
672
|
auth: {
|
|
664
673
|
person,
|
|
665
674
|
},
|
|
@@ -53,7 +53,7 @@ export default class PersonFixture {
|
|
|
53
53
|
var _a, _b, _c;
|
|
54
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
55
|
if (this.lastLoggedIn &&
|
|
56
|
-
(!phone || phone === this.lastLoggedIn.person.phone)) {
|
|
56
|
+
(!phone || formatPhoneNumber(phone) === this.lastLoggedIn.person.phone)) {
|
|
57
57
|
return this.lastLoggedIn;
|
|
58
58
|
}
|
|
59
59
|
const client = (yield this.connectToApi({
|
|
@@ -49,7 +49,7 @@ export default class ViewFixture {
|
|
|
49
49
|
static beforeAll(): Promise<void>;
|
|
50
50
|
static beforeEach(): Promise<void>;
|
|
51
51
|
private static resetMaps;
|
|
52
|
-
|
|
52
|
+
static resetAuth(): void;
|
|
53
53
|
load<Svc extends SkillViewController = SkillViewController>(vc: Pick<Svc, 'load' | 'getScope'>, args?: ArgsFromSvc<Svc>): Promise<void>;
|
|
54
54
|
private assertScopeRequirementsMet;
|
|
55
55
|
setScope(scope: Scope): void;
|
|
@@ -16,7 +16,7 @@ declare type Role = SpruceSchemas.Spruce.v2020_07_22.Role;
|
|
|
16
16
|
declare type Skill = SpruceSchemas.Spruce.v2020_07_22.Skill;
|
|
17
17
|
declare type Organization = SpruceSchemas.Spruce.v2020_07_22.Organization;
|
|
18
18
|
export default abstract class AbstractSpruceFixtureTest extends AbstractSkillTest {
|
|
19
|
-
static
|
|
19
|
+
static fakedPerson: Person;
|
|
20
20
|
static fakedPeople: Person[];
|
|
21
21
|
static fakedTeammates: Person[];
|
|
22
22
|
static fakedOwners: Person[];
|
|
@@ -36,7 +36,8 @@ const strategies = {
|
|
|
36
36
|
groupManagers: buildSeeder('groupManagers'),
|
|
37
37
|
owners: buildSeeder('owners'),
|
|
38
38
|
};
|
|
39
|
-
function
|
|
39
|
+
function resetFakedRecords(Class) {
|
|
40
|
+
var _a, _b, _c;
|
|
40
41
|
if (shouldSkipNextReset) {
|
|
41
42
|
shouldSkipNextReset = false;
|
|
42
43
|
return;
|
|
@@ -51,10 +52,12 @@ function resetFakes(Class) {
|
|
|
51
52
|
Class.fakedGroupManagers = [];
|
|
52
53
|
Class.fakedGuests = [];
|
|
53
54
|
Class.fakedRoles = [];
|
|
54
|
-
Class.fakedPeople = [];
|
|
55
|
+
Class.fakedPeople = ((_a = Class.fakedPeople) === null || _a === void 0 ? void 0 : _a[0]) ? [Class.fakedPeople[0]] : [];
|
|
55
56
|
Class.fakedSkills = [];
|
|
56
|
-
Class.fakedTokens = [];
|
|
57
|
-
Class.fakedProxyTokens = []
|
|
57
|
+
Class.fakedTokens = ((_b = Class.fakedTokens) === null || _b === void 0 ? void 0 : _b[0]) ? [Class.fakedTokens[0]] : [];
|
|
58
|
+
Class.fakedProxyTokens = ((_c = Class.fakedProxyTokens) === null || _c === void 0 ? void 0 : _c[0])
|
|
59
|
+
? [Class.fakedProxyTokens[0]]
|
|
60
|
+
: [];
|
|
58
61
|
}
|
|
59
62
|
function fake(target, total) {
|
|
60
63
|
(0, schema_1.assertOptions)({ target, total }, ['target', 'total']);
|
|
@@ -63,7 +66,7 @@ function fake(target, total) {
|
|
|
63
66
|
const Class = TestClass;
|
|
64
67
|
const bound = (_b = (_a = descriptor === null || descriptor === void 0 ? void 0 : descriptor.value) === null || _a === void 0 ? void 0 : _a.bind) === null || _b === void 0 ? void 0 : _b.call(_a, Class);
|
|
65
68
|
descriptor.value = async (...args) => {
|
|
66
|
-
test_1.assert.isTruthy(Class.
|
|
69
|
+
test_1.assert.isTruthy(Class.fakedPerson, `You gotta @faker.login(...) before you can create fake '${target}'!`);
|
|
67
70
|
const strategy = strategies[target];
|
|
68
71
|
test_1.assert.isTruthy(strategy, `Faking ${target} is not ready yet!`);
|
|
69
72
|
await (strategy === null || strategy === void 0 ? void 0 : strategy(Class, total));
|
|
@@ -75,6 +78,7 @@ exports.default = fake;
|
|
|
75
78
|
fake.login = (phone = '555-000-0000') => {
|
|
76
79
|
test_1.assert.isTruthy(phone, `You need to pass a phone to 'faker.login(...)'`);
|
|
77
80
|
test_1.assert.isTrue((0, schema_1.isValidNumber)(phone), `'${phone}' is not a valid phone. Try something like: 555-000-0000`);
|
|
81
|
+
MercuryFixture_1.default.setShouldAutomaticallyClearDefaultClient(false);
|
|
78
82
|
mercury_client_1.MercuryTestClient.setShouldRequireLocalListeners(true);
|
|
79
83
|
mercury_client_1.MercuryClientFactory.setIsTestMode(true);
|
|
80
84
|
seed_1.default.disableResettingTestClient();
|
|
@@ -93,28 +97,26 @@ fake.login = (phone = '555-000-0000') => {
|
|
|
93
97
|
MercuryFixture_1.default.beforeEach = async (...args) => {
|
|
94
98
|
//@ts-ignore
|
|
95
99
|
await old(...args);
|
|
96
|
-
await
|
|
97
|
-
MercuryFixture_1.default.setDefaultClient(Class.fakedOwnerClient);
|
|
100
|
+
await setupFakeListeners(Class);
|
|
98
101
|
};
|
|
99
102
|
}
|
|
100
103
|
Class.beforeAll = async () => {
|
|
101
104
|
await (beforeAll === null || beforeAll === void 0 ? void 0 : beforeAll());
|
|
102
|
-
|
|
103
|
-
await
|
|
105
|
+
resetFakedRecords(Class);
|
|
106
|
+
await setupFakeListeners(Class);
|
|
104
107
|
await login(Class, phone);
|
|
105
|
-
MercuryFixture_1.default.setDefaultClient(Class.
|
|
108
|
+
MercuryFixture_1.default.setDefaultClient(Class.fakedClient);
|
|
106
109
|
};
|
|
107
110
|
Class.afterEach = async () => {
|
|
108
|
-
await
|
|
111
|
+
await setupFakeListeners(Class);
|
|
109
112
|
await (afterEach === null || afterEach === void 0 ? void 0 : afterEach());
|
|
110
113
|
};
|
|
111
114
|
Class.beforeEach = async () => {
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
resetFakedRecords(Class);
|
|
116
|
+
await setupFakeListeners(Class);
|
|
114
117
|
if (!TestClass.cwd) {
|
|
115
118
|
return;
|
|
116
119
|
}
|
|
117
|
-
await login(Class, phone);
|
|
118
120
|
shouldPassHookCalls && (await (beforeEach === null || beforeEach === void 0 ? void 0 : beforeEach()));
|
|
119
121
|
};
|
|
120
122
|
};
|
|
@@ -127,6 +129,16 @@ fake.getPerson = () => {
|
|
|
127
129
|
return fake.getClient().auth.person;
|
|
128
130
|
};
|
|
129
131
|
async function login(Class, phone) {
|
|
132
|
+
const { person, client } = await loginUsingViewsFallingBackToPeople(Class, phone);
|
|
133
|
+
if (!person.firstName) {
|
|
134
|
+
givePersonName(person);
|
|
135
|
+
}
|
|
136
|
+
//@ts-ignore
|
|
137
|
+
client.auth.person = person;
|
|
138
|
+
Class.fakedClient = client;
|
|
139
|
+
Class.fakedPerson = person;
|
|
140
|
+
}
|
|
141
|
+
async function loginUsingViewsFallingBackToPeople(Class, phone) {
|
|
130
142
|
let person;
|
|
131
143
|
let client;
|
|
132
144
|
try {
|
|
@@ -139,13 +151,8 @@ async function login(Class, phone) {
|
|
|
139
151
|
person = p;
|
|
140
152
|
client = c;
|
|
141
153
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
Class.fakedPeople = [person];
|
|
146
|
-
Class.fakedOwners = [person];
|
|
147
|
-
Class.fakedOwner = person;
|
|
148
|
-
Class.fakedOwnerClient = client;
|
|
154
|
+
await client.registerProxyToken();
|
|
155
|
+
return { person: Class.fakedPeople.find((p) => p.id === person.id), client };
|
|
149
156
|
}
|
|
150
157
|
function givePersonName(person) {
|
|
151
158
|
const names = (0, generateRandomName_1.default)();
|
|
@@ -153,7 +160,7 @@ function givePersonName(person) {
|
|
|
153
160
|
person.firstName = names.firstName;
|
|
154
161
|
person.lastName = names.lastName;
|
|
155
162
|
}
|
|
156
|
-
async function
|
|
163
|
+
async function setupFakeListeners(Class) {
|
|
157
164
|
await Promise.all([
|
|
158
165
|
fakeSkillLifecycleEvents(Class),
|
|
159
166
|
fakeGetPerson(Class),
|
|
@@ -364,7 +371,7 @@ async function fakeCreateLocation(Class) {
|
|
|
364
371
|
addPersonAsRoleToLocationOrOrg({
|
|
365
372
|
Class,
|
|
366
373
|
roleId: role.id,
|
|
367
|
-
person: Class.
|
|
374
|
+
person: Class.fakedPerson,
|
|
368
375
|
locationId: location.id,
|
|
369
376
|
});
|
|
370
377
|
}
|
|
@@ -383,7 +390,7 @@ async function fakeCreateOrganization(Class) {
|
|
|
383
390
|
Class,
|
|
384
391
|
organizationId: organization.id,
|
|
385
392
|
roleId: roles.find((r) => r.base === 'owner').id,
|
|
386
|
-
person: Class.
|
|
393
|
+
person: Class.fakedPerson,
|
|
387
394
|
});
|
|
388
395
|
return {
|
|
389
396
|
organization,
|
|
@@ -410,7 +417,7 @@ async function fakeSkillLifecycleEvents(Class) {
|
|
|
410
417
|
process.env.SKILL_API_KEY = process.env.SKILL_API_KEY || (0, test_utils_1.generateId)();
|
|
411
418
|
await eventFaker_1.default.on('register-skill::v2020_12_25', ({ payload }) => {
|
|
412
419
|
var _a;
|
|
413
|
-
const skill = Object.assign(Object.assign({ apiKey: (0, test_utils_1.generateId)(), creators: [{ personId: Class.
|
|
420
|
+
const skill = Object.assign(Object.assign({ apiKey: (0, test_utils_1.generateId)(), creators: [{ personId: Class.fakedPerson.id }], dateCreated: new Date().getTime(), id: (0, test_utils_1.generateId)() }, payload), { slug: (_a = payload.slug) !== null && _a !== void 0 ? _a : (0, test_utils_1.generateId)() });
|
|
414
421
|
Class.fakedSkills.unshift(skill);
|
|
415
422
|
return {
|
|
416
423
|
skill,
|
|
@@ -544,8 +551,8 @@ async function fakeAuthenticationEvents(Class) {
|
|
|
544
551
|
let person = Class.fakedPeople.find((p) => p.phone === formattedPhone);
|
|
545
552
|
if (!person) {
|
|
546
553
|
person =
|
|
547
|
-
((_a = Class.
|
|
548
|
-
? Class.
|
|
554
|
+
((_a = Class.fakedPerson) === null || _a === void 0 ? void 0 : _a.phone) === formattedPhone
|
|
555
|
+
? Class.fakedPerson
|
|
549
556
|
: {
|
|
550
557
|
id: (0, test_utils_1.generateId)(),
|
|
551
558
|
casualName: 'friend',
|
|
@@ -610,7 +617,7 @@ async function fakeAuthenticationEvents(Class) {
|
|
|
610
617
|
}
|
|
611
618
|
const person = getPersonById(Class, match.personId);
|
|
612
619
|
return {
|
|
613
|
-
type: '
|
|
620
|
+
type: 'authenticated',
|
|
614
621
|
auth: {
|
|
615
622
|
person,
|
|
616
623
|
},
|
|
@@ -44,7 +44,7 @@ class PersonFixture {
|
|
|
44
44
|
async loginAsDemoPerson(phone) {
|
|
45
45
|
var _a, _b, _c;
|
|
46
46
|
if (this.lastLoggedIn &&
|
|
47
|
-
(!phone || phone === this.lastLoggedIn.person.phone)) {
|
|
47
|
+
(!phone || (0, schema_1.formatPhoneNumber)(phone) === this.lastLoggedIn.person.phone)) {
|
|
48
48
|
return this.lastLoggedIn;
|
|
49
49
|
}
|
|
50
50
|
const client = (await this.connectToApi({
|
|
@@ -49,7 +49,7 @@ export default class ViewFixture {
|
|
|
49
49
|
static beforeAll(): Promise<void>;
|
|
50
50
|
static beforeEach(): Promise<void>;
|
|
51
51
|
private static resetMaps;
|
|
52
|
-
|
|
52
|
+
static resetAuth(): void;
|
|
53
53
|
load<Svc extends SkillViewController = SkillViewController>(vc: Pick<Svc, 'load' | 'getScope'>, args?: ArgsFromSvc<Svc>): Promise<void>;
|
|
54
54
|
private assertScopeRequirementsMet;
|
|
55
55
|
setScope(scope: Scope): void;
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@sprucelabs/spruce-test-fixtures"
|
|
14
14
|
]
|
|
15
15
|
},
|
|
16
|
-
"version": "44.2.
|
|
16
|
+
"version": "44.2.16",
|
|
17
17
|
"files": [
|
|
18
18
|
"build/**/*",
|
|
19
19
|
"!build/__tests__",
|
|
@@ -64,14 +64,14 @@
|
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@sprucelabs/data-stores": "^17.0.59",
|
|
66
66
|
"@sprucelabs/error": "^5.0.487",
|
|
67
|
-
"@sprucelabs/heartwood-view-controllers": "^86.13.
|
|
68
|
-
"@sprucelabs/mercury-client": "^31.0.
|
|
67
|
+
"@sprucelabs/heartwood-view-controllers": "^86.13.19",
|
|
68
|
+
"@sprucelabs/mercury-client": "^31.0.97",
|
|
69
69
|
"@sprucelabs/mercury-core-events": "^12.0.97",
|
|
70
|
-
"@sprucelabs/mercury-event-emitter": "^31.0.
|
|
70
|
+
"@sprucelabs/mercury-event-emitter": "^31.0.97",
|
|
71
71
|
"@sprucelabs/schema": "^28.3.16",
|
|
72
72
|
"@sprucelabs/spruce-core-schemas": "^34.2.17",
|
|
73
73
|
"@sprucelabs/spruce-event-utils": "^27.0.72",
|
|
74
|
-
"@sprucelabs/spruce-skill-booter": "^44.2.
|
|
74
|
+
"@sprucelabs/spruce-skill-booter": "^44.2.16",
|
|
75
75
|
"@sprucelabs/spruce-skill-utils": "^26.3.7",
|
|
76
76
|
"dotenv": "^16.0.1",
|
|
77
77
|
"unique-names-generator": "^4.7.1"
|
|
@@ -131,5 +131,5 @@
|
|
|
131
131
|
]
|
|
132
132
|
]
|
|
133
133
|
},
|
|
134
|
-
"gitHead": "
|
|
134
|
+
"gitHead": "05de2950403d182f60c9f9885bc4fa9749b6947e"
|
|
135
135
|
}
|