@sprucelabs/spruce-test-fixtures 44.2.14 → 44.2.15

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.
@@ -29,6 +29,7 @@ import AbstractSpruceFixtureTest from '../AbstractSpruceFixtureTest.js';
29
29
  import eventFaker from '../eventFaker.js';
30
30
  import generateRandomName from '../fixtures/generateRandomName.js';
31
31
  import MercuryFixture from '../fixtures/MercuryFixture.js';
32
+ import ViewFixture from '../fixtures/ViewFixture.js';
32
33
  import seed from './seed.js';
33
34
  const strategies = {
34
35
  organizations: seedOrganizations,
@@ -111,6 +112,7 @@ fake.login = (phone = '555-000-0000') => {
111
112
  yield (afterEach === null || afterEach === void 0 ? void 0 : afterEach());
112
113
  });
113
114
  Class.beforeEach = () => __awaiter(this, void 0, void 0, function* () {
115
+ ViewFixture.resetAuth();
114
116
  yield fakeAuthenticationEvents(Class);
115
117
  resetFakes(Class);
116
118
  if (!TestClass.cwd) {
@@ -129,6 +131,18 @@ fake.getPerson = () => {
129
131
  return fake.getClient().auth.person;
130
132
  };
131
133
  function login(Class, phone) {
134
+ return __awaiter(this, void 0, void 0, function* () {
135
+ const { person, client } = yield loginUsingViewsFallingBackToPeople(Class, phone);
136
+ if (!person.firstName) {
137
+ givePersonName(person);
138
+ }
139
+ Class.fakedPeople = [person];
140
+ Class.fakedOwners = [person];
141
+ Class.fakedOwner = person;
142
+ Class.fakedOwnerClient = client;
143
+ });
144
+ }
145
+ function loginUsingViewsFallingBackToPeople(Class, phone) {
132
146
  return __awaiter(this, void 0, void 0, function* () {
133
147
  let person;
134
148
  let client;
@@ -142,13 +156,7 @@ function login(Class, phone) {
142
156
  person = p;
143
157
  client = c;
144
158
  }
145
- if (!person.firstName) {
146
- givePersonName(person);
147
- }
148
- Class.fakedPeople = [person];
149
- Class.fakedOwners = [person];
150
- Class.fakedOwner = person;
151
- Class.fakedOwnerClient = client;
159
+ return { person, client };
152
160
  });
153
161
  }
154
162
  function givePersonName(person) {
@@ -49,7 +49,7 @@ export default class ViewFixture {
49
49
  static beforeAll(): Promise<void>;
50
50
  static beforeEach(): Promise<void>;
51
51
  private static resetMaps;
52
- private static resetAuth;
52
+ static resetAuth(): void;
53
53
  load<Svc extends SkillViewController = SkillViewController>(vc: Pick<Svc, 'load' | 'getScope'>, args?: ArgsFromSvc<Svc>): Promise<void>;
54
54
  private assertScopeRequirementsMet;
55
55
  setScope(scope: Scope): void;
@@ -26,6 +26,7 @@ const AbstractSpruceFixtureTest_1 = __importDefault(require("../AbstractSpruceFi
26
26
  const eventFaker_1 = __importDefault(require("../eventFaker"));
27
27
  const generateRandomName_1 = __importDefault(require("../fixtures/generateRandomName"));
28
28
  const MercuryFixture_1 = __importDefault(require("../fixtures/MercuryFixture"));
29
+ const ViewFixture_1 = __importDefault(require("../fixtures/ViewFixture"));
29
30
  const seed_1 = __importDefault(require("./seed"));
30
31
  const strategies = {
31
32
  organizations: seedOrganizations,
@@ -109,6 +110,7 @@ fake.login = (phone = '555-000-0000') => {
109
110
  await (afterEach === null || afterEach === void 0 ? void 0 : afterEach());
110
111
  };
111
112
  Class.beforeEach = async () => {
113
+ ViewFixture_1.default.resetAuth();
112
114
  await fakeAuthenticationEvents(Class);
113
115
  resetFakes(Class);
114
116
  if (!TestClass.cwd) {
@@ -127,6 +129,16 @@ fake.getPerson = () => {
127
129
  return fake.getClient().auth.person;
128
130
  };
129
131
  async function login(Class, phone) {
132
+ const { person, client } = await loginUsingViewsFallingBackToPeople(Class, phone);
133
+ if (!person.firstName) {
134
+ givePersonName(person);
135
+ }
136
+ Class.fakedPeople = [person];
137
+ Class.fakedOwners = [person];
138
+ Class.fakedOwner = person;
139
+ Class.fakedOwnerClient = client;
140
+ }
141
+ async function loginUsingViewsFallingBackToPeople(Class, phone) {
130
142
  let person;
131
143
  let client;
132
144
  try {
@@ -139,13 +151,7 @@ async function login(Class, phone) {
139
151
  person = p;
140
152
  client = c;
141
153
  }
142
- if (!person.firstName) {
143
- givePersonName(person);
144
- }
145
- Class.fakedPeople = [person];
146
- Class.fakedOwners = [person];
147
- Class.fakedOwner = person;
148
- Class.fakedOwnerClient = client;
154
+ return { person, client };
149
155
  }
150
156
  function givePersonName(person) {
151
157
  const names = (0, generateRandomName_1.default)();
@@ -49,7 +49,7 @@ export default class ViewFixture {
49
49
  static beforeAll(): Promise<void>;
50
50
  static beforeEach(): Promise<void>;
51
51
  private static resetMaps;
52
- private static resetAuth;
52
+ static resetAuth(): void;
53
53
  load<Svc extends SkillViewController = SkillViewController>(vc: Pick<Svc, 'load' | 'getScope'>, args?: ArgsFromSvc<Svc>): Promise<void>;
54
54
  private assertScopeRequirementsMet;
55
55
  setScope(scope: Scope): void;
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "@sprucelabs/spruce-test-fixtures"
14
14
  ]
15
15
  },
16
- "version": "44.2.14",
16
+ "version": "44.2.15",
17
17
  "files": [
18
18
  "build/**/*",
19
19
  "!build/__tests__",
@@ -71,7 +71,7 @@
71
71
  "@sprucelabs/schema": "^28.3.16",
72
72
  "@sprucelabs/spruce-core-schemas": "^34.2.17",
73
73
  "@sprucelabs/spruce-event-utils": "^27.0.72",
74
- "@sprucelabs/spruce-skill-booter": "^44.2.14",
74
+ "@sprucelabs/spruce-skill-booter": "^44.2.15",
75
75
  "@sprucelabs/spruce-skill-utils": "^26.3.7",
76
76
  "dotenv": "^16.0.1",
77
77
  "unique-names-generator": "^4.7.1"
@@ -131,5 +131,5 @@
131
131
  ]
132
132
  ]
133
133
  },
134
- "gitHead": "8989101e1e2144b87c8a9a3f781bd3a60805a9ce"
134
+ "gitHead": "0c47b39b20b4f7cb2041c318e025c70891bb2617"
135
135
  }