@sprucelabs/spruce-calendar-components 22.8.12 → 22.8.14
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/.spruce/schemas/schemas.types.d.ts +42 -42
- package/build/__tests__/support/utilities/calendarAssert.js +13 -13
- package/build/__tests__/support/utilities/calendarSkillAssert.js +30 -30
- package/build/esm/.spruce/schemas/schemas.types.d.ts +42 -42
- package/build/esm/__tests__/support/utilities/calendarAssert.js +1 -1
- package/build/esm/__tests__/support/utilities/calendarSkillAssert.js +1 -1
- package/build/esm/toolBelt/CalendarToolTestFactory.js +1 -1
- package/build/toolBelt/CalendarToolTestFactory.js +2 -2
- package/package.json +2 -2
|
@@ -2044,41 +2044,41 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
|
2044
2044
|
}
|
|
2045
2045
|
}
|
|
2046
2046
|
namespace SpruceSchemas.Calendar.v2021_05_19 {
|
|
2047
|
-
interface
|
|
2048
|
-
'
|
|
2049
|
-
'
|
|
2047
|
+
interface GetCalendarEventEmitTarget {
|
|
2048
|
+
'locationId': string;
|
|
2049
|
+
'calendarEventId': string;
|
|
2050
2050
|
}
|
|
2051
|
-
interface
|
|
2052
|
-
id: '
|
|
2051
|
+
interface GetCalendarEventEmitTargetSchema extends SpruceSchema.Schema {
|
|
2052
|
+
id: 'getCalendarEventEmitTarget';
|
|
2053
2053
|
version: 'v2021_05_19';
|
|
2054
2054
|
namespace: 'Calendar';
|
|
2055
2055
|
name: '';
|
|
2056
2056
|
fields: {
|
|
2057
2057
|
/** . */
|
|
2058
|
-
'
|
|
2058
|
+
'locationId': {
|
|
2059
2059
|
type: 'id';
|
|
2060
2060
|
isRequired: true;
|
|
2061
2061
|
options: undefined;
|
|
2062
2062
|
};
|
|
2063
2063
|
/** . */
|
|
2064
|
-
'
|
|
2064
|
+
'calendarEventId': {
|
|
2065
2065
|
type: 'id';
|
|
2066
2066
|
isRequired: true;
|
|
2067
2067
|
options: undefined;
|
|
2068
2068
|
};
|
|
2069
2069
|
};
|
|
2070
2070
|
}
|
|
2071
|
-
interface
|
|
2071
|
+
interface GetCalendarEventEmitTargetEntity extends SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.GetCalendarEventEmitTargetSchema> {
|
|
2072
2072
|
}
|
|
2073
2073
|
}
|
|
2074
2074
|
namespace SpruceSchemas.Calendar.v2021_05_19 {
|
|
2075
|
-
interface
|
|
2075
|
+
interface GetCalendarEventEmitTargetAndPayload {
|
|
2076
2076
|
/** Source. */
|
|
2077
2077
|
'source'?: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSource | undefined | null;
|
|
2078
|
-
'target': SpruceSchemas.Calendar.v2021_05_19.
|
|
2078
|
+
'target': SpruceSchemas.Calendar.v2021_05_19.GetCalendarEventEmitTarget;
|
|
2079
2079
|
}
|
|
2080
|
-
interface
|
|
2081
|
-
id: '
|
|
2080
|
+
interface GetCalendarEventEmitTargetAndPayloadSchema extends SpruceSchema.Schema {
|
|
2081
|
+
id: 'getCalendarEventEmitTargetAndPayload';
|
|
2082
2082
|
version: 'v2021_05_19';
|
|
2083
2083
|
namespace: 'Calendar';
|
|
2084
2084
|
name: '';
|
|
@@ -2096,73 +2096,73 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
|
2096
2096
|
type: 'schema';
|
|
2097
2097
|
isRequired: true;
|
|
2098
2098
|
options: {
|
|
2099
|
-
schema: SpruceSchemas.Calendar.v2021_05_19.
|
|
2099
|
+
schema: SpruceSchemas.Calendar.v2021_05_19.GetCalendarEventEmitTargetSchema;
|
|
2100
2100
|
};
|
|
2101
2101
|
};
|
|
2102
2102
|
};
|
|
2103
2103
|
}
|
|
2104
|
-
interface
|
|
2104
|
+
interface GetCalendarEventEmitTargetAndPayloadEntity extends SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.GetCalendarEventEmitTargetAndPayloadSchema> {
|
|
2105
2105
|
}
|
|
2106
2106
|
}
|
|
2107
2107
|
namespace SpruceSchemas.Calendar.v2021_05_19 {
|
|
2108
|
-
interface
|
|
2109
|
-
'
|
|
2108
|
+
interface GetCalendarEventResponsePayload {
|
|
2109
|
+
'calendarEvent': SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent;
|
|
2110
2110
|
}
|
|
2111
|
-
interface
|
|
2112
|
-
id: '
|
|
2111
|
+
interface GetCalendarEventResponsePayloadSchema extends SpruceSchema.Schema {
|
|
2112
|
+
id: 'getCalendarEventResponsePayload';
|
|
2113
2113
|
version: 'v2021_05_19';
|
|
2114
2114
|
namespace: 'Calendar';
|
|
2115
2115
|
name: '';
|
|
2116
2116
|
fields: {
|
|
2117
2117
|
/** . */
|
|
2118
|
-
'
|
|
2118
|
+
'calendarEvent': {
|
|
2119
2119
|
type: 'schema';
|
|
2120
2120
|
isRequired: true;
|
|
2121
2121
|
options: {
|
|
2122
|
-
schema: SpruceSchemas.
|
|
2122
|
+
schema: SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema;
|
|
2123
2123
|
};
|
|
2124
2124
|
};
|
|
2125
2125
|
};
|
|
2126
2126
|
}
|
|
2127
|
-
interface
|
|
2127
|
+
interface GetCalendarEventResponsePayloadEntity extends SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.GetCalendarEventResponsePayloadSchema> {
|
|
2128
2128
|
}
|
|
2129
2129
|
}
|
|
2130
2130
|
namespace SpruceSchemas.Calendar.v2021_05_19 {
|
|
2131
|
-
interface
|
|
2132
|
-
'
|
|
2133
|
-
'
|
|
2131
|
+
interface GetCalendarEmitTarget {
|
|
2132
|
+
'organizationId': string;
|
|
2133
|
+
'slug': string;
|
|
2134
2134
|
}
|
|
2135
|
-
interface
|
|
2136
|
-
id: '
|
|
2135
|
+
interface GetCalendarEmitTargetSchema extends SpruceSchema.Schema {
|
|
2136
|
+
id: 'getCalendarEmitTarget';
|
|
2137
2137
|
version: 'v2021_05_19';
|
|
2138
2138
|
namespace: 'Calendar';
|
|
2139
2139
|
name: '';
|
|
2140
2140
|
fields: {
|
|
2141
2141
|
/** . */
|
|
2142
|
-
'
|
|
2142
|
+
'organizationId': {
|
|
2143
2143
|
type: 'id';
|
|
2144
2144
|
isRequired: true;
|
|
2145
2145
|
options: undefined;
|
|
2146
2146
|
};
|
|
2147
2147
|
/** . */
|
|
2148
|
-
'
|
|
2148
|
+
'slug': {
|
|
2149
2149
|
type: 'id';
|
|
2150
2150
|
isRequired: true;
|
|
2151
2151
|
options: undefined;
|
|
2152
2152
|
};
|
|
2153
2153
|
};
|
|
2154
2154
|
}
|
|
2155
|
-
interface
|
|
2155
|
+
interface GetCalendarEmitTargetEntity extends SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.GetCalendarEmitTargetSchema> {
|
|
2156
2156
|
}
|
|
2157
2157
|
}
|
|
2158
2158
|
namespace SpruceSchemas.Calendar.v2021_05_19 {
|
|
2159
|
-
interface
|
|
2159
|
+
interface GetCalendarEmitTargetAndPayload {
|
|
2160
2160
|
/** Source. */
|
|
2161
2161
|
'source'?: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSource | undefined | null;
|
|
2162
|
-
'target': SpruceSchemas.Calendar.v2021_05_19.
|
|
2162
|
+
'target': SpruceSchemas.Calendar.v2021_05_19.GetCalendarEmitTarget;
|
|
2163
2163
|
}
|
|
2164
|
-
interface
|
|
2165
|
-
id: '
|
|
2164
|
+
interface GetCalendarEmitTargetAndPayloadSchema extends SpruceSchema.Schema {
|
|
2165
|
+
id: 'getCalendarEmitTargetAndPayload';
|
|
2166
2166
|
version: 'v2021_05_19';
|
|
2167
2167
|
namespace: 'Calendar';
|
|
2168
2168
|
name: '';
|
|
@@ -2180,35 +2180,35 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
|
2180
2180
|
type: 'schema';
|
|
2181
2181
|
isRequired: true;
|
|
2182
2182
|
options: {
|
|
2183
|
-
schema: SpruceSchemas.Calendar.v2021_05_19.
|
|
2183
|
+
schema: SpruceSchemas.Calendar.v2021_05_19.GetCalendarEmitTargetSchema;
|
|
2184
2184
|
};
|
|
2185
2185
|
};
|
|
2186
2186
|
};
|
|
2187
2187
|
}
|
|
2188
|
-
interface
|
|
2188
|
+
interface GetCalendarEmitTargetAndPayloadEntity extends SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.GetCalendarEmitTargetAndPayloadSchema> {
|
|
2189
2189
|
}
|
|
2190
2190
|
}
|
|
2191
2191
|
namespace SpruceSchemas.Calendar.v2021_05_19 {
|
|
2192
|
-
interface
|
|
2193
|
-
'
|
|
2192
|
+
interface GetCalendarResponsePayload {
|
|
2193
|
+
'calendar': SpruceSchemas.Calendar.v2021_05_19.Calendar;
|
|
2194
2194
|
}
|
|
2195
|
-
interface
|
|
2196
|
-
id: '
|
|
2195
|
+
interface GetCalendarResponsePayloadSchema extends SpruceSchema.Schema {
|
|
2196
|
+
id: 'getCalendarResponsePayload';
|
|
2197
2197
|
version: 'v2021_05_19';
|
|
2198
2198
|
namespace: 'Calendar';
|
|
2199
2199
|
name: '';
|
|
2200
2200
|
fields: {
|
|
2201
2201
|
/** . */
|
|
2202
|
-
'
|
|
2202
|
+
'calendar': {
|
|
2203
2203
|
type: 'schema';
|
|
2204
2204
|
isRequired: true;
|
|
2205
2205
|
options: {
|
|
2206
|
-
schema: SpruceSchemas.
|
|
2206
|
+
schema: SpruceSchemas.Calendar.v2021_05_19.CalendarSchema;
|
|
2207
2207
|
};
|
|
2208
2208
|
};
|
|
2209
2209
|
};
|
|
2210
2210
|
}
|
|
2211
|
-
interface
|
|
2211
|
+
interface GetCalendarResponsePayloadEntity extends SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.GetCalendarResponsePayloadSchema> {
|
|
2212
2212
|
}
|
|
2213
2213
|
}
|
|
2214
2214
|
namespace SpruceSchemas.Calendar.v2021_05_19 {
|
|
@@ -5,12 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const calendar_utils_1 = require("@sprucelabs/calendar-utils");
|
|
7
7
|
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
8
|
-
const
|
|
8
|
+
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
9
9
|
const just_clone_1 = __importDefault(require("just-clone"));
|
|
10
10
|
const calendarAssert = {
|
|
11
11
|
rendersTotalEvents(vc, expected) {
|
|
12
12
|
const model = heartwood_view_controllers_1.renderUtil.render(vc);
|
|
13
|
-
|
|
13
|
+
test_utils_1.assert.isLength(model.events, expected);
|
|
14
14
|
},
|
|
15
15
|
hasEvent(vc, lookup) {
|
|
16
16
|
const { events } = heartwood_view_controllers_1.renderUtil.render(vc);
|
|
@@ -22,19 +22,19 @@ const calendarAssert = {
|
|
|
22
22
|
}
|
|
23
23
|
actual.sort(sort);
|
|
24
24
|
expected.sort(sort);
|
|
25
|
-
|
|
25
|
+
test_utils_1.assert.isEqualDeep(actual, expected);
|
|
26
26
|
},
|
|
27
27
|
includesInEvent(events, lookup) {
|
|
28
28
|
const match = events.find((e) => {
|
|
29
29
|
try {
|
|
30
|
-
|
|
30
|
+
test_utils_1.assert.doesInclude(e, lookup);
|
|
31
31
|
return e;
|
|
32
32
|
// eslint-disable-next-line no-empty
|
|
33
33
|
}
|
|
34
34
|
catch (_a) { }
|
|
35
35
|
return null;
|
|
36
36
|
});
|
|
37
|
-
|
|
37
|
+
test_utils_1.assert.isTruthy(match, `I could not find an event that matched:\n\n${test_utils_1.assertUtil.stringify(lookup)}`);
|
|
38
38
|
return match;
|
|
39
39
|
},
|
|
40
40
|
eventIsDuration(event, expectedDuration) {
|
|
@@ -42,7 +42,7 @@ const calendarAssert = {
|
|
|
42
42
|
minutes += timeBlock.durationMinutes;
|
|
43
43
|
return minutes;
|
|
44
44
|
}, 0);
|
|
45
|
-
|
|
45
|
+
test_utils_1.assert.isEqual(duration, expectedDuration);
|
|
46
46
|
},
|
|
47
47
|
eventsFallOnDows(events, expectedDows) {
|
|
48
48
|
const remaining = [...expectedDows];
|
|
@@ -50,25 +50,25 @@ const calendarAssert = {
|
|
|
50
50
|
const dow = calendar_utils_1.dateUtil.getDayOfWeek(event.startDateTimeMs);
|
|
51
51
|
const idx = remaining.indexOf(dow);
|
|
52
52
|
if (idx === -1) {
|
|
53
|
-
|
|
53
|
+
test_utils_1.assert.fail(`Checking days of week and got ${dow} but it wasn't in the array of expected dows.`);
|
|
54
54
|
}
|
|
55
55
|
remaining.splice(idx, 1);
|
|
56
56
|
}
|
|
57
57
|
if (remaining.length > 0) {
|
|
58
|
-
|
|
58
|
+
test_utils_1.assert.fail(`Didn't find the following days of week in events:\n\n${test_utils_1.assertUtil.stringify(remaining)}`);
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
eventEquals(actual, expected) {
|
|
62
62
|
var _a, _b, _c;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
test_utils_1.assert.isTruthy(actual, 'Event is missing');
|
|
64
|
+
test_utils_1.assert.isTruthy(expected, 'Event is missing');
|
|
65
|
+
test_utils_1.assert.isEqual(actual.startDateTimeMs, expected.startDateTimeMs, 'startDateTimeMs does not match');
|
|
66
|
+
test_utils_1.assert.isEqual((_a = actual.isBusy) !== null && _a !== void 0 ? _a : false, (_b = expected.isBusy) !== null && _b !== void 0 ? _b : false, `isBusy does not match, needs to be '${(_c = expected.isBusy) !== null && _c !== void 0 ? _c : false}'`);
|
|
67
67
|
const cleanedActual = (0, just_clone_1.default)(actual);
|
|
68
68
|
const cleanedExpected = (0, just_clone_1.default)(expected);
|
|
69
69
|
cleanEvent(cleanedActual);
|
|
70
70
|
cleanEvent(cleanedExpected);
|
|
71
|
-
|
|
71
|
+
test_utils_1.assert.isEqualDeep(cleanedActual, cleanedExpected, 'Your event did not equal what I expected!');
|
|
72
72
|
},
|
|
73
73
|
};
|
|
74
74
|
function cleanEvent(obj, propsToIgnore = [
|
|
@@ -7,8 +7,8 @@ const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-control
|
|
|
7
7
|
const schema_1 = require("@sprucelabs/schema");
|
|
8
8
|
const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
|
|
9
9
|
const spruce_test_fixtures_1 = require("@sprucelabs/spruce-test-fixtures");
|
|
10
|
-
const test_1 = require("@sprucelabs/test");
|
|
11
10
|
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
11
|
+
const test_utils_2 = require("@sprucelabs/test-utils");
|
|
12
12
|
const AbstractCalendarEventToolBeltState_1 = __importDefault(require("../../../toolBelt/states/AbstractCalendarEventToolBeltState"));
|
|
13
13
|
const Calendar_vc_1 = __importDefault(require("../../../viewControllers/Calendar.vc"));
|
|
14
14
|
const EventControlsCard_vc_1 = __importDefault(require("../../../viewControllers/EventControlsCard.vc"));
|
|
@@ -67,9 +67,9 @@ const calendarSkillAssert = {
|
|
|
67
67
|
},
|
|
68
68
|
});
|
|
69
69
|
const organization = organizations.pop();
|
|
70
|
-
|
|
70
|
+
test_utils_1.assert.isTruthy(organization, `You gotta @seed('organizations', 1) before you can assert a calendar is created on install.`);
|
|
71
71
|
const skill = spruce_skill_utils_1.AuthService.Auth(process.cwd()).getCurrentSkill();
|
|
72
|
-
|
|
72
|
+
test_utils_1.assert.isTruthy(skill, `Make sure you registered your skill before you can do anything else. Try 'spruce register'.`);
|
|
73
73
|
const responses = await client.emit('did-install::v2020_12_25', {
|
|
74
74
|
target: {
|
|
75
75
|
organizationId: organization.id,
|
|
@@ -80,7 +80,7 @@ const calendarSkillAssert = {
|
|
|
80
80
|
throw (_b = (_a = responses.responses[0].errors) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : `did-instal error`;
|
|
81
81
|
}
|
|
82
82
|
if (responses.totalResponses === 0) {
|
|
83
|
-
|
|
83
|
+
test_utils_1.assert.fail(`did-install listener missing! To get this test passing your skill will need to be listening to did-install, try 'spruce create.listener' and look under Mercury. You may also need to boot your skill with 'await this.bootSkill()'`);
|
|
84
84
|
}
|
|
85
85
|
let cal;
|
|
86
86
|
try {
|
|
@@ -93,7 +93,7 @@ const calendarSkillAssert = {
|
|
|
93
93
|
cal = calendar;
|
|
94
94
|
}
|
|
95
95
|
catch (err) {
|
|
96
|
-
|
|
96
|
+
test_utils_1.assert.fail(`It looks like you still need to create a calendar, maybe the following code will help:
|
|
97
97
|
const events = event.skill.getFeatureByCode('event') as EventFeature
|
|
98
98
|
const client = await events.connectToApi()
|
|
99
99
|
|
|
@@ -112,7 +112,7 @@ await client.emitAndFlattenResponses(
|
|
|
112
112
|
)\n\nOh, and here's the original error: ${(_d = (_c = err.stack) !== null && _c !== void 0 ? _c : err.message) !== null && _d !== void 0 ? _d : err}`);
|
|
113
113
|
}
|
|
114
114
|
if (typeSlugs) {
|
|
115
|
-
|
|
115
|
+
test_utils_1.assert.isEqualDeep(cal.eventTypes, typeSlugs, `Your calendar does not have types set to: [${typeSlugs.join(', ')}]`);
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
async createsCalendarsWithMultipleInstalls(calendarSlug, client) {
|
|
@@ -121,7 +121,7 @@ await client.emitAndFlattenResponses(
|
|
|
121
121
|
await this.createsCalendarOnInstall(calendarSlug, client);
|
|
122
122
|
}
|
|
123
123
|
catch (err) {
|
|
124
|
-
|
|
124
|
+
test_utils_1.assert.fail(`You tried to create the same calendar twice! It's time for the next step (don't forget to extract):
|
|
125
125
|
|
|
126
126
|
try {
|
|
127
127
|
await client.emitAndFlattenResponses('calendar.get-calendar::v2021_05_19', {
|
|
@@ -150,7 +150,7 @@ try {
|
|
|
150
150
|
async createsEventTypesOnBoot(types, client, boot) {
|
|
151
151
|
assertRanBeforeEach(this);
|
|
152
152
|
await (boot === null || boot === void 0 ? void 0 : boot());
|
|
153
|
-
|
|
153
|
+
test_utils_1.assert.isTruthy(
|
|
154
154
|
//@ts-ignore
|
|
155
155
|
client.auth.skill, `You gotta be logged in as a skill! Try 'const { client } = await this.skills.loginAsCurrentSkill()'`);
|
|
156
156
|
const typeSlugs = types.map((t) => (typeof t === 'string' ? t : t.typeSlug));
|
|
@@ -169,7 +169,7 @@ try {
|
|
|
169
169
|
shouldShowOnlyMine: true,
|
|
170
170
|
},
|
|
171
171
|
});
|
|
172
|
-
|
|
172
|
+
test_utils_1.assert.isAbove(calendarEventTypes.length, 0, `No event types were created. Make sure you are listening to the 'did-boot' event and booted. Use 'spruce create.listener' and look under Skill (or await this.bootSkill()). Then, drop in something like this:\n\n
|
|
173
173
|
await client.emitAndFlattenResponses('calendar.create-calendar-event-type::v2021_05_19', {
|
|
174
174
|
payload: {
|
|
175
175
|
name: '${typeSlugs[0]}',
|
|
@@ -182,7 +182,7 @@ await client.emitAndFlattenResponses('calendar.create-calendar-event-type::v2021
|
|
|
182
182
|
viewControllerId: cet.viewControllerId,
|
|
183
183
|
}))
|
|
184
184
|
.sort(sort);
|
|
185
|
-
|
|
185
|
+
test_utils_1.assert.isEqualDeep(normalizedActual, normalizedExpected, 'The event types I was found were not created as expected.');
|
|
186
186
|
},
|
|
187
187
|
async createsEventTypesWithMultipleBoots(types, client, boot) {
|
|
188
188
|
await this.createsEventTypesOnBoot(types, client, boot);
|
|
@@ -204,20 +204,20 @@ await client.emitAndFlattenResponses('calendar.create-calendar-event-type::v2021
|
|
|
204
204
|
});
|
|
205
205
|
calendarVc.setDefaultControllerForEvents(event.id);
|
|
206
206
|
const vc = calendarVc.getEventVc(event.id);
|
|
207
|
-
|
|
207
|
+
test_utils_1.assert.isFunction(vc.getToolBeltState, `Bad event vc. You need to make sure your event vc extends and implements what it needs to! Try:
|
|
208
208
|
|
|
209
209
|
class MyEventViewController
|
|
210
210
|
extends AbstractCalendarEventViewController
|
|
211
211
|
implements EventWithToolBeltState`);
|
|
212
212
|
const state = vc.getToolBeltState();
|
|
213
|
-
|
|
213
|
+
test_utils_1.assert.isTrue(state instanceof ToolBeltClass, `Your event vc did not return the state I expected. Make sure getToolBeltState() is returning an instance of ${ToolBeltClass.name}.`);
|
|
214
214
|
},
|
|
215
215
|
async stateFetchesAndRendersRemoteTools(options) {
|
|
216
216
|
assertRanBeforeEach(this);
|
|
217
217
|
const { views, state } = (0, schema_1.assertOptions)(options, ['state', 'views']);
|
|
218
|
-
const event = Object.assign(Object.assign({}, heartwood_view_controllers_1.calendarSeeder.generateEventValues()), { eventTypeSlug: (0,
|
|
218
|
+
const event = Object.assign(Object.assign({}, heartwood_view_controllers_1.calendarSeeder.generateEventValues()), { eventTypeSlug: (0, test_utils_2.generateId)() });
|
|
219
219
|
const org = await views.getScope().getCurrentOrganization();
|
|
220
|
-
|
|
220
|
+
test_utils_1.assert.isTruthy(org, `You gotta @seed('organizations', 1) to test fetching and rendering remote tools.`);
|
|
221
221
|
let passedTargetAndPayload;
|
|
222
222
|
const VC_NAME_1 = 'calendars.test-one';
|
|
223
223
|
const VC_NAME_2 = 'calendars.test-two';
|
|
@@ -236,19 +236,19 @@ class MyEventViewController
|
|
|
236
236
|
const { toolBeltVc, stateMachine } = await CalendarToolBeltStateMachineTestFactory_1.default.StateMachine(views);
|
|
237
237
|
await stateMachine.updateContext({ event });
|
|
238
238
|
await stateMachine.transitionTo(state);
|
|
239
|
-
|
|
239
|
+
test_utils_1.assert.isTruthy(passedTargetAndPayload, `You aren't emitting 'calendar.register-event-tools::v2021_05_19'.
|
|
240
240
|
|
|
241
241
|
Try adding the following to your state's load():
|
|
242
242
|
|
|
243
243
|
const tools = new CalendarToolRegistrar(stateMachine)
|
|
244
244
|
await tools.fetchAndAddCards()
|
|
245
245
|
`);
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
test_utils_1.assert.isEqualDeep(passedTargetAndPayload.target, { organizationId: org.id, calendarEventId: event.id }, `Your target is not what is expected! Make sure you are sending organizationId and calendarEventId`);
|
|
247
|
+
test_utils_1.assert.isEqualDeep(passedTargetAndPayload.payload, {
|
|
248
248
|
eventTypeSlug: event.eventTypeSlug,
|
|
249
249
|
}, `Your payload does not what is expected! Make sure you pass through eventTypeSlug.`);
|
|
250
250
|
const tools = toolBeltVc.getTools();
|
|
251
|
-
|
|
251
|
+
test_utils_1.assert.isAbove(tools.length, 0, `It looks like you didn't add any tools to the tool belt! try sm.getToolBeltVc().addTool()`);
|
|
252
252
|
const results = [];
|
|
253
253
|
for (let c = 0; c < vcIds.length; c++) {
|
|
254
254
|
const id = vcIds[c];
|
|
@@ -257,22 +257,22 @@ await tools.fetchAndAddCards()
|
|
|
257
257
|
toolId: id,
|
|
258
258
|
Class: Classes[c],
|
|
259
259
|
});
|
|
260
|
-
|
|
260
|
+
test_utils_1.assert.isTruthy(tool, `You didn't add the tools I expected! Make sure you are using the CalendarToolRegistrar!`);
|
|
261
261
|
}
|
|
262
262
|
return results;
|
|
263
263
|
},
|
|
264
264
|
async toolBeltStateProperlyInheritsAbstractToolBeltState(stateMachine, state) {
|
|
265
265
|
assertRanBeforeEach(this);
|
|
266
266
|
(0, schema_1.assertOptions)({ stateMachine, state }, ['stateMachine', 'state']);
|
|
267
|
-
|
|
267
|
+
test_utils_1.assert.isTrue(state instanceof AbstractCalendarEventToolBeltState_1.default, `Your state does not extend 'AbstractCalendarEventToolBeltState'. Make sure you do that next!`);
|
|
268
268
|
await stateMachine.transitionTo(state);
|
|
269
|
-
|
|
269
|
+
test_utils_1.assert.isTruthy(state.getIsLoaded(), `You need to call super.load(stateMachine) in your state!`);
|
|
270
270
|
await stateMachine.on('did-update-context', () => { });
|
|
271
271
|
const originalListenCount = stateMachine.listenCount('did-update-context');
|
|
272
272
|
await state.destroy();
|
|
273
273
|
const count = stateMachine.listenCount('did-update-context');
|
|
274
|
-
|
|
275
|
-
|
|
274
|
+
test_utils_1.assert.isAbove(count, originalListenCount - 2, `You 'sm.off(...)'ed too many listeners, make sure you pass the callback to remove to 'this.sm.off(...)'. It's the second param.`);
|
|
275
|
+
test_utils_1.assert.isEqual(count, originalListenCount - 1, `Don't forget to remove all listeners to the stateMachine. Either implement 'destroy()' and call 'this.sm.off(...)' or try 'await super.destroy()' in your state.`);
|
|
276
276
|
},
|
|
277
277
|
async toolBeltStateAddsTool(options) {
|
|
278
278
|
const { state, toolId, views, Class } = (0, schema_1.assertOptions)(options, [
|
|
@@ -282,10 +282,10 @@ await tools.fetchAndAddCards()
|
|
|
282
282
|
]);
|
|
283
283
|
const { toolBeltVc, stateMachine } = await CalendarToolBeltStateMachineTestFactory_1.default.StateMachine(views);
|
|
284
284
|
await stateMachine.transitionTo(state);
|
|
285
|
-
|
|
285
|
+
test_utils_1.assert.isTruthy(toolBeltVc.getTool(toolId), `I could not find the tool with the id '${toolId}', try 'this.addTool(...)' from inside your state!`);
|
|
286
286
|
//@ts-ignore
|
|
287
287
|
const match = state.vcs.find((o) => o.toolId === toolId);
|
|
288
|
-
|
|
288
|
+
test_utils_1.assert.isTruthy(match, `It looks like you added your tool directly to the toolBeltVc instead of to your parent class. 'this.addTool(...)'`);
|
|
289
289
|
if (Class) {
|
|
290
290
|
heartwood_view_controllers_1.vcAssert.assertToolInstanceOf(toolBeltVc, toolId, Class);
|
|
291
291
|
}
|
|
@@ -302,7 +302,7 @@ async function fakeEventTypeEvents(eventTypes) {
|
|
|
302
302
|
};
|
|
303
303
|
});
|
|
304
304
|
await spruce_test_fixtures_1.eventFaker.on('calendar.create-calendar-event-type::v2021_05_19', ({ payload, source }) => {
|
|
305
|
-
const type = Object.assign({ id: (0,
|
|
305
|
+
const type = Object.assign({ id: (0, test_utils_2.generateId)(), source: source, viewControllerId: null }, payload);
|
|
306
306
|
eventTypes.push(type);
|
|
307
307
|
return {
|
|
308
308
|
calendarEventType: type,
|
|
@@ -316,7 +316,7 @@ async function fakeEventTypeEvents(eventTypes) {
|
|
|
316
316
|
calendarEventType: match,
|
|
317
317
|
};
|
|
318
318
|
}
|
|
319
|
-
const type = Object.assign({ id: (0,
|
|
319
|
+
const type = Object.assign({ id: (0, test_utils_2.generateId)(), source: source, viewControllerId: null, slug: target.slug }, payload);
|
|
320
320
|
eventTypes.push(type);
|
|
321
321
|
return {
|
|
322
322
|
calendarEventType: type,
|
|
@@ -326,8 +326,8 @@ async function fakeEventTypeEvents(eventTypes) {
|
|
|
326
326
|
async function fakeCalendarEvents(calendars) {
|
|
327
327
|
await spruce_test_fixtures_1.eventFaker.on('calendar.create-calendar::v2021_05_19', ({ payload, source, target }) => {
|
|
328
328
|
const matches = calendars.filter((c) => c.slug === payload.slug);
|
|
329
|
-
|
|
330
|
-
const calendar = Object.assign({ id: (0,
|
|
329
|
+
test_utils_1.assert.isLength(matches, 0, `You already created a calendar the slug: ${payload.slug}!`);
|
|
330
|
+
const calendar = Object.assign({ id: (0, test_utils_2.generateId)(), source: source, target }, payload);
|
|
331
331
|
calendars.push(calendar);
|
|
332
332
|
return { calendar };
|
|
333
333
|
});
|
|
@@ -340,7 +340,7 @@ async function fakeCalendarEvents(calendars) {
|
|
|
340
340
|
});
|
|
341
341
|
}
|
|
342
342
|
function assertRanBeforeEach(me) {
|
|
343
|
-
|
|
343
|
+
test_utils_1.assert.isTrue(
|
|
344
344
|
//@ts-ignore
|
|
345
345
|
me._didBeforeEach, `You gotta add 'await calendarSkillAssert.beforeEach(...)' to the beforeEach() of your test.`);
|
|
346
346
|
}
|
|
@@ -2044,41 +2044,41 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
|
2044
2044
|
}
|
|
2045
2045
|
}
|
|
2046
2046
|
namespace SpruceSchemas.Calendar.v2021_05_19 {
|
|
2047
|
-
interface
|
|
2048
|
-
'
|
|
2049
|
-
'
|
|
2047
|
+
interface GetCalendarEventEmitTarget {
|
|
2048
|
+
'locationId': string;
|
|
2049
|
+
'calendarEventId': string;
|
|
2050
2050
|
}
|
|
2051
|
-
interface
|
|
2052
|
-
id: '
|
|
2051
|
+
interface GetCalendarEventEmitTargetSchema extends SpruceSchema.Schema {
|
|
2052
|
+
id: 'getCalendarEventEmitTarget';
|
|
2053
2053
|
version: 'v2021_05_19';
|
|
2054
2054
|
namespace: 'Calendar';
|
|
2055
2055
|
name: '';
|
|
2056
2056
|
fields: {
|
|
2057
2057
|
/** . */
|
|
2058
|
-
'
|
|
2058
|
+
'locationId': {
|
|
2059
2059
|
type: 'id';
|
|
2060
2060
|
isRequired: true;
|
|
2061
2061
|
options: undefined;
|
|
2062
2062
|
};
|
|
2063
2063
|
/** . */
|
|
2064
|
-
'
|
|
2064
|
+
'calendarEventId': {
|
|
2065
2065
|
type: 'id';
|
|
2066
2066
|
isRequired: true;
|
|
2067
2067
|
options: undefined;
|
|
2068
2068
|
};
|
|
2069
2069
|
};
|
|
2070
2070
|
}
|
|
2071
|
-
interface
|
|
2071
|
+
interface GetCalendarEventEmitTargetEntity extends SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.GetCalendarEventEmitTargetSchema> {
|
|
2072
2072
|
}
|
|
2073
2073
|
}
|
|
2074
2074
|
namespace SpruceSchemas.Calendar.v2021_05_19 {
|
|
2075
|
-
interface
|
|
2075
|
+
interface GetCalendarEventEmitTargetAndPayload {
|
|
2076
2076
|
/** Source. */
|
|
2077
2077
|
'source'?: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSource | undefined | null;
|
|
2078
|
-
'target': SpruceSchemas.Calendar.v2021_05_19.
|
|
2078
|
+
'target': SpruceSchemas.Calendar.v2021_05_19.GetCalendarEventEmitTarget;
|
|
2079
2079
|
}
|
|
2080
|
-
interface
|
|
2081
|
-
id: '
|
|
2080
|
+
interface GetCalendarEventEmitTargetAndPayloadSchema extends SpruceSchema.Schema {
|
|
2081
|
+
id: 'getCalendarEventEmitTargetAndPayload';
|
|
2082
2082
|
version: 'v2021_05_19';
|
|
2083
2083
|
namespace: 'Calendar';
|
|
2084
2084
|
name: '';
|
|
@@ -2096,73 +2096,73 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
|
2096
2096
|
type: 'schema';
|
|
2097
2097
|
isRequired: true;
|
|
2098
2098
|
options: {
|
|
2099
|
-
schema: SpruceSchemas.Calendar.v2021_05_19.
|
|
2099
|
+
schema: SpruceSchemas.Calendar.v2021_05_19.GetCalendarEventEmitTargetSchema;
|
|
2100
2100
|
};
|
|
2101
2101
|
};
|
|
2102
2102
|
};
|
|
2103
2103
|
}
|
|
2104
|
-
interface
|
|
2104
|
+
interface GetCalendarEventEmitTargetAndPayloadEntity extends SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.GetCalendarEventEmitTargetAndPayloadSchema> {
|
|
2105
2105
|
}
|
|
2106
2106
|
}
|
|
2107
2107
|
namespace SpruceSchemas.Calendar.v2021_05_19 {
|
|
2108
|
-
interface
|
|
2109
|
-
'
|
|
2108
|
+
interface GetCalendarEventResponsePayload {
|
|
2109
|
+
'calendarEvent': SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent;
|
|
2110
2110
|
}
|
|
2111
|
-
interface
|
|
2112
|
-
id: '
|
|
2111
|
+
interface GetCalendarEventResponsePayloadSchema extends SpruceSchema.Schema {
|
|
2112
|
+
id: 'getCalendarEventResponsePayload';
|
|
2113
2113
|
version: 'v2021_05_19';
|
|
2114
2114
|
namespace: 'Calendar';
|
|
2115
2115
|
name: '';
|
|
2116
2116
|
fields: {
|
|
2117
2117
|
/** . */
|
|
2118
|
-
'
|
|
2118
|
+
'calendarEvent': {
|
|
2119
2119
|
type: 'schema';
|
|
2120
2120
|
isRequired: true;
|
|
2121
2121
|
options: {
|
|
2122
|
-
schema: SpruceSchemas.
|
|
2122
|
+
schema: SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema;
|
|
2123
2123
|
};
|
|
2124
2124
|
};
|
|
2125
2125
|
};
|
|
2126
2126
|
}
|
|
2127
|
-
interface
|
|
2127
|
+
interface GetCalendarEventResponsePayloadEntity extends SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.GetCalendarEventResponsePayloadSchema> {
|
|
2128
2128
|
}
|
|
2129
2129
|
}
|
|
2130
2130
|
namespace SpruceSchemas.Calendar.v2021_05_19 {
|
|
2131
|
-
interface
|
|
2132
|
-
'
|
|
2133
|
-
'
|
|
2131
|
+
interface GetCalendarEmitTarget {
|
|
2132
|
+
'organizationId': string;
|
|
2133
|
+
'slug': string;
|
|
2134
2134
|
}
|
|
2135
|
-
interface
|
|
2136
|
-
id: '
|
|
2135
|
+
interface GetCalendarEmitTargetSchema extends SpruceSchema.Schema {
|
|
2136
|
+
id: 'getCalendarEmitTarget';
|
|
2137
2137
|
version: 'v2021_05_19';
|
|
2138
2138
|
namespace: 'Calendar';
|
|
2139
2139
|
name: '';
|
|
2140
2140
|
fields: {
|
|
2141
2141
|
/** . */
|
|
2142
|
-
'
|
|
2142
|
+
'organizationId': {
|
|
2143
2143
|
type: 'id';
|
|
2144
2144
|
isRequired: true;
|
|
2145
2145
|
options: undefined;
|
|
2146
2146
|
};
|
|
2147
2147
|
/** . */
|
|
2148
|
-
'
|
|
2148
|
+
'slug': {
|
|
2149
2149
|
type: 'id';
|
|
2150
2150
|
isRequired: true;
|
|
2151
2151
|
options: undefined;
|
|
2152
2152
|
};
|
|
2153
2153
|
};
|
|
2154
2154
|
}
|
|
2155
|
-
interface
|
|
2155
|
+
interface GetCalendarEmitTargetEntity extends SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.GetCalendarEmitTargetSchema> {
|
|
2156
2156
|
}
|
|
2157
2157
|
}
|
|
2158
2158
|
namespace SpruceSchemas.Calendar.v2021_05_19 {
|
|
2159
|
-
interface
|
|
2159
|
+
interface GetCalendarEmitTargetAndPayload {
|
|
2160
2160
|
/** Source. */
|
|
2161
2161
|
'source'?: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSource | undefined | null;
|
|
2162
|
-
'target': SpruceSchemas.Calendar.v2021_05_19.
|
|
2162
|
+
'target': SpruceSchemas.Calendar.v2021_05_19.GetCalendarEmitTarget;
|
|
2163
2163
|
}
|
|
2164
|
-
interface
|
|
2165
|
-
id: '
|
|
2164
|
+
interface GetCalendarEmitTargetAndPayloadSchema extends SpruceSchema.Schema {
|
|
2165
|
+
id: 'getCalendarEmitTargetAndPayload';
|
|
2166
2166
|
version: 'v2021_05_19';
|
|
2167
2167
|
namespace: 'Calendar';
|
|
2168
2168
|
name: '';
|
|
@@ -2180,35 +2180,35 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
|
2180
2180
|
type: 'schema';
|
|
2181
2181
|
isRequired: true;
|
|
2182
2182
|
options: {
|
|
2183
|
-
schema: SpruceSchemas.Calendar.v2021_05_19.
|
|
2183
|
+
schema: SpruceSchemas.Calendar.v2021_05_19.GetCalendarEmitTargetSchema;
|
|
2184
2184
|
};
|
|
2185
2185
|
};
|
|
2186
2186
|
};
|
|
2187
2187
|
}
|
|
2188
|
-
interface
|
|
2188
|
+
interface GetCalendarEmitTargetAndPayloadEntity extends SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.GetCalendarEmitTargetAndPayloadSchema> {
|
|
2189
2189
|
}
|
|
2190
2190
|
}
|
|
2191
2191
|
namespace SpruceSchemas.Calendar.v2021_05_19 {
|
|
2192
|
-
interface
|
|
2193
|
-
'
|
|
2192
|
+
interface GetCalendarResponsePayload {
|
|
2193
|
+
'calendar': SpruceSchemas.Calendar.v2021_05_19.Calendar;
|
|
2194
2194
|
}
|
|
2195
|
-
interface
|
|
2196
|
-
id: '
|
|
2195
|
+
interface GetCalendarResponsePayloadSchema extends SpruceSchema.Schema {
|
|
2196
|
+
id: 'getCalendarResponsePayload';
|
|
2197
2197
|
version: 'v2021_05_19';
|
|
2198
2198
|
namespace: 'Calendar';
|
|
2199
2199
|
name: '';
|
|
2200
2200
|
fields: {
|
|
2201
2201
|
/** . */
|
|
2202
|
-
'
|
|
2202
|
+
'calendar': {
|
|
2203
2203
|
type: 'schema';
|
|
2204
2204
|
isRequired: true;
|
|
2205
2205
|
options: {
|
|
2206
|
-
schema: SpruceSchemas.
|
|
2206
|
+
schema: SpruceSchemas.Calendar.v2021_05_19.CalendarSchema;
|
|
2207
2207
|
};
|
|
2208
2208
|
};
|
|
2209
2209
|
};
|
|
2210
2210
|
}
|
|
2211
|
-
interface
|
|
2211
|
+
interface GetCalendarResponsePayloadEntity extends SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.GetCalendarResponsePayloadSchema> {
|
|
2212
2212
|
}
|
|
2213
2213
|
}
|
|
2214
2214
|
namespace SpruceSchemas.Calendar.v2021_05_19 {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dateUtil } from '@sprucelabs/calendar-utils';
|
|
2
2
|
import { renderUtil, } from '@sprucelabs/heartwood-view-controllers';
|
|
3
|
-
import { assert, assertUtil } from '@sprucelabs/test';
|
|
3
|
+
import { assert, assertUtil } from '@sprucelabs/test-utils';
|
|
4
4
|
import clone from 'just-clone';
|
|
5
5
|
const calendarAssert = {
|
|
6
6
|
rendersTotalEvents(vc, expected) {
|
|
@@ -11,7 +11,7 @@ import { calendarSeeder, CardViewControllerImpl, vcAssert, } from '@sprucelabs/h
|
|
|
11
11
|
import { assertOptions } from '@sprucelabs/schema';
|
|
12
12
|
import { AuthService } from '@sprucelabs/spruce-skill-utils';
|
|
13
13
|
import { eventFaker } from '@sprucelabs/spruce-test-fixtures';
|
|
14
|
-
import { assert } from '@sprucelabs/test';
|
|
14
|
+
import { assert } from '@sprucelabs/test-utils';
|
|
15
15
|
import { generateId } from '@sprucelabs/test-utils';
|
|
16
16
|
import AbstractCalendarEventToolBeltState from '../../../toolBelt/states/AbstractCalendarEventToolBeltState.js';
|
|
17
17
|
import CalendarViewController from '../../../viewControllers/Calendar.vc.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assertOptions, SchemaError } from '@sprucelabs/schema';
|
|
2
|
-
import { assert } from '@sprucelabs/test';
|
|
2
|
+
import { assert } from '@sprucelabs/test-utils';
|
|
3
3
|
import clone from 'just-clone';
|
|
4
4
|
export default class CalendarToolTestFactory {
|
|
5
5
|
static Tool(stateMachine, vcId, options) {
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const schema_1 = require("@sprucelabs/schema");
|
|
7
|
-
const
|
|
7
|
+
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
8
8
|
const just_clone_1 = __importDefault(require("just-clone"));
|
|
9
9
|
class CalendarToolTestFactory {
|
|
10
10
|
static Tool(stateMachine, vcId, options) {
|
|
@@ -27,7 +27,7 @@ class CalendarToolTestFactory {
|
|
|
27
27
|
void stateMachine.on('did-update-context', () => {
|
|
28
28
|
return vc.handleUpdateContext(stateMachine.getContext());
|
|
29
29
|
});
|
|
30
|
-
|
|
30
|
+
test_utils_1.assert.isFunction(vc.handleUpdateContext, `You need to make sure your card view controller implements the CalendarTool interface!`);
|
|
31
31
|
return vc;
|
|
32
32
|
}
|
|
33
33
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sprucelabs/spruce-calendar-components",
|
|
3
3
|
"description": "Calendar components for working with calendars and Sprucebot.",
|
|
4
|
-
"version": "22.8.
|
|
4
|
+
"version": "22.8.14",
|
|
5
5
|
"skill": {
|
|
6
6
|
"namespace": "calendar"
|
|
7
7
|
},
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
"@sprucelabs/mercury-client": "latest",
|
|
180
180
|
"@sprucelabs/schema": "latest",
|
|
181
181
|
"@sprucelabs/spruce-skill-utils": "latest",
|
|
182
|
-
"@sprucelabs/test": "latest",
|
|
182
|
+
"@sprucelabs/test-utils": "latest",
|
|
183
183
|
"@sprucelabs/data-stores": "latest",
|
|
184
184
|
"@sprucelabs/calendar-utils": "latest",
|
|
185
185
|
"@sprucelabs/heartwood-view-controllers": "latest",
|