@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,541 +1,541 @@
1
- import DocumentEdit from "./DocumentEdit.vue";
2
-
3
- describe("Document Edit", () => {
4
- beforeEach(() => {
5
- cy.fetchDocument().then(() => {
6
- cy.getStore("project")
7
- .then($project => {
8
- cy.fetchCategories($project.projectId);
9
- });
10
- });
11
- cy.setFullMode();
12
- cy.dispatchAction("edit", "enableEditMode");
13
- cy.dispatchAction("edit", "setRenameAndCategorize", false);
14
- cy.mount(DocumentEdit);
15
- });
16
-
17
- it("Shows edit mode - split, rotate & reorder view", () => {
18
- cy.get("#document-edit").find(".pages-section").should("be.visible");
19
- });
20
-
21
- it("Shows as many thumbnails as the document has", () => {
22
- cy.getStore("document").then(($document) => {
23
- const pages = $document.selectedDocument.pages;
24
- const pagesLength = pages.length;
25
-
26
- cy.get("#document-edit")
27
- .find(".pages-section")
28
- .find(".edit-pages")
29
- .find(".document-grid")
30
- .find(".image-section")
31
- .its("length")
32
- .should("equal", pagesLength);
33
- });
34
- });
35
-
36
- it("Shows the sidebar & buttons", () => {
37
- cy.get("#document-edit").find(".sidebar").should("be.visible");
38
-
39
- cy.get("#document-edit")
40
- .find(".sidebar")
41
- .find(".edit-buttons")
42
- .find(".sidebar-buttons")
43
- .its("length")
44
- .should("equal", 4);
45
- });
46
-
47
- it("Enables & disables automatic splitting switch, shows and hides 'new' badge, splitting suggestions info bar & tooltip when hovering if there are or not splitting suggestions", () => {
48
- cy.get("#document-edit")
49
- .find(".sidebar")
50
- .find(".smart-split")
51
- .should("be.visible");
52
-
53
- cy.getStore("document").then(($document) => {
54
- if ($document.selectedDocument.proposed_split) {
55
- cy.get("#document-edit")
56
- .find(".sidebar")
57
- .find(".smart-split")
58
- .find(".split-switch")
59
- .should("not.have.class", "is-disabled");
60
-
61
- cy.get("#document-edit")
62
- .find(".sidebar")
63
- .find(".smart-split")
64
- .find(".switch-info")
65
- .find(".new-badge")
66
- .should("be.visible");
67
-
68
- cy.get("#document-edit")
69
- .find(".pages-section")
70
- .find(".info-bar")
71
- .find(".split-info-bar")
72
- .should("be.visible");
73
- } else {
74
- cy.get("#document-edit")
75
- .find(".sidebar")
76
- .find(".smart-split")
77
- .find(".split-switch")
78
- .should("have.class", "is-disabled");
79
-
80
- cy.get("#document-edit")
81
- .find(".sidebar")
82
- .find(".smart-split")
83
- .trigger("mouseenter");
84
-
85
- cy.get("#document-edit")
86
- .find(".sidebar")
87
- .find(".smart-split")
88
- .find(".split-tooltip")
89
- .should("be.visible");
90
- }
91
- });
92
- });
93
-
94
- it("Can toggle automatic splitting switch if there are splitting suggestions", () => {
95
- cy.getStore("document").then(($document) => {
96
- if ($document.selectedDocument.proposed_split) {
97
- cy.get("#document-edit")
98
- .find(".sidebar")
99
- .find(".smart-split")
100
- .find(".split-switch")
101
- .click();
102
-
103
- cy.get("#document-edit")
104
- .find(".pages-section")
105
- .find(".info-bar")
106
- .find(".split-info-bar")
107
- .should("not.exist");
108
-
109
- cy.get("#document-edit")
110
- .find(".pages-section")
111
- .find(".image-section")
112
- .find(".splitting-lines")
113
- .find(".lines")
114
- .should("have.class", "not-active-split");
115
-
116
- cy.getStore("edit").then(($edit) => {
117
- expect($edit.updatedDocument).to.have.lengthOf(1);
118
- });
119
- }
120
- });
121
- });
122
-
123
- it("Shows the splitting points if there are splitting suggestions", () => {
124
- cy.getStore("document").then(($document) => {
125
- if ($document.selectedDocument.proposed_split) {
126
- const split = $document.selectedDocument.proposed_split;
127
- const splitLength = split.length;
128
-
129
- cy.get("#document-edit")
130
- .find(".pages-section")
131
- .find(".image-section")
132
- .find(".splitting-lines")
133
- .find(".active-split")
134
- .its("length")
135
- .should("equal", splitLength);
136
- }
137
- });
138
- });
139
-
140
- it("Shows the splitting lines by default when no suggestions, and the visible lines should be number of pages, and last one not visible", () => {
141
- cy.getStore("document").then(($document) => {
142
- const pages = $document.selectedDocument.pages;
143
- const pagesLength = pages.length;
144
-
145
- if (!$document.selectedDocument.proposed_split && $document.pages.length > 1) {
146
- cy.get("#document-edit")
147
- .find(".pages-section")
148
- .find(".image-section")
149
- .find(".splitting-lines")
150
- .find(".lines")
151
- .should("have.class", "not-active-split")
152
- .and(($lines) => {
153
- expect($lines).to.have.lengthOf(pagesLength);
154
- expect($lines[pagesLength - 1]).not.to.be.visible;
155
- });
156
- }
157
- });
158
- });
159
-
160
- it("Clicking splitting lines creates new documents", () => {
161
- cy.getStore("document").then(($document) => {
162
- if ($document.pages.length > 1) {
163
- if ($document.selectedDocument.proposed_split) {
164
- cy.get("#document-edit")
165
- .find(".sidebar")
166
- .find(".smart-split")
167
- .find(".split-switch")
168
- .click();
169
-
170
- cy.wait(1000);
171
- }
172
-
173
- cy.get("#document-edit")
174
- .find(".pages-section")
175
- .find(".image-section")
176
- .find(".splitting-lines")
177
- .find(".lines")
178
- .first()
179
- .click();
180
-
181
- cy.getStore("edit").then(($edit) => {
182
- expect($edit.updatedDocument).to.have.lengthOf(2);
183
- });
184
- }
185
- });
186
- });
187
-
188
- it("Clicking thumbnail selects & removes selection", () => {
189
- cy.get("#document-edit")
190
- .find(".pages-section")
191
- .find(".edit-pages")
192
- .find(".document-grid")
193
- .find(".image-section")
194
- .find(".top-section")
195
- .find(".edit-page-thumbnail")
196
- .find(".page-thumbnail")
197
- .first()
198
- .click();
199
-
200
- cy.get("#document-edit")
201
- .find(".pages-section")
202
- .find(".edit-pages")
203
- .find(".document-grid")
204
- .find(".image-section")
205
- .find(".top-section")
206
- .find(".edit-page-thumbnail")
207
- .find(".page-thumbnail")
208
- .first()
209
- .should("have.class", "selected");
210
-
211
- cy.get("#document-edit")
212
- .find(".pages-section")
213
- .find(".edit-pages")
214
- .find(".document-grid")
215
- .find(".image-section")
216
- .find(".top-section")
217
- .find(".edit-page-thumbnail")
218
- .find(".page-thumbnail")
219
- .first()
220
- .click();
221
-
222
- cy.get("#document-edit")
223
- .find(".pages-section")
224
- .find(".edit-pages")
225
- .find(".document-grid")
226
- .find(".image-section")
227
- .find(".top-section")
228
- .find(".edit-page-thumbnail")
229
- .find(".page-thumbnail")
230
- .first()
231
- .should("not.have.class", "selected");
232
- });
233
-
234
- it("Clicking thumbnail enables rotate selected buttons", () => {
235
- cy.get("#document-edit")
236
- .find(".pages-section")
237
- .find(".edit-pages")
238
- .find(".document-grid")
239
- .find(".image-section")
240
- .find(".top-section")
241
- .find(".edit-page-thumbnail")
242
- .find(".page-thumbnail")
243
- .first()
244
- .click();
245
-
246
- cy.get("#document-edit")
247
- .find(".sidebar")
248
- .find(".edit-buttons")
249
- .find(".sidebar-buttons")
250
- .find(".edit-mode-btn")
251
- .first()
252
- .should("not.be.disabled");
253
-
254
- cy.get("#document-edit")
255
- .find(".pages-section")
256
- .find(".edit-pages")
257
- .find(".document-grid")
258
- .find(".image-section")
259
- .find(".top-section")
260
- .find(".edit-page-thumbnail")
261
- .find(".page-thumbnail")
262
- .first()
263
- .click();
264
-
265
- cy.get("#document-edit")
266
- .find(".sidebar")
267
- .find(".edit-buttons")
268
- .find(".sidebar-buttons")
269
- .find(".edit-mode-btn")
270
- .first()
271
- .should("be.disabled");
272
- });
273
-
274
- it("Rotates the selected thumbnails", () => {
275
- cy.get("#document-edit")
276
- .find(".pages-section")
277
- .find(".edit-pages")
278
- .find(".document-grid")
279
- .find(".image-section")
280
- .find(".top-section")
281
- .find(".edit-page-thumbnail")
282
- .find(".page-thumbnail")
283
- .first()
284
- .click();
285
-
286
- cy.get("#document-edit")
287
- .find(".sidebar")
288
- .find(".edit-buttons")
289
- .find(".sidebar-buttons")
290
- .find(".edit-mode-btn")
291
- .first()
292
- .click();
293
-
294
- cy.getStore("edit").then(($edit) => {
295
- expect($edit.pagesForPostprocess[0].angle).to.equal(-90);
296
- });
297
- });
298
-
299
- it("Rotates all thumbnails", () => {
300
- cy.get("#document-edit")
301
- .find(".sidebar")
302
- .find(".edit-buttons")
303
- .find(".sidebar-buttons")
304
- .find(".edit-mode-btn")
305
- .last()
306
- .click();
307
-
308
- cy.getStore("edit").then(($edit) => {
309
- $edit.pagesForPostprocess.map((page) => {
310
- expect(page.angle).to.equal(90);
311
- });
312
- });
313
- });
314
-
315
- it("Can drag and drop to reorder pages", () => {
316
- cy.getStore("edit").then(($edit) => {
317
- if ($edit.pagesForPostprocess.length > 1) {
318
- const firstPageId = $edit.pagesForPostprocess[0].id;
319
- cy.get(
320
- "#document-edit .pages-section .edit-pages .document-grid .image-section:last-child"
321
- ).drag(
322
- "#document-edit .pages-section .edit-pages .document-grid .image-section:first-child"
323
- );
324
- cy.getStore("edit").then(($newEdit) => {
325
- const newFirstPageId = $newEdit.pagesForPostprocess[0].id;
326
- expect(newFirstPageId).to.not.equal(firstPageId);
327
- });
328
- } else {
329
- cy.log("Can't test drag and drop, this document has only one page");
330
- }
331
- });
332
- });
333
-
334
- it("Shows edit mode - rename and categorize view", () => {
335
- cy.dispatchAction("edit", "setRenameAndCategorize", true);
336
-
337
- cy.get("#document-edit").find(".rename-and-categorize-section").should("be.visible");
338
- });
339
-
340
- it("Changes visible page when clicking the thumbnail", () => {
341
- cy.dispatchAction("edit", "setRenameAndCategorize", true);
342
-
343
- cy.get("#document-edit")
344
- .find(".rename-and-categorize-section")
345
- .find(".thumbnail")
346
- .last()
347
- .click();
348
-
349
- cy.getStore("display").then($display => {
350
- cy.getStore("edit").then($edit => {
351
- const length = $edit.updatedDocument.length;
352
- const page = $edit.updatedDocument[length - 1].pages[0].number;
353
-
354
- expect($display.currentPage).to.equal(page);
355
- });
356
- });
357
- });
358
-
359
- it("Shows correct name for the new documents", () => {
360
- let fileName;
361
-
362
- cy.dispatchAction("edit", "setRenameAndCategorize", true);
363
-
364
- cy.getStore("document")
365
- .then($document => {
366
- fileName = $document.selectedDocument.data_file_name;
367
- fileName = fileName.split(".").slice(0, -1).join(".");
368
- });
369
-
370
- cy.get("#document-edit")
371
- .find(".rename-and-categorize-section")
372
- .find(".document-details")
373
- .find(".doc-info")
374
- .find(".file-name-section")
375
- .each(($document, index) => {
376
- let name;
377
- if (index === 0) {
378
- name = fileName;
379
- } else if (index === 1) {
380
- name = `${fileName}_copy`;
381
- } else {
382
- name = `${fileName}_copy${index}`;
383
- }
384
-
385
- cy.wrap($document)
386
- .find(".name-input")
387
- .invoke('val')
388
- .then($text => {
389
- expect($text).to.equal(name);
390
- });
391
- });
392
-
393
- });
394
-
395
- it("Changes name of the first document", () => {
396
- cy.dispatchAction("edit", "setRenameAndCategorize", true);
397
-
398
- const randomName = `test-name-${Math.floor(Math.random() * 100)}`;
399
- let inputValue;
400
-
401
- cy.get("#document-edit")
402
- .find(".rename-and-categorize-section")
403
- .find(".document-details")
404
- .find(".doc-info")
405
- .find(".file-name-section")
406
- .find(".name-input")
407
- .first()
408
- .then($firstInput => {
409
- cy.wrap($firstInput)
410
- .invoke('val')
411
- .then($text => {
412
- inputValue = $text;
413
- });
414
-
415
- cy.wrap($firstInput).click();
416
- });
417
-
418
- cy.get("#document-edit")
419
- .find(".rename-and-categorize-section")
420
- .find(".document-details")
421
- .find(".doc-info")
422
- .find(".file-name-section")
423
- .find(".name-input")
424
- .first()
425
- .type('{selectAll}')
426
- .type('{backspace}')
427
- .type(randomName);
428
-
429
- cy.get("#document-edit")
430
- .find(".rename-and-categorize-section")
431
- .find(".document-details")
432
- .find(".doc-info")
433
- .find(".file-name-section")
434
- .find(".name-input")
435
- .first()
436
- .then($firstInput => {
437
- cy.wrap($firstInput)
438
- .invoke('val')
439
- .then($text => {
440
- expect($text).to.not.equal(inputValue);
441
- });
442
- });
443
- });
444
-
445
- it("Shows correct name for the new documents", () => {
446
- cy.dispatchAction("edit", "setRenameAndCategorize", true);
447
-
448
- cy.get("#document-edit")
449
- .find(".rename-and-categorize-section")
450
- .find(".document-details")
451
- .find(".doc-info")
452
- .find(".category")
453
- .each(($categoryRow, index) => {
454
-
455
- cy.getStore("edit")
456
- .then($edit => {
457
- cy.gettersStore().then(($getters) => {
458
- const categoryName = $getters["category/categoryName"]($edit.updatedDocument[index].category);
459
-
460
- cy.wrap($categoryRow)
461
- .find(".category-name")
462
- .contains(categoryName);
463
- });
464
- });
465
- });
466
- });
467
-
468
- it("Shows category confidence if automatic split", () => {
469
- cy.dispatchAction("edit", "setRenameAndCategorize", true);
470
-
471
- cy.getStore("document").then(($document) => {
472
- if ($document.selectedDocument.proposed_split) {
473
-
474
- cy.get("#document-edit")
475
- .find(".rename-and-categorize-section")
476
- .find(".document-details")
477
- .find(".doc-info")
478
- .find(".category")
479
- .each(($categoryRow, index) => {
480
- cy.getStore("edit")
481
- .then($edit => {
482
- cy.gettersStore().then(($getters) => {
483
- const found = $edit.updatedDocument[index].categories.find(category =>
484
- category.id === $edit.updatedDocument[index].category
485
- );
486
-
487
- const confidence = $getters["category/categoryConfidence"](found.confidence);
488
-
489
- cy.wrap($categoryRow)
490
- .find(".category-name")
491
- .contains(confidence);
492
- });
493
- });
494
- });
495
-
496
- }
497
- });
498
- });
499
-
500
- it("Can change the category from the dropdown", () => {
501
- cy.dispatchAction("edit", "setRenameAndCategorize", true);
502
-
503
- cy.getStore("document").then(($document) => {
504
- if ($document.selectedDocument.proposed_split) {
505
-
506
- cy.get("#document-edit")
507
- .find(".rename-and-categorize-section")
508
- .find(".document-details")
509
- .find(".doc-info")
510
- .find(".category")
511
- .find(".category-drop-down")
512
- .first()
513
- .click();
514
-
515
- cy.get("#document-edit")
516
- .find(".rename-and-categorize-section")
517
- .find(".document-details")
518
- .find(".doc-info")
519
- .find(".category")
520
- .first()
521
- .then($categoryRow => {
522
- cy.getStore("edit")
523
- .then($edit => {
524
- cy.gettersStore().then(($getters) => {
525
- const categoryName = $getters["category/categoryName"]($edit.updatedDocument[0].category);
526
-
527
- cy.wrap($categoryRow)
528
- .find(".list-item")
529
- .first()
530
- .click();
531
-
532
- cy.wrap($categoryRow)
533
- .find(".category-name")
534
- .should("not.contain", categoryName);
535
- });
536
- });
537
- });
538
- }
539
- });
540
- });
541
- });
1
+ import DocumentEdit from "./DocumentEdit.vue";
2
+
3
+ describe("Document Edit", () => {
4
+ beforeEach(() => {
5
+ cy.fetchDocument().then(() => {
6
+ cy.getStore("project")
7
+ .then($project => {
8
+ cy.fetchCategories($project.projectId);
9
+ });
10
+ });
11
+ cy.setFullMode();
12
+ cy.dispatchAction("edit", "enableEditMode");
13
+ cy.dispatchAction("edit", "setRenameAndCategorize", false);
14
+ cy.mount(DocumentEdit);
15
+ });
16
+
17
+ it("Shows edit mode - split, rotate & reorder view", () => {
18
+ cy.get("#document-edit").find(".pages-section").should("be.visible");
19
+ });
20
+
21
+ it("Shows as many thumbnails as the document has", () => {
22
+ cy.getStore("document").then(($document) => {
23
+ const pages = $document.selectedDocument.pages;
24
+ const pagesLength = pages.length;
25
+
26
+ cy.get("#document-edit")
27
+ .find(".pages-section")
28
+ .find(".edit-pages")
29
+ .find(".document-grid")
30
+ .find(".image-section")
31
+ .its("length")
32
+ .should("equal", pagesLength);
33
+ });
34
+ });
35
+
36
+ it("Shows the sidebar & buttons", () => {
37
+ cy.get("#document-edit").find(".sidebar").should("be.visible");
38
+
39
+ cy.get("#document-edit")
40
+ .find(".sidebar")
41
+ .find(".edit-buttons")
42
+ .find(".sidebar-buttons")
43
+ .its("length")
44
+ .should("equal", 4);
45
+ });
46
+
47
+ it("Enables & disables automatic splitting switch, shows and hides 'new' badge, splitting suggestions info bar & tooltip when hovering if there are or not splitting suggestions", () => {
48
+ cy.get("#document-edit")
49
+ .find(".sidebar")
50
+ .find(".smart-split")
51
+ .should("be.visible");
52
+
53
+ cy.getStore("document").then(($document) => {
54
+ if ($document.selectedDocument.proposed_split) {
55
+ cy.get("#document-edit")
56
+ .find(".sidebar")
57
+ .find(".smart-split")
58
+ .find(".split-switch")
59
+ .should("not.have.class", "is-disabled");
60
+
61
+ cy.get("#document-edit")
62
+ .find(".sidebar")
63
+ .find(".smart-split")
64
+ .find(".switch-info")
65
+ .find(".new-badge")
66
+ .should("be.visible");
67
+
68
+ cy.get("#document-edit")
69
+ .find(".pages-section")
70
+ .find(".info-bar")
71
+ .find(".split-info-bar")
72
+ .should("be.visible");
73
+ } else {
74
+ cy.get("#document-edit")
75
+ .find(".sidebar")
76
+ .find(".smart-split")
77
+ .find(".split-switch")
78
+ .should("have.class", "is-disabled");
79
+
80
+ cy.get("#document-edit")
81
+ .find(".sidebar")
82
+ .find(".smart-split")
83
+ .trigger("mouseenter");
84
+
85
+ cy.get("#document-edit")
86
+ .find(".sidebar")
87
+ .find(".smart-split")
88
+ .find(".split-tooltip")
89
+ .should("be.visible");
90
+ }
91
+ });
92
+ });
93
+
94
+ it("Can toggle automatic splitting switch if there are splitting suggestions", () => {
95
+ cy.getStore("document").then(($document) => {
96
+ if ($document.selectedDocument.proposed_split) {
97
+ cy.get("#document-edit")
98
+ .find(".sidebar")
99
+ .find(".smart-split")
100
+ .find(".split-switch")
101
+ .click();
102
+
103
+ cy.get("#document-edit")
104
+ .find(".pages-section")
105
+ .find(".info-bar")
106
+ .find(".split-info-bar")
107
+ .should("not.exist");
108
+
109
+ cy.get("#document-edit")
110
+ .find(".pages-section")
111
+ .find(".image-section")
112
+ .find(".splitting-lines")
113
+ .find(".lines")
114
+ .should("have.class", "not-active-split");
115
+
116
+ cy.getStore("edit").then(($edit) => {
117
+ expect($edit.updatedDocument).to.have.lengthOf(1);
118
+ });
119
+ }
120
+ });
121
+ });
122
+
123
+ it("Shows the splitting points if there are splitting suggestions", () => {
124
+ cy.getStore("document").then(($document) => {
125
+ if ($document.selectedDocument.proposed_split) {
126
+ const split = $document.selectedDocument.proposed_split;
127
+ const splitLength = split.length;
128
+
129
+ cy.get("#document-edit")
130
+ .find(".pages-section")
131
+ .find(".image-section")
132
+ .find(".splitting-lines")
133
+ .find(".active-split")
134
+ .its("length")
135
+ .should("equal", splitLength);
136
+ }
137
+ });
138
+ });
139
+
140
+ it("Shows the splitting lines by default when no suggestions, and the visible lines should be number of pages, and last one not visible", () => {
141
+ cy.getStore("document").then(($document) => {
142
+ const pages = $document.selectedDocument.pages;
143
+ const pagesLength = pages.length;
144
+
145
+ if (!$document.selectedDocument.proposed_split && $document.pages.length > 1) {
146
+ cy.get("#document-edit")
147
+ .find(".pages-section")
148
+ .find(".image-section")
149
+ .find(".splitting-lines")
150
+ .find(".lines")
151
+ .should("have.class", "not-active-split")
152
+ .and(($lines) => {
153
+ expect($lines).to.have.lengthOf(pagesLength);
154
+ expect($lines[pagesLength - 1]).not.to.be.visible;
155
+ });
156
+ }
157
+ });
158
+ });
159
+
160
+ it("Clicking splitting lines creates new documents", () => {
161
+ cy.getStore("document").then(($document) => {
162
+ if ($document.pages.length > 1) {
163
+ if ($document.selectedDocument.proposed_split) {
164
+ cy.get("#document-edit")
165
+ .find(".sidebar")
166
+ .find(".smart-split")
167
+ .find(".split-switch")
168
+ .click();
169
+
170
+ cy.wait(1000);
171
+ }
172
+
173
+ cy.get("#document-edit")
174
+ .find(".pages-section")
175
+ .find(".image-section")
176
+ .find(".splitting-lines")
177
+ .find(".lines")
178
+ .first()
179
+ .click();
180
+
181
+ cy.getStore("edit").then(($edit) => {
182
+ expect($edit.updatedDocument).to.have.lengthOf(2);
183
+ });
184
+ }
185
+ });
186
+ });
187
+
188
+ it("Clicking thumbnail selects & removes selection", () => {
189
+ cy.get("#document-edit")
190
+ .find(".pages-section")
191
+ .find(".edit-pages")
192
+ .find(".document-grid")
193
+ .find(".image-section")
194
+ .find(".top-section")
195
+ .find(".edit-page-thumbnail")
196
+ .find(".page-thumbnail")
197
+ .first()
198
+ .click();
199
+
200
+ cy.get("#document-edit")
201
+ .find(".pages-section")
202
+ .find(".edit-pages")
203
+ .find(".document-grid")
204
+ .find(".image-section")
205
+ .find(".top-section")
206
+ .find(".edit-page-thumbnail")
207
+ .find(".page-thumbnail")
208
+ .first()
209
+ .should("have.class", "selected");
210
+
211
+ cy.get("#document-edit")
212
+ .find(".pages-section")
213
+ .find(".edit-pages")
214
+ .find(".document-grid")
215
+ .find(".image-section")
216
+ .find(".top-section")
217
+ .find(".edit-page-thumbnail")
218
+ .find(".page-thumbnail")
219
+ .first()
220
+ .click();
221
+
222
+ cy.get("#document-edit")
223
+ .find(".pages-section")
224
+ .find(".edit-pages")
225
+ .find(".document-grid")
226
+ .find(".image-section")
227
+ .find(".top-section")
228
+ .find(".edit-page-thumbnail")
229
+ .find(".page-thumbnail")
230
+ .first()
231
+ .should("not.have.class", "selected");
232
+ });
233
+
234
+ it("Clicking thumbnail enables rotate selected buttons", () => {
235
+ cy.get("#document-edit")
236
+ .find(".pages-section")
237
+ .find(".edit-pages")
238
+ .find(".document-grid")
239
+ .find(".image-section")
240
+ .find(".top-section")
241
+ .find(".edit-page-thumbnail")
242
+ .find(".page-thumbnail")
243
+ .first()
244
+ .click();
245
+
246
+ cy.get("#document-edit")
247
+ .find(".sidebar")
248
+ .find(".edit-buttons")
249
+ .find(".sidebar-buttons")
250
+ .find(".edit-mode-btn")
251
+ .first()
252
+ .should("not.be.disabled");
253
+
254
+ cy.get("#document-edit")
255
+ .find(".pages-section")
256
+ .find(".edit-pages")
257
+ .find(".document-grid")
258
+ .find(".image-section")
259
+ .find(".top-section")
260
+ .find(".edit-page-thumbnail")
261
+ .find(".page-thumbnail")
262
+ .first()
263
+ .click();
264
+
265
+ cy.get("#document-edit")
266
+ .find(".sidebar")
267
+ .find(".edit-buttons")
268
+ .find(".sidebar-buttons")
269
+ .find(".edit-mode-btn")
270
+ .first()
271
+ .should("be.disabled");
272
+ });
273
+
274
+ it("Rotates the selected thumbnails", () => {
275
+ cy.get("#document-edit")
276
+ .find(".pages-section")
277
+ .find(".edit-pages")
278
+ .find(".document-grid")
279
+ .find(".image-section")
280
+ .find(".top-section")
281
+ .find(".edit-page-thumbnail")
282
+ .find(".page-thumbnail")
283
+ .first()
284
+ .click();
285
+
286
+ cy.get("#document-edit")
287
+ .find(".sidebar")
288
+ .find(".edit-buttons")
289
+ .find(".sidebar-buttons")
290
+ .find(".edit-mode-btn")
291
+ .first()
292
+ .click();
293
+
294
+ cy.getStore("edit").then(($edit) => {
295
+ expect($edit.pagesForPostprocess[0].angle).to.equal(-90);
296
+ });
297
+ });
298
+
299
+ it("Rotates all thumbnails", () => {
300
+ cy.get("#document-edit")
301
+ .find(".sidebar")
302
+ .find(".edit-buttons")
303
+ .find(".sidebar-buttons")
304
+ .find(".edit-mode-btn")
305
+ .last()
306
+ .click();
307
+
308
+ cy.getStore("edit").then(($edit) => {
309
+ $edit.pagesForPostprocess.map((page) => {
310
+ expect(page.angle).to.equal(90);
311
+ });
312
+ });
313
+ });
314
+
315
+ it("Can drag and drop to reorder pages", () => {
316
+ cy.getStore("edit").then(($edit) => {
317
+ if ($edit.pagesForPostprocess.length > 1) {
318
+ const firstPageId = $edit.pagesForPostprocess[0].id;
319
+ cy.get(
320
+ "#document-edit .pages-section .edit-pages .document-grid .image-section:last-child"
321
+ ).drag(
322
+ "#document-edit .pages-section .edit-pages .document-grid .image-section:first-child"
323
+ );
324
+ cy.getStore("edit").then(($newEdit) => {
325
+ const newFirstPageId = $newEdit.pagesForPostprocess[0].id;
326
+ expect(newFirstPageId).to.not.equal(firstPageId);
327
+ });
328
+ } else {
329
+ cy.log("Can't test drag and drop, this document has only one page");
330
+ }
331
+ });
332
+ });
333
+
334
+ it("Shows edit mode - rename and categorize view", () => {
335
+ cy.dispatchAction("edit", "setRenameAndCategorize", true);
336
+
337
+ cy.get("#document-edit").find(".rename-and-categorize-section").should("be.visible");
338
+ });
339
+
340
+ it("Changes visible page when clicking the thumbnail", () => {
341
+ cy.dispatchAction("edit", "setRenameAndCategorize", true);
342
+
343
+ cy.get("#document-edit")
344
+ .find(".rename-and-categorize-section")
345
+ .find(".thumbnail")
346
+ .last()
347
+ .click();
348
+
349
+ cy.getStore("display").then($display => {
350
+ cy.getStore("edit").then($edit => {
351
+ const length = $edit.updatedDocument.length;
352
+ const page = $edit.updatedDocument[length - 1].pages[0].number;
353
+
354
+ expect($display.currentPage).to.equal(page);
355
+ });
356
+ });
357
+ });
358
+
359
+ it("Shows correct name for the new documents", () => {
360
+ let fileName;
361
+
362
+ cy.dispatchAction("edit", "setRenameAndCategorize", true);
363
+
364
+ cy.getStore("document")
365
+ .then($document => {
366
+ fileName = $document.selectedDocument.data_file_name;
367
+ fileName = fileName.split(".").slice(0, -1).join(".");
368
+ });
369
+
370
+ cy.get("#document-edit")
371
+ .find(".rename-and-categorize-section")
372
+ .find(".document-details")
373
+ .find(".doc-info")
374
+ .find(".file-name-section")
375
+ .each(($document, index) => {
376
+ let name;
377
+ if (index === 0) {
378
+ name = fileName;
379
+ } else if (index === 1) {
380
+ name = `${fileName}_copy`;
381
+ } else {
382
+ name = `${fileName}_copy${index}`;
383
+ }
384
+
385
+ cy.wrap($document)
386
+ .find(".name-input")
387
+ .invoke('val')
388
+ .then($text => {
389
+ expect($text).to.equal(name);
390
+ });
391
+ });
392
+
393
+ });
394
+
395
+ it("Changes name of the first document", () => {
396
+ cy.dispatchAction("edit", "setRenameAndCategorize", true);
397
+
398
+ const randomName = `test-name-${Math.floor(Math.random() * 100)}`;
399
+ let inputValue;
400
+
401
+ cy.get("#document-edit")
402
+ .find(".rename-and-categorize-section")
403
+ .find(".document-details")
404
+ .find(".doc-info")
405
+ .find(".file-name-section")
406
+ .find(".name-input")
407
+ .first()
408
+ .then($firstInput => {
409
+ cy.wrap($firstInput)
410
+ .invoke('val')
411
+ .then($text => {
412
+ inputValue = $text;
413
+ });
414
+
415
+ cy.wrap($firstInput).click();
416
+ });
417
+
418
+ cy.get("#document-edit")
419
+ .find(".rename-and-categorize-section")
420
+ .find(".document-details")
421
+ .find(".doc-info")
422
+ .find(".file-name-section")
423
+ .find(".name-input")
424
+ .first()
425
+ .type('{selectAll}')
426
+ .type('{backspace}')
427
+ .type(randomName);
428
+
429
+ cy.get("#document-edit")
430
+ .find(".rename-and-categorize-section")
431
+ .find(".document-details")
432
+ .find(".doc-info")
433
+ .find(".file-name-section")
434
+ .find(".name-input")
435
+ .first()
436
+ .then($firstInput => {
437
+ cy.wrap($firstInput)
438
+ .invoke('val')
439
+ .then($text => {
440
+ expect($text).to.not.equal(inputValue);
441
+ });
442
+ });
443
+ });
444
+
445
+ it("Shows correct name for the new documents", () => {
446
+ cy.dispatchAction("edit", "setRenameAndCategorize", true);
447
+
448
+ cy.get("#document-edit")
449
+ .find(".rename-and-categorize-section")
450
+ .find(".document-details")
451
+ .find(".doc-info")
452
+ .find(".category")
453
+ .each(($categoryRow, index) => {
454
+
455
+ cy.getStore("edit")
456
+ .then($edit => {
457
+ cy.gettersStore().then(($getters) => {
458
+ const categoryName = $getters["category/categoryName"]($edit.updatedDocument[index].category);
459
+
460
+ cy.wrap($categoryRow)
461
+ .find(".category-name")
462
+ .contains(categoryName);
463
+ });
464
+ });
465
+ });
466
+ });
467
+
468
+ it("Shows category confidence if automatic split", () => {
469
+ cy.dispatchAction("edit", "setRenameAndCategorize", true);
470
+
471
+ cy.getStore("document").then(($document) => {
472
+ if ($document.selectedDocument.proposed_split) {
473
+
474
+ cy.get("#document-edit")
475
+ .find(".rename-and-categorize-section")
476
+ .find(".document-details")
477
+ .find(".doc-info")
478
+ .find(".category")
479
+ .each(($categoryRow, index) => {
480
+ cy.getStore("edit")
481
+ .then($edit => {
482
+ cy.gettersStore().then(($getters) => {
483
+ const found = $edit.updatedDocument[index].categories.find(category =>
484
+ category.id === $edit.updatedDocument[index].category
485
+ );
486
+
487
+ const confidence = $getters["category/categoryConfidence"](found.confidence);
488
+
489
+ cy.wrap($categoryRow)
490
+ .find(".category-name")
491
+ .contains(confidence);
492
+ });
493
+ });
494
+ });
495
+
496
+ }
497
+ });
498
+ });
499
+
500
+ it("Can change the category from the dropdown", () => {
501
+ cy.dispatchAction("edit", "setRenameAndCategorize", true);
502
+
503
+ cy.getStore("document").then(($document) => {
504
+ if ($document.selectedDocument.proposed_split) {
505
+
506
+ cy.get("#document-edit")
507
+ .find(".rename-and-categorize-section")
508
+ .find(".document-details")
509
+ .find(".doc-info")
510
+ .find(".category")
511
+ .find(".category-drop-down")
512
+ .first()
513
+ .click();
514
+
515
+ cy.get("#document-edit")
516
+ .find(".rename-and-categorize-section")
517
+ .find(".document-details")
518
+ .find(".doc-info")
519
+ .find(".category")
520
+ .first()
521
+ .then($categoryRow => {
522
+ cy.getStore("edit")
523
+ .then($edit => {
524
+ cy.gettersStore().then(($getters) => {
525
+ const categoryName = $getters["category/categoryName"]($edit.updatedDocument[0].category);
526
+
527
+ cy.wrap($categoryRow)
528
+ .find(".list-item")
529
+ .first()
530
+ .click();
531
+
532
+ cy.wrap($categoryRow)
533
+ .find(".category-name")
534
+ .should("not.contain", categoryName);
535
+ });
536
+ });
537
+ });
538
+ }
539
+ });
540
+ });
541
+ });