@sprucelabs/spruce-test-fixtures 52.5.6 → 52.5.7

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.
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const data_stores_1 = require("@sprucelabs/data-stores");
13
13
  const test_utils_1 = require("@sprucelabs/test-utils");
14
14
  const __1 = require("../..");
15
+ const PermissionFixture_1 = __importDefault(require("../../tests/fixtures/PermissionFixture"));
15
16
  const SeedFixture_1 = __importDefault(require("../../tests/fixtures/SeedFixture"));
16
17
  const toCheck = [
17
18
  {
@@ -74,6 +75,12 @@ const toCheck = [
74
75
  fixtureName: 'store',
75
76
  instanceOf: __1.StoreFixture,
76
77
  },
78
+ {
79
+ prop: 'permissions',
80
+ privatePropName: '_permissions',
81
+ fixtureName: 'permission',
82
+ instanceOf: PermissionFixture_1.default,
83
+ },
77
84
  ];
78
85
  class ResettingFixtureFieldsBeforeEachTest extends __1.AbstractSpruceFixtureTest {
79
86
  static shouldBeAbleToGetAllFixtures() {
@@ -16,6 +16,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
16
16
  import { DatabaseFixture } from '@sprucelabs/data-stores';
17
17
  import { assert, test } from '@sprucelabs/test-utils';
18
18
  import { AbstractSpruceFixtureTest, LocationFixture, MercuryFixture, OrganizationFixture, PersonFixture, RoleFixture, SkillFixture, StoreFixture, ViewFixture, } from '../../index.js';
19
+ import PermissionFixture from '../../tests/fixtures/PermissionFixture.js';
19
20
  import SeedFixture from '../../tests/fixtures/SeedFixture.js';
20
21
  const toCheck = [
21
22
  {
@@ -78,6 +79,12 @@ const toCheck = [
78
79
  fixtureName: 'store',
79
80
  instanceOf: StoreFixture,
80
81
  },
82
+ {
83
+ prop: 'permissions',
84
+ privatePropName: '_permissions',
85
+ fixtureName: 'permission',
86
+ instanceOf: PermissionFixture,
87
+ },
81
88
  ];
82
89
  export default class ResettingFixtureFieldsBeforeEachTest extends AbstractSpruceFixtureTest {
83
90
  static shouldBeAbleToGetAllFixtures() {
@@ -1,7 +1,8 @@
1
1
  import { DatabaseFixture } from '@sprucelabs/data-stores';
2
2
  import { MercuryClient } from '@sprucelabs/mercury-client';
3
- import { Location, Organization, Person, Role, Skill } from '@sprucelabs/spruce-core-schemas';
3
+ import { Location, Organization, Person, Role, Skill as ISkill } from '@sprucelabs/spruce-core-schemas';
4
4
  import { AbstractSkillTest, SkillFactoryOptions } from '@sprucelabs/spruce-skill-booter';
5
+ import { Skill } from '@sprucelabs/spruce-skill-utils';
5
6
  import { FixtureConstructorOptionsMap, FixtureName } from '../types/fixture.types';
6
7
  import LocationFixture from './fixtures/LocationFixture';
7
8
  import MercuryFixture from './fixtures/MercuryFixture';
@@ -20,39 +21,13 @@ export default abstract class AbstractSpruceFixtureTest extends AbstractSkillTes
20
21
  static fakedTeammates: Person[];
21
22
  static fakedOwners: Person[];
22
23
  static fakedRoles: Role[];
23
- static fakedSkills: Skill[];
24
+ static fakedSkills: ISkill[];
24
25
  static fakedManagers: Person[];
25
26
  static fakedGuests: Person[];
26
27
  static fakedGroupManagers: Person[];
27
- static get fakedOrganizations(): Organization[];
28
- static set fakedOrganizations(orgs: Organization[]);
29
- static get fakedLocations(): Location[];
30
- static set fakedLocations(locations: Location[]);
31
28
  private static _fakedOrganizations;
32
29
  private static _fakedLocations;
33
30
  static cwd: string;
34
- static get views(): ViewFixture;
35
- static set views(fixture: ViewFixture | undefined);
36
- static get permissions(): PermissionFixture;
37
- static set permissions(fixture: PermissionFixture | undefined);
38
- static get roles(): RoleFixture;
39
- static set roles(fixture: RoleFixture | undefined);
40
- static get locations(): LocationFixture;
41
- static set locations(fixture: LocationFixture | undefined);
42
- static get organizations(): OrganizationFixture;
43
- static set organizations(fixture: OrganizationFixture | undefined);
44
- static get people(): PersonFixture;
45
- static set people(fixture: PersonFixture | undefined);
46
- static get seeder(): SeedFixture;
47
- static set seeder(fixture: SeedFixture | undefined);
48
- static get skills(): SkillFixture;
49
- static set skills(fixture: SkillFixture | undefined);
50
- static get mercury(): MercuryFixture;
51
- static set mercury(fixture: MercuryFixture | undefined);
52
- static get stores(): StoreFixture;
53
- static set stores(fixture: StoreFixture | undefined);
54
- static get database(): DatabaseFixture;
55
- static set database(fixture: DatabaseFixture | undefined);
56
31
  private static _views?;
57
32
  private static _roles?;
58
33
  private static _locations?;
@@ -64,6 +39,7 @@ export default abstract class AbstractSpruceFixtureTest extends AbstractSkillTes
64
39
  private static _stores?;
65
40
  private static _database?;
66
41
  private static _permissions?;
42
+ private static _fixtures?;
67
43
  protected static beforeAll(): Promise<void>;
68
44
  protected static beforeEach(): Promise<void>;
69
45
  private static clearLocalFixtures;
@@ -74,7 +50,7 @@ export default abstract class AbstractSpruceFixtureTest extends AbstractSkillTes
74
50
  name: string;
75
51
  slug?: string;
76
52
  }): Promise<{
77
- skill: import("@sprucelabs/spruce-skill-utils").Skill;
53
+ skill: Skill;
78
54
  client: import("@sprucelabs/mercury-types").MercuryEventEmitter<import("@sprucelabs/mercury-types").SkillEventContract> & {
79
55
  disconnect: () => Promise<void>;
80
56
  isConnected: () => boolean;
@@ -96,7 +72,34 @@ export default abstract class AbstractSpruceFixtureTest extends AbstractSkillTes
96
72
  executionPromise: Promise<void>;
97
73
  }>;
98
74
  protected static bootAndRegisterSkillFromTestDir(key: string): Promise<{
99
- skill: import("@sprucelabs/spruce-skill-utils").Skill;
75
+ skill: Skill;
100
76
  executionPromise: Promise<void>;
101
77
  }>;
78
+ protected static SkillFromTestDir(key: string, options?: SkillFactoryOptions | undefined): Promise<Skill>;
79
+ static get fakedOrganizations(): Organization[];
80
+ static set fakedOrganizations(orgs: Organization[]);
81
+ static get fakedLocations(): Location[];
82
+ static set fakedLocations(locations: Location[]);
83
+ static get views(): ViewFixture;
84
+ static set views(fixture: ViewFixture | undefined);
85
+ static get permissions(): PermissionFixture;
86
+ static set permissions(fixture: PermissionFixture | undefined);
87
+ static get roles(): RoleFixture;
88
+ static set roles(fixture: RoleFixture | undefined);
89
+ static get locations(): LocationFixture;
90
+ static set locations(fixture: LocationFixture | undefined);
91
+ static get organizations(): OrganizationFixture;
92
+ static set organizations(fixture: OrganizationFixture | undefined);
93
+ static get people(): PersonFixture;
94
+ static set people(fixture: PersonFixture | undefined);
95
+ static get seeder(): SeedFixture;
96
+ static set seeder(fixture: SeedFixture | undefined);
97
+ static get skills(): SkillFixture;
98
+ static set skills(fixture: SkillFixture | undefined);
99
+ static get mercury(): MercuryFixture;
100
+ static set mercury(fixture: MercuryFixture | undefined);
101
+ static get stores(): StoreFixture;
102
+ static set stores(fixture: StoreFixture | undefined);
103
+ static get database(): DatabaseFixture;
104
+ static set database(fixture: DatabaseFixture | undefined);
102
105
  }
@@ -23,6 +23,108 @@ import { diskUtil, testLog } from '@sprucelabs/spruce-skill-utils';
23
23
  import { assert } from '@sprucelabs/test-utils';
24
24
  import FixtureFactory from './fixtures/FixtureFactory.js';
25
25
  export default class AbstractSpruceFixtureTest extends AbstractSkillTest {
26
+ static beforeAll() {
27
+ const _super = Object.create(null, {
28
+ beforeAll: { get: () => super.beforeAll }
29
+ });
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ yield _super.beforeAll.call(this);
32
+ yield FixtureFactory.beforeAll();
33
+ console.error = testLog.error;
34
+ });
35
+ }
36
+ static beforeEach() {
37
+ const _super = Object.create(null, {
38
+ beforeEach: { get: () => super.beforeEach }
39
+ });
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ yield _super.beforeEach.call(this);
42
+ yield FixtureFactory.beforeEach(this.cwd);
43
+ this._fixtures = undefined;
44
+ this.clearLocalFixtures();
45
+ });
46
+ }
47
+ static clearLocalFixtures() {
48
+ this.views = undefined;
49
+ this.roles = undefined;
50
+ this.locations = undefined;
51
+ this.organizations = undefined;
52
+ this.people = undefined;
53
+ this.seeder = undefined;
54
+ this.skills = undefined;
55
+ this.mercury = undefined;
56
+ this.stores = undefined;
57
+ this.database = undefined;
58
+ this.permissions = undefined;
59
+ }
60
+ static afterEach() {
61
+ const _super = Object.create(null, {
62
+ afterEach: { get: () => super.afterEach }
63
+ });
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ yield _super.afterEach.call(this);
66
+ yield FixtureFactory.afterEach();
67
+ this.clearLocalFixtures();
68
+ });
69
+ }
70
+ static afterAll() {
71
+ const _super = Object.create(null, {
72
+ afterAll: { get: () => super.afterAll }
73
+ });
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ yield _super.afterAll.call(this);
76
+ yield FixtureFactory.afterAll();
77
+ });
78
+ }
79
+ static Fixture(name, options) {
80
+ var _a;
81
+ if (!this._fixtures) {
82
+ const pkg = diskUtil.resolvePath(this.cwd, 'package.json');
83
+ let namespace;
84
+ if (diskUtil.doesFileExist(pkg)) {
85
+ const values = JSON.parse(diskUtil.readFile(pkg));
86
+ namespace = (_a = values === null || values === void 0 ? void 0 : values.skill) === null || _a === void 0 ? void 0 : _a.namespace;
87
+ }
88
+ this._fixtures = new FixtureFactory({
89
+ cwd: this.cwd,
90
+ namespace,
91
+ });
92
+ }
93
+ return this._fixtures.Fixture(name, options);
94
+ }
95
+ static bootAndRegisterNewSkill(options) {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ const { name, slug } = options, skillOptions = __rest(options, ["name", "slug"]);
98
+ const { skill, client } = yield this.skills.loginAsDemoSkill({
99
+ name,
100
+ slug,
101
+ });
102
+ process.env.SKILL_ID = skill.id;
103
+ process.env.SKILL_API_KEY = skill.apiKey;
104
+ const { skill: bootedSkill, executionPromise } = yield this.bootSkill(skillOptions);
105
+ return { skill: bootedSkill, client, executionPromise };
106
+ });
107
+ }
108
+ static bootAndRegisterSkillFromTestDir(key) {
109
+ return __awaiter(this, void 0, void 0, function* () {
110
+ const registeredSkill = yield this.skills.seedDemoSkill({
111
+ name: 'my test skill',
112
+ });
113
+ process.env.SKILL_ID = registeredSkill.id;
114
+ process.env.SKILL_API_KEY = registeredSkill.apiKey;
115
+ return this.bootSkillFromTestDir(key);
116
+ });
117
+ }
118
+ static SkillFromTestDir(key, options) {
119
+ const _super = Object.create(null, {
120
+ SkillFromTestDir: { get: () => super.SkillFromTestDir }
121
+ });
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ const skill = yield _super.SkillFromTestDir.call(this, key, options);
124
+ this._fixtures = undefined;
125
+ return skill;
126
+ });
127
+ }
26
128
  static get fakedOrganizations() {
27
129
  return this._fakedOrganizations;
28
130
  }
@@ -136,90 +238,6 @@ export default class AbstractSpruceFixtureTest extends AbstractSkillTest {
136
238
  static set database(fixture) {
137
239
  this._database = fixture;
138
240
  }
139
- static beforeAll() {
140
- const _super = Object.create(null, {
141
- beforeAll: { get: () => super.beforeAll }
142
- });
143
- return __awaiter(this, void 0, void 0, function* () {
144
- yield _super.beforeAll.call(this);
145
- yield FixtureFactory.beforeAll();
146
- console.error = testLog.error;
147
- });
148
- }
149
- static beforeEach() {
150
- const _super = Object.create(null, {
151
- beforeEach: { get: () => super.beforeEach }
152
- });
153
- return __awaiter(this, void 0, void 0, function* () {
154
- yield _super.beforeEach.call(this);
155
- yield FixtureFactory.beforeEach(this.cwd);
156
- this.clearLocalFixtures();
157
- });
158
- }
159
- static clearLocalFixtures() {
160
- this.views = undefined;
161
- this.roles = undefined;
162
- this.locations = undefined;
163
- this.organizations = undefined;
164
- this.people = undefined;
165
- this.seeder = undefined;
166
- this.skills = undefined;
167
- this.mercury = undefined;
168
- this.stores = undefined;
169
- this.database = undefined;
170
- }
171
- static afterEach() {
172
- const _super = Object.create(null, {
173
- afterEach: { get: () => super.afterEach }
174
- });
175
- return __awaiter(this, void 0, void 0, function* () {
176
- yield _super.afterEach.call(this);
177
- yield FixtureFactory.afterEach();
178
- this.clearLocalFixtures();
179
- });
180
- }
181
- static afterAll() {
182
- const _super = Object.create(null, {
183
- afterAll: { get: () => super.afterAll }
184
- });
185
- return __awaiter(this, void 0, void 0, function* () {
186
- yield _super.afterAll.call(this);
187
- yield FixtureFactory.afterAll();
188
- });
189
- }
190
- static Fixture(name, options) {
191
- var _a;
192
- const pkg = diskUtil.resolvePath(this.cwd, 'package.json');
193
- let namespace;
194
- if (diskUtil.doesFileExist(pkg)) {
195
- const values = JSON.parse(diskUtil.readFile(pkg));
196
- namespace = (_a = values === null || values === void 0 ? void 0 : values.skill) === null || _a === void 0 ? void 0 : _a.namespace;
197
- }
198
- return new FixtureFactory({ cwd: this.cwd, namespace }).Fixture(name, options);
199
- }
200
- static bootAndRegisterNewSkill(options) {
201
- return __awaiter(this, void 0, void 0, function* () {
202
- const { name, slug } = options, skillOptions = __rest(options, ["name", "slug"]);
203
- const { skill, client } = yield this.skills.loginAsDemoSkill({
204
- name,
205
- slug,
206
- });
207
- process.env.SKILL_ID = skill.id;
208
- process.env.SKILL_API_KEY = skill.apiKey;
209
- const { skill: bootedSkill, executionPromise } = yield this.bootSkill(skillOptions);
210
- return { skill: bootedSkill, client, executionPromise };
211
- });
212
- }
213
- static bootAndRegisterSkillFromTestDir(key) {
214
- return __awaiter(this, void 0, void 0, function* () {
215
- const registeredSkill = yield this.skills.seedDemoSkill({
216
- name: 'my test skill',
217
- });
218
- process.env.SKILL_ID = registeredSkill.id;
219
- process.env.SKILL_API_KEY = registeredSkill.apiKey;
220
- return this.bootSkillFromTestDir(key);
221
- });
222
- }
223
241
  }
224
242
  AbstractSpruceFixtureTest._fakedOrganizations = [];
225
243
  AbstractSpruceFixtureTest._fakedLocations = [];
@@ -8,6 +8,8 @@ export default class FixtureFactory {
8
8
  cwd: string;
9
9
  namespace?: string;
10
10
  });
11
+ setCwd(cwd: string): void;
12
+ setNamespace(namespace: string): void;
11
13
  Fixture<Name extends FixtureName>(named: Name, options?: Partial<FixtureConstructorOptionsMap[Name]>): FixtureMap[Name];
12
14
  private getMercuryFixture;
13
15
  static destroy(): Promise<void>;
@@ -35,6 +35,12 @@ export default class FixtureFactory {
35
35
  }
36
36
  this.namespace = options.namespace;
37
37
  }
38
+ setCwd(cwd) {
39
+ this.cwd = cwd;
40
+ }
41
+ setNamespace(namespace) {
42
+ this.namespace = namespace;
43
+ }
38
44
  Fixture(named, options) {
39
45
  var _a, _b, _c, _d, _e;
40
46
  const mercuryFixture = this.getMercuryFixture(named);
@@ -1,7 +1,8 @@
1
1
  import { DatabaseFixture } from '@sprucelabs/data-stores';
2
2
  import { MercuryClient } from '@sprucelabs/mercury-client';
3
- import { Location, Organization, Person, Role, Skill } from '@sprucelabs/spruce-core-schemas';
3
+ import { Location, Organization, Person, Role, Skill as ISkill } from '@sprucelabs/spruce-core-schemas';
4
4
  import { AbstractSkillTest, SkillFactoryOptions } from '@sprucelabs/spruce-skill-booter';
5
+ import { Skill } from '@sprucelabs/spruce-skill-utils';
5
6
  import { FixtureConstructorOptionsMap, FixtureName } from '../types/fixture.types';
6
7
  import LocationFixture from './fixtures/LocationFixture';
7
8
  import MercuryFixture from './fixtures/MercuryFixture';
@@ -20,39 +21,13 @@ export default abstract class AbstractSpruceFixtureTest extends AbstractSkillTes
20
21
  static fakedTeammates: Person[];
21
22
  static fakedOwners: Person[];
22
23
  static fakedRoles: Role[];
23
- static fakedSkills: Skill[];
24
+ static fakedSkills: ISkill[];
24
25
  static fakedManagers: Person[];
25
26
  static fakedGuests: Person[];
26
27
  static fakedGroupManagers: Person[];
27
- static get fakedOrganizations(): Organization[];
28
- static set fakedOrganizations(orgs: Organization[]);
29
- static get fakedLocations(): Location[];
30
- static set fakedLocations(locations: Location[]);
31
28
  private static _fakedOrganizations;
32
29
  private static _fakedLocations;
33
30
  static cwd: string;
34
- static get views(): ViewFixture;
35
- static set views(fixture: ViewFixture | undefined);
36
- static get permissions(): PermissionFixture;
37
- static set permissions(fixture: PermissionFixture | undefined);
38
- static get roles(): RoleFixture;
39
- static set roles(fixture: RoleFixture | undefined);
40
- static get locations(): LocationFixture;
41
- static set locations(fixture: LocationFixture | undefined);
42
- static get organizations(): OrganizationFixture;
43
- static set organizations(fixture: OrganizationFixture | undefined);
44
- static get people(): PersonFixture;
45
- static set people(fixture: PersonFixture | undefined);
46
- static get seeder(): SeedFixture;
47
- static set seeder(fixture: SeedFixture | undefined);
48
- static get skills(): SkillFixture;
49
- static set skills(fixture: SkillFixture | undefined);
50
- static get mercury(): MercuryFixture;
51
- static set mercury(fixture: MercuryFixture | undefined);
52
- static get stores(): StoreFixture;
53
- static set stores(fixture: StoreFixture | undefined);
54
- static get database(): DatabaseFixture;
55
- static set database(fixture: DatabaseFixture | undefined);
56
31
  private static _views?;
57
32
  private static _roles?;
58
33
  private static _locations?;
@@ -64,6 +39,7 @@ export default abstract class AbstractSpruceFixtureTest extends AbstractSkillTes
64
39
  private static _stores?;
65
40
  private static _database?;
66
41
  private static _permissions?;
42
+ private static _fixtures?;
67
43
  protected static beforeAll(): Promise<void>;
68
44
  protected static beforeEach(): Promise<void>;
69
45
  private static clearLocalFixtures;
@@ -74,7 +50,7 @@ export default abstract class AbstractSpruceFixtureTest extends AbstractSkillTes
74
50
  name: string;
75
51
  slug?: string;
76
52
  }): Promise<{
77
- skill: import("@sprucelabs/spruce-skill-utils").Skill;
53
+ skill: Skill;
78
54
  client: import("@sprucelabs/mercury-types").MercuryEventEmitter<import("@sprucelabs/mercury-types").SkillEventContract> & {
79
55
  disconnect: () => Promise<void>;
80
56
  isConnected: () => boolean;
@@ -96,7 +72,34 @@ export default abstract class AbstractSpruceFixtureTest extends AbstractSkillTes
96
72
  executionPromise: Promise<void>;
97
73
  }>;
98
74
  protected static bootAndRegisterSkillFromTestDir(key: string): Promise<{
99
- skill: import("@sprucelabs/spruce-skill-utils").Skill;
75
+ skill: Skill;
100
76
  executionPromise: Promise<void>;
101
77
  }>;
78
+ protected static SkillFromTestDir(key: string, options?: SkillFactoryOptions | undefined): Promise<Skill>;
79
+ static get fakedOrganizations(): Organization[];
80
+ static set fakedOrganizations(orgs: Organization[]);
81
+ static get fakedLocations(): Location[];
82
+ static set fakedLocations(locations: Location[]);
83
+ static get views(): ViewFixture;
84
+ static set views(fixture: ViewFixture | undefined);
85
+ static get permissions(): PermissionFixture;
86
+ static set permissions(fixture: PermissionFixture | undefined);
87
+ static get roles(): RoleFixture;
88
+ static set roles(fixture: RoleFixture | undefined);
89
+ static get locations(): LocationFixture;
90
+ static set locations(fixture: LocationFixture | undefined);
91
+ static get organizations(): OrganizationFixture;
92
+ static set organizations(fixture: OrganizationFixture | undefined);
93
+ static get people(): PersonFixture;
94
+ static set people(fixture: PersonFixture | undefined);
95
+ static get seeder(): SeedFixture;
96
+ static set seeder(fixture: SeedFixture | undefined);
97
+ static get skills(): SkillFixture;
98
+ static set skills(fixture: SkillFixture | undefined);
99
+ static get mercury(): MercuryFixture;
100
+ static set mercury(fixture: MercuryFixture | undefined);
101
+ static get stores(): StoreFixture;
102
+ static set stores(fixture: StoreFixture | undefined);
103
+ static get database(): DatabaseFixture;
104
+ static set database(fixture: DatabaseFixture | undefined);
102
105
  }
@@ -19,6 +19,79 @@ const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
19
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
+ static async beforeAll() {
23
+ await super.beforeAll();
24
+ await FixtureFactory_1.default.beforeAll();
25
+ console.error = spruce_skill_utils_1.testLog.error;
26
+ }
27
+ static async beforeEach() {
28
+ await super.beforeEach();
29
+ await FixtureFactory_1.default.beforeEach(this.cwd);
30
+ this._fixtures = undefined;
31
+ this.clearLocalFixtures();
32
+ }
33
+ static clearLocalFixtures() {
34
+ this.views = undefined;
35
+ this.roles = undefined;
36
+ this.locations = undefined;
37
+ this.organizations = undefined;
38
+ this.people = undefined;
39
+ this.seeder = undefined;
40
+ this.skills = undefined;
41
+ this.mercury = undefined;
42
+ this.stores = undefined;
43
+ this.database = undefined;
44
+ this.permissions = undefined;
45
+ }
46
+ static async afterEach() {
47
+ await super.afterEach();
48
+ await FixtureFactory_1.default.afterEach();
49
+ this.clearLocalFixtures();
50
+ }
51
+ static async afterAll() {
52
+ await super.afterAll();
53
+ await FixtureFactory_1.default.afterAll();
54
+ }
55
+ static Fixture(name, options) {
56
+ var _a;
57
+ if (!this._fixtures) {
58
+ const pkg = spruce_skill_utils_1.diskUtil.resolvePath(this.cwd, 'package.json');
59
+ let namespace;
60
+ if (spruce_skill_utils_1.diskUtil.doesFileExist(pkg)) {
61
+ const values = JSON.parse(spruce_skill_utils_1.diskUtil.readFile(pkg));
62
+ namespace = (_a = values === null || values === void 0 ? void 0 : values.skill) === null || _a === void 0 ? void 0 : _a.namespace;
63
+ }
64
+ this._fixtures = new FixtureFactory_1.default({
65
+ cwd: this.cwd,
66
+ namespace,
67
+ });
68
+ }
69
+ return this._fixtures.Fixture(name, options);
70
+ }
71
+ static async bootAndRegisterNewSkill(options) {
72
+ const { name, slug } = options, skillOptions = __rest(options, ["name", "slug"]);
73
+ const { skill, client } = await this.skills.loginAsDemoSkill({
74
+ name,
75
+ slug,
76
+ });
77
+ process.env.SKILL_ID = skill.id;
78
+ process.env.SKILL_API_KEY = skill.apiKey;
79
+ const { skill: bootedSkill, executionPromise } = await this.bootSkill(skillOptions);
80
+ return { skill: bootedSkill, client, executionPromise };
81
+ }
82
+ static async bootAndRegisterSkillFromTestDir(key) {
83
+ const registeredSkill = await this.skills.seedDemoSkill({
84
+ name: 'my test skill',
85
+ });
86
+ process.env.SKILL_ID = registeredSkill.id;
87
+ process.env.SKILL_API_KEY = registeredSkill.apiKey;
88
+ return this.bootSkillFromTestDir(key);
89
+ }
90
+ static async SkillFromTestDir(key, options) {
91
+ const skill = await super.SkillFromTestDir(key, options);
92
+ this._fixtures = undefined;
93
+ return skill;
94
+ }
22
95
  static get fakedOrganizations() {
23
96
  return this._fakedOrganizations;
24
97
  }
@@ -132,66 +205,6 @@ class AbstractSpruceFixtureTest extends spruce_skill_booter_1.AbstractSkillTest
132
205
  static set database(fixture) {
133
206
  this._database = fixture;
134
207
  }
135
- static async beforeAll() {
136
- await super.beforeAll();
137
- await FixtureFactory_1.default.beforeAll();
138
- console.error = spruce_skill_utils_1.testLog.error;
139
- }
140
- static async beforeEach() {
141
- await super.beforeEach();
142
- await FixtureFactory_1.default.beforeEach(this.cwd);
143
- this.clearLocalFixtures();
144
- }
145
- static clearLocalFixtures() {
146
- this.views = undefined;
147
- this.roles = undefined;
148
- this.locations = undefined;
149
- this.organizations = undefined;
150
- this.people = undefined;
151
- this.seeder = undefined;
152
- this.skills = undefined;
153
- this.mercury = undefined;
154
- this.stores = undefined;
155
- this.database = undefined;
156
- }
157
- static async afterEach() {
158
- await super.afterEach();
159
- await FixtureFactory_1.default.afterEach();
160
- this.clearLocalFixtures();
161
- }
162
- static async afterAll() {
163
- await super.afterAll();
164
- await FixtureFactory_1.default.afterAll();
165
- }
166
- static Fixture(name, options) {
167
- var _a;
168
- const pkg = spruce_skill_utils_1.diskUtil.resolvePath(this.cwd, 'package.json');
169
- let namespace;
170
- if (spruce_skill_utils_1.diskUtil.doesFileExist(pkg)) {
171
- const values = JSON.parse(spruce_skill_utils_1.diskUtil.readFile(pkg));
172
- namespace = (_a = values === null || values === void 0 ? void 0 : values.skill) === null || _a === void 0 ? void 0 : _a.namespace;
173
- }
174
- return new FixtureFactory_1.default({ cwd: this.cwd, namespace }).Fixture(name, options);
175
- }
176
- static async bootAndRegisterNewSkill(options) {
177
- const { name, slug } = options, skillOptions = __rest(options, ["name", "slug"]);
178
- const { skill, client } = await this.skills.loginAsDemoSkill({
179
- name,
180
- slug,
181
- });
182
- process.env.SKILL_ID = skill.id;
183
- process.env.SKILL_API_KEY = skill.apiKey;
184
- const { skill: bootedSkill, executionPromise } = await this.bootSkill(skillOptions);
185
- return { skill: bootedSkill, client, executionPromise };
186
- }
187
- static async bootAndRegisterSkillFromTestDir(key) {
188
- const registeredSkill = await this.skills.seedDemoSkill({
189
- name: 'my test skill',
190
- });
191
- process.env.SKILL_ID = registeredSkill.id;
192
- process.env.SKILL_API_KEY = registeredSkill.apiKey;
193
- return this.bootSkillFromTestDir(key);
194
- }
195
208
  }
196
209
  exports.default = AbstractSpruceFixtureTest;
197
210
  AbstractSpruceFixtureTest._fakedOrganizations = [];
@@ -8,6 +8,8 @@ export default class FixtureFactory {
8
8
  cwd: string;
9
9
  namespace?: string;
10
10
  });
11
+ setCwd(cwd: string): void;
12
+ setNamespace(namespace: string): void;
11
13
  Fixture<Name extends FixtureName>(named: Name, options?: Partial<FixtureConstructorOptionsMap[Name]>): FixtureMap[Name];
12
14
  private getMercuryFixture;
13
15
  static destroy(): Promise<void>;
@@ -31,6 +31,12 @@ class FixtureFactory {
31
31
  }
32
32
  this.namespace = options.namespace;
33
33
  }
34
+ setCwd(cwd) {
35
+ this.cwd = cwd;
36
+ }
37
+ setNamespace(namespace) {
38
+ this.namespace = namespace;
39
+ }
34
40
  Fixture(named, options) {
35
41
  var _a, _b, _c, _d, _e;
36
42
  const mercuryFixture = this.getMercuryFixture(named);
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "@sprucelabs/spruce-test-fixtures"
14
14
  ]
15
15
  },
16
- "version": "52.5.6",
16
+ "version": "52.5.7",
17
17
  "files": [
18
18
  "build/**/*",
19
19
  "!build/__tests__",
@@ -64,15 +64,15 @@
64
64
  "dependencies": {
65
65
  "@sprucelabs/data-stores": "^19.1.13",
66
66
  "@sprucelabs/error": "^5.0.555",
67
- "@sprucelabs/heartwood-view-controllers": "^99.1.14",
67
+ "@sprucelabs/heartwood-view-controllers": "^99.1.15",
68
68
  "@sprucelabs/mercury-client": "^35.0.29",
69
69
  "@sprucelabs/mercury-core-events": "^15.0.144",
70
70
  "@sprucelabs/mercury-event-emitter": "^35.0.29",
71
71
  "@sprucelabs/schema": "^28.5.88",
72
72
  "@sprucelabs/spruce-core-schemas": "^35.1.95",
73
73
  "@sprucelabs/spruce-event-utils": "^30.0.25",
74
- "@sprucelabs/spruce-permission-utils": "^1.0.0",
75
- "@sprucelabs/spruce-skill-booter": "^52.5.6",
74
+ "@sprucelabs/spruce-permission-utils": "^1.0.1",
75
+ "@sprucelabs/spruce-skill-booter": "^52.5.7",
76
76
  "@sprucelabs/spruce-skill-utils": "^28.1.18",
77
77
  "@sprucelabs/test-utils": "^3.2.76",
78
78
  "dotenv": "^16.0.3",
@@ -132,5 +132,5 @@
132
132
  ]
133
133
  ]
134
134
  },
135
- "gitHead": "708f8b4190cf6ec41041462d4b0c52c2d7bc10b2"
135
+ "gitHead": "f5414aaaaae8ce0237ec49191419cf159e49d4ab"
136
136
  }