@sprucelabs/spruce-test-fixtures 49.0.1 → 49.0.2
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/faking/FakingAuthenticator.test.d.ts +1 -0
- package/build/__tests__/behavioral/faking/FakingAuthenticator.test.js +8 -0
- package/build/__tests__/behavioral/faking/WhoAmI.test.d.ts +1 -1
- package/build/__tests__/behavioral/faking/WhoAmI.test.js +2 -2
- package/build/esm/__tests__/behavioral/faking/FakingAuthenticator.test.d.ts +1 -0
- package/build/esm/__tests__/behavioral/faking/FakingAuthenticator.test.js +10 -0
- package/build/esm/__tests__/behavioral/faking/WhoAmI.test.d.ts +1 -1
- package/build/esm/__tests__/behavioral/faking/WhoAmI.test.js +2 -2
- package/build/esm/tests/decorators/fake.js +12 -4
- package/build/esm/tests/fixtures/FixtureFactory.js +1 -1
- package/build/tests/decorators/fake.js +12 -4
- package/build/tests/fixtures/FixtureFactory.js +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import AbstractSpruceFixtureTest from '../../../tests/AbstractSpruceFixtureTest';
|
|
2
2
|
export default class FakingAuthenticatorTest extends AbstractSpruceFixtureTest {
|
|
3
3
|
protected static canCreateFakingAuthenticator(): Promise<void>;
|
|
4
|
+
protected static setsProperSessionToken(): Promise<void>;
|
|
4
5
|
}
|
|
@@ -17,10 +17,18 @@ let FakingAuthenticatorTest = class FakingAuthenticatorTest extends AbstractSpru
|
|
|
17
17
|
const auth = this.views.getAuthenticator();
|
|
18
18
|
test_1.assert.isEqualDeep(auth.getPerson(), this.fakedPerson);
|
|
19
19
|
}
|
|
20
|
+
static async setsProperSessionToken() {
|
|
21
|
+
const auth = this.views.getAuthenticator();
|
|
22
|
+
//@ts-ignore
|
|
23
|
+
test_1.assert.isEqual(auth.getSessionToken(), this.fakedClient.auth.token);
|
|
24
|
+
}
|
|
20
25
|
};
|
|
21
26
|
__decorate([
|
|
22
27
|
(0, test_1.test)()
|
|
23
28
|
], FakingAuthenticatorTest, "canCreateFakingAuthenticator", null);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, test_1.test)()
|
|
31
|
+
], FakingAuthenticatorTest, "setsProperSessionToken", null);
|
|
24
32
|
FakingAuthenticatorTest = __decorate([
|
|
25
33
|
fake_1.default.login()
|
|
26
34
|
], FakingAuthenticatorTest);
|
|
@@ -6,7 +6,7 @@ export default class WhoAmITest extends AbstractSpruceFixtureTest {
|
|
|
6
6
|
protected static afterEach(): Promise<void>;
|
|
7
7
|
protected static afterAll(): Promise<void>;
|
|
8
8
|
protected static canWhoAmI(): Promise<void>;
|
|
9
|
-
protected static
|
|
9
|
+
protected static authIsResetBeforeEachSoListenersAreReset(): Promise<void>;
|
|
10
10
|
protected static canRegisterProxyToken(): Promise<void>;
|
|
11
11
|
protected static canUseProxyToEmitAsOtherPerson(): Promise<void>;
|
|
12
12
|
protected static canUseProxyAsSecondPerson(): Promise<void>;
|
|
@@ -33,7 +33,7 @@ let WhoAmITest = class WhoAmITest extends AbstractSpruceFixtureTest_1.default {
|
|
|
33
33
|
this.didLoginCount++;
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
-
static async
|
|
36
|
+
static async authIsResetBeforeEachSoListenersAreReset() {
|
|
37
37
|
test_1.assert.isNotEqual(this.views.getAuthenticator(), this.auth);
|
|
38
38
|
await __1.fake.getClient().emitAndFlattenResponses('whoami::v2020_12_25');
|
|
39
39
|
test_1.assert.isEqual(this.didLoginCount, 0);
|
|
@@ -87,7 +87,7 @@ __decorate([
|
|
|
87
87
|
], WhoAmITest, "canWhoAmI", null);
|
|
88
88
|
__decorate([
|
|
89
89
|
(0, test_1.test)()
|
|
90
|
-
], WhoAmITest, "
|
|
90
|
+
], WhoAmITest, "authIsResetBeforeEachSoListenersAreReset", null);
|
|
91
91
|
__decorate([
|
|
92
92
|
(0, test_1.test)()
|
|
93
93
|
], WhoAmITest, "canRegisterProxyToken", null);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import AbstractSpruceFixtureTest from '../../../tests/AbstractSpruceFixtureTest';
|
|
2
2
|
export default class FakingAuthenticatorTest extends AbstractSpruceFixtureTest {
|
|
3
3
|
protected static canCreateFakingAuthenticator(): Promise<void>;
|
|
4
|
+
protected static setsProperSessionToken(): Promise<void>;
|
|
4
5
|
}
|
|
@@ -23,10 +23,20 @@ let FakingAuthenticatorTest = class FakingAuthenticatorTest extends AbstractSpru
|
|
|
23
23
|
assert.isEqualDeep(auth.getPerson(), this.fakedPerson);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
+
static setsProperSessionToken() {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const auth = this.views.getAuthenticator();
|
|
29
|
+
//@ts-ignore
|
|
30
|
+
assert.isEqual(auth.getSessionToken(), this.fakedClient.auth.token);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
26
33
|
};
|
|
27
34
|
__decorate([
|
|
28
35
|
test()
|
|
29
36
|
], FakingAuthenticatorTest, "canCreateFakingAuthenticator", null);
|
|
37
|
+
__decorate([
|
|
38
|
+
test()
|
|
39
|
+
], FakingAuthenticatorTest, "setsProperSessionToken", null);
|
|
30
40
|
FakingAuthenticatorTest = __decorate([
|
|
31
41
|
fake.login()
|
|
32
42
|
], FakingAuthenticatorTest);
|
|
@@ -6,7 +6,7 @@ export default class WhoAmITest extends AbstractSpruceFixtureTest {
|
|
|
6
6
|
protected static afterEach(): Promise<void>;
|
|
7
7
|
protected static afterAll(): Promise<void>;
|
|
8
8
|
protected static canWhoAmI(): Promise<void>;
|
|
9
|
-
protected static
|
|
9
|
+
protected static authIsResetBeforeEachSoListenersAreReset(): Promise<void>;
|
|
10
10
|
protected static canRegisterProxyToken(): Promise<void>;
|
|
11
11
|
protected static canUseProxyToEmitAsOtherPerson(): Promise<void>;
|
|
12
12
|
protected static canUseProxyAsSecondPerson(): Promise<void>;
|
|
@@ -54,7 +54,7 @@ let WhoAmITest = class WhoAmITest extends AbstractSpruceFixtureTest {
|
|
|
54
54
|
}));
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
static
|
|
57
|
+
static authIsResetBeforeEachSoListenersAreReset() {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
59
|
assert.isNotEqual(this.views.getAuthenticator(), this.auth);
|
|
60
60
|
yield fake.getClient().emitAndFlattenResponses('whoami::v2020_12_25');
|
|
@@ -124,7 +124,7 @@ __decorate([
|
|
|
124
124
|
], WhoAmITest, "canWhoAmI", null);
|
|
125
125
|
__decorate([
|
|
126
126
|
test()
|
|
127
|
-
], WhoAmITest, "
|
|
127
|
+
], WhoAmITest, "authIsResetBeforeEachSoListenersAreReset", null);
|
|
128
128
|
__decorate([
|
|
129
129
|
test()
|
|
130
130
|
], WhoAmITest, "canRegisterProxyToken", null);
|
|
@@ -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,
|
|
@@ -83,6 +84,7 @@ fake.login = (phone = '555-000-0000') => {
|
|
|
83
84
|
MercuryFixture.setShouldAutomaticallyClearDefaultClient(false);
|
|
84
85
|
MercuryTestClient.setShouldRequireLocalListeners(true);
|
|
85
86
|
MercuryClientFactory.setIsTestMode(true);
|
|
87
|
+
ViewFixture.setShouldAutomaticallyResetAuth(false);
|
|
86
88
|
seed.disableResettingTestClient();
|
|
87
89
|
return function (TestClass, shouldPassHookCalls = true) {
|
|
88
90
|
var _a, _b, _c;
|
|
@@ -119,10 +121,16 @@ fake.login = (phone = '555-000-0000') => {
|
|
|
119
121
|
if (!TestClass.cwd) {
|
|
120
122
|
return;
|
|
121
123
|
}
|
|
124
|
+
ViewFixture.resetAuth();
|
|
125
|
+
try {
|
|
126
|
+
const auth = Class.views.getAuthenticator();
|
|
127
|
+
//@ts-ignore
|
|
128
|
+
auth.setSessionToken(Class.fakedClient.auth.token, Class.fakedPerson);
|
|
129
|
+
}
|
|
130
|
+
catch (_d) {
|
|
131
|
+
//hits if not in skill because cant find nameplace
|
|
132
|
+
}
|
|
122
133
|
shouldPassHookCalls && (yield (beforeEach === null || beforeEach === void 0 ? void 0 : beforeEach()));
|
|
123
|
-
Class.views
|
|
124
|
-
.getAuthenticator()
|
|
125
|
-
.setSessionToken(generateId(), Class.fakedPerson);
|
|
126
134
|
});
|
|
127
135
|
};
|
|
128
136
|
};
|
|
@@ -139,6 +147,7 @@ function login(Class, phone) {
|
|
|
139
147
|
if (!person.firstName) {
|
|
140
148
|
givePersonName(person);
|
|
141
149
|
}
|
|
150
|
+
yield client.registerProxyToken();
|
|
142
151
|
//@ts-ignore
|
|
143
152
|
client.auth.person = person;
|
|
144
153
|
Class.fakedClient = client;
|
|
@@ -159,7 +168,6 @@ function loginUsingViewsFallingBackToPeople(Class, phone) {
|
|
|
159
168
|
person = p;
|
|
160
169
|
client = c;
|
|
161
170
|
}
|
|
162
|
-
yield client.registerProxyToken();
|
|
163
171
|
return { person: Class.fakedPeople.find((p) => p.id === person.id), client };
|
|
164
172
|
});
|
|
165
173
|
}
|
|
@@ -105,7 +105,7 @@ export default class FixtureFactory {
|
|
|
105
105
|
break;
|
|
106
106
|
case 'view': {
|
|
107
107
|
if (!this.namespace) {
|
|
108
|
-
throw new Error('You need to be in a
|
|
108
|
+
throw new Error('You need to be in a registered skill to load view controllers.');
|
|
109
109
|
}
|
|
110
110
|
fixture = new ViewFixture(Object.assign({
|
|
111
111
|
//@ts-ignore
|
|
@@ -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,
|
|
@@ -81,6 +82,7 @@ fake.login = (phone = '555-000-0000') => {
|
|
|
81
82
|
MercuryFixture_1.default.setShouldAutomaticallyClearDefaultClient(false);
|
|
82
83
|
mercury_client_1.MercuryTestClient.setShouldRequireLocalListeners(true);
|
|
83
84
|
mercury_client_1.MercuryClientFactory.setIsTestMode(true);
|
|
85
|
+
ViewFixture_1.default.setShouldAutomaticallyResetAuth(false);
|
|
84
86
|
seed_1.default.disableResettingTestClient();
|
|
85
87
|
return function (TestClass, shouldPassHookCalls = true) {
|
|
86
88
|
var _a, _b, _c;
|
|
@@ -117,10 +119,16 @@ fake.login = (phone = '555-000-0000') => {
|
|
|
117
119
|
if (!TestClass.cwd) {
|
|
118
120
|
return;
|
|
119
121
|
}
|
|
122
|
+
ViewFixture_1.default.resetAuth();
|
|
123
|
+
try {
|
|
124
|
+
const auth = Class.views.getAuthenticator();
|
|
125
|
+
//@ts-ignore
|
|
126
|
+
auth.setSessionToken(Class.fakedClient.auth.token, Class.fakedPerson);
|
|
127
|
+
}
|
|
128
|
+
catch (_a) {
|
|
129
|
+
//hits if not in skill because cant find nameplace
|
|
130
|
+
}
|
|
120
131
|
shouldPassHookCalls && (await (beforeEach === null || beforeEach === void 0 ? void 0 : beforeEach()));
|
|
121
|
-
Class.views
|
|
122
|
-
.getAuthenticator()
|
|
123
|
-
.setSessionToken((0, test_utils_1.generateId)(), Class.fakedPerson);
|
|
124
132
|
};
|
|
125
133
|
};
|
|
126
134
|
};
|
|
@@ -136,6 +144,7 @@ async function login(Class, phone) {
|
|
|
136
144
|
if (!person.firstName) {
|
|
137
145
|
givePersonName(person);
|
|
138
146
|
}
|
|
147
|
+
await client.registerProxyToken();
|
|
139
148
|
//@ts-ignore
|
|
140
149
|
client.auth.person = person;
|
|
141
150
|
Class.fakedClient = client;
|
|
@@ -154,7 +163,6 @@ async function loginUsingViewsFallingBackToPeople(Class, phone) {
|
|
|
154
163
|
person = p;
|
|
155
164
|
client = c;
|
|
156
165
|
}
|
|
157
|
-
await client.registerProxyToken();
|
|
158
166
|
return { person: Class.fakedPeople.find((p) => p.id === person.id), client };
|
|
159
167
|
}
|
|
160
168
|
function givePersonName(person) {
|
|
@@ -101,7 +101,7 @@ class FixtureFactory {
|
|
|
101
101
|
break;
|
|
102
102
|
case 'view': {
|
|
103
103
|
if (!this.namespace) {
|
|
104
|
-
throw new Error('You need to be in a
|
|
104
|
+
throw new Error('You need to be in a registered skill to load view controllers.');
|
|
105
105
|
}
|
|
106
106
|
fixture = new ViewFixture_1.default(Object.assign({
|
|
107
107
|
//@ts-ignore
|
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.2",
|
|
17
17
|
"files": [
|
|
18
18
|
"build/**/*",
|
|
19
19
|
"!build/__tests__",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"@sprucelabs/schema": "^28.4.33",
|
|
72
72
|
"@sprucelabs/spruce-core-schemas": "^34.2.80",
|
|
73
73
|
"@sprucelabs/spruce-event-utils": "^27.0.152",
|
|
74
|
-
"@sprucelabs/spruce-skill-booter": "^49.0.
|
|
74
|
+
"@sprucelabs/spruce-skill-booter": "^49.0.2",
|
|
75
75
|
"@sprucelabs/spruce-skill-utils": "^26.4.55",
|
|
76
76
|
"dotenv": "^16.0.2",
|
|
77
77
|
"unique-names-generator": "^4.7.1"
|
|
@@ -131,5 +131,5 @@
|
|
|
131
131
|
]
|
|
132
132
|
]
|
|
133
133
|
},
|
|
134
|
-
"gitHead": "
|
|
134
|
+
"gitHead": "40fdf5d626c6e327264530181acf1a692d58c5e2"
|
|
135
135
|
}
|