@sprucelabs/spruce-test-fixtures 61.1.35 → 62.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/build/.spruce/errors/errors.types.d.ts +30 -27
- package/build/.spruce/errors/errors.types.js +0 -2
- package/build/.spruce/errors/options.types.d.ts +2 -2
- package/build/.spruce/errors/spruceTestFixtures/fakeEventError.schema.js +3 -3
- package/build/.spruce/errors/spruceTestFixtures/invalidFixture.schema.js +5 -5
- package/build/.spruce/errors/spruceTestFixtures/invalidScopeRequest.schema.js +10 -5
- package/build/.spruce/errors/spruceTestFixtures/invalidTarget.schema.js +1 -1
- package/build/.spruce/errors/spruceTestFixtures/invalidViewController.schema.js +5 -5
- package/build/.spruce/errors/spruceTestFixtures/notFound.schema.js +1 -1
- package/build/.spruce/errors/spruceTestFixtures/scopeRequirementsNotMet.schema.js +1 -1
- package/build/.spruce/errors/spruceTestFixtures/skillNotFound.schema.js +3 -3
- package/build/.spruce/errors/spruceTestFixtures/unknownViewControllerError.schema.js +5 -5
- package/build/.spruce/schemas/fields/fields.types.d.ts +1 -1
- package/build/.spruce/schemas/schemas.types.d.ts +7 -7
- package/build/.spruce/schemas/schemas.types.js +0 -2
- package/build/.spruce/schemas/spruceTestFixtures/v2021_07_19/testRouterEmitPayload.schema.js +9 -7
- package/build/ClientProxyDecorator.js +6 -2
- package/build/__tests__/behavioral/OrganizationFixture.test.js +3 -1
- package/build/__tests__/behavioral/PhoneNumberIncrementor.test.js +4 -4
- package/build/__tests__/behavioral/faking/AuthenticatingAsAPerson.test.js +3 -1
- package/build/__tests__/behavioral/faking/FakeDecorator.test.js +5 -2
- package/build/__tests__/behavioral/faking/WhoAmI.test.js +3 -1
- package/build/__tests__/behavioral/seeding/SeedingData.test.js +3 -3
- package/build/__tests__/behavioral/seeding/UsingDecoratorsToInstallSkills.test.js +3 -1
- package/build/__tests__/behavioral/views/ViewFixture.test.js +3 -1
- package/build/__tests__/testDirsAndFiles/one-good-store-skill/build/.spruce/stores/stores.js +1 -1
- package/build/__tests__/testDirsAndFiles/one-good-store-skill/build/stores/Good.store.js +3 -3
- package/build/__tests__/testDirsAndFiles/plugins1/build/.spruce/views/views.d.ts +1 -1
- package/build/__tests__/testDirsAndFiles/plugins2/build/.spruce/views/views.d.ts +1 -1
- package/build/__tests__/testDirsAndFiles/skill/build/skillViewControllers/Book.svc.d.ts +1 -1
- package/build/__tests__/testDirsAndFiles/skill/build/skillViewControllers/Spy.svc.d.ts +1 -1
- package/build/__tests__/testDirsAndFiles/skill/src/.spruce/views/views.js +2 -1
- package/build/errors/SpruceError.d.ts +1 -1
- package/build/esm/.spruce/errors/errors.types.d.ts +30 -27
- package/build/esm/.spruce/errors/errors.types.js +0 -2
- package/build/esm/.spruce/errors/options.types.d.ts +2 -2
- package/build/esm/.spruce/schemas/schemas.types.d.ts +7 -7
- package/build/esm/.spruce/schemas/schemas.types.js +0 -2
- package/build/esm/.spruce/schemas/spruceTestFixtures/v2021_07_19/testRouterEmitPayload.schema.js +9 -7
- package/build/esm/ClientProxyDecorator.js +6 -2
- package/build/esm/__tests__/behavioral/OrganizationFixture.test.js +3 -1
- package/build/esm/__tests__/behavioral/PhoneNumberIncrementor.test.js +4 -4
- package/build/esm/__tests__/behavioral/faking/AuthenticatingAsAPerson.test.js +3 -1
- package/build/esm/__tests__/behavioral/faking/FakeDecorator.test.js +5 -2
- package/build/esm/__tests__/behavioral/faking/WhoAmI.test.js +3 -1
- package/build/esm/__tests__/behavioral/seeding/SeedingData.test.js +3 -3
- package/build/esm/__tests__/behavioral/seeding/UsingDecoratorsToInstallSkills.test.js +3 -1
- package/build/esm/__tests__/behavioral/views/ViewFixture.test.js +3 -1
- package/build/esm/__tests__/testDirsAndFiles/one-good-store-skill/build/stores/Good.store.js +3 -3
- package/build/esm/__tests__/testDirsAndFiles/skill/build/skillViewControllers/Book.svc.d.ts +1 -1
- package/build/esm/__tests__/testDirsAndFiles/skill/build/skillViewControllers/Spy.svc.d.ts +1 -1
- package/build/esm/__tests__/testDirsAndFiles/skill/build/skillViewControllers/Spy.svc.js +1 -1
- package/build/esm/errors/SpruceError.d.ts +1 -1
- package/build/esm/index.d.ts +1 -1
- package/build/esm/tests/decorators/fake.js +16 -6
- package/build/esm/tests/fixtures/FixtureFactory.js +4 -2
- package/build/esm/tests/fixtures/MercuryFixture.js +5 -3
- package/build/esm/tests/fixtures/PersonFixture.js +2 -1
- package/build/esm/tests/fixtures/ViewFixture.js +2 -1
- package/build/index.d.ts +1 -1
- package/build/tests/decorators/fake.js +16 -6
- package/build/tests/fixtures/FixtureFactory.js +4 -2
- package/build/tests/fixtures/MercuryFixture.js +5 -3
- package/build/tests/fixtures/PersonFixture.js +2 -1
- package/build/tests/fixtures/ViewFixture.js +2 -1
- package/package.json +32 -32
@@ -122,8 +122,9 @@ fake.login = (phone = '555-000-0000') => {
|
|
122
122
|
ViewFixture_1.default.resetAuth();
|
123
123
|
try {
|
124
124
|
const auth = Class.views.getAuthenticator();
|
125
|
+
auth.setSessionToken(
|
125
126
|
//@ts-ignore
|
126
|
-
|
127
|
+
Class.fakedClient.auth.token, Class.fakedPerson);
|
127
128
|
}
|
128
129
|
catch (_a) {
|
129
130
|
//hits if not in skill because cant find nameplace
|
@@ -163,7 +164,10 @@ async function loginUsingViewsFallingBackToPeople(Class, phone) {
|
|
163
164
|
person = p;
|
164
165
|
client = c;
|
165
166
|
}
|
166
|
-
return {
|
167
|
+
return {
|
168
|
+
person: Class.fakedPeople.find((p) => p.id === person.id),
|
169
|
+
client,
|
170
|
+
};
|
167
171
|
}
|
168
172
|
function givePersonName(person) {
|
169
173
|
const names = (0, generateRandomName_1.default)();
|
@@ -276,7 +280,9 @@ function getPersonById(Class, personId, shouldThrowWhenNotFound = true) {
|
|
276
280
|
}
|
277
281
|
async function fakeUpdatePerson(Class) {
|
278
282
|
await eventFaker_1.default.on('update-person::v2020_12_25', ({ target, source, payload }) => {
|
279
|
-
const person = Class.fakedPeople.find((p) => (target === null || target === void 0 ? void 0 : target.personId)
|
283
|
+
const person = Class.fakedPeople.find((p) => (target === null || target === void 0 ? void 0 : target.personId)
|
284
|
+
? p.id === (target === null || target === void 0 ? void 0 : target.personId)
|
285
|
+
: p.id === (source === null || source === void 0 ? void 0 : source.personId));
|
280
286
|
if (!person) {
|
281
287
|
throw new SpruceError_1.default({
|
282
288
|
code: 'INVALID_TARGET',
|
@@ -300,7 +306,8 @@ async function fakeListRoles(Class) {
|
|
300
306
|
if (personId) {
|
301
307
|
const personRoles = Class.fakedPeopleRoles
|
302
308
|
.filter((p) => p.personId === personId &&
|
303
|
-
((p.organizationId &&
|
309
|
+
((p.organizationId &&
|
310
|
+
p.organizationId === organizationId) ||
|
304
311
|
(p.locationId && p.locationId === locationId) ||
|
305
312
|
(!locationId && !organizationId)))
|
306
313
|
.map((pr) => getRoleById(Class, pr.roleId));
|
@@ -347,7 +354,8 @@ function getFakedRecordsByRoleBase(Class, base) {
|
|
347
354
|
async function fakeListLocations(Class) {
|
348
355
|
await eventFaker_1.default.on('list-locations::v2020_12_25', ({ target, payload }) => {
|
349
356
|
return {
|
350
|
-
locations: applyPaging(Class._fakedLocations, payload).filter((l) => !(target === null || target === void 0 ? void 0 : target.organizationId) ||
|
357
|
+
locations: applyPaging(Class._fakedLocations, payload).filter((l) => !(target === null || target === void 0 ? void 0 : target.organizationId) ||
|
358
|
+
l.organizationId === (target === null || target === void 0 ? void 0 : target.organizationId)),
|
351
359
|
};
|
352
360
|
});
|
353
361
|
}
|
@@ -550,7 +558,9 @@ async function fakeWhoAmI(Class) {
|
|
550
558
|
skill,
|
551
559
|
person,
|
552
560
|
},
|
553
|
-
type: person || skill
|
561
|
+
type: person || skill
|
562
|
+
? 'authenticated'
|
563
|
+
: 'anonymous',
|
554
564
|
};
|
555
565
|
});
|
556
566
|
}
|
@@ -73,8 +73,9 @@ class FixtureFactory {
|
|
73
73
|
break;
|
74
74
|
}
|
75
75
|
case 'skill': {
|
76
|
+
const personFixture =
|
76
77
|
//@ts-ignore
|
77
|
-
|
78
|
+
(_b = options === null || options === void 0 ? void 0 : options.personFixture) !== null && _b !== void 0 ? _b : this.Fixture('person');
|
78
79
|
fixture = new SkillFixture_1.default({
|
79
80
|
personFixture,
|
80
81
|
connectToApi: mercuryFixture.getConnectFactory(),
|
@@ -94,8 +95,9 @@ class FixtureFactory {
|
|
94
95
|
roles: this.Fixture('role'),
|
95
96
|
//@ts-ignore
|
96
97
|
people: (_c = options === null || options === void 0 ? void 0 : options.people) !== null && _c !== void 0 ? _c : this.Fixture('person'),
|
98
|
+
organizations:
|
97
99
|
//@ts-ignore
|
98
|
-
|
100
|
+
(_d = options === null || options === void 0 ? void 0 : options.organizations) !== null && _d !== void 0 ? _d : this.Fixture('organization'),
|
99
101
|
});
|
100
102
|
break;
|
101
103
|
}
|
@@ -113,7 +113,8 @@ class MercuryFixture {
|
|
113
113
|
}
|
114
114
|
static beforeAll() {
|
115
115
|
var _a, _b;
|
116
|
-
this.originalHost =
|
116
|
+
this.originalHost =
|
117
|
+
(_b = (_a = process.env.TEST_HOST) !== null && _a !== void 0 ? _a : process.env.HOST) !== null && _b !== void 0 ? _b : TEST_HOST;
|
117
118
|
}
|
118
119
|
static async beforeEach(cwd) {
|
119
120
|
var _a;
|
@@ -134,9 +135,10 @@ class MercuryFixture {
|
|
134
135
|
const auth = spruce_skill_utils_1.AuthService.Auth(cwd);
|
135
136
|
const namespace = (_a = auth.getCurrentSkill()) === null || _a === void 0 ? void 0 : _a.slug;
|
136
137
|
if (namespace) {
|
137
|
-
mercury_client_1.MercuryTestClient.setNamespacesThatMustBeHandledLocally([
|
138
|
+
mercury_client_1.MercuryTestClient.setNamespacesThatMustBeHandledLocally([
|
139
|
+
namespace,
|
140
|
+
]);
|
138
141
|
}
|
139
|
-
// eslint-disable-next-line no-empty
|
140
142
|
}
|
141
143
|
catch (_b) { }
|
142
144
|
}
|
@@ -44,7 +44,8 @@ class PersonFixture {
|
|
44
44
|
async loginAsDemoPerson(phone) {
|
45
45
|
var _a, _b, _c;
|
46
46
|
if (this.lastLoggedIn &&
|
47
|
-
(!phone ||
|
47
|
+
(!phone ||
|
48
|
+
(0, schema_1.formatPhoneNumber)(phone) === this.lastLoggedIn.person.phone)) {
|
48
49
|
return this.lastLoggedIn;
|
49
50
|
}
|
50
51
|
const client = (await this.connectToApi({
|
@@ -26,7 +26,8 @@ class ViewFixture {
|
|
26
26
|
const { connectToApi, people, fixtureFactory, vcDir, cwd, namespace, proxyDecorator, permissions, } = options;
|
27
27
|
this.connectToApi = connectToApi;
|
28
28
|
this.people = people;
|
29
|
-
this.vcDir =
|
29
|
+
this.vcDir =
|
30
|
+
vcDir !== null && vcDir !== void 0 ? vcDir : spruce_skill_utils_1.diskUtil.resolvePath(cwd !== null && cwd !== void 0 ? cwd : process.cwd(), 'build');
|
30
31
|
this.controllerMap = options === null || options === void 0 ? void 0 : options.controllerMap;
|
31
32
|
this.namespace = namespace;
|
32
33
|
this.proxyDecorator = proxyDecorator;
|
package/package.json
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
"@sprucelabs/spruce-test-fixtures"
|
14
14
|
]
|
15
15
|
},
|
16
|
-
"version": "
|
16
|
+
"version": "62.0.1",
|
17
17
|
"files": [
|
18
18
|
"build/**/*",
|
19
19
|
"!build/__tests__",
|
@@ -35,15 +35,15 @@
|
|
35
35
|
"url": "https://github.com/sprucelabsai/spruce-features-workspace/issues"
|
36
36
|
},
|
37
37
|
"scripts": {
|
38
|
-
"build.ci": "yarn build.tsc && yarn build.resolve-paths && yarn lint",
|
38
|
+
"build.ci": "yarn run build.tsc && yarn run build.resolve-paths && yarn run lint",
|
39
39
|
"build.copy-files": "mkdir -p build && rsync -avzq --exclude='*.ts' ./src/ ./build/",
|
40
|
-
"build.dev": "yarn build.tsc --sourceMap ; yarn resolve-paths.lint",
|
40
|
+
"build.dev": "yarn run build.tsc --sourceMap ; yarn run resolve-paths.lint",
|
41
41
|
"build.dist": "tsc --project tsconfig.dist.json && yarn build.resolve-paths && mv build esm && yarn build.esm-postbuild && yarn build.tsc && yarn build.resolve-paths && mv esm build/ && yarn clean.dist",
|
42
42
|
"build.esm-postbuild": "esm-postbuild --target esm --patterns '**/*.js'",
|
43
43
|
"build.resolve-paths": "resolve-path-aliases --target build --patterns '**/*.js,**/*.d.ts'",
|
44
44
|
"build.tsc": "yarn build.copy-files && tsc",
|
45
|
-
"clean": "yarn clean.build",
|
46
|
-
"clean.all": "yarn clean.dependencies && yarn clean.build",
|
45
|
+
"clean": "yarn run clean.build",
|
46
|
+
"clean.all": "yarn run clean.dependencies && yarn run clean.build",
|
47
47
|
"clean.build": "rm -rf build/",
|
48
48
|
"clean.dependencies": "rm -rf node_modules/ package-lock.json yarn.lock",
|
49
49
|
"clean.dist": "true",
|
@@ -51,47 +51,47 @@
|
|
51
51
|
"fix.lint.local": "eslint --fix --cache '**/*.ts'",
|
52
52
|
"lint": "eslint --cache '**/*.ts'",
|
53
53
|
"rebuild": "cd .. && yarn rebuild",
|
54
|
-
"resolve-paths.lint": "yarn build.resolve-paths ; yarn lint",
|
54
|
+
"resolve-paths.lint": "yarn run build.resolve-paths ; yarn run lint",
|
55
55
|
"test": "jest",
|
56
|
-
"post.watch.build": "yarn build.copy-files && yarn build.resolve-paths",
|
56
|
+
"post.watch.build": "yarn run build.copy-files && yarn run build.resolve-paths",
|
57
57
|
"spruce.upgrade": "spruce upgrade",
|
58
|
-
"watch.build.dev": "tsc-watch --sourceMap --onCompilationComplete 'yarn post.watch.build'",
|
59
|
-
"watch.lint": "concurrently 'yarn lint' \"chokidar 'src/**/*' -c 'yarn lint.tsc'\"",
|
60
|
-
"watch.rebuild": "yarn clean.all && yarn && yarn watch.build.dev",
|
58
|
+
"watch.build.dev": "tsc-watch --sourceMap --onCompilationComplete 'yarn run post.watch.build'",
|
59
|
+
"watch.lint": "concurrently 'yarn run lint' \"chokidar 'src/**/*' -c 'yarn run lint.tsc'\"",
|
60
|
+
"watch.rebuild": "yarn run clean.all && yarn install && yarn run watch.build.dev",
|
61
61
|
"watch.tsc": "tsc -w",
|
62
62
|
"lint.tsc": "tsc -p . --noEmit"
|
63
63
|
},
|
64
64
|
"dependencies": {
|
65
|
-
"@sprucelabs/data-stores": "^
|
66
|
-
"@sprucelabs/error": "^
|
67
|
-
"@sprucelabs/heartwood-view-controllers": "^
|
68
|
-
"@sprucelabs/mercury-client": "^
|
69
|
-
"@sprucelabs/mercury-core-events": "^
|
70
|
-
"@sprucelabs/mercury-event-emitter": "^
|
71
|
-
"@sprucelabs/schema": "^
|
72
|
-
"@sprucelabs/spruce-core-schemas": "^
|
73
|
-
"@sprucelabs/spruce-event-utils": "^
|
74
|
-
"@sprucelabs/spruce-permission-utils": "^
|
75
|
-
"@sprucelabs/spruce-skill-booter": "^
|
76
|
-
"@sprucelabs/spruce-skill-utils": "^
|
77
|
-
"@sprucelabs/test-utils": "^
|
65
|
+
"@sprucelabs/data-stores": "^27.0.2",
|
66
|
+
"@sprucelabs/error": "^6.0.3",
|
67
|
+
"@sprucelabs/heartwood-view-controllers": "^110.0.2",
|
68
|
+
"@sprucelabs/mercury-client": "^42.0.3",
|
69
|
+
"@sprucelabs/mercury-core-events": "^24.0.2",
|
70
|
+
"@sprucelabs/mercury-event-emitter": "^42.0.3",
|
71
|
+
"@sprucelabs/schema": "^30.0.4",
|
72
|
+
"@sprucelabs/spruce-core-schemas": "^40.0.2",
|
73
|
+
"@sprucelabs/spruce-event-utils": "^40.0.2",
|
74
|
+
"@sprucelabs/spruce-permission-utils": "^8.0.2",
|
75
|
+
"@sprucelabs/spruce-skill-booter": "^62.0.1",
|
76
|
+
"@sprucelabs/spruce-skill-utils": "^31.0.5",
|
77
|
+
"@sprucelabs/test-utils": "^5.0.3",
|
78
78
|
"dotenv": "^16.4.5",
|
79
79
|
"unique-names-generator": "^4.7.1"
|
80
80
|
},
|
81
81
|
"devDependencies": {
|
82
|
-
"@sprucelabs/esm-postbuild": "^
|
83
|
-
"@sprucelabs/jest-json-reporter": "^
|
82
|
+
"@sprucelabs/esm-postbuild": "^6.0.3",
|
83
|
+
"@sprucelabs/jest-json-reporter": "^8.0.1",
|
84
84
|
"@sprucelabs/jest-sheets-reporter": "^3.0.26",
|
85
|
-
"@sprucelabs/mercury-types": "^
|
86
|
-
"@sprucelabs/resolve-path-aliases": "^
|
87
|
-
"@sprucelabs/semantic-release": "^
|
88
|
-
"@sprucelabs/test": "^
|
85
|
+
"@sprucelabs/mercury-types": "^47.0.2",
|
86
|
+
"@sprucelabs/resolve-path-aliases": "^2.0.5",
|
87
|
+
"@sprucelabs/semantic-release": "^5.0.1",
|
88
|
+
"@sprucelabs/test": "^9.0.4",
|
89
89
|
"@types/node": "17.0.5",
|
90
90
|
"calendar-utils": "^0.10.4",
|
91
91
|
"chokidar-cli": "^3.0.0",
|
92
92
|
"concurrently": "^8.2.2",
|
93
|
-
"eslint": "^
|
94
|
-
"eslint-config-spruce": "^
|
93
|
+
"eslint": "^9.0.0",
|
94
|
+
"eslint-config-spruce": "^11.2.7",
|
95
95
|
"jest": "^29.7.0",
|
96
96
|
"jest-circus": "^29.7.0",
|
97
97
|
"prettier": "^3.2.5",
|
@@ -132,5 +132,5 @@
|
|
132
132
|
]
|
133
133
|
]
|
134
134
|
},
|
135
|
-
"gitHead": "
|
135
|
+
"gitHead": "611e0486870e0121549bddb4a086a3c388b2e02d"
|
136
136
|
}
|