@konfuzio/document-validation-ui 0.1.19-dev.2 → 0.1.19

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 (143) hide show
  1. package/.eslintrc.js +10 -10
  2. package/.prettierrc.json +1 -1
  3. package/LICENSE +21 -21
  4. package/README.md +24 -24
  5. package/cypress.config.js +13 -13
  6. package/dist/js/app.js +1 -1
  7. package/dist/js/app.js.map +1 -1
  8. package/dist/js/chunk-vendors.js +1 -1
  9. package/dist/js/chunk-vendors.js.map +1 -1
  10. package/jest.config.js +4 -4
  11. package/package.json +66 -66
  12. package/src/api.js +82 -82
  13. package/src/assets/images/AcceptedCheckMark.vue +8 -8
  14. package/src/assets/images/AcceptedUser.vue +8 -8
  15. package/src/assets/images/ActionIcon.vue +60 -60
  16. package/src/assets/images/ArrowDownKey.vue +11 -11
  17. package/src/assets/images/ArrowUpKey.vue +11 -11
  18. package/src/assets/images/CategoryIconImg.vue +13 -13
  19. package/src/assets/images/CheckMark.vue +8 -8
  20. package/src/assets/images/DraggableIcon.vue +14 -14
  21. package/src/assets/images/EditDocIcon.vue +12 -12
  22. package/src/assets/images/EmptyStateImg.vue +129 -129
  23. package/src/assets/images/ErrorIcon.vue +28 -28
  24. package/src/assets/images/EyeIcon.vue +11 -11
  25. package/src/assets/images/FileNameNotSavedImage.vue +26 -26
  26. package/src/assets/images/FileNameSavedImage.vue +14 -14
  27. package/src/assets/images/FitZoomIcon.vue +16 -16
  28. package/src/assets/images/GridIcon.vue +16 -16
  29. package/src/assets/images/KeyboardIcon.vue +16 -16
  30. package/src/assets/images/MagicWandIcon.vue +16 -16
  31. package/src/assets/images/MinusIcon.vue +13 -13
  32. package/src/assets/images/NotFoundIcon.vue +16 -16
  33. package/src/assets/images/NotOptimizedIllustration.vue +651 -651
  34. package/src/assets/images/PlusIcon.vue +13 -13
  35. package/src/assets/images/QuestionMark.vue +12 -12
  36. package/src/assets/images/ServerImage.vue +73 -73
  37. package/src/assets/images/SettingsIcon.vue +14 -14
  38. package/src/assets/images/SplitLines.vue +18 -18
  39. package/src/assets/images/SplitZigZag.vue +49 -49
  40. package/src/assets/images/StarIcon.vue +16 -16
  41. package/src/assets/images/StatusImg.vue +14 -14
  42. package/src/assets/images/TranslateArrows.vue +33 -33
  43. package/src/assets/scss/ann_set_table_options.scss +26 -26
  44. package/src/assets/scss/annotation_details.scss +141 -141
  45. package/src/assets/scss/choose_label_set_modal.scss +65 -65
  46. package/src/assets/scss/document_action_bar.scss +37 -37
  47. package/src/assets/scss/document_annotations.scss +558 -558
  48. package/src/assets/scss/document_category.scss +85 -85
  49. package/src/assets/scss/document_dashboard.scss +52 -52
  50. package/src/assets/scss/document_edit.scss +410 -410
  51. package/src/assets/scss/document_error.scss +81 -81
  52. package/src/assets/scss/document_name.scss +60 -60
  53. package/src/assets/scss/document_page.scss +12 -12
  54. package/src/assets/scss/document_thumbnails.scss +41 -41
  55. package/src/assets/scss/document_toolbar.scss +111 -111
  56. package/src/assets/scss/document_top_bar.scss +171 -171
  57. package/src/assets/scss/document_viewport_modal.scss +25 -25
  58. package/src/assets/scss/documents_list.scss +141 -141
  59. package/src/assets/scss/edit_page_thumbnail.scss +53 -53
  60. package/src/assets/scss/empty_state.scss +34 -34
  61. package/src/assets/scss/extracting_data.scss +35 -35
  62. package/src/assets/scss/imports.scss +1 -1
  63. package/src/assets/scss/multi_ann_table_overlay.scss +38 -38
  64. package/src/assets/scss/multi_ann_table_popup.scss +12 -12
  65. package/src/assets/scss/new_annotation.scss +102 -102
  66. package/src/assets/scss/scrolling_document.scss +19 -19
  67. package/src/assets/scss/theme.scss +801 -801
  68. package/src/assets/scss/variables.scss +66 -66
  69. package/src/components/App.cy.js +7 -7
  70. package/src/components/App.vue +187 -187
  71. package/src/components/DocumentAnnotations/AnnotationActionButtons.vue +152 -152
  72. package/src/components/DocumentAnnotations/AnnotationContent.vue +210 -210
  73. package/src/components/DocumentAnnotations/AnnotationDetails.vue +251 -251
  74. package/src/components/DocumentAnnotations/AnnotationRow.vue +752 -752
  75. package/src/components/DocumentAnnotations/AnnotationSetActionButtons.vue +89 -89
  76. package/src/components/DocumentAnnotations/ChooseLabelSetModal.vue +186 -186
  77. package/src/components/DocumentAnnotations/DocumentAnnotations.cy.js +441 -441
  78. package/src/components/DocumentAnnotations/DocumentAnnotations.vue +534 -534
  79. package/src/components/DocumentAnnotations/DocumentLabel.vue +189 -189
  80. package/src/components/DocumentAnnotations/EmptyAnnotation.vue +193 -193
  81. package/src/components/DocumentAnnotations/EmptyState.vue +21 -21
  82. package/src/components/DocumentAnnotations/ExtractingData.vue +41 -41
  83. package/src/components/DocumentAnnotations/LoadingAnnotations.vue +43 -43
  84. package/src/components/DocumentAnnotations/LoadingLabels.vue +43 -43
  85. package/src/components/DocumentAnnotations/MultiAnnotationTableOverlay.vue +338 -338
  86. package/src/components/DocumentAnnotations/index.js +8 -8
  87. package/src/components/DocumentCategory.vue +281 -281
  88. package/src/components/DocumentDashboard.vue +170 -170
  89. package/src/components/DocumentEdit/DocumentEdit.cy.js +541 -541
  90. package/src/components/DocumentEdit/DocumentEdit.vue +503 -503
  91. package/src/components/DocumentEdit/EditConfirmationModal.vue +55 -55
  92. package/src/components/DocumentEdit/EditPageThumbnail.vue +114 -114
  93. package/src/components/DocumentEdit/EditPages.vue +161 -161
  94. package/src/components/DocumentEdit/EditSidebar.vue +154 -154
  95. package/src/components/DocumentEdit/RenameAndCategorize.vue +184 -184
  96. package/src/components/DocumentEdit/SidebarButtons.vue +53 -53
  97. package/src/components/DocumentEdit/SplitInfoBar.vue +21 -21
  98. package/src/components/DocumentEdit/index.js +4 -4
  99. package/src/components/DocumentModals/DocumentErrorModal.vue +58 -58
  100. package/src/components/DocumentModals/NotOptimizedViewportModal.vue +51 -51
  101. package/src/components/DocumentPage/ActionBar.vue +48 -48
  102. package/src/components/DocumentPage/AnnSetTableOptions.vue +111 -111
  103. package/src/components/DocumentPage/BoxSelection.vue +152 -152
  104. package/src/components/DocumentPage/DocumentPage.cy.js +92 -92
  105. package/src/components/DocumentPage/DocumentPage.vue +568 -568
  106. package/src/components/DocumentPage/DocumentToolbar.cy.js +215 -215
  107. package/src/components/DocumentPage/DocumentToolbar.vue +228 -228
  108. package/src/components/DocumentPage/DummyPage.vue +55 -55
  109. package/src/components/DocumentPage/MultiAnnSelection.vue +371 -371
  110. package/src/components/DocumentPage/NewAnnotation.vue +308 -308
  111. package/src/components/DocumentPage/ScrollingDocument.vue +149 -149
  112. package/src/components/DocumentPage/ScrollingPage.vue +179 -179
  113. package/src/components/DocumentPage/index.js +5 -5
  114. package/src/components/DocumentThumbnails/DocumentThumbnails.cy.js +67 -67
  115. package/src/components/DocumentThumbnails/DocumentThumbnails.vue +132 -132
  116. package/src/components/DocumentThumbnails/LoadingThumbnail.vue +25 -25
  117. package/src/components/DocumentThumbnails/index.js +1 -1
  118. package/src/components/DocumentTopBar/DocumentName.vue +236 -236
  119. package/src/components/DocumentTopBar/DocumentTopBar.cy.js +222 -222
  120. package/src/components/DocumentTopBar/DocumentTopBar.vue +202 -202
  121. package/src/components/DocumentTopBar/DocumentTopBarButtons.vue +183 -183
  122. package/src/components/DocumentTopBar/KeyboardActionsDescription.vue +74 -74
  123. package/src/components/DocumentTopBar/index.js +3 -3
  124. package/src/components/DocumentsList/DocumentsList.vue +121 -121
  125. package/src/components/DocumentsList/index.js +1 -1
  126. package/src/components/ErrorMessage.vue +40 -40
  127. package/src/components/index.js +1 -1
  128. package/src/constants.js +5 -5
  129. package/src/directives/scroll.js +28 -28
  130. package/src/i18n.js +22 -22
  131. package/src/icons.js +45 -45
  132. package/src/locales/de.json +148 -148
  133. package/src/locales/en.json +148 -148
  134. package/src/main.js +26 -26
  135. package/src/store/category.js +191 -191
  136. package/src/store/display.js +311 -311
  137. package/src/store/document.js +1438 -1438
  138. package/src/store/edit.js +316 -316
  139. package/src/store/index.js +21 -21
  140. package/src/store/project.js +143 -143
  141. package/src/store/selection.js +210 -210
  142. package/src/utils/utils.js +54 -54
  143. package/vue.config.js +25 -25
@@ -1,442 +1,442 @@
1
- import DocumentAnnotations from "./DocumentAnnotations.vue";
2
-
3
- describe("Document Annotations", () => {
4
- beforeEach(() => {
5
- cy.fetchDocument();
6
- cy.dispatchAction("document", "setPublicView", false);
7
- cy.dispatchAction("edit", "disableEditMode");
8
- cy.mount(DocumentAnnotations);
9
- });
10
-
11
- it("shows loading when there are no annotation sets loaded yet or when loading the data", () => {
12
- cy.dispatchAction("document", "setAnnotationSets", null);
13
- cy.mount(DocumentAnnotations);
14
- cy.get("#document-annotations")
15
- .find(".document-annotations-loading")
16
- .its("length")
17
- .should("equal", 1);
18
-
19
-
20
- cy.dispatchAction("document", "startLoading");
21
- cy.get("#document-annotations")
22
- .find(".document-annotations-loading")
23
- .its("length")
24
- .should("equal", 1);
25
- });
26
-
27
- it("shows 3 rows of loading annotation sets", () => {
28
- cy.dispatchAction("document", "startLoading");
29
- cy.get("#document-annotations")
30
- .find(".loading-annotation-set")
31
- .its("length")
32
- .should("equal", 3);
33
- });
34
-
35
- it("shows all annotation sets", () => {
36
- cy.get("#document-annotations")
37
- .find(".annotation-set-group")
38
- .then(($elements) => {
39
- cy.getStore("document")
40
- .then($document => {
41
- expect($document.annotationSets).to.have.lengthOf($elements.length);
42
- });
43
- });
44
- });
45
-
46
- it("shows the empty state if there are no annotation sets", () => {
47
- cy.dispatchAction("document", "setAnnotationSets", []);
48
-
49
- cy.get("#document-annotations")
50
- .find(".empty-annotation-sets")
51
- .find(".empty-container")
52
- .find(".title")
53
- .should('be.visible');
54
- });
55
-
56
- it("shows no annotation set action buttons if the document is read only", () => {
57
- cy.dispatchAction("document", "setPublicView", true);
58
-
59
- cy.get("#document-annotations")
60
- .find(".labelset-action-buttons")
61
- .should("not.be.visible");
62
- });
63
-
64
- it("renders action buttons for the annotation sets and annotations", () => {
65
- cy.get("#document-annotations")
66
- .find(".labelset-action-buttons")
67
- .should("be.visible");
68
-
69
- cy.get("#document-annotations")
70
- .find(".label")
71
- .find(".annotation-row")
72
- .find(".buttons-container")
73
- .should("exist");
74
- });
75
-
76
- it("does not show annotations action buttons by default", () => {
77
- cy.get("#document-annotations")
78
- .find(".label")
79
- .find(".annotation-row")
80
- .find(".buttons-container")
81
- .should("not.be.visible");
82
- });
83
-
84
- it("clicks each annotation and empty annotation and checks that it is in edit mode", () => {
85
- cy.get("#document-annotations")
86
- .find(".label")
87
- .find(".annotation-row")
88
- .find(".annotation-value")
89
- .not(".missing-annotation")
90
- .each($annotation => {
91
- cy.wrap($annotation)
92
- .should("not.have.class", "clicked-ann");
93
- cy.wrap($annotation)
94
- .click();
95
- cy.wrap($annotation)
96
- .should("have.class", "clicked-ann");
97
- cy.wait(1000);
98
- });
99
- });
100
-
101
- it("clicks each annotation and shows action buttons", () => {
102
- cy.getStore("document").then($document => {
103
- if ($document.annotations.length > 0) {
104
- cy.get("#document-annotations")
105
- .find(".label")
106
- .find(".annotation-row")
107
- .find(".annotation")
108
- .each(($row) => {
109
- cy.wrap($row)
110
- .find(".annotation-value")
111
- .click();
112
-
113
- cy.get("#document-annotations")
114
- .find(".label")
115
- .find(".annotation-row")
116
- .find(".action-buttons")
117
- .find(".annotation-save-btn")
118
- .should("be.visible");
119
-
120
-
121
- cy.get("#document-annotations")
122
- .find(".label")
123
- .find(".annotation-row")
124
- .find(".action-buttons")
125
- .find(".annotation-cancel-btn")
126
- .should("be.visible");
127
-
128
- cy.get("#document-annotations")
129
- .find(".label")
130
- .find(".annotation-row")
131
- .find(".action-buttons")
132
- .find(".annotation-cancel-btn")
133
- .click();
134
-
135
- cy.wait(1000);
136
- });
137
- }
138
- });
139
- });
140
-
141
- it("shows accept and decline buttons when hovering annotation", () => {
142
- cy.getStore("document").then($document => {
143
- if ($document.annotations.length > 0) {
144
- cy.get("#document-annotations")
145
- .find(".label")
146
- .find(".annotation-row")
147
- .find(".annotation")
148
- .each(($row) => {
149
- cy.wrap($row)
150
- .trigger("mouseover");
151
-
152
- cy.get("#document-annotations")
153
- .find(".label")
154
- .find(".annotation-row")
155
- .find(".action-buttons")
156
- .find(".decline-button-container")
157
- .should("be.visible");
158
-
159
- cy.get("#document-annotations")
160
- .find(".label")
161
- .find(".annotation-row")
162
- .find(".action-buttons")
163
- .find(".annotation-accept-btn")
164
- .should("be.visible");
165
-
166
- cy.wait(1000);
167
- });
168
- }
169
- });
170
- });
171
-
172
- it("clicks each empty annotation and shows action buttons", () => {
173
- cy.get("#document-annotations")
174
- .find(".label")
175
- .find(".annotation-row")
176
- .find(".empty-annotation")
177
- .find(".annotation-value")
178
- .each(($annotation) => {
179
- if ($annotation.hasClass("missing-annotation")) {
180
- return;
181
- } else {
182
- cy.wrap($annotation)
183
- .click();
184
-
185
- cy.get("#document-annotations")
186
- .find(".label")
187
- .find(".annotation-row")
188
- .find(".action-buttons")
189
- .find(".annotation-cancel-btn")
190
- .should("be.visible");
191
-
192
- cy.get("#document-annotations")
193
- .find(".label")
194
- .find(".annotation-row")
195
- .find(".action-buttons")
196
- .find(".annotation-cancel-btn")
197
- .click();
198
-
199
- cy.wait(1000);
200
- }
201
- });
202
- });
203
-
204
- it("shows mark as missing button when hovering empty annotation", () => {
205
- cy.get("#document-annotations")
206
- .find(".label")
207
- .find(".annotation-row")
208
- .find(".empty-annotation")
209
- .find(".annotation-value")
210
- .not(".missing-annotation")
211
- .each(($annotation) => {
212
- cy.wrap($annotation)
213
- .trigger("mouseover");
214
-
215
- cy.get("#document-annotations")
216
- .find(".label")
217
- .find(".annotation-row")
218
- .find(".action-buttons")
219
- .find(".missing-button-container")
220
- .should("be.visible");
221
-
222
- cy.wait(1000);
223
- });
224
- });
225
-
226
- it("marks empty annotation as missing", () => {
227
- cy.get("#document-annotations")
228
- .find(".label")
229
- .find(".annotation-row")
230
- .find(".empty-annotation")
231
- .find(".annotation-value")
232
- .not(".missing-annotation")
233
- .each(($annotation) => {
234
- cy.wrap($annotation)
235
- .trigger("mouseover");
236
-
237
- cy.get("#document-annotations")
238
- .find(".label")
239
- .find(".annotation-row")
240
- .find(".action-buttons")
241
- .find(".missing-button-container")
242
- .find(".missing-btn")
243
- .click();
244
-
245
- cy.wrap($annotation)
246
- .trigger("mouseleave");
247
-
248
- cy.wait(1000);
249
- });
250
-
251
- cy.get("#document-annotations")
252
- .find(".label")
253
- .find(".annotation-row")
254
- .find(".empty-annotation")
255
- .then($elements => {
256
-
257
- cy.getStore("document")
258
- .then($document => {
259
- expect($document.missingAnnotations)
260
- .to.have.lengthOf($elements.length);
261
- });
262
- });
263
- });
264
-
265
- it("restores empty annotation", () => {
266
- cy.get("#document-annotations")
267
- .find(".label")
268
- .find(".annotation-row")
269
- .find(".empty-annotation")
270
- .find(".missing-annotation")
271
- .each(($annotation) => {
272
- cy.wrap($annotation)
273
- .trigger("mouseover");
274
-
275
- cy.get("#document-annotations")
276
- .find(".label")
277
- .find(".annotation-row")
278
- .find(".action-buttons")
279
- .find(".restore-btn")
280
- .click();
281
-
282
- cy.wrap($annotation)
283
- .trigger("mouseleave");
284
-
285
- cy.wait(1000);
286
- });
287
-
288
- cy.get("#document-annotations")
289
- .find(".label")
290
- .find(".annotation-row")
291
- .find(".empty-annotation")
292
- .should("not.have.class", "missing-annotation");
293
- });
294
-
295
- it("gets successfull response from the API when accepting annotation", () => {
296
- cy.get("#document-annotations")
297
- .find(".label")
298
- .find(".annotation-row")
299
- .find(".annotation")
300
- .first()
301
- .then(($element) => {
302
- const annotationId = $element[0].id;
303
-
304
- cy.intercept('PATCH', `**/annotations/${annotationId}/`).as('updateAnnotation');
305
-
306
- cy.wrap($element)
307
- .trigger("mouseover");
308
-
309
- cy.wait(1000);
310
-
311
- cy.get("#document-annotations")
312
- .find(".label")
313
- .find(".annotation-row")
314
- .find(".action-buttons")
315
- .find(".annotation-accept-btn")
316
- .click();
317
-
318
- cy.wait("@updateAnnotation").its("response.statusCode").should("eq", 200);
319
- });
320
- });
321
-
322
- it("gets successfull response from the API when declining annotation", () => {
323
- cy.get("#document-annotations")
324
- .find(".label")
325
- .find(".annotation-row")
326
- .find(".annotation")
327
- .first()
328
- .then(($element) => {
329
- const annotationId = $element[0].id;
330
-
331
- cy.intercept('DELETE', `**/annotations/${annotationId}/`).as('deleteAnnotation');
332
-
333
- cy.wrap($element)
334
- .trigger("mouseover");
335
-
336
- cy.wait(1000);
337
-
338
- cy.get("#document-annotations")
339
- .find(".label")
340
- .find(".annotation-row")
341
- .find(".action-buttons")
342
- .find(".decline-btn")
343
- .click();
344
-
345
- cy.wait("@deleteAnnotation").its("response.statusCode").should("eq", 204);
346
- });
347
- });
348
-
349
- it("gets successfull response from the API when marking annotation as missing", () => {
350
- cy.get("#document-annotations")
351
- .find(".label")
352
- .find(".annotation-row")
353
- .find(".empty-annotation")
354
- .first()
355
- .then(($element) => {
356
- cy.intercept('POST', `**/missing-annotations/`).as('addMissingAnnotations');
357
-
358
- cy.wrap($element)
359
- .trigger("mouseover");
360
-
361
- cy.wait(1000);
362
-
363
- cy.get("#document-annotations")
364
- .find(".label")
365
- .find(".annotation-row")
366
- .find(".action-buttons")
367
- .find(".missing-btn")
368
- .click();
369
-
370
- cy.wait("@addMissingAnnotations").its("response.statusCode").should("eq", 201);
371
- });
372
- });
373
-
374
- it("gets successfull response from the API when restoring missing annotation", () => {
375
- cy.get("#document-annotations")
376
- .find(".label")
377
- .find(".annotation-row")
378
- .find(".empty-annotation")
379
- .find(".missing-annotation")
380
- .first()
381
- .then(($element) => {
382
-
383
- cy.getStore("document").then($document => {
384
- cy.intercept('DELETE', `**/missing-annotations/${$document.missingAnnotations[0].id}/`).as('deleteMissingAnnotation');
385
- });
386
-
387
- cy.wrap($element)
388
- .trigger("mouseover");
389
-
390
- cy.wait(1000);
391
-
392
- cy.get("#document-annotations")
393
- .find(".label")
394
- .find(".annotation-row")
395
- .find(".action-buttons")
396
- .find(".restore-btn")
397
- .click();
398
-
399
- cy.wait("@deleteMissingAnnotation").its("response.statusCode").should("eq", 204);
400
- });
401
- });
402
-
403
- it("shows details regarding translated strings if they are enabled for the project", () => {
404
- cy.getStore("project").then($project => {
405
- if ($project.translationsEnabled) {
406
- cy.getStore("document").then($document => {
407
- if ($document.annotations.length > 0) {
408
- cy.get("#document-annotations")
409
- .find(".labels")
410
- .find(".label")
411
- .find(".annotation-row")
412
- .find(".annotation-row-left")
413
- .find(".annotation-translation")
414
- .first()
415
- .find(".icon")
416
- .should("be.visible");
417
-
418
- cy.get("#document-annotations")
419
- .find(".labels")
420
- .find(".label")
421
- .find(".annotation-row")
422
- .find(".annotation-row-left")
423
- .find(".annotation-translation")
424
- .first()
425
- .trigger("mouseenter");
426
-
427
- cy.get("#document-annotations")
428
- .find(".labels")
429
- .find(".label")
430
- .find(".annotation-row")
431
- .find(".annotation-row-left")
432
- .find(".annotation-translation")
433
- .first()
434
- .find(".tooltip-content")
435
- .find(".translation-details")
436
- .should("be.visible");
437
- }
438
- });
439
- }
440
- });
441
- });
1
+ import DocumentAnnotations from "./DocumentAnnotations.vue";
2
+
3
+ describe("Document Annotations", () => {
4
+ beforeEach(() => {
5
+ cy.fetchDocument();
6
+ cy.dispatchAction("document", "setPublicView", false);
7
+ cy.dispatchAction("edit", "disableEditMode");
8
+ cy.mount(DocumentAnnotations);
9
+ });
10
+
11
+ it("shows loading when there are no annotation sets loaded yet or when loading the data", () => {
12
+ cy.dispatchAction("document", "setAnnotationSets", null);
13
+ cy.mount(DocumentAnnotations);
14
+ cy.get("#document-annotations")
15
+ .find(".document-annotations-loading")
16
+ .its("length")
17
+ .should("equal", 1);
18
+
19
+
20
+ cy.dispatchAction("document", "startLoading");
21
+ cy.get("#document-annotations")
22
+ .find(".document-annotations-loading")
23
+ .its("length")
24
+ .should("equal", 1);
25
+ });
26
+
27
+ it("shows 3 rows of loading annotation sets", () => {
28
+ cy.dispatchAction("document", "startLoading");
29
+ cy.get("#document-annotations")
30
+ .find(".loading-annotation-set")
31
+ .its("length")
32
+ .should("equal", 3);
33
+ });
34
+
35
+ it("shows all annotation sets", () => {
36
+ cy.get("#document-annotations")
37
+ .find(".annotation-set-group")
38
+ .then(($elements) => {
39
+ cy.getStore("document")
40
+ .then($document => {
41
+ expect($document.annotationSets).to.have.lengthOf($elements.length);
42
+ });
43
+ });
44
+ });
45
+
46
+ it("shows the empty state if there are no annotation sets", () => {
47
+ cy.dispatchAction("document", "setAnnotationSets", []);
48
+
49
+ cy.get("#document-annotations")
50
+ .find(".empty-annotation-sets")
51
+ .find(".empty-container")
52
+ .find(".title")
53
+ .should('be.visible');
54
+ });
55
+
56
+ it("shows no annotation set action buttons if the document is read only", () => {
57
+ cy.dispatchAction("document", "setPublicView", true);
58
+
59
+ cy.get("#document-annotations")
60
+ .find(".labelset-action-buttons")
61
+ .should("not.be.visible");
62
+ });
63
+
64
+ it("renders action buttons for the annotation sets and annotations", () => {
65
+ cy.get("#document-annotations")
66
+ .find(".labelset-action-buttons")
67
+ .should("be.visible");
68
+
69
+ cy.get("#document-annotations")
70
+ .find(".label")
71
+ .find(".annotation-row")
72
+ .find(".buttons-container")
73
+ .should("exist");
74
+ });
75
+
76
+ it("does not show annotations action buttons by default", () => {
77
+ cy.get("#document-annotations")
78
+ .find(".label")
79
+ .find(".annotation-row")
80
+ .find(".buttons-container")
81
+ .should("not.be.visible");
82
+ });
83
+
84
+ it("clicks each annotation and empty annotation and checks that it is in edit mode", () => {
85
+ cy.get("#document-annotations")
86
+ .find(".label")
87
+ .find(".annotation-row")
88
+ .find(".annotation-value")
89
+ .not(".missing-annotation")
90
+ .each($annotation => {
91
+ cy.wrap($annotation)
92
+ .should("not.have.class", "clicked-ann");
93
+ cy.wrap($annotation)
94
+ .click();
95
+ cy.wrap($annotation)
96
+ .should("have.class", "clicked-ann");
97
+ cy.wait(1000);
98
+ });
99
+ });
100
+
101
+ it("clicks each annotation and shows action buttons", () => {
102
+ cy.getStore("document").then($document => {
103
+ if ($document.annotations.length > 0) {
104
+ cy.get("#document-annotations")
105
+ .find(".label")
106
+ .find(".annotation-row")
107
+ .find(".annotation")
108
+ .each(($row) => {
109
+ cy.wrap($row)
110
+ .find(".annotation-value")
111
+ .click();
112
+
113
+ cy.get("#document-annotations")
114
+ .find(".label")
115
+ .find(".annotation-row")
116
+ .find(".action-buttons")
117
+ .find(".annotation-save-btn")
118
+ .should("be.visible");
119
+
120
+
121
+ cy.get("#document-annotations")
122
+ .find(".label")
123
+ .find(".annotation-row")
124
+ .find(".action-buttons")
125
+ .find(".annotation-cancel-btn")
126
+ .should("be.visible");
127
+
128
+ cy.get("#document-annotations")
129
+ .find(".label")
130
+ .find(".annotation-row")
131
+ .find(".action-buttons")
132
+ .find(".annotation-cancel-btn")
133
+ .click();
134
+
135
+ cy.wait(1000);
136
+ });
137
+ }
138
+ });
139
+ });
140
+
141
+ it("shows accept and decline buttons when hovering annotation", () => {
142
+ cy.getStore("document").then($document => {
143
+ if ($document.annotations.length > 0) {
144
+ cy.get("#document-annotations")
145
+ .find(".label")
146
+ .find(".annotation-row")
147
+ .find(".annotation")
148
+ .each(($row) => {
149
+ cy.wrap($row)
150
+ .trigger("mouseover");
151
+
152
+ cy.get("#document-annotations")
153
+ .find(".label")
154
+ .find(".annotation-row")
155
+ .find(".action-buttons")
156
+ .find(".decline-button-container")
157
+ .should("be.visible");
158
+
159
+ cy.get("#document-annotations")
160
+ .find(".label")
161
+ .find(".annotation-row")
162
+ .find(".action-buttons")
163
+ .find(".annotation-accept-btn")
164
+ .should("be.visible");
165
+
166
+ cy.wait(1000);
167
+ });
168
+ }
169
+ });
170
+ });
171
+
172
+ it("clicks each empty annotation and shows action buttons", () => {
173
+ cy.get("#document-annotations")
174
+ .find(".label")
175
+ .find(".annotation-row")
176
+ .find(".empty-annotation")
177
+ .find(".annotation-value")
178
+ .each(($annotation) => {
179
+ if ($annotation.hasClass("missing-annotation")) {
180
+ return;
181
+ } else {
182
+ cy.wrap($annotation)
183
+ .click();
184
+
185
+ cy.get("#document-annotations")
186
+ .find(".label")
187
+ .find(".annotation-row")
188
+ .find(".action-buttons")
189
+ .find(".annotation-cancel-btn")
190
+ .should("be.visible");
191
+
192
+ cy.get("#document-annotations")
193
+ .find(".label")
194
+ .find(".annotation-row")
195
+ .find(".action-buttons")
196
+ .find(".annotation-cancel-btn")
197
+ .click();
198
+
199
+ cy.wait(1000);
200
+ }
201
+ });
202
+ });
203
+
204
+ it("shows mark as missing button when hovering empty annotation", () => {
205
+ cy.get("#document-annotations")
206
+ .find(".label")
207
+ .find(".annotation-row")
208
+ .find(".empty-annotation")
209
+ .find(".annotation-value")
210
+ .not(".missing-annotation")
211
+ .each(($annotation) => {
212
+ cy.wrap($annotation)
213
+ .trigger("mouseover");
214
+
215
+ cy.get("#document-annotations")
216
+ .find(".label")
217
+ .find(".annotation-row")
218
+ .find(".action-buttons")
219
+ .find(".missing-button-container")
220
+ .should("be.visible");
221
+
222
+ cy.wait(1000);
223
+ });
224
+ });
225
+
226
+ it("marks empty annotation as missing", () => {
227
+ cy.get("#document-annotations")
228
+ .find(".label")
229
+ .find(".annotation-row")
230
+ .find(".empty-annotation")
231
+ .find(".annotation-value")
232
+ .not(".missing-annotation")
233
+ .each(($annotation) => {
234
+ cy.wrap($annotation)
235
+ .trigger("mouseover");
236
+
237
+ cy.get("#document-annotations")
238
+ .find(".label")
239
+ .find(".annotation-row")
240
+ .find(".action-buttons")
241
+ .find(".missing-button-container")
242
+ .find(".missing-btn")
243
+ .click();
244
+
245
+ cy.wrap($annotation)
246
+ .trigger("mouseleave");
247
+
248
+ cy.wait(1000);
249
+ });
250
+
251
+ cy.get("#document-annotations")
252
+ .find(".label")
253
+ .find(".annotation-row")
254
+ .find(".empty-annotation")
255
+ .then($elements => {
256
+
257
+ cy.getStore("document")
258
+ .then($document => {
259
+ expect($document.missingAnnotations)
260
+ .to.have.lengthOf($elements.length);
261
+ });
262
+ });
263
+ });
264
+
265
+ it("restores empty annotation", () => {
266
+ cy.get("#document-annotations")
267
+ .find(".label")
268
+ .find(".annotation-row")
269
+ .find(".empty-annotation")
270
+ .find(".missing-annotation")
271
+ .each(($annotation) => {
272
+ cy.wrap($annotation)
273
+ .trigger("mouseover");
274
+
275
+ cy.get("#document-annotations")
276
+ .find(".label")
277
+ .find(".annotation-row")
278
+ .find(".action-buttons")
279
+ .find(".restore-btn")
280
+ .click();
281
+
282
+ cy.wrap($annotation)
283
+ .trigger("mouseleave");
284
+
285
+ cy.wait(1000);
286
+ });
287
+
288
+ cy.get("#document-annotations")
289
+ .find(".label")
290
+ .find(".annotation-row")
291
+ .find(".empty-annotation")
292
+ .should("not.have.class", "missing-annotation");
293
+ });
294
+
295
+ it("gets successfull response from the API when accepting annotation", () => {
296
+ cy.get("#document-annotations")
297
+ .find(".label")
298
+ .find(".annotation-row")
299
+ .find(".annotation")
300
+ .first()
301
+ .then(($element) => {
302
+ const annotationId = $element[0].id;
303
+
304
+ cy.intercept('PATCH', `**/annotations/${annotationId}/`).as('updateAnnotation');
305
+
306
+ cy.wrap($element)
307
+ .trigger("mouseover");
308
+
309
+ cy.wait(1000);
310
+
311
+ cy.get("#document-annotations")
312
+ .find(".label")
313
+ .find(".annotation-row")
314
+ .find(".action-buttons")
315
+ .find(".annotation-accept-btn")
316
+ .click();
317
+
318
+ cy.wait("@updateAnnotation").its("response.statusCode").should("eq", 200);
319
+ });
320
+ });
321
+
322
+ it("gets successfull response from the API when declining annotation", () => {
323
+ cy.get("#document-annotations")
324
+ .find(".label")
325
+ .find(".annotation-row")
326
+ .find(".annotation")
327
+ .first()
328
+ .then(($element) => {
329
+ const annotationId = $element[0].id;
330
+
331
+ cy.intercept('DELETE', `**/annotations/${annotationId}/`).as('deleteAnnotation');
332
+
333
+ cy.wrap($element)
334
+ .trigger("mouseover");
335
+
336
+ cy.wait(1000);
337
+
338
+ cy.get("#document-annotations")
339
+ .find(".label")
340
+ .find(".annotation-row")
341
+ .find(".action-buttons")
342
+ .find(".decline-btn")
343
+ .click();
344
+
345
+ cy.wait("@deleteAnnotation").its("response.statusCode").should("eq", 204);
346
+ });
347
+ });
348
+
349
+ it("gets successfull response from the API when marking annotation as missing", () => {
350
+ cy.get("#document-annotations")
351
+ .find(".label")
352
+ .find(".annotation-row")
353
+ .find(".empty-annotation")
354
+ .first()
355
+ .then(($element) => {
356
+ cy.intercept('POST', `**/missing-annotations/`).as('addMissingAnnotations');
357
+
358
+ cy.wrap($element)
359
+ .trigger("mouseover");
360
+
361
+ cy.wait(1000);
362
+
363
+ cy.get("#document-annotations")
364
+ .find(".label")
365
+ .find(".annotation-row")
366
+ .find(".action-buttons")
367
+ .find(".missing-btn")
368
+ .click();
369
+
370
+ cy.wait("@addMissingAnnotations").its("response.statusCode").should("eq", 201);
371
+ });
372
+ });
373
+
374
+ it("gets successfull response from the API when restoring missing annotation", () => {
375
+ cy.get("#document-annotations")
376
+ .find(".label")
377
+ .find(".annotation-row")
378
+ .find(".empty-annotation")
379
+ .find(".missing-annotation")
380
+ .first()
381
+ .then(($element) => {
382
+
383
+ cy.getStore("document").then($document => {
384
+ cy.intercept('DELETE', `**/missing-annotations/${$document.missingAnnotations[0].id}/`).as('deleteMissingAnnotation');
385
+ });
386
+
387
+ cy.wrap($element)
388
+ .trigger("mouseover");
389
+
390
+ cy.wait(1000);
391
+
392
+ cy.get("#document-annotations")
393
+ .find(".label")
394
+ .find(".annotation-row")
395
+ .find(".action-buttons")
396
+ .find(".restore-btn")
397
+ .click();
398
+
399
+ cy.wait("@deleteMissingAnnotation").its("response.statusCode").should("eq", 204);
400
+ });
401
+ });
402
+
403
+ it("shows details regarding translated strings if they are enabled for the project", () => {
404
+ cy.getStore("project").then($project => {
405
+ if ($project.translationsEnabled) {
406
+ cy.getStore("document").then($document => {
407
+ if ($document.annotations.length > 0) {
408
+ cy.get("#document-annotations")
409
+ .find(".labels")
410
+ .find(".label")
411
+ .find(".annotation-row")
412
+ .find(".annotation-row-left")
413
+ .find(".annotation-translation")
414
+ .first()
415
+ .find(".icon")
416
+ .should("be.visible");
417
+
418
+ cy.get("#document-annotations")
419
+ .find(".labels")
420
+ .find(".label")
421
+ .find(".annotation-row")
422
+ .find(".annotation-row-left")
423
+ .find(".annotation-translation")
424
+ .first()
425
+ .trigger("mouseenter");
426
+
427
+ cy.get("#document-annotations")
428
+ .find(".labels")
429
+ .find(".label")
430
+ .find(".annotation-row")
431
+ .find(".annotation-row-left")
432
+ .find(".annotation-translation")
433
+ .first()
434
+ .find(".tooltip-content")
435
+ .find(".translation-details")
436
+ .should("be.visible");
437
+ }
438
+ });
439
+ }
440
+ });
441
+ });
442
442
  });