@sprucelabs/spruce-test-fixtures 49.0.39 → 49.0.42
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/__tests__/behavioral/CanUseStoresSetupInBeforeEach.test.js +5 -5
- package/build/__tests__/behavioral/DatabaseFixture.test.d.ts +1 -1
- package/build/__tests__/behavioral/DatabaseFixture.test.js +7 -7
- package/build/__tests__/behavioral/DbResetsAsExpected.test.js +4 -4
- package/build/__tests__/behavioral/DecoratoringEmitToPassThroughProxy.test.js +18 -18
- package/build/__tests__/behavioral/DelaysConnectWhenOnlyUsingLoginDecorator.test.js +3 -3
- package/build/__tests__/behavioral/DisablingSchemaValidationOnTest.test.js +5 -5
- package/build/__tests__/behavioral/DoesntResetAccountIfOnlySeedingLocally.test.js +9 -9
- package/build/__tests__/behavioral/FakingEventResponses.test.js +15 -15
- package/build/__tests__/behavioral/FixtureFactory.test.d.ts +1 -1
- package/build/__tests__/behavioral/FixtureFactory.test.js +14 -14
- package/build/__tests__/behavioral/LocationFixture.test.js +17 -17
- package/build/__tests__/behavioral/LoginDecoratorHandlingProxiesForMe.test.js +11 -11
- package/build/__tests__/behavioral/MakingSureLocalEventsAreHandledLocally.test.js +3 -3
- package/build/__tests__/behavioral/MercuryFixture.test.js +28 -28
- package/build/__tests__/behavioral/OrganizationFixture.test.js +50 -50
- package/build/__tests__/behavioral/PatchingConsoleErrorToErrorStream.test.js +3 -3
- package/build/__tests__/behavioral/PersonFixture.test.d.ts +1 -1
- package/build/__tests__/behavioral/PersonFixture.test.js +37 -37
- package/build/__tests__/behavioral/PhoneNumberIncrementor.test.js +22 -22
- package/build/__tests__/behavioral/ResettingAccountLocationsInBeforeAll.test.js +5 -5
- package/build/__tests__/behavioral/ResettingAccountOrgsInAfterAll.test.js +3 -3
- package/build/__tests__/behavioral/ResettingAccountOrgsInBeforeAll.test.js +5 -5
- package/build/__tests__/behavioral/ResettingFixtureFieldsBeforeEach.test.js +9 -9
- package/build/__tests__/behavioral/ResettingLocalEventListeningBeforeSeeding.test.js +4 -4
- package/build/__tests__/behavioral/RetainsContractWhenLoggingInUsingDecotorator.test.js +2 -2
- package/build/__tests__/behavioral/RoleFixture.test.js +15 -15
- package/build/__tests__/behavioral/SeedingData.test.js +43 -43
- package/build/__tests__/behavioral/SkillFixture.test.js +22 -22
- package/build/__tests__/behavioral/StoreFixture.test.d.ts +1 -1
- package/build/__tests__/behavioral/StoreFixture.test.js +20 -20
- package/build/__tests__/behavioral/faking/AuthenticatingAsAPerson.test.js +11 -11
- package/build/__tests__/behavioral/faking/FakeDecorator.test.js +74 -74
- package/build/__tests__/behavioral/faking/FakeDecoratorSetsPerson.test.js +3 -3
- package/build/__tests__/behavioral/faking/FakeDecoratorWhoAmI.test.js +3 -3
- package/build/__tests__/behavioral/faking/FakeThemeManager.test.d.ts +1 -1
- package/build/__tests__/behavioral/faking/FakeThemeManager.test.js +8 -8
- package/build/__tests__/behavioral/faking/FakingAddingPeopleToALocation.test.js +6 -6
- package/build/__tests__/behavioral/faking/FakingAddingPeopleToAnOrg.test.js +15 -15
- package/build/__tests__/behavioral/faking/FakingAuthenticator.test.js +5 -5
- package/build/__tests__/behavioral/faking/FakingInBeforeEach.test.js +5 -5
- package/build/__tests__/behavioral/faking/FakingRoleEvents.test.js +19 -19
- package/build/__tests__/behavioral/faking/FakingSkillEvents.test.js +41 -41
- package/build/__tests__/behavioral/faking/UpdatePerson.test.js +5 -5
- package/build/__tests__/behavioral/faking/UsingFakeDecorators.test.js +60 -60
- package/build/__tests__/behavioral/faking/UsingFakesOnIncompatibleClass.test.d.ts +1 -1
- package/build/__tests__/behavioral/faking/UsingFakesOnIncompatibleClass.test.js +4 -4
- package/build/__tests__/behavioral/faking/WhoAmI.test.js +12 -12
- package/build/__tests__/behavioral/maps/SpyingMapUtil.test.js +17 -17
- package/build/__tests__/behavioral/seeding/UsingDecorators.test.js +54 -54
- package/build/__tests__/behavioral/seeding/UsingDecoratorsToInstallSkills.test.js +16 -16
- package/build/__tests__/behavioral/views/CheckingPermissions.test.js +30 -30
- package/build/__tests__/behavioral/views/FakingSkillViewControllers.test.js +8 -8
- package/build/__tests__/behavioral/views/Routing.test.js +30 -30
- package/build/__tests__/behavioral/views/TestingScope.test.js +10 -10
- package/build/__tests__/behavioral/views/ViewFixture.test.js +107 -107
- package/build/__tests__/behavioral/views/WorkingWithTimezones.test.js +10 -10
- package/build/__tests__/support/AbstractFakeDecoratorTest.js +4 -4
- package/build/esm/__tests__/behavioral/CanUseStoresSetupInBeforeEach.test.js +1 -1
- package/build/esm/__tests__/behavioral/DatabaseFixture.test.d.ts +1 -1
- package/build/esm/__tests__/behavioral/DatabaseFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/DbResetsAsExpected.test.js +1 -1
- package/build/esm/__tests__/behavioral/DecoratoringEmitToPassThroughProxy.test.js +1 -1
- package/build/esm/__tests__/behavioral/DelaysConnectWhenOnlyUsingLoginDecorator.test.js +1 -1
- package/build/esm/__tests__/behavioral/DisablingSchemaValidationOnTest.test.js +1 -1
- package/build/esm/__tests__/behavioral/DoesntResetAccountIfOnlySeedingLocally.test.js +1 -1
- package/build/esm/__tests__/behavioral/FakingEventResponses.test.js +1 -1
- package/build/esm/__tests__/behavioral/FixtureFactory.test.d.ts +1 -1
- package/build/esm/__tests__/behavioral/FixtureFactory.test.js +1 -1
- package/build/esm/__tests__/behavioral/LocationFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/LoginDecoratorHandlingProxiesForMe.test.js +1 -1
- package/build/esm/__tests__/behavioral/MakingSureLocalEventsAreHandledLocally.test.js +1 -1
- package/build/esm/__tests__/behavioral/MercuryFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/OrganizationFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/PatchingConsoleErrorToErrorStream.test.js +1 -1
- package/build/esm/__tests__/behavioral/PersonFixture.test.d.ts +1 -1
- package/build/esm/__tests__/behavioral/PersonFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/PhoneNumberIncrementor.test.js +1 -1
- package/build/esm/__tests__/behavioral/ResettingAccountLocationsInBeforeAll.test.js +1 -1
- package/build/esm/__tests__/behavioral/ResettingAccountOrgsInAfterAll.test.js +1 -1
- package/build/esm/__tests__/behavioral/ResettingAccountOrgsInBeforeAll.test.js +1 -1
- package/build/esm/__tests__/behavioral/ResettingFixtureFieldsBeforeEach.test.js +1 -1
- package/build/esm/__tests__/behavioral/ResettingLocalEventListeningBeforeSeeding.test.js +1 -1
- package/build/esm/__tests__/behavioral/RetainsContractWhenLoggingInUsingDecotorator.test.js +1 -1
- package/build/esm/__tests__/behavioral/RoleFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/SeedingData.test.js +1 -1
- package/build/esm/__tests__/behavioral/SkillFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/StoreFixture.test.d.ts +1 -1
- package/build/esm/__tests__/behavioral/StoreFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/AuthenticatingAsAPerson.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakeDecorator.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakeDecoratorSetsPerson.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakeDecoratorWhoAmI.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakeThemeManager.test.d.ts +1 -1
- package/build/esm/__tests__/behavioral/faking/FakeThemeManager.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakingAddingPeopleToALocation.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakingAddingPeopleToAnOrg.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakingAuthenticator.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakingInBeforeEach.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakingRoleEvents.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakingSkillEvents.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/UpdatePerson.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/UsingFakeDecorators.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/UsingFakesOnIncompatibleClass.test.d.ts +1 -1
- package/build/esm/__tests__/behavioral/faking/UsingFakesOnIncompatibleClass.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/WhoAmI.test.js +1 -1
- package/build/esm/__tests__/behavioral/maps/SpyingMapUtil.test.js +1 -1
- package/build/esm/__tests__/behavioral/seeding/UsingDecorators.test.js +1 -1
- package/build/esm/__tests__/behavioral/seeding/UsingDecoratorsToInstallSkills.test.js +1 -1
- package/build/esm/__tests__/behavioral/views/CheckingPermissions.test.js +1 -1
- package/build/esm/__tests__/behavioral/views/FakingSkillViewControllers.test.js +1 -1
- package/build/esm/__tests__/behavioral/views/Routing.test.js +1 -1
- package/build/esm/__tests__/behavioral/views/TestingScope.test.js +1 -1
- package/build/esm/__tests__/behavioral/views/ViewFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/views/WorkingWithTimezones.test.js +1 -1
- package/build/esm/__tests__/support/AbstractFakeDecoratorTest.js +1 -1
- package/build/esm/tests/AbstractSpruceFixtureTest.js +1 -1
- package/build/esm/tests/SpyAuthorizer.js +1 -1
- package/build/esm/tests/decorators/fake.js +1 -1
- package/build/esm/tests/decorators/install.js +1 -1
- package/build/esm/tests/decorators/login.js +1 -1
- package/build/esm/tests/decorators/seed.js +1 -1
- package/build/esm/tests/fixtures/LocationFixture.js +1 -1
- package/build/esm/tests/fixtures/RoleFixture.js +1 -1
- package/build/esm/tests/fixtures/SeedFixture.js +1 -1
- package/build/tests/AbstractSpruceFixtureTest.js +3 -3
- package/build/tests/SpyAuthorizer.js +3 -3
- package/build/tests/decorators/fake.js +20 -20
- package/build/tests/decorators/install.js +3 -3
- package/build/tests/decorators/login.js +4 -4
- package/build/tests/decorators/seed.js +2 -2
- package/build/tests/fixtures/LocationFixture.js +3 -3
- package/build/tests/fixtures/RoleFixture.js +2 -2
- package/build/tests/fixtures/SeedFixture.js +2 -2
- package/package.json +5 -5
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { MercuryTestClient } from '@sprucelabs/mercury-client';
|
|
11
|
-
import { assert } from '@sprucelabs/test';
|
|
11
|
+
import { assert } from '@sprucelabs/test-utils';
|
|
12
12
|
import StoreFixture from '../fixtures/StoreFixture.js';
|
|
13
13
|
import login from './login.js';
|
|
14
14
|
export default function seed(storeName, totalToSeed, ...params) {
|
|
@@ -19,7 +19,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
19
19
|
return t;
|
|
20
20
|
};
|
|
21
21
|
import { eventResponseUtil } from '@sprucelabs/spruce-event-utils';
|
|
22
|
-
import { assert } from '@sprucelabs/test';
|
|
22
|
+
import { assert } from '@sprucelabs/test-utils';
|
|
23
23
|
import { generateId } from '@sprucelabs/test-utils';
|
|
24
24
|
export default class LocationFixture {
|
|
25
25
|
constructor(options) {
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { SchemaError } from '@sprucelabs/schema';
|
|
11
11
|
import { eventResponseUtil } from '@sprucelabs/spruce-event-utils';
|
|
12
|
-
import { assert } from '@sprucelabs/test';
|
|
12
|
+
import { assert } from '@sprucelabs/test-utils';
|
|
13
13
|
export default class RoleFixture {
|
|
14
14
|
constructor(options) {
|
|
15
15
|
this.personFixture = options.people;
|
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { assertOptions, SchemaError } from '@sprucelabs/schema';
|
|
11
11
|
import { roleSchema } from '@sprucelabs/spruce-core-schemas';
|
|
12
12
|
import { namesUtil } from '@sprucelabs/spruce-skill-utils';
|
|
13
|
-
import { assert } from '@sprucelabs/test';
|
|
13
|
+
import { assert } from '@sprucelabs/test-utils';
|
|
14
14
|
import phoneNumberIncrementor from '../../utilities/phoneNumberIncrementor.js';
|
|
15
15
|
export default class SeedFixture {
|
|
16
16
|
constructor(options) {
|
|
@@ -16,18 +16,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
const spruce_skill_booter_1 = require("@sprucelabs/spruce-skill-booter");
|
|
18
18
|
const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
|
|
19
|
-
const
|
|
19
|
+
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
20
20
|
const FixtureFactory_1 = __importDefault(require("./fixtures/FixtureFactory"));
|
|
21
21
|
class AbstractSpruceFixtureTest extends spruce_skill_booter_1.AbstractSkillTest {
|
|
22
22
|
static get fakedOrganizations() {
|
|
23
23
|
return this._fakedOrganizations;
|
|
24
24
|
}
|
|
25
25
|
static set fakedOrganizations(orgs) {
|
|
26
|
-
|
|
26
|
+
test_utils_1.assert.isAbove(this._fakedOrganizations.length, 0, `You gotta @seed('organizations', 1) (and use @fake.login(...)) before getting faked orgs.`);
|
|
27
27
|
this._fakedOrganizations = orgs;
|
|
28
28
|
}
|
|
29
29
|
static get fakedLocations() {
|
|
30
|
-
|
|
30
|
+
test_utils_1.assert.isAbove(this._fakedLocations.length, 0, `You gotta @seed('locations', 1) (and use @fake.login(...)) before getting faked locations.`);
|
|
31
31
|
return this._fakedLocations;
|
|
32
32
|
}
|
|
33
33
|
static set fakedLocations(locations) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const schema_1 = require("@sprucelabs/schema");
|
|
4
|
-
const
|
|
4
|
+
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
5
5
|
class SpyAuthorizer {
|
|
6
6
|
constructor() {
|
|
7
7
|
this.fakedPermissions = [];
|
|
@@ -21,7 +21,7 @@ class SpyAuthorizer {
|
|
|
21
21
|
async can(options) {
|
|
22
22
|
const { contractId, permissionIds } = (0, schema_1.assertOptions)(options, ['contractId', 'permissionIds']);
|
|
23
23
|
const faked = this.fakedPermissions.find((f) => f.contractId === contractId);
|
|
24
|
-
|
|
24
|
+
test_utils_1.assert.isTruthy(faked, `Contract by the id '${contractId}' not found! You need to tell the authorizer how to respond. Try 'this.views.getAuthorizer().fakePermissions(...)'
|
|
25
25
|
|
|
26
26
|
Valid contracts are:
|
|
27
27
|
|
|
@@ -30,7 +30,7 @@ ${this.fakedPermissions.map((p) => p.contractId).join('\n')}`);
|
|
|
30
30
|
const results = {};
|
|
31
31
|
for (const actual of permissionIds) {
|
|
32
32
|
const fakedPerm = faked.permissions.find((p) => p.id === actual);
|
|
33
|
-
|
|
33
|
+
test_utils_1.assert.isTruthy(fakedPerm, `Oops! I could not find the permissionId '${actual}'! Make sure you faked it with 'this.views.getAuthorizer().fakePermissions(...)'
|
|
34
34
|
|
|
35
35
|
Valid permissions on this contract are:
|
|
36
36
|
|
|
@@ -19,8 +19,8 @@ const mercury_client_1 = require("@sprucelabs/mercury-client");
|
|
|
19
19
|
const schema_1 = require("@sprucelabs/schema");
|
|
20
20
|
const spruce_core_schemas_1 = require("@sprucelabs/spruce-core-schemas");
|
|
21
21
|
const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
|
|
22
|
-
const test_1 = require("@sprucelabs/test");
|
|
23
22
|
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
23
|
+
const test_utils_2 = require("@sprucelabs/test-utils");
|
|
24
24
|
const SpruceError_1 = __importDefault(require("../../errors/SpruceError"));
|
|
25
25
|
const AbstractSpruceFixtureTest_1 = __importDefault(require("../AbstractSpruceFixtureTest"));
|
|
26
26
|
const eventFaker_1 = __importDefault(require("../eventFaker"));
|
|
@@ -67,9 +67,9 @@ function fake(target, total) {
|
|
|
67
67
|
const Class = TestClass;
|
|
68
68
|
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);
|
|
69
69
|
descriptor.value = async (...args) => {
|
|
70
|
-
|
|
70
|
+
test_utils_1.assert.isTruthy(Class.fakedPerson, `You gotta @faker.login(...) before you can create fake '${target}'!`);
|
|
71
71
|
const strategy = strategies[target];
|
|
72
|
-
|
|
72
|
+
test_utils_1.assert.isTruthy(strategy, `Faking ${target} is not ready yet!`);
|
|
73
73
|
await (strategy === null || strategy === void 0 ? void 0 : strategy(Class, total));
|
|
74
74
|
await (bound === null || bound === void 0 ? void 0 : bound(...args));
|
|
75
75
|
};
|
|
@@ -77,8 +77,8 @@ function fake(target, total) {
|
|
|
77
77
|
}
|
|
78
78
|
exports.default = fake;
|
|
79
79
|
fake.login = (phone = '555-000-0000') => {
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
test_utils_1.assert.isTruthy(phone, `You need to pass a phone to 'faker.login(...)'`);
|
|
81
|
+
test_utils_1.assert.isTrue((0, schema_1.isValidNumber)(phone), `'${phone}' is not a valid phone. Try something like: 555-000-0000`);
|
|
82
82
|
MercuryFixture_1.default.setShouldAutomaticallyClearDefaultClient(false);
|
|
83
83
|
mercury_client_1.MercuryTestClient.setShouldRequireLocalListeners(true);
|
|
84
84
|
mercury_client_1.MercuryClientFactory.setIsTestMode(true);
|
|
@@ -215,7 +215,7 @@ function addPersonAsRoleToLocationOrOrg(options) {
|
|
|
215
215
|
const role = getRoleById(Class, roleId);
|
|
216
216
|
const key = roleBaseToLocalFakedProp(role.base);
|
|
217
217
|
//@ts-ignore
|
|
218
|
-
|
|
218
|
+
test_utils_1.assert.isTruthy(Class[key], `Could not find property ${key}`);
|
|
219
219
|
const idx = Class[key].findIndex((p) => p.id === person.id);
|
|
220
220
|
if (idx === -1) {
|
|
221
221
|
//@ts-ignore
|
|
@@ -230,7 +230,7 @@ function addPersonAsRoleToLocationOrOrg(options) {
|
|
|
230
230
|
}
|
|
231
231
|
function getRoleById(Class, roleId) {
|
|
232
232
|
const role = Class.fakedRoles.find((r) => r.id === roleId);
|
|
233
|
-
|
|
233
|
+
test_utils_1.assert.isTruthy(role, `Could not load faked role with the id of ${roleId}.`);
|
|
234
234
|
return role;
|
|
235
235
|
}
|
|
236
236
|
async function fakeGetRole(Class) {
|
|
@@ -326,8 +326,8 @@ async function fakeListPeople(Class) {
|
|
|
326
326
|
await eventFaker_1.default.on('list-people::v2020_12_25', ({ payload }) => {
|
|
327
327
|
var _a;
|
|
328
328
|
let people = [];
|
|
329
|
-
|
|
330
|
-
|
|
329
|
+
test_utils_1.assert.isFalsy(payload === null || payload === void 0 ? void 0 : payload.roleIds, `@fake does not support listing people by roleIds. You will need to use 'eventFaker.on('list-people')' to fake your own response OR consider checking this.fakedPeople on your test class.`);
|
|
330
|
+
test_utils_1.assert.isFalsy(payload === null || payload === void 0 ? void 0 : payload.personIds, `@fake does not support listing people by personIds. You will need to use 'eventFaker.on(...)' to fake your own response OR consider checking this.fakedPeople on your test class`);
|
|
331
331
|
for (const base of (_a = payload === null || payload === void 0 ? void 0 : payload.roleBases) !== null && _a !== void 0 ? _a : []) {
|
|
332
332
|
const faked = getFakedRecordsByRoleBase(Class, base);
|
|
333
333
|
if (faked) {
|
|
@@ -384,7 +384,7 @@ async function fakeCreateLocation(Class) {
|
|
|
384
384
|
await eventFaker_1.default.on('create-location::v2020_12_25', ({ target, payload, source }) => {
|
|
385
385
|
var _a;
|
|
386
386
|
const { personId } = source !== null && source !== void 0 ? source : {};
|
|
387
|
-
const location = Object.assign(Object.assign({ id: (0,
|
|
387
|
+
const location = Object.assign(Object.assign({ id: (0, test_utils_2.generateId)(), dateCreated: new Date().getTime(), organizationId: target.organizationId }, payload), { slug: (_a = payload.slug) !== null && _a !== void 0 ? _a : spruce_skill_utils_1.namesUtil.toKebab(payload.name) });
|
|
388
388
|
Class._fakedLocations.unshift(location);
|
|
389
389
|
if (personId) {
|
|
390
390
|
const role = Class.fakedRoles.find((r) => r.base === 'owner');
|
|
@@ -403,7 +403,7 @@ async function fakeCreateLocation(Class) {
|
|
|
403
403
|
async function fakeCreateOrganization(Class) {
|
|
404
404
|
await eventFaker_1.default.on('create-organization::v2020_12_25', ({ payload }) => {
|
|
405
405
|
var _a;
|
|
406
|
-
const organization = Object.assign(Object.assign({ id: (0,
|
|
406
|
+
const organization = Object.assign(Object.assign({ id: (0, test_utils_2.generateId)(), dateCreated: new Date().getTime(), isPublic: null }, payload), { slug: (_a = payload.slug) !== null && _a !== void 0 ? _a : spruce_skill_utils_1.namesUtil.toKebab(payload.name) });
|
|
407
407
|
Class._fakedOrganizations.unshift(organization);
|
|
408
408
|
const roles = seedRoles(Class, organization.id);
|
|
409
409
|
addPersonAsRoleToLocationOrOrg({
|
|
@@ -419,7 +419,7 @@ async function fakeCreateOrganization(Class) {
|
|
|
419
419
|
}
|
|
420
420
|
async function fakeGetPerson(Class) {
|
|
421
421
|
await eventFaker_1.default.on('get-person::v2020_12_25', ({ target }) => {
|
|
422
|
-
|
|
422
|
+
test_utils_1.assert.isTruthy(target === null || target === void 0 ? void 0 : target.personId, `@fake only supports 'get-person::v2020_12_25' when passing an id. To fake more, use 'eventFaker.on(...)'.`);
|
|
423
423
|
const person = getPersonById(Class, target.personId);
|
|
424
424
|
if (!person) {
|
|
425
425
|
throw new SpruceError_1.default({
|
|
@@ -433,11 +433,11 @@ async function fakeGetPerson(Class) {
|
|
|
433
433
|
});
|
|
434
434
|
}
|
|
435
435
|
async function fakeSkillLifecycleEvents(Class) {
|
|
436
|
-
process.env.SKILL_ID = process.env.SKILL_ID || (0,
|
|
437
|
-
process.env.SKILL_API_KEY = process.env.SKILL_API_KEY || (0,
|
|
436
|
+
process.env.SKILL_ID = process.env.SKILL_ID || (0, test_utils_2.generateId)();
|
|
437
|
+
process.env.SKILL_API_KEY = process.env.SKILL_API_KEY || (0, test_utils_2.generateId)();
|
|
438
438
|
await eventFaker_1.default.on('register-skill::v2020_12_25', ({ payload }) => {
|
|
439
439
|
var _a;
|
|
440
|
-
const skill = Object.assign(Object.assign({ apiKey: (0,
|
|
440
|
+
const skill = Object.assign(Object.assign({ apiKey: (0, test_utils_2.generateId)(), creators: [{ personId: Class.fakedPerson.id }], dateCreated: new Date().getTime(), id: (0, test_utils_2.generateId)() }, payload), { slug: (_a = payload.slug) !== null && _a !== void 0 ? _a : (0, test_utils_2.generateId)() });
|
|
441
441
|
Class.fakedSkills.unshift(skill);
|
|
442
442
|
return {
|
|
443
443
|
skill,
|
|
@@ -508,7 +508,7 @@ async function seedOrganizations(Class, total) {
|
|
|
508
508
|
}
|
|
509
509
|
function seedRoles(Class, orgId) {
|
|
510
510
|
const roles = spruce_core_schemas_1.BASE_ROLES_WITH_META.map((r) => ({
|
|
511
|
-
id: (0,
|
|
511
|
+
id: (0, test_utils_2.generateId)(),
|
|
512
512
|
name: `Faked ${r.name}`,
|
|
513
513
|
base: r.slug,
|
|
514
514
|
dateCreated: new Date().getTime(),
|
|
@@ -526,7 +526,7 @@ async function seedLocations(Class, total) {
|
|
|
526
526
|
function buildSeeder(target) {
|
|
527
527
|
return async function seed(Class, total) {
|
|
528
528
|
if (Class._fakedLocations.length === 0) {
|
|
529
|
-
|
|
529
|
+
test_utils_1.assert.fail(`You gotta @seed('locations', 1) before seeding teammates!`);
|
|
530
530
|
}
|
|
531
531
|
//@ts-ignore
|
|
532
532
|
await Class.seeder[`seed${upperCaseFirst(target)}`]({
|
|
@@ -555,7 +555,7 @@ async function fakeWhoAmI(Class) {
|
|
|
555
555
|
}
|
|
556
556
|
async function fakeRegisterProxyToken(Class) {
|
|
557
557
|
await eventFaker_1.default.on('register-proxy-token::v2020_12_25', ({ source }) => {
|
|
558
|
-
const token = (0,
|
|
558
|
+
const token = (0, test_utils_2.generateId)();
|
|
559
559
|
Class.fakedProxyTokens.push({
|
|
560
560
|
personId: source.personId,
|
|
561
561
|
token,
|
|
@@ -575,7 +575,7 @@ async function fakeAuthenticationEvents(Class) {
|
|
|
575
575
|
((_a = Class.fakedPerson) === null || _a === void 0 ? void 0 : _a.phone) === formattedPhone
|
|
576
576
|
? Class.fakedPerson
|
|
577
577
|
: {
|
|
578
|
-
id: (0,
|
|
578
|
+
id: (0, test_utils_2.generateId)(),
|
|
579
579
|
casualName: 'friend',
|
|
580
580
|
dateCreated: new Date().getTime(),
|
|
581
581
|
phone: (0, schema_1.formatPhoneNumber)(formattedPhone),
|
|
@@ -596,7 +596,7 @@ async function fakeAuthenticationEvents(Class) {
|
|
|
596
596
|
}
|
|
597
597
|
//@ts-ignore
|
|
598
598
|
delete person._challenge;
|
|
599
|
-
const token = (0,
|
|
599
|
+
const token = (0, test_utils_2.generateId)();
|
|
600
600
|
Class.fakedTokens.push({
|
|
601
601
|
personId: person.id,
|
|
602
602
|
token,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
4
4
|
function install() { }
|
|
5
5
|
exports.default = install;
|
|
6
6
|
install.skills = (...namespaces) => {
|
|
7
7
|
if (namespaces.length === 0) {
|
|
8
|
-
|
|
8
|
+
test_utils_1.assert.fail(`You must pass the skill namespaces so I can install them.`);
|
|
9
9
|
}
|
|
10
10
|
return function (Class, key, descriptor) {
|
|
11
11
|
const old = descriptor.value.bind(Class);
|
|
12
12
|
descriptor.value = async (...args) => {
|
|
13
13
|
const orgsFixture = Class.Fixture('organization');
|
|
14
14
|
const latestOrg = await orgsFixture.getNewestOrganization();
|
|
15
|
-
|
|
15
|
+
test_utils_1.assert.isTruthy(latestOrg, `You need to seed at least 1 organization. Heads up, I'll install it in the newest organization only.`);
|
|
16
16
|
await orgsFixture.installSkillsByNamespace({
|
|
17
17
|
organizationId: latestOrg.id,
|
|
18
18
|
namespaces,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const mercury_client_1 = require("@sprucelabs/mercury-client");
|
|
4
|
-
const
|
|
4
|
+
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
5
5
|
const __1 = require("../..");
|
|
6
6
|
function login(phone) {
|
|
7
7
|
return function (Class) {
|
|
8
|
-
|
|
8
|
+
test_utils_1.assert.isFunction(Class.Fixture, `You can only @login if your test extends AbstractSpruceFixtureTest`);
|
|
9
9
|
__1.MercuryFixture.setShouldAutomaticallyClearDefaultClient(false);
|
|
10
10
|
__1.ViewFixture.setShouldAutomaticallyResetAuth(false);
|
|
11
11
|
const beforeAll = Class.beforeAll.bind(Class);
|
|
@@ -41,11 +41,11 @@ function login(phone) {
|
|
|
41
41
|
exports.default = login;
|
|
42
42
|
login.getClient = () => {
|
|
43
43
|
const client = __1.MercuryFixture.getDefaultClient();
|
|
44
|
-
|
|
44
|
+
test_utils_1.assert.isTruthy(client, `You must @login() on your test class before getting the client!`);
|
|
45
45
|
return client;
|
|
46
46
|
};
|
|
47
47
|
login.getPerson = () => {
|
|
48
|
-
|
|
48
|
+
test_utils_1.assert.isTruthy(
|
|
49
49
|
//@ts-ignore
|
|
50
50
|
login.loggedInPerson, `You must @login() on your test class before getting the person`);
|
|
51
51
|
//@ts-ignore
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const mercury_client_1 = require("@sprucelabs/mercury-client");
|
|
7
|
-
const
|
|
7
|
+
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
8
8
|
const StoreFixture_1 = __importDefault(require("../fixtures/StoreFixture"));
|
|
9
9
|
const login_1 = __importDefault(require("./login"));
|
|
10
10
|
function seed(storeName, totalToSeed, ...params) {
|
|
@@ -119,7 +119,7 @@ function attachSeeder(storeName, TestClass, totalToSeed, params) {
|
|
|
119
119
|
else {
|
|
120
120
|
TestClass.__shouldResetAccount = true;
|
|
121
121
|
}
|
|
122
|
-
|
|
122
|
+
test_utils_1.assert.isFunction(fixture[method], `The '${storeName}' store you created needs a method called 'seed(options: StoreSeedOptions)' in order for seeding. You must implement it yourself... for now.`);
|
|
123
123
|
const args = [options, ...(params !== null && params !== void 0 ? params : [])];
|
|
124
124
|
await fixture[method](...args);
|
|
125
125
|
};
|
|
@@ -12,8 +12,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const spruce_event_utils_1 = require("@sprucelabs/spruce-event-utils");
|
|
15
|
-
const test_1 = require("@sprucelabs/test");
|
|
16
15
|
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
16
|
+
const test_utils_2 = require("@sprucelabs/test-utils");
|
|
17
17
|
class LocationFixture {
|
|
18
18
|
constructor(options) {
|
|
19
19
|
this.locationCounter = 0;
|
|
@@ -41,7 +41,7 @@ class LocationFixture {
|
|
|
41
41
|
target: {
|
|
42
42
|
organizationId: orgId,
|
|
43
43
|
},
|
|
44
|
-
payload: Object.assign({ name: `Location ${LocationFixture.locationCount++} - ${(0,
|
|
44
|
+
payload: Object.assign({ name: `Location ${LocationFixture.locationCount++} - ${(0, test_utils_2.generateId)()}`, slug: this.generateLocationSlug(), isPublic: true, address: {
|
|
45
45
|
street1: '123 Main St',
|
|
46
46
|
city: 'Denver',
|
|
47
47
|
province: 'CO',
|
|
@@ -71,7 +71,7 @@ class LocationFixture {
|
|
|
71
71
|
const { client } = await this.people.loginAsDemoPerson();
|
|
72
72
|
if (!organizationId) {
|
|
73
73
|
const org = await this.orgs.getNewestOrganization();
|
|
74
|
-
|
|
74
|
+
test_utils_1.assert.isTruthy(org, `You gotta @seed('locations', 1) before you can get the newest location.`);
|
|
75
75
|
organizationId = org.id;
|
|
76
76
|
}
|
|
77
77
|
const results = await client.emit('list-locations::v2020_12_25', {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const schema_1 = require("@sprucelabs/schema");
|
|
4
4
|
const spruce_event_utils_1 = require("@sprucelabs/spruce-event-utils");
|
|
5
|
-
const
|
|
5
|
+
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
6
6
|
class RoleFixture {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
this.personFixture = options.people;
|
|
@@ -87,7 +87,7 @@ class RoleFixture {
|
|
|
87
87
|
async getFirstRoleWithBase(options) {
|
|
88
88
|
const roles = await this.listRoles(options);
|
|
89
89
|
const role = roles.find((role) => role.base === options.base);
|
|
90
|
-
|
|
90
|
+
test_utils_1.assert.isTruthy(role, `I could not find a role based on ${options.base}!`);
|
|
91
91
|
return role;
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const schema_1 = require("@sprucelabs/schema");
|
|
7
7
|
const spruce_core_schemas_1 = require("@sprucelabs/spruce-core-schemas");
|
|
8
8
|
const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
|
|
9
|
-
const
|
|
9
|
+
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
10
10
|
const phoneNumberIncrementor_1 = __importDefault(require("../../utilities/phoneNumberIncrementor"));
|
|
11
11
|
class SeedFixture {
|
|
12
12
|
constructor(options) {
|
|
@@ -64,7 +64,7 @@ class SeedFixture {
|
|
|
64
64
|
let { totalGroupManagers, totalGuests, totalManagers, totalOwners, totalTeammates, startingPhone, locationId, organizationId, } = options;
|
|
65
65
|
if (!organizationId) {
|
|
66
66
|
const org = await this.organizations.getNewestOrganization();
|
|
67
|
-
|
|
67
|
+
test_utils_1.assert.isTruthy(org, `You gotta @seed('organizations',1) before seeding people.`);
|
|
68
68
|
organizationId = org.id;
|
|
69
69
|
}
|
|
70
70
|
if (!locationId) {
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@sprucelabs/spruce-test-fixtures"
|
|
14
14
|
]
|
|
15
15
|
},
|
|
16
|
-
"version": "49.0.
|
|
16
|
+
"version": "49.0.42",
|
|
17
17
|
"files": [
|
|
18
18
|
"build/**/*",
|
|
19
19
|
"!build/__tests__",
|
|
@@ -64,15 +64,16 @@
|
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@sprucelabs/data-stores": "^18.1.50",
|
|
66
66
|
"@sprucelabs/error": "^5.0.512",
|
|
67
|
-
"@sprucelabs/heartwood-view-controllers": "^90.10.
|
|
67
|
+
"@sprucelabs/heartwood-view-controllers": "^90.10.14",
|
|
68
68
|
"@sprucelabs/mercury-client": "^31.0.201",
|
|
69
69
|
"@sprucelabs/mercury-core-events": "^12.2.15",
|
|
70
70
|
"@sprucelabs/mercury-event-emitter": "^31.0.201",
|
|
71
71
|
"@sprucelabs/schema": "^28.5.12",
|
|
72
72
|
"@sprucelabs/spruce-core-schemas": "^34.2.102",
|
|
73
73
|
"@sprucelabs/spruce-event-utils": "^27.0.175",
|
|
74
|
-
"@sprucelabs/spruce-skill-booter": "^49.0.
|
|
74
|
+
"@sprucelabs/spruce-skill-booter": "^49.0.42",
|
|
75
75
|
"@sprucelabs/spruce-skill-utils": "^26.4.79",
|
|
76
|
+
"@sprucelabs/test-utils": "^3.2.2",
|
|
76
77
|
"dotenv": "^16.0.2",
|
|
77
78
|
"unique-names-generator": "^4.7.1"
|
|
78
79
|
},
|
|
@@ -84,7 +85,6 @@
|
|
|
84
85
|
"@sprucelabs/resolve-path-aliases": "^1.1.99",
|
|
85
86
|
"@sprucelabs/semantic-release": "^4.0.8",
|
|
86
87
|
"@sprucelabs/test": "^7.7.360",
|
|
87
|
-
"@sprucelabs/test-utils": "^3.2.2",
|
|
88
88
|
"@types/node": "17.0.5",
|
|
89
89
|
"calendar-utils": "^0.10.1",
|
|
90
90
|
"chokidar-cli": "^3.0.0",
|
|
@@ -131,5 +131,5 @@
|
|
|
131
131
|
]
|
|
132
132
|
]
|
|
133
133
|
},
|
|
134
|
-
"gitHead": "
|
|
134
|
+
"gitHead": "5b528e70f1ced8136792eb731fef7e4e42368f22"
|
|
135
135
|
}
|