@sprucelabs/spruce-test-fixtures 62.3.44 → 62.3.45
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 +12 -6
- package/build/errors/SpruceError.js +3 -4
- package/build/tests/AbstractSpruceFixtureTest.js +2 -14
- package/build/tests/FakeThemeManager.js +3 -1
- package/build/tests/constants.js +28 -29
- package/build/tests/decorators/fake.js +82 -85
- package/build/tests/decorators/login.js +4 -6
- package/build/tests/decorators/seed.js +8 -10
- package/build/tests/eventFaker.js +5 -4
- package/build/tests/fixtures/FixtureFactory.js +17 -9
- package/build/tests/fixtures/LocationFixture.js +14 -21
- package/build/tests/fixtures/MercuryFixture.js +7 -12
- package/build/tests/fixtures/OrganizationFixture.js +13 -18
- package/build/tests/fixtures/PersonFixture.js +8 -18
- package/build/tests/fixtures/RoleFixture.js +2 -2
- package/build/tests/fixtures/SeedFixture.js +39 -23
- package/build/tests/fixtures/SkillFixture.js +16 -17
- package/build/tests/fixtures/SpyScope.js +1 -2
- package/build/tests/fixtures/ViewFixture.js +17 -15
- package/build/tests/fixtures/generateRandomName.js +1 -2
- package/build/tests/fixtures/scopeUtils.js +2 -2
- package/build/tests/routers/TestRouter.js +3 -5
- package/build/utilities/vcDisk.utility.js +2 -3
- package/package.json +20 -20
- package/tsconfig.json +1 -2
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
const schema_1 = require("@sprucelabs/schema");
|
|
15
4
|
class SkillFixture {
|
|
@@ -20,10 +9,14 @@ class SkillFixture {
|
|
|
20
9
|
this.personFixture = options.personFixture;
|
|
21
10
|
}
|
|
22
11
|
async seedDemoSkill(options) {
|
|
23
|
-
const
|
|
12
|
+
const { creatorPhone, ...values } = options ?? {};
|
|
24
13
|
const { client } = await this.personFixture.loginAsDemoPerson(creatorPhone);
|
|
25
14
|
const [{ skill }] = await client.emitAndFlattenResponses('register-skill::v2020_12_25', {
|
|
26
|
-
payload:
|
|
15
|
+
payload: {
|
|
16
|
+
slug: this.generateSkillSlug(),
|
|
17
|
+
name: this.generateSkillName(),
|
|
18
|
+
...values,
|
|
19
|
+
},
|
|
27
20
|
});
|
|
28
21
|
this.skills.push({ client, skill });
|
|
29
22
|
return skill;
|
|
@@ -35,7 +28,11 @@ class SkillFixture {
|
|
|
35
28
|
return `seed-skill-${Math.round(new Date().getTime() * Math.random())}-${this.skillCounter++}`;
|
|
36
29
|
}
|
|
37
30
|
async loginAsDemoSkill(values) {
|
|
38
|
-
const skill = await this.seedDemoSkill(
|
|
31
|
+
const skill = await this.seedDemoSkill({
|
|
32
|
+
slug: this.generateSkillSlug(),
|
|
33
|
+
...values,
|
|
34
|
+
name: `${values.name} (SkillFixture)`,
|
|
35
|
+
});
|
|
39
36
|
const skillClient = (await this.connectToApi({
|
|
40
37
|
shouldReUseClient: false,
|
|
41
38
|
}));
|
|
@@ -46,7 +43,6 @@ class SkillFixture {
|
|
|
46
43
|
return { skill, client: skillClient };
|
|
47
44
|
}
|
|
48
45
|
async loginAsCurrentSkill() {
|
|
49
|
-
var _a;
|
|
50
46
|
const missing = [];
|
|
51
47
|
if (!process.env.SKILL_ID) {
|
|
52
48
|
missing.push('env.SKILL_ID');
|
|
@@ -64,7 +60,7 @@ class SkillFixture {
|
|
|
64
60
|
shouldReUseClient: false,
|
|
65
61
|
});
|
|
66
62
|
//@ts-ignore
|
|
67
|
-
let skill =
|
|
63
|
+
let skill = client.auth?.skill;
|
|
68
64
|
if (!skill) {
|
|
69
65
|
const auth = await client.authenticate({
|
|
70
66
|
skillId: process.env.SKILL_ID,
|
|
@@ -80,7 +76,10 @@ class SkillFixture {
|
|
|
80
76
|
}
|
|
81
77
|
return {
|
|
82
78
|
client,
|
|
83
|
-
skill:
|
|
79
|
+
skill: {
|
|
80
|
+
...skill,
|
|
81
|
+
apiKey: process.env.SKILL_API_KEY,
|
|
82
|
+
},
|
|
84
83
|
};
|
|
85
84
|
}
|
|
86
85
|
async destroy() {
|
|
@@ -28,8 +28,8 @@ class ViewFixture {
|
|
|
28
28
|
this.connectToApi = connectToApi;
|
|
29
29
|
this.people = people;
|
|
30
30
|
this.vcDir =
|
|
31
|
-
vcDir
|
|
32
|
-
this.controllerMap = options
|
|
31
|
+
vcDir ?? spruce_skill_utils_1.diskUtil.resolvePath(cwd ?? process.cwd(), 'build');
|
|
32
|
+
this.controllerMap = options?.controllerMap;
|
|
33
33
|
this.namespace = namespace;
|
|
34
34
|
this.proxyDecorator = proxyDecorator;
|
|
35
35
|
this.orgs = fixtureFactory.Fixture('organization', {
|
|
@@ -77,7 +77,10 @@ class ViewFixture {
|
|
|
77
77
|
let pluginsByName = {};
|
|
78
78
|
try {
|
|
79
79
|
const { map: loadedControllerMap, pluginsByName: plugins } = vcDisk_utility_1.default.loadViewControllersAndBuildMap(namespace, vcDir);
|
|
80
|
-
controllerMap =
|
|
80
|
+
controllerMap = {
|
|
81
|
+
...loadedControllerMap,
|
|
82
|
+
...map,
|
|
83
|
+
};
|
|
81
84
|
pluginsByName = plugins;
|
|
82
85
|
}
|
|
83
86
|
catch (err) {
|
|
@@ -101,8 +104,7 @@ class ViewFixture {
|
|
|
101
104
|
device: this.device,
|
|
102
105
|
pluginsByName,
|
|
103
106
|
connectToApi: async (options) => {
|
|
104
|
-
|
|
105
|
-
return (_a = this.viewClient) !== null && _a !== void 0 ? _a : connectToApi(options);
|
|
107
|
+
return this.viewClient ?? connectToApi(options);
|
|
106
108
|
},
|
|
107
109
|
log: {
|
|
108
110
|
prefix: 'ViewFixture',
|
|
@@ -132,15 +134,17 @@ class ViewFixture {
|
|
|
132
134
|
return ViewFixture.device;
|
|
133
135
|
}
|
|
134
136
|
Controller(name, options) {
|
|
135
|
-
var _a;
|
|
136
137
|
try {
|
|
137
138
|
const controller = this.getFactory().Controller(name, options);
|
|
138
139
|
return controller;
|
|
139
140
|
}
|
|
140
141
|
catch (err) {
|
|
141
|
-
if (
|
|
142
|
-
throw new SpruceError_1.default(
|
|
143
|
-
|
|
142
|
+
if (err.options?.code === 'MISSING_STORAGE') {
|
|
143
|
+
throw new SpruceError_1.default({
|
|
144
|
+
...err.options,
|
|
145
|
+
friendlyMessage: err.message +
|
|
146
|
+
"\n\nIf you are testing, make sure you're calling `await super.beforeEach()` in your test class.",
|
|
147
|
+
});
|
|
144
148
|
}
|
|
145
149
|
else {
|
|
146
150
|
throw err;
|
|
@@ -190,20 +194,18 @@ class ViewFixture {
|
|
|
190
194
|
__1.ClientProxyDecorator.getInstance().clearProxyTokenGenerator();
|
|
191
195
|
}
|
|
192
196
|
async load(vc, args) {
|
|
193
|
-
var _a;
|
|
194
197
|
await this.assertScopeRequirementsMet(vc);
|
|
195
|
-
const scope =
|
|
198
|
+
const scope = vc?.getScope?.();
|
|
196
199
|
if (scope) {
|
|
197
200
|
this.getScope().setFlags(scope);
|
|
198
201
|
}
|
|
199
|
-
await vc.load(this.getRouter().buildLoadOptions(args
|
|
202
|
+
await vc.load(this.getRouter().buildLoadOptions(args ?? {}));
|
|
200
203
|
}
|
|
201
204
|
getThemes() {
|
|
202
205
|
return this.getRouter().getThemes();
|
|
203
206
|
}
|
|
204
207
|
async assertScopeRequirementsMet(vc) {
|
|
205
|
-
|
|
206
|
-
if ((0, scopeUtils_1.doesScopeIncludeOrganization)((_a = vc.getScope) === null || _a === void 0 ? void 0 : _a.call(vc))) {
|
|
208
|
+
if ((0, scopeUtils_1.doesScopeIncludeOrganization)(vc.getScope?.())) {
|
|
207
209
|
const org = await this.getScope().getCurrentOrganization();
|
|
208
210
|
if (!org) {
|
|
209
211
|
throw new SpruceError_1.default({
|
|
@@ -212,7 +214,7 @@ class ViewFixture {
|
|
|
212
214
|
});
|
|
213
215
|
}
|
|
214
216
|
}
|
|
215
|
-
if ((0, scopeUtils_1.doesScopeIncludeLocation)(
|
|
217
|
+
if ((0, scopeUtils_1.doesScopeIncludeLocation)(vc.getScope?.())) {
|
|
216
218
|
const location = await this.getScope().getCurrentLocation();
|
|
217
219
|
if (!location) {
|
|
218
220
|
throw new SpruceError_1.default({
|
|
@@ -3,13 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = generateRandomName;
|
|
4
4
|
const unique_names_generator_1 = require("unique-names-generator");
|
|
5
5
|
function generateRandomName() {
|
|
6
|
-
var _a;
|
|
7
6
|
const randomName = (0, unique_names_generator_1.uniqueNamesGenerator)({
|
|
8
7
|
dictionaries: [unique_names_generator_1.starWars],
|
|
9
8
|
}).split(' ');
|
|
10
9
|
const values = {
|
|
11
10
|
firstName: randomName[0],
|
|
12
|
-
lastName:
|
|
11
|
+
lastName: randomName[1] ?? null,
|
|
13
12
|
};
|
|
14
13
|
return values;
|
|
15
14
|
}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.doesScopeIncludeOrganization = doesScopeIncludeOrganization;
|
|
4
4
|
exports.doesScopeIncludeLocation = doesScopeIncludeLocation;
|
|
5
5
|
function doesScopeIncludeOrganization(flags) {
|
|
6
|
-
return flags
|
|
6
|
+
return flags?.includes('organization');
|
|
7
7
|
}
|
|
8
8
|
function doesScopeIncludeLocation(flags) {
|
|
9
|
-
return flags
|
|
9
|
+
return flags?.includes('location');
|
|
10
10
|
}
|
|
@@ -48,12 +48,11 @@ class TestRouter extends mercury_event_emitter_1.AbstractEventEmitter {
|
|
|
48
48
|
this.manuallySetNamespace = namespace;
|
|
49
49
|
}
|
|
50
50
|
getNamespace() {
|
|
51
|
-
var _a, _b;
|
|
52
51
|
if (this.manuallySetNamespace) {
|
|
53
52
|
return this.manuallySetNamespace;
|
|
54
53
|
}
|
|
55
54
|
//@ts-ignore
|
|
56
|
-
const id =
|
|
55
|
+
const id = this.presentVc?.id ?? 'heartwood.root';
|
|
57
56
|
return id.split('.')[0];
|
|
58
57
|
}
|
|
59
58
|
static setup(options) {
|
|
@@ -66,18 +65,17 @@ class TestRouter extends mercury_event_emitter_1.AbstractEventEmitter {
|
|
|
66
65
|
return this.presentVc;
|
|
67
66
|
}
|
|
68
67
|
async redirect(id, args) {
|
|
69
|
-
var _a, _b;
|
|
70
68
|
if (TestRouter.shouldThrowWhenRedirectingToBadSvc ||
|
|
71
69
|
this.vcFactory.hasController(id)) {
|
|
72
70
|
//@ts-ignore
|
|
73
71
|
this.presentVc = this.vcFactory.Controller(id, {});
|
|
74
72
|
}
|
|
75
73
|
if (TestRouter.shouldLoadDestinationVc) {
|
|
76
|
-
await
|
|
74
|
+
await this.presentVc?.load(this.buildLoadOptions(args));
|
|
77
75
|
}
|
|
78
76
|
await this.emit('did-redirect', {
|
|
79
77
|
id: id,
|
|
80
|
-
vc:
|
|
78
|
+
vc: this.presentVc ?? {},
|
|
81
79
|
args,
|
|
82
80
|
});
|
|
83
81
|
return this.presentVc;
|
|
@@ -9,8 +9,7 @@ const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
|
|
|
9
9
|
const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
10
10
|
const vcDiskUtil = {
|
|
11
11
|
loadViewControllers(activeDir, options) {
|
|
12
|
-
|
|
13
|
-
const { shouldThrowOnError = true } = options !== null && options !== void 0 ? options : {};
|
|
12
|
+
const { shouldThrowOnError = true } = options ?? {};
|
|
14
13
|
const path = this.resolveCombinedViewsPath(activeDir);
|
|
15
14
|
if (!path) {
|
|
16
15
|
throw new Error(`Could not find path to skill views. Running \`spruce sync.views\` may help.`);
|
|
@@ -28,7 +27,7 @@ const vcDiskUtil = {
|
|
|
28
27
|
};
|
|
29
28
|
try {
|
|
30
29
|
if (!item.id) {
|
|
31
|
-
const name =
|
|
30
|
+
const name = controller.name ?? 'Unknown View Controller';
|
|
32
31
|
throw new SpruceError_1.default({
|
|
33
32
|
code: 'INVALID_VIEW_CONTROLLER',
|
|
34
33
|
friendlyMessage: `${name} is missing \`public static id = '${spruce_skill_utils_1.namesUtil.toKebab(name
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@sprucelabs/spruce-test-fixtures"
|
|
14
14
|
]
|
|
15
15
|
},
|
|
16
|
-
"version": "62.3.
|
|
16
|
+
"version": "62.3.45",
|
|
17
17
|
"files": [
|
|
18
18
|
"build/**/*",
|
|
19
19
|
"!build/__tests__",
|
|
@@ -61,29 +61,29 @@
|
|
|
61
61
|
"lint.tsc": "tsc -p . --noEmit"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@sprucelabs/data-stores": "^28.3.
|
|
65
|
-
"@sprucelabs/error": "^6.0.
|
|
66
|
-
"@sprucelabs/heartwood-view-controllers": "^110.12.
|
|
67
|
-
"@sprucelabs/mercury-client": "^42.0.
|
|
68
|
-
"@sprucelabs/mercury-core-events": "^24.3.
|
|
69
|
-
"@sprucelabs/mercury-event-emitter": "^42.0.
|
|
70
|
-
"@sprucelabs/schema": "^30.0.
|
|
71
|
-
"@sprucelabs/spruce-core-schemas": "^40.1.
|
|
72
|
-
"@sprucelabs/spruce-event-utils": "^40.1.
|
|
73
|
-
"@sprucelabs/spruce-permission-utils": "^8.0.
|
|
74
|
-
"@sprucelabs/spruce-skill-booter": "^62.3.
|
|
75
|
-
"@sprucelabs/spruce-skill-utils": "^31.0.
|
|
76
|
-
"@sprucelabs/test-utils": "^5.1.
|
|
64
|
+
"@sprucelabs/data-stores": "^28.3.141",
|
|
65
|
+
"@sprucelabs/error": "^6.0.479",
|
|
66
|
+
"@sprucelabs/heartwood-view-controllers": "^110.12.159",
|
|
67
|
+
"@sprucelabs/mercury-client": "^42.0.528",
|
|
68
|
+
"@sprucelabs/mercury-core-events": "^24.3.290",
|
|
69
|
+
"@sprucelabs/mercury-event-emitter": "^42.0.528",
|
|
70
|
+
"@sprucelabs/schema": "^30.0.488",
|
|
71
|
+
"@sprucelabs/spruce-core-schemas": "^40.1.473",
|
|
72
|
+
"@sprucelabs/spruce-event-utils": "^40.1.249",
|
|
73
|
+
"@sprucelabs/spruce-permission-utils": "^8.0.605",
|
|
74
|
+
"@sprucelabs/spruce-skill-booter": "^62.3.45",
|
|
75
|
+
"@sprucelabs/spruce-skill-utils": "^31.0.547",
|
|
76
|
+
"@sprucelabs/test-utils": "^5.1.432",
|
|
77
77
|
"dotenv": "^16.4.5",
|
|
78
78
|
"unique-names-generator": "^4.7.1"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@sprucelabs/esm-postbuild": "^6.0.
|
|
82
|
-
"@sprucelabs/jest-json-reporter": "^8.0.
|
|
83
|
-
"@sprucelabs/mercury-types": "^47.0.
|
|
84
|
-
"@sprucelabs/resolve-path-aliases": "^2.0.
|
|
81
|
+
"@sprucelabs/esm-postbuild": "^6.0.462",
|
|
82
|
+
"@sprucelabs/jest-json-reporter": "^8.0.480",
|
|
83
|
+
"@sprucelabs/mercury-types": "^47.0.529",
|
|
84
|
+
"@sprucelabs/resolve-path-aliases": "^2.0.457",
|
|
85
85
|
"@sprucelabs/semantic-release": "^5.0.2",
|
|
86
|
-
"@sprucelabs/test": "^9.0.
|
|
86
|
+
"@sprucelabs/test": "^9.0.51",
|
|
87
87
|
"@types/node": "17.0.5",
|
|
88
88
|
"calendar-utils": "^0.11.0",
|
|
89
89
|
"chokidar-cli": "^3.0.0",
|
|
@@ -114,5 +114,5 @@
|
|
|
114
114
|
"^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
|
|
115
115
|
}
|
|
116
116
|
},
|
|
117
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "59b913c0b16c2e83a7506abd5618082abfcd1f65"
|
|
118
118
|
}
|