@livepreso/api 6.42.1 → 6.43.0

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.
Files changed (117) hide show
  1. package/.rush/temp/build-cache-tar.log +7 -0
  2. package/.rush/temp/package-deps_build.json +151 -133
  3. package/.rush/temp/shrinkwrap-deps.json +189 -192
  4. package/CHANGELOG.json +12 -0
  5. package/CHANGELOG.md +8 -1
  6. package/api.build.log +10 -24
  7. package/babel.config.js +1 -1
  8. package/cjs/api.js +1 -1
  9. package/cjs/api.js.map +1 -1
  10. package/cjs/auth.js +2 -1
  11. package/cjs/auth.js.map +1 -1
  12. package/cjs/caching.js +3 -3
  13. package/cjs/collections/appointment-adjunct-tags.js +28 -0
  14. package/cjs/collections/appointment-adjunct-tags.js.map +1 -0
  15. package/cjs/collections/appointment-deckversion-tags.js +28 -0
  16. package/cjs/collections/appointment-deckversion-tags.js.map +1 -0
  17. package/cjs/collections/appointment-section-tags.js +28 -0
  18. package/cjs/collections/appointment-section-tags.js.map +1 -0
  19. package/cjs/collections/appointment-slide-tags.js +28 -0
  20. package/cjs/collections/appointment-slide-tags.js.map +1 -0
  21. package/cjs/collections/appointment-tags.js +208 -0
  22. package/cjs/collections/appointment-tags.js.map +1 -0
  23. package/cjs/collections/tags.js +28 -0
  24. package/cjs/collections/tags.js.map +1 -0
  25. package/cjs/collections.js +78 -0
  26. package/cjs/collections.js.map +1 -1
  27. package/cjs/models/appointment-adjunct-tags.js +52 -0
  28. package/cjs/models/appointment-adjunct-tags.js.map +1 -0
  29. package/cjs/models/appointment-deckversion-tags.js +52 -0
  30. package/cjs/models/appointment-deckversion-tags.js.map +1 -0
  31. package/cjs/models/appointment-section-tags.js +52 -0
  32. package/cjs/models/appointment-section-tags.js.map +1 -0
  33. package/cjs/models/appointment-slide-tags.js +52 -0
  34. package/cjs/models/appointment-slide-tags.js.map +1 -0
  35. package/cjs/models/appointment-tags.js +16 -15
  36. package/cjs/models/appointment-tags.js.map +1 -1
  37. package/cjs/models/appointment.js +8 -2
  38. package/cjs/models/appointment.js.map +1 -1
  39. package/cjs/models/deck-tags.js +61 -0
  40. package/cjs/models/deck-tags.js.map +1 -0
  41. package/cjs/models/deck-version.js +2 -0
  42. package/cjs/models/deck-version.js.map +1 -1
  43. package/cjs/models/deck.js +4 -1
  44. package/cjs/models/deck.js.map +1 -1
  45. package/cjs/models/manifest-json.js +47 -12
  46. package/cjs/models/manifest-json.js.map +1 -1
  47. package/cjs/models/preset.js +21 -1
  48. package/cjs/models/preset.js.map +1 -1
  49. package/cjs/models/tag.js +54 -0
  50. package/cjs/models/tag.js.map +1 -0
  51. package/cjs/models/user.js +2 -1
  52. package/cjs/models/user.js.map +1 -1
  53. package/cjs/models.js +78 -0
  54. package/cjs/models.js.map +1 -1
  55. package/cjs/presentation/appointment-presentation.js +5 -2
  56. package/cjs/presentation/appointment-presentation.js.map +1 -1
  57. package/cjs/presentation/base-presentation-model.js +56 -7
  58. package/cjs/presentation/base-presentation-model.js.map +1 -1
  59. package/cjs/presentation/base-presentation-model.spec.js +40 -6
  60. package/cjs/presentation/base-presentation-model.spec.js.map +1 -1
  61. package/cjs/presentation/presentation-deck.js +2 -1
  62. package/cjs/presentation/presentation-deck.js.map +1 -1
  63. package/cjs/presentation/presentation-section.js +21 -8
  64. package/cjs/presentation/presentation-section.js.map +1 -1
  65. package/cjs/presentation/presentation-section.spec.js +418 -0
  66. package/cjs/presentation/presentation-section.spec.js.map +1 -0
  67. package/cjs/presentation/presentation-slide.js +12 -4
  68. package/cjs/presentation/presentation-slide.js.map +1 -1
  69. package/cjs/presentation/presentation-slide.spec.js +294 -0
  70. package/cjs/presentation/presentation-slide.spec.js.map +1 -0
  71. package/cjs/presentation/presentation-subslide.js +5 -2
  72. package/cjs/presentation/presentation-subslide.js.map +1 -1
  73. package/cjs/presentation/presentation-subslide.spec.js +58 -12
  74. package/cjs/presentation/presentation-subslide.spec.js.map +1 -1
  75. package/cjs/presentation/presentation.js +13 -3
  76. package/cjs/presentation/presentation.js.map +1 -1
  77. package/cjs/state-register.js +11 -1
  78. package/cjs/state-register.js.map +1 -1
  79. package/cjs/sync.js +1 -1
  80. package/cjs/utils.js +5 -5
  81. package/config/rush-project.json +53 -0
  82. package/package.json +64 -66
  83. package/src/api.js +1 -1
  84. package/src/collections/appointment-adjunct-tags.js +18 -0
  85. package/src/collections/appointment-deckversion-tags.js +21 -0
  86. package/src/collections/appointment-section-tags.js +18 -0
  87. package/src/collections/appointment-slide-tags.js +18 -0
  88. package/src/collections/appointment-tags.js +136 -0
  89. package/src/collections/tags.js +18 -0
  90. package/src/collections.js +6 -0
  91. package/src/models/appointment-adjunct-tags.js +41 -0
  92. package/src/models/appointment-deckversion-tags.js +41 -0
  93. package/src/models/appointment-section-tags.js +41 -0
  94. package/src/models/appointment-slide-tags.js +41 -0
  95. package/src/models/appointment-tags.js +16 -14
  96. package/src/models/appointment.js +6 -1
  97. package/src/models/deck-tags.js +52 -0
  98. package/src/models/deck-version.js +2 -0
  99. package/src/models/deck.js +2 -0
  100. package/src/models/manifest-json.js +46 -7
  101. package/src/models/preset.js +19 -0
  102. package/src/models/tag.js +42 -0
  103. package/src/models/user.js +2 -0
  104. package/src/models.js +6 -0
  105. package/src/presentation/appointment-presentation.js +4 -1
  106. package/src/presentation/base-presentation-model.js +52 -7
  107. package/src/presentation/base-presentation-model.spec.js +44 -6
  108. package/src/presentation/presentation-deck.js +1 -0
  109. package/src/presentation/presentation-section.js +20 -9
  110. package/src/presentation/presentation-section.spec.js +363 -0
  111. package/src/presentation/presentation-slide.js +16 -3
  112. package/src/presentation/presentation-slide.spec.js +250 -0
  113. package/src/presentation/presentation-subslide.js +7 -2
  114. package/src/presentation/presentation-subslide.spec.js +32 -3
  115. package/src/presentation/presentation.js +15 -3
  116. package/src/state-register.js +7 -0
  117. package/api.build.error.log +0 -16
package/src/models.js CHANGED
@@ -17,6 +17,7 @@ export * from "./models/cms-val";
17
17
  export * from "./models/contact";
18
18
  export * from "./models/customer";
19
19
  export * from "./models/deck";
20
+ export * from "./models/deck-tags";
20
21
  export * from "./models/deck-version";
21
22
  export * from "./models/dispatch";
22
23
  export * from "./models/dispatch-preview";
@@ -46,6 +47,7 @@ export * from "./models/slide-selection";
46
47
  export * from "./models/snapshot";
47
48
  export * from "./models/sub-slide";
48
49
  export * from "./models/support-ticket.js";
50
+ export * from "./models/tag.js";
49
51
  export * from "./models/tenancy.js";
50
52
  export * from "./models/timing-log.js";
51
53
  export * from "./models/upload.js";
@@ -55,6 +57,10 @@ export * from "./models/appointment-editor.js";
55
57
  export * from "./models/appointment-duplicate.js";
56
58
  export * from "./models/appointment-stats.js";
57
59
  export * from "./models/appointment-viewing.js";
60
+ export * from "./models/appointment-deckversion-tags.js";
61
+ export * from "./models/appointment-section-tags.js";
62
+ export * from "./models/appointment-slide-tags.js";
63
+ export * from "./models/appointment-adjunct-tags.js";
58
64
  export * from "./models/team.js";
59
65
  export * from "./models/template.js";
60
66
  export * from "./models/auto-adjunct-key-check.js";
@@ -59,6 +59,9 @@ export const AppointmentPresentation = BaseModel.extend(
59
59
  const createFromAppointment = function (appointment, options) {
60
60
  const appointmentPresentation = new AppointmentPresentation();
61
61
 
62
+ // Note that we're not passing through tags if appointment.tags is empty.
63
+ // This is because tags currently aren't available in the telepresenter
64
+ // bundle and we want to fall back on the model tags for now.
62
65
  appointmentPresentation.presentation.decks.add(
63
66
  appointment.deckversion_set.map((model, index) => {
64
67
  return PresentationDeck.createFromDeckVersion(model, {
@@ -68,7 +71,7 @@ const createFromAppointment = function (appointment, options) {
68
71
  sectionSelections: appointment.appointmentssection_set,
69
72
  slideSelections: appointment.appointmentsslide_set,
70
73
  index,
71
- tags: appointment.tags.items,
74
+ appointmentTags: appointment.tags.length ? appointment.tags : null,
72
75
  ...options,
73
76
  });
74
77
  })
@@ -64,15 +64,60 @@ BasePresentationModel.getVisibilityAndSequence = function (
64
64
  return config;
65
65
  };
66
66
 
67
+ const getAppointmentTags = function (model, tags) {
68
+ const url = model.adjunct?.url() || model.url();
69
+ const tagItem = tags.find((tag) => tag.content_url === url);
70
+
71
+ if (tagItem) {
72
+ return tagItem.tags || [];
73
+ }
74
+
75
+ // Subslide tags currently aren't included in the
76
+ // appointmentTags data.
77
+ return model.tags || [];
78
+ };
79
+
80
+ const getDeckTags = function (model, tags) {
81
+ // All non-adjunct sections, slides and subslides have namespaced_key
82
+ if (model.namespaced_key) {
83
+ return tags[model.namespaced_key] || model.tags || [];
84
+ } else if (model.adjunct || model.isAutoAdjunct) {
85
+ // Autoadjunct keys are unique and move around so we search for them
86
+ // and ignore the rest of the namespaced key
87
+ const keys = Object.keys(tags).filter((key) => {
88
+ if (key.includes("/")) {
89
+ const splitKey = key.split("/");
90
+
91
+ return splitKey[splitKey.length - 1] === model.key;
92
+ }
93
+ return key === model.key;
94
+ });
95
+ return keys.length ? tags[keys[0]] : [];
96
+ } else if (model.deck) {
97
+ // The deck's namespaced key is always "" - this is because the
98
+ // namespaced key format is section-key/slide-key, but the
99
+ // deck sits above sections.
100
+ return tags[""] || model.tags || [];
101
+ }
102
+
103
+ return model.tags || [];
104
+ };
105
+
106
+ // Retrieve the tags for the model.
107
+ // If appointmentTags is passed through in the options, we call the
108
+ // getAppointmentTags function above to retrieve the appointment tags
109
+ // for the model.
110
+ // if there are no appointmentTags but deckTags are passed
111
+ // through then we call the getDeckTags function.
112
+ // In the future we will always use one of these two methods and
113
+ // references to model.tags should be removed.
67
114
  BasePresentationModel.getTags = function (model, options = {}) {
68
- if (options.tags) {
69
- if (model.namespaced_key) {
70
- return options.tags[model.namespaced_key] || [];
71
- } else if (model.deck) {
72
- return options.tags[""];
73
- }
115
+ if (options.appointmentTags) {
116
+ return getAppointmentTags(model, options.appointmentTags);
117
+ }
74
118
 
75
- return [];
119
+ if (options.deckTags) {
120
+ return getDeckTags(model, options.deckTags);
76
121
  }
77
122
 
78
123
  return model.tags || [];
@@ -137,14 +137,14 @@ describe("#getVisibilityAndSequence", () => {
137
137
  });
138
138
 
139
139
  describe("#getTags", () => {
140
- it("should return empty array when no options or model.tags", () => {
140
+ it("should return empty array when no options or model tags", () => {
141
141
  const tags = BasePresentationModel.getTags({});
142
142
 
143
143
  expect(typeof tags).toEqual("object");
144
144
  expect(tags.length).toEqual(0);
145
145
  });
146
146
 
147
- it("should return model.tags when no tags passed in options", () => {
147
+ it("should return tags when no tags passed in options", () => {
148
148
  const model = {
149
149
  tags: ["model-tag-1", "model-tag-2"],
150
150
  };
@@ -153,14 +153,14 @@ describe("#getTags", () => {
153
153
  expect(tags).toEqual(model.tags);
154
154
  });
155
155
 
156
- it("should return options.tags for slide when tags passed in options", () => {
156
+ it("should return tags for slide when tags passed in options", () => {
157
157
  const model = {
158
158
  namespaced_key: "slide-key",
159
159
  tags: ["model-tag-1", "model-tag-2"],
160
160
  };
161
161
 
162
162
  const options = {
163
- tags: {
163
+ deckTags: {
164
164
  "": ["deck-tags"],
165
165
  "slide-key": ["slide-tags"],
166
166
  },
@@ -171,14 +171,14 @@ describe("#getTags", () => {
171
171
  expect(tags).toEqual(["slide-tags"]);
172
172
  });
173
173
 
174
- it("should return options.tags[''] for welcome slide ", () => {
174
+ it("should return tags for welcome slide when tags passed in options", () => {
175
175
  const model = {
176
176
  deck: {},
177
177
  tags: ["model-tag-1", "model-tag-2"],
178
178
  };
179
179
 
180
180
  const options = {
181
- tags: {
181
+ deckTags: {
182
182
  "": ["deck-tags"],
183
183
  "slide-key": ["slide-tags"],
184
184
  },
@@ -188,4 +188,42 @@ describe("#getTags", () => {
188
188
 
189
189
  expect(tags).toEqual(["deck-tags"]);
190
190
  });
191
+
192
+ it("should return tags for an adjunct section when tags passed in options", () => {
193
+ const model = {
194
+ adjunct: true,
195
+ key: "adjunctsection-key",
196
+ tags: ["old-tag-1", "old-tag-2"],
197
+ };
198
+
199
+ const options = {
200
+ deckTags: {
201
+ "": ["deck-tags"],
202
+ "adjunctsection-key": ["adjunctsection-tags"],
203
+ },
204
+ };
205
+
206
+ const tags = BasePresentationModel.getTags(model, options);
207
+
208
+ expect(tags).toEqual(["adjunctsection-tags"]);
209
+ });
210
+
211
+ it("should return tags for an adjunct slide when tags passed in options", () => {
212
+ const model = {
213
+ adjunct: true,
214
+ key: "adjunctslide-key",
215
+ tags: ["old-tag-1", "old-tag-2"],
216
+ };
217
+
218
+ const options = {
219
+ deckTags: {
220
+ "": ["deck-tags"],
221
+ "section-key/adjunctslide-key": ["adjunctslide-tags"],
222
+ },
223
+ };
224
+
225
+ const tags = BasePresentationModel.getTags(model, options);
226
+
227
+ expect(tags).toEqual(["adjunctslide-tags"]);
228
+ });
191
229
  });
@@ -367,6 +367,7 @@ PresentationDeck.createFromManifestJSON = function (manifestJSON) {
367
367
  deckID: 1,
368
368
  title: "Local",
369
369
  version: 1,
370
+ tags: manifestJSON.tags[""] || [],
370
371
  });
371
372
 
372
373
  const usesImpostorSections = _.some(
@@ -206,7 +206,7 @@ PresentationSection.createFromSection = function (sectionModel, options = {}) {
206
206
  impostor: false,
207
207
  title: sectionModel.title,
208
208
  deckversion: sectionModel.deckversion.id,
209
- editable: sectionModel.tags.indexOf("editable") > -1,
209
+ editable: tags.indexOf("editable") > -1,
210
210
  tags,
211
211
  index: config.sequence,
212
212
  sequence: config.sequence,
@@ -228,7 +228,7 @@ PresentationSection.createFromSection = function (sectionModel, options = {}) {
228
228
  PresentationSection.createFromAdjunctSection = function (
229
229
  adjunctSectionModel,
230
230
  deckVersionModel,
231
- options
231
+ options = {}
232
232
  ) {
233
233
  _.defaults(options, {
234
234
  rootAssetPath: null,
@@ -251,6 +251,7 @@ PresentationSection.createFromAdjunctSection = function (
251
251
  key = adjunctSectionModel.key;
252
252
  } else if (keyID) {
253
253
  key = `adjunct-${keyID}`;
254
+ adjunctSectionModel.key = key;
254
255
  }
255
256
 
256
257
  const config = PresentationSection.getVisibilityAndSequence(
@@ -258,6 +259,8 @@ PresentationSection.createFromAdjunctSection = function (
258
259
  options
259
260
  );
260
261
 
262
+ const tags = PresentationSection.getTags(adjunctSectionModel, options);
263
+
261
264
  const section = new PresentationSection({
262
265
  id: options.getUniqueAdjunctID(),
263
266
  adjunct: adjunctSectionModel.adjunct
@@ -272,10 +275,8 @@ PresentationSection.createFromAdjunctSection = function (
272
275
  custom: !adjunctSectionModel.created_by_autoadjunct,
273
276
  createdByAutoAdjunct: adjunctSectionModel.created_by_autoadjunct,
274
277
  createdByTemplate: Boolean(adjunctSectionModel.template),
275
- impostor:
276
- adjunctSectionModel.tags &&
277
- adjunctSectionModel.tags.indexOf("section-header") > -1,
278
- tags: adjunctSectionModel.tags,
278
+ impostor: tags.indexOf("section-header") > -1,
279
+ tags: tags,
279
280
  temporary: adjunctSectionModel.created_by_autoadjunct,
280
281
  title: adjunctSectionModel.title,
281
282
  deckversion: deckVersionModel.id,
@@ -318,7 +319,7 @@ PresentationSection.createFromAdjunctSection = function (
318
319
  PresentationSection.createFromImpostorSection = function (
319
320
  slideModel,
320
321
  DeckVersionModel,
321
- options
322
+ options = {}
322
323
  ) {
323
324
  _.defaults(options, {
324
325
  rootAssetPath: null,
@@ -363,7 +364,7 @@ PresentationSection.createFromImpostorSection = function (
363
364
  impostor: true,
364
365
  title: slideModel.title,
365
366
  deckversion: slideModel.section.deckversion.id,
366
- editable: slideModel.tags.indexOf("editable") > -1,
367
+ editable: tags.indexOf("editable") > -1,
367
368
  tags,
368
369
  index: config.sequence,
369
370
  sequence: config.sequence,
@@ -439,7 +440,7 @@ PresentationSection.createFromManifestImpostor = function (section, index) {
439
440
  return presentationSection;
440
441
  };
441
442
 
442
- PresentationSection.createFromAutoAdjunct = function (model, opts) {
443
+ PresentationSection.createFromAutoAdjunct = function (model, opts = {}) {
443
444
  const requiredKeys = ["index", "deckversionID"];
444
445
  for (const key of requiredKeys) {
445
446
  if (typeof opts[key] === "undefined") {
@@ -456,6 +457,15 @@ PresentationSection.createFromAutoAdjunct = function (model, opts) {
456
457
  impostor: false,
457
458
  });
458
459
 
460
+ const tags = PresentationSection.getTags(
461
+ {
462
+ isAutoAdjunct: true,
463
+ key: model.key,
464
+ tags: model.tags,
465
+ },
466
+ options
467
+ );
468
+
459
469
  const autoAdjunct = new AutoAdjunctModel(model);
460
470
 
461
471
  const autoAdjunctSection = new PresentationSection({
@@ -477,6 +487,7 @@ PresentationSection.createFromAutoAdjunct = function (model, opts) {
477
487
  allowConvert: options.allowConvert,
478
488
  deckversion: options.deckversionID,
479
489
  impostor: options.impostor,
490
+ tags,
480
491
  });
481
492
 
482
493
  if (autoAdjunct.template) {
@@ -0,0 +1,363 @@
1
+ import { AdjunctSectionModel } from "../models/adjunct-section";
2
+ import { AutoAdjunctModel } from "../models/auto-adjunct";
3
+ import { PresentationSection } from "./presentation-section";
4
+ import { SectionModel } from "../models/section";
5
+ import { SlideModel } from "../models/slide";
6
+
7
+ describe("#createFromSection", () => {
8
+ const getSectionJSON = () => {
9
+ return {
10
+ adjunctslide_limit: 0,
11
+ created_date: "2021-07-19T01:17:59.522119Z",
12
+ deckversion: "https://staging-test.salespreso.com/api/deckversions/408/",
13
+ description: "",
14
+ enabled: true,
15
+ id: 1728,
16
+ image_128:
17
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/section/123/456.jpg",
18
+ image_256:
19
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/section/123/456.jpg",
20
+ image_512:
21
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/section/123/456.jpg",
22
+ index_asset: {
23
+ created_date: "2021-07-19T01:17:58.068483Z",
24
+ data: "sections/agenda/index.html",
25
+ hash_algorithm: "sha-256",
26
+ hash_digest:
27
+ "f84e1e0b43f4b25168e4a8997b11a2c1c2848376b128b2d72ba5bd4f44c17dcc",
28
+ id: 148115,
29
+ modified_date: "2021-07-19T01:17:58.068507Z",
30
+ orig_path: "sections/agenda",
31
+ pack: "https://staging-test.salespreso.com/api/packs/409/",
32
+ url: "https://staging-test-cdn.salespreso.com/media/pack/409/assets/sections/agenda/index.html",
33
+ },
34
+ key: "agenda",
35
+ modified_date: "2021-07-19T01:20:43.815965Z",
36
+ namespaced_key: "agenda",
37
+ sequence: 0,
38
+ slide_set: [],
39
+ tags: [],
40
+ title: "Agenda",
41
+ url: "https://staging-test.salespreso.com/api/sections/1728/",
42
+ };
43
+ };
44
+
45
+ it("should create a presentation section", async () => {
46
+ const section = new SectionModel(getSectionJSON());
47
+ const presentationSection = PresentationSection.createFromSection(section);
48
+
49
+ const expected = {
50
+ adjunctID: null,
51
+ adjunctSlideLimit: 0,
52
+ autoAdjunctID: null,
53
+ createdByAutoAdjunct: false,
54
+ createdByTemplate: false,
55
+ css: "https://staging-test-cdn.salespreso.com/media/pack/409/assets/sections/agenda/slide.css",
56
+ custom: false,
57
+ deckversion: 408,
58
+ editable: false,
59
+ html: "https://staging-test-cdn.salespreso.com/media/pack/409/assets/sections/agenda/index.html",
60
+ id: 1728,
61
+ impostor: false,
62
+ index: 0,
63
+ isWelcome: false,
64
+ key: "agenda",
65
+ selectionID: null,
66
+ sequence: 0,
67
+ slides: [],
68
+ tags: [],
69
+ templateID: null,
70
+ thumbnail:
71
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/section/123/456.jpg",
72
+ title: "Agenda",
73
+ url: "/api/sections/1728/",
74
+ visible: true,
75
+ };
76
+
77
+ expect(presentationSection.toJSON()).toEqual(expected);
78
+ });
79
+
80
+ it("should use deckTags when available", async () => {
81
+ const section = new SectionModel(getSectionJSON());
82
+ const options = {
83
+ deckTags: { agenda: ["section-tag"] },
84
+ };
85
+
86
+ const presentationSection = PresentationSection.createFromSection(
87
+ section,
88
+ options
89
+ );
90
+
91
+ expect(presentationSection.tags).toEqual(["section-tag"]);
92
+ });
93
+ });
94
+
95
+ describe("#createFromAdjunctSection", () => {
96
+ const getAdjunctSectionJSON = () => {
97
+ return {
98
+ adjunct: "https://staging-test.salespreso.com/api/adjuncts/7470/",
99
+ appointment: "https://staging-test.salespreso.com/api/appointments/2422/",
100
+ created_by_autoadjunct: true,
101
+ created_date: "2021-09-20T01:57:55.125224Z",
102
+ creator_autoadjunct:
103
+ "https://staging-test.salespreso.com/api/autoadjuncts/545/",
104
+ deckversion: "https://staging-test.salespreso.com/api/deckversions/408/",
105
+ deleted: false,
106
+ enabled: true,
107
+ html_content:
108
+ '<img src="https://staging-test-cdn.salespreso.com/media/autoadjunct/123.png">',
109
+ id: 1737,
110
+ image_128:
111
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/autoadjunct/123/456.jpg",
112
+ image_256:
113
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/autoadjunct/123/456.jpg",
114
+ image_512:
115
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/autoadjunct/123/456.jpg",
116
+ image_1024:
117
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/autoadjunct/123/456.png",
118
+ image_original:
119
+ "https://staging-test-cdn.salespreso.com/media/autoadjunct/123.png",
120
+ modified_date: "2021-09-20T01:57:55.125229Z",
121
+ sequence: 1,
122
+ tags: [],
123
+ template: null,
124
+ title: "Five",
125
+ url: "https://staging-test.salespreso.com/api/adjunctsections/1737/",
126
+ };
127
+ };
128
+
129
+ it("should create a presentation section", async () => {
130
+ const adjunctSection = new AdjunctSectionModel(getAdjunctSectionJSON());
131
+ const presentationSection = PresentationSection.createFromAdjunctSection(
132
+ adjunctSection,
133
+ { id: 1 }
134
+ );
135
+
136
+ const expected = {
137
+ adjunct: {
138
+ url: "https://staging-test.salespreso.com/api/adjuncts/7470/",
139
+ },
140
+ adjunctID: 1737,
141
+ adjunctSlideLimit: 0,
142
+ autoAdjunctID: 545,
143
+ createdByAutoAdjunct: true,
144
+ createdByTemplate: false,
145
+ custom: false,
146
+ deckversion: 1,
147
+ editable: false,
148
+ id: 1,
149
+ image:
150
+ "https://staging-test-cdn.salespreso.com/media/autoadjunct/123.png",
151
+ impostor: false,
152
+ index: 1,
153
+ isWelcome: false,
154
+ key: "adjunct-1737",
155
+ sequence: 1,
156
+ slides: [],
157
+ tags: [],
158
+ templateID: null,
159
+ temporary: true,
160
+ thumbnail:
161
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/autoadjunct/123/456.jpg",
162
+ title: "Five",
163
+ url: "/api/adjunctsections/1737/",
164
+ visible: true,
165
+ };
166
+
167
+ expect(presentationSection.toJSON()).toEqual(expected);
168
+ });
169
+
170
+ it("should use deckTags when available", async () => {
171
+ const adjunctSection = new AdjunctSectionModel(getAdjunctSectionJSON());
172
+ const options = {
173
+ deckTags: { "adjunct-1737": ["adjunctsection-tag"] },
174
+ };
175
+ const presentationSection = PresentationSection.createFromAdjunctSection(
176
+ adjunctSection,
177
+ { id: 1 },
178
+ options
179
+ );
180
+
181
+ expect(presentationSection.tags).toEqual(["adjunctsection-tag"]);
182
+ });
183
+ });
184
+
185
+ describe("#createFromImpostorSection", () => {
186
+ const getImpostorSectionJSON = () => {
187
+ return {
188
+ created_date: "2021-09-20T02:59:06.968285Z",
189
+ description: "",
190
+ enabled: true,
191
+ id: 23898,
192
+ image_128:
193
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/slide/123/456.jpg",
194
+ image_256:
195
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/slide/123/456.jpg",
196
+ image_512:
197
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/slide/123/456.jpg",
198
+ index_asset: {
199
+ created_date: "2021-09-20T02:59:02.361498Z",
200
+ data: "sections/test-deck/slides/agenda/index.html",
201
+ hash_algorithm: "sha-256",
202
+ hash_digest:
203
+ "b77283717f1a99bce5b8aea67e007f11aad06473f5fe26412c15e707f8758343",
204
+ id: 153400,
205
+ modified_date: "2021-09-20T02:59:02.361528Z",
206
+ orig_path: "sections/test-deck/slides/agenda",
207
+ pack: "https://staging-test.salespreso.com/api/packs/427/",
208
+ url: "https://staging-test-cdn.salespreso.com/media/pack/427/assets/sections/test-deck/slides/agenda/index.html",
209
+ },
210
+ key: "agenda",
211
+ modified_date: "2021-09-20T03:05:27.811485Z",
212
+ namespaced_key: "test-deck/agenda",
213
+ section: {
214
+ id: 2,
215
+ deckversion: {
216
+ id: 3,
217
+ },
218
+ },
219
+ sequence: 0,
220
+ subslide_set: [],
221
+ tags: ["section-header"],
222
+ title: "Agenda",
223
+ url: "https://staging-test.salespreso.com/api/slides/23898/",
224
+ };
225
+ };
226
+
227
+ it("should create a presentation section", async () => {
228
+ const impostorSection = new SlideModel(getImpostorSectionJSON());
229
+ const presentationSection =
230
+ PresentationSection.createFromImpostorSection(impostorSection);
231
+
232
+ const expected = {
233
+ adjunctID: null,
234
+ adjunctSlideLimit: 0,
235
+ autoAdjunctID: null,
236
+ createdByAutoAdjunct: false,
237
+ createdByTemplate: false,
238
+ css: "https://staging-test-cdn.salespreso.com/media/pack/427/assets/sections/test-deck/slides/agenda/slide.css",
239
+ custom: false,
240
+ deckversion: 3,
241
+ editable: false,
242
+ html: "https://staging-test-cdn.salespreso.com/media/pack/427/assets/sections/test-deck/slides/agenda/index.html",
243
+ id: 23898,
244
+ impostor: true,
245
+ index: 0,
246
+ isWelcome: false,
247
+ key: "agenda",
248
+ selectionID: null,
249
+ sequence: 0,
250
+ slides: [],
251
+ tags: ["section-header"],
252
+ templateID: null,
253
+ thumbnail:
254
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/slide/123/456.jpg",
255
+ title: "Agenda",
256
+ url: "/api/slides/23898/",
257
+ visible: true,
258
+ };
259
+
260
+ expect(presentationSection.toJSON()).toEqual(expected);
261
+ });
262
+
263
+ it("should use deckTags when available", async () => {
264
+ const impostorSection = new SlideModel(getImpostorSectionJSON());
265
+ const options = {
266
+ deckTags: { "test-deck/agenda": ["impostorsection-tag"] },
267
+ };
268
+ const presentationSection = PresentationSection.createFromImpostorSection(
269
+ impostorSection,
270
+ null,
271
+ options
272
+ );
273
+
274
+ expect(presentationSection.tags).toEqual(["impostorsection-tag"]);
275
+ });
276
+ });
277
+
278
+ describe("#createFromAutoAdjunct", () => {
279
+ const getAutoAdjunctJSON = () => {
280
+ return {
281
+ after_key: "autoadjunct-i-am-template-section",
282
+ created_date: "2021-09-16T04:25:54.459641Z",
283
+ deck: "https://staging-test.salespreso.com/api/decks/6/",
284
+ enabled: true,
285
+ id: 545,
286
+ image_128:
287
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/autoadjunct/123/456.jpg",
288
+ image_256:
289
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/autoadjunct/123/456.jpg",
290
+ image_512:
291
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/autoadjunct/123/456.jpg",
292
+ image_1024:
293
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/autoadjunct/123/456.png",
294
+ image_original:
295
+ "https://staging-test-cdn.salespreso.com/media/autoadjunct/123.png",
296
+ key: "autoadjunct-five",
297
+ modified_date: "2021-09-20T01:57:55.090828Z",
298
+ name: "Five",
299
+ parent_key: "",
300
+ sequence: 1,
301
+ tags: [],
302
+ team: null,
303
+ template: null,
304
+ url: "https://staging-test.salespreso.com/api/autoadjuncts/545/",
305
+ };
306
+ };
307
+
308
+ it("should create a presentation section", async () => {
309
+ const autoAdjunct = new AutoAdjunctModel(getAutoAdjunctJSON());
310
+ const options = {
311
+ index: 3,
312
+ deckversionID: 12,
313
+ };
314
+ const presentationSection = PresentationSection.createFromAutoAdjunct(
315
+ autoAdjunct,
316
+ options
317
+ );
318
+
319
+ const expected = {
320
+ adjunctID: 545,
321
+ adjunctSlideLimit: 0,
322
+ autoAdjunctID: 545,
323
+ createdByAutoAdjunct: false,
324
+ createdByTemplate: false,
325
+ css: "",
326
+ deckversion: 12,
327
+ html: "",
328
+ id: 545,
329
+ image:
330
+ "https://staging-test-cdn.salespreso.com/media/autoadjunct/123.png",
331
+ impostor: false,
332
+ index: 3,
333
+ isWelcome: false,
334
+ key: "autoadjunct-five",
335
+ sequence: 3,
336
+ slides: [],
337
+ tags: [],
338
+ templateID: null,
339
+ temporary: true,
340
+ thumbnail:
341
+ "https://staging-test-cdn.salespreso.com/media/CACHE/images/autoadjunct/123/456.jpg",
342
+ title: "Five",
343
+ url: "/api/adjunctsections/545/",
344
+ visible: true,
345
+ };
346
+ expect(presentationSection.toJSON()).toEqual(expected);
347
+ });
348
+
349
+ it("should use deckTags when available", async () => {
350
+ const autoAdjunct = new AutoAdjunctModel(getAutoAdjunctJSON());
351
+ const options = {
352
+ index: 3,
353
+ deckversionID: 12,
354
+ deckTags: { "autoadjunct-five": ["autoadjunct-tag"] },
355
+ };
356
+ const presentationSection = PresentationSection.createFromAutoAdjunct(
357
+ autoAdjunct,
358
+ options
359
+ );
360
+
361
+ expect(presentationSection.tags).toEqual(["autoadjunct-tag"]);
362
+ });
363
+ });