@konfuzio/document-validation-ui 0.1.18-dev.0 → 0.1.18-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konfuzio/document-validation-ui",
3
- "version": "0.1.18-dev.0",
3
+ "version": "0.1.18-dev.2",
4
4
  "repository": "git://github.com:konfuzio-ai/document-validation-ui.git",
5
5
  "main": "dist/app.js",
6
6
  "scripts": {
@@ -16,7 +16,7 @@ describe("Document Annotations", () => {
16
16
  .its("length")
17
17
  .should("equal", 1);
18
18
 
19
-
19
+
20
20
  cy.dispatchAction("document", "startLoading");
21
21
  cy.get("#document-annotations")
22
22
  .find(".document-annotations-loading")
@@ -32,20 +32,20 @@ describe("Document Annotations", () => {
32
32
  .should("equal", 3);
33
33
  });
34
34
 
35
- it("shows all annotation sets", () => {
35
+ it("shows all annotation sets", () => {
36
36
  cy.get("#document-annotations")
37
37
  .find(".annotation-set-group")
38
38
  .then(($elements) => {
39
39
  cy.getStore("document")
40
40
  .then($document => {
41
41
  expect($document.annotationSets).to.have.lengthOf($elements.length);
42
- })
42
+ });
43
43
  });
44
44
  });
45
45
 
46
46
  it("shows the empty state if there are no annotation sets", () => {
47
47
  cy.dispatchAction("document", "setAnnotationSets", []);
48
-
48
+
49
49
  cy.get("#document-annotations")
50
50
  .find(".empty-annotation-sets")
51
51
  .find(".empty-container")
@@ -55,7 +55,7 @@ describe("Document Annotations", () => {
55
55
 
56
56
  it("shows no annotation set action buttons if the document is read only", () => {
57
57
  cy.dispatchAction("document", "setPublicView", true);
58
-
58
+
59
59
  cy.get("#document-annotations")
60
60
  .find(".labelset-action-buttons")
61
61
  .should("not.be.visible");
@@ -81,7 +81,7 @@ describe("Document Annotations", () => {
81
81
  .should("not.be.visible");
82
82
  });
83
83
 
84
- it("clicks each annotation and empty annotation and checks that it is in edit mode", () => {
84
+ it("clicks each annotation and empty annotation and checks that it is in edit mode", () => {
85
85
  cy.get("#document-annotations")
86
86
  .find(".label")
87
87
  .find(".annotation-row")
@@ -89,58 +89,58 @@ describe("Document Annotations", () => {
89
89
  .not(".missing-annotation")
90
90
  .each($annotation => {
91
91
  cy.wrap($annotation)
92
- .should("not.have.class", "clicked-ann")
92
+ .should("not.have.class", "clicked-ann");
93
93
  cy.wrap($annotation)
94
94
  .click();
95
95
  cy.wrap($annotation)
96
- .should("have.class", "clicked-ann")
96
+ .should("have.class", "clicked-ann");
97
97
  cy.wait(1000);
98
- })
98
+ });
99
99
  });
100
100
 
101
101
  it("clicks each annotation and shows action buttons", () => {
102
102
  cy.getStore("document").then($document => {
103
- if($document.annotations.length > 0) {
103
+ if ($document.annotations.length > 0) {
104
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();
105
+ .find(".label")
106
+ .find(".annotation-row")
107
+ .find(".annotation")
108
+ .each(($row) => {
109
+ cy.wrap($row)
110
+ .find(".annotation-value")
111
+ .click();
112
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
-
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");
120
119
 
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
120
 
135
- cy.wait(1000);
136
- });
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
137
  }
138
138
  });
139
139
  });
140
140
 
141
141
  it("shows accept and decline buttons when hovering annotation", () => {
142
142
  cy.getStore("document").then($document => {
143
- if($document.annotations.length > 0) {
143
+ if ($document.annotations.length > 0) {
144
144
  cy.get("#document-annotations")
145
145
  .find(".label")
146
146
  .find(".annotation-row")
@@ -148,21 +148,21 @@ describe("Document Annotations", () => {
148
148
  .each(($row) => {
149
149
  cy.wrap($row)
150
150
  .trigger("mouseover");
151
-
151
+
152
152
  cy.get("#document-annotations")
153
153
  .find(".label")
154
154
  .find(".annotation-row")
155
155
  .find(".action-buttons")
156
156
  .find(".decline-button-container")
157
157
  .should("be.visible");
158
-
158
+
159
159
  cy.get("#document-annotations")
160
160
  .find(".label")
161
161
  .find(".annotation-row")
162
162
  .find(".action-buttons")
163
163
  .find(".annotation-accept-btn")
164
164
  .should("be.visible");
165
-
165
+
166
166
  cy.wait(1000);
167
167
  });
168
168
  }
@@ -180,25 +180,25 @@ describe("Document Annotations", () => {
180
180
  return;
181
181
  } else {
182
182
  cy.wrap($annotation)
183
- .click();
183
+ .click();
184
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();
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");
198
191
 
199
- cy.wait(1000);
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
200
  }
201
- });
201
+ });
202
202
  });
203
203
 
204
204
  it("shows mark as missing button when hovering empty annotation", () => {
@@ -218,12 +218,12 @@ describe("Document Annotations", () => {
218
218
  .find(".action-buttons")
219
219
  .find(".missing-button-container")
220
220
  .should("be.visible");
221
-
221
+
222
222
  cy.wait(1000);
223
- })
223
+ });
224
224
  });
225
225
 
226
- it("marks empty annotation as missing", () => {
226
+ it("marks empty annotation as missing", () => {
227
227
  cy.get("#document-annotations")
228
228
  .find(".label")
229
229
  .find(".annotation-row")
@@ -240,7 +240,7 @@ describe("Document Annotations", () => {
240
240
  .find(".action-buttons")
241
241
  .find(".missing-button-container")
242
242
  .find(".missing-btn")
243
- .click();
243
+ .click();
244
244
 
245
245
  cy.wrap($annotation)
246
246
  .trigger("mouseleave");
@@ -248,18 +248,18 @@ describe("Document Annotations", () => {
248
248
  cy.wait(1000);
249
249
  });
250
250
 
251
- cy.get("#document-annotations")
252
- .find(".label")
253
- .find(".annotation-row")
254
- .find(".empty-annotation")
255
- .then($elements => {
251
+ cy.get("#document-annotations")
252
+ .find(".label")
253
+ .find(".annotation-row")
254
+ .find(".empty-annotation")
255
+ .then($elements => {
256
256
 
257
- cy.getStore("document")
258
- .then($document => {
259
- expect($document.missingAnnotations)
260
- .to.have.lengthOf($elements.length);
257
+ cy.getStore("document")
258
+ .then($document => {
259
+ expect($document.missingAnnotations)
260
+ .to.have.lengthOf($elements.length);
261
261
  });
262
- });
262
+ });
263
263
  });
264
264
 
265
265
  it("restores empty annotation", () => {
@@ -300,9 +300,9 @@ describe("Document Annotations", () => {
300
300
  .first()
301
301
  .then(($element) => {
302
302
  const annotationId = $element[0].id;
303
-
303
+
304
304
  cy.intercept('PATCH', `**/annotations/${annotationId}/`).as('updateAnnotation');
305
-
305
+
306
306
  cy.wrap($element)
307
307
  .trigger("mouseover");
308
308
 
@@ -314,7 +314,7 @@ describe("Document Annotations", () => {
314
314
  .find(".action-buttons")
315
315
  .find(".annotation-accept-btn")
316
316
  .click();
317
-
317
+
318
318
  cy.wait("@updateAnnotation").its("response.statusCode").should("eq", 200);
319
319
  });
320
320
  });
@@ -327,9 +327,9 @@ describe("Document Annotations", () => {
327
327
  .first()
328
328
  .then(($element) => {
329
329
  const annotationId = $element[0].id;
330
-
330
+
331
331
  cy.intercept('DELETE', `**/annotations/${annotationId}/`).as('deleteAnnotation');
332
-
332
+
333
333
  cy.wrap($element)
334
334
  .trigger("mouseover");
335
335
 
@@ -341,7 +341,7 @@ describe("Document Annotations", () => {
341
341
  .find(".action-buttons")
342
342
  .find(".decline-btn")
343
343
  .click();
344
-
344
+
345
345
  cy.wait("@deleteAnnotation").its("response.statusCode").should("eq", 204);
346
346
  });
347
347
  });
@@ -352,9 +352,9 @@ describe("Document Annotations", () => {
352
352
  .find(".annotation-row")
353
353
  .find(".empty-annotation")
354
354
  .first()
355
- .then(($element) => {
355
+ .then(($element) => {
356
356
  cy.intercept('POST', `**/missing-annotations/`).as('addMissingAnnotations');
357
-
357
+
358
358
  cy.wrap($element)
359
359
  .trigger("mouseover");
360
360
 
@@ -366,7 +366,7 @@ describe("Document Annotations", () => {
366
366
  .find(".action-buttons")
367
367
  .find(".missing-btn")
368
368
  .click();
369
-
369
+
370
370
  cy.wait("@addMissingAnnotations").its("response.statusCode").should("eq", 201);
371
371
  });
372
372
  });
@@ -379,11 +379,11 @@ describe("Document Annotations", () => {
379
379
  .find(".missing-annotation")
380
380
  .first()
381
381
  .then(($element) => {
382
-
382
+
383
383
  cy.getStore("document").then($document => {
384
384
  cy.intercept('DELETE', `**/missing-annotations/${$document.missingAnnotations[0].id}/`).as('deleteMissingAnnotation');
385
- })
386
-
385
+ });
386
+
387
387
  cy.wrap($element)
388
388
  .trigger("mouseover");
389
389
 
@@ -395,16 +395,16 @@ describe("Document Annotations", () => {
395
395
  .find(".action-buttons")
396
396
  .find(".restore-btn")
397
397
  .click();
398
-
398
+
399
399
  cy.wait("@deleteMissingAnnotation").its("response.statusCode").should("eq", 204);
400
400
  });
401
401
  });
402
402
 
403
403
  it("shows details regarding translated strings if they are enabled for the project", () => {
404
- cy.getStore("project").then($project => {
405
- if($project.translationsEnabled) {
404
+ cy.getStore("project").then($project => {
405
+ if ($project.translationsEnabled) {
406
406
  cy.getStore("document").then($document => {
407
- if($document.annotations.length > 0) {
407
+ if ($document.annotations.length > 0) {
408
408
  cy.get("#document-annotations")
409
409
  .find(".labels")
410
410
  .find(".label")
@@ -437,6 +437,6 @@ describe("Document Annotations", () => {
437
437
  }
438
438
  });
439
439
  }
440
- })
440
+ });
441
441
  });
442
442
  });
@@ -57,6 +57,7 @@
57
57
  :key="category.id"
58
58
  aria-role="listitem"
59
59
  :disabled="handleOptionInDropdownDisabled(category)"
60
+ class="list-item"
60
61
  @click="handleChangeCategory(category)"
61
62
  >
62
63
  <span>{{ category.name }}</span>
@@ -99,7 +100,11 @@ export default {
99
100
  };
100
101
  },
101
102
  computed: {
102
- ...mapGetters("category", ["categoryName", "projectHasSingleCategory"]),
103
+ ...mapGetters("category", [
104
+ "categoryName",
105
+ "projectHasSingleCategory",
106
+ "categoryConfidence",
107
+ ]),
103
108
  ...mapGetters("document", [
104
109
  "documentCannotBeEdited",
105
110
  "documentHasCorrectAnnotations",
@@ -159,7 +164,7 @@ export default {
159
164
  (category) => category.id === this.updatedDocument[this.index].category
160
165
  );
161
166
 
162
- return this.handleCategoryConfidence(found.confidence);
167
+ return this.categoryConfidence(found.confidence);
163
168
  },
164
169
  },
165
170
  watch: {
@@ -199,19 +204,10 @@ export default {
199
204
  return {
200
205
  id: category.id,
201
206
  name: this.categoryName(category.id),
202
- confidence: this.handleCategoryConfidence(category.confidence),
207
+ confidence: this.categoryConfidence(category.confidence),
203
208
  };
204
209
  });
205
210
  },
206
- handleCategoryConfidence(confidence) {
207
- if (!confidence) {
208
- if (confidence === 0) return confidence.toFixed(2);
209
-
210
- return;
211
- }
212
-
213
- return (confidence * 100).toFixed(2);
214
- },
215
211
  checkIfDropdownIsDisabled() {
216
212
  if (
217
213
  this.projectHasSingleCategory ||
@@ -2,7 +2,12 @@ import DocumentEdit from "./DocumentEdit.vue";
2
2
 
3
3
  describe("Document Edit", () => {
4
4
  beforeEach(() => {
5
- cy.fetchDocument();
5
+ cy.fetchDocument().then(() => {
6
+ cy.getStore("project")
7
+ .then($project => {
8
+ cy.fetchCategories($project.projectId);
9
+ });
10
+ });
6
11
  cy.setFullMode();
7
12
  cy.dispatchAction("edit", "enableEditMode");
8
13
  cy.dispatchAction("edit", "setRenameAndCategorize", false);
@@ -325,4 +330,212 @@ describe("Document Edit", () => {
325
330
  }
326
331
  });
327
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
+ });
328
541
  });
@@ -251,7 +251,10 @@ export default {
251
251
  // check if the selected label already has a negative annotation
252
252
  let negativeAnnotationId;
253
253
 
254
- if (this.selectedLabel.annotations.length > 0) {
254
+ if (
255
+ this.selectedLabel.annotations &&
256
+ this.selectedLabel.annotations.length > 0
257
+ ) {
255
258
  const negativeAnnotation = this.selectedLabel.annotations.find(
256
259
  (annotation) => this.isNegative(annotation)
257
260
  );