@konfuzio/document-validation-ui 0.1.16-dev.5 → 0.1.16

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.
@@ -190,7 +190,7 @@ export default {
190
190
  },
191
191
  handleCategoryConfidence(confidence) {
192
192
  if(!confidence) {
193
- if(confidence === 0) return 0;
193
+ if(confidence === 0) return confidence.toFixed(2);
194
194
 
195
195
  return;
196
196
  }
@@ -0,0 +1,313 @@
1
+ import DocumentEdit from "./DocumentEdit.vue";
2
+
3
+ describe("Document Edit", () => {
4
+ beforeEach(() => {
5
+ cy.fetchDocument();
6
+ cy.setFullMode();
7
+ cy.dispatchAction("edit", "enableEditMode");
8
+ cy.dispatchAction("edit", "setRenameAndCategorize", false);
9
+ cy.mount(DocumentEdit);
10
+ });
11
+
12
+ it("Shows edit mode - split, rotate & reorder view", () => {
13
+ cy.get("#document-edit")
14
+ .find(".pages-section")
15
+ .should("be.visible");
16
+ });
17
+
18
+ it("Shows as many thumbnails as the document has", () => {
19
+ cy.getStore("document").then(($document) => {
20
+ const pages = $document.selectedDocument.pages
21
+ const pagesLength = pages.length;
22
+
23
+ cy.get("#document-edit")
24
+ .find(".pages-section")
25
+ .find(".edit-pages")
26
+ .find(".document-grid")
27
+ .find(".image-section")
28
+ .its("length")
29
+ .should("equal", pagesLength);
30
+ });
31
+ });
32
+
33
+ it("Shows the sidebar & buttons", () => {
34
+ cy.get("#document-edit")
35
+ .find(".sidebar")
36
+ .should("be.visible");
37
+
38
+ cy.get("#document-edit")
39
+ .find(".sidebar")
40
+ .find(".edit-buttons")
41
+ .find(".sidebar-buttons")
42
+ .its("length")
43
+ .should("equal", 4);
44
+ });
45
+
46
+ 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", () => {
47
+ cy.get("#document-edit")
48
+ .find(".sidebar")
49
+ .find(".smart-split")
50
+ .should("be.visible");
51
+
52
+ cy.getStore("document").then($document => {
53
+ if($document.selectedDocument.proposed_split) {
54
+ cy.get("#document-edit")
55
+ .find(".sidebar")
56
+ .find(".smart-split")
57
+ .find(".split-switch")
58
+ .should("not.have.class", "is-disabled");
59
+
60
+ cy.get("#document-edit")
61
+ .find(".sidebar")
62
+ .find(".smart-split")
63
+ .find(".switch-info")
64
+ .find(".new-badge")
65
+ .should("be.visible");
66
+
67
+ cy.get("#document-edit")
68
+ .find(".pages-section")
69
+ .find(".info-bar")
70
+ .find(".split-info-bar")
71
+ .should("be.visible");
72
+ } else {
73
+ cy.get("#document-edit")
74
+ .find(".sidebar")
75
+ .find(".smart-split")
76
+ .find(".split-switch")
77
+ .should("have.class", "is-disabled");
78
+
79
+ cy.get("#document-edit")
80
+ .find(".sidebar")
81
+ .find(".smart-split")
82
+ .trigger("mouseenter");
83
+
84
+ cy.get("#document-edit")
85
+ .find(".sidebar")
86
+ .find(".smart-split")
87
+ .find(".split-tooltip")
88
+ .should("be.visible");
89
+
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
+
141
+ it("Shows the splitting lines by default when no suggestions, and the visible lines should be number of pages, and last one not visible", () => {
142
+ cy.getStore("document").then($document => {
143
+ const pages = $document.selectedDocument.pages
144
+ const pagesLength = pages.length;
145
+
146
+ if(!$document.selectedDocument.proposed_split) {
147
+ cy.get("#document-edit")
148
+ .find(".pages-section")
149
+ .find(".image-section")
150
+ .find(".splitting-lines")
151
+ .find(".lines")
152
+ .should("have.class", "not-active-split")
153
+ .and($lines => {
154
+ expect($lines).to.have.lengthOf(pagesLength);
155
+ expect($lines[pagesLength - 1]).not.to.be.visible;
156
+ });
157
+ }
158
+ });
159
+ });
160
+
161
+ it("Clicking splitting lines creates new documents", () => {
162
+ cy.getStore("document").then($document => {
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
+ it("Clicking thumbnail selects & removes selection", () => {
188
+ cy.get("#document-edit")
189
+ .find(".pages-section")
190
+ .find(".edit-pages")
191
+ .find(".document-grid")
192
+ .find(".image-section")
193
+ .find(".top-section")
194
+ .find(".edit-page-thumbnail")
195
+ .find(".page-thumbnail")
196
+ .first()
197
+ .click();
198
+
199
+ cy.get("#document-edit")
200
+ .find(".pages-section")
201
+ .find(".edit-pages")
202
+ .find(".document-grid")
203
+ .find(".image-section")
204
+ .find(".top-section")
205
+ .find(".edit-page-thumbnail")
206
+ .find(".page-thumbnail")
207
+ .first()
208
+ .should("have.class", "selected");
209
+
210
+ cy.get("#document-edit")
211
+ .find(".pages-section")
212
+ .find(".edit-pages")
213
+ .find(".document-grid")
214
+ .find(".image-section")
215
+ .find(".top-section")
216
+ .find(".edit-page-thumbnail")
217
+ .find(".page-thumbnail")
218
+ .first()
219
+ .click();
220
+
221
+ cy.get("#document-edit")
222
+ .find(".pages-section")
223
+ .find(".edit-pages")
224
+ .find(".document-grid")
225
+ .find(".image-section")
226
+ .find(".top-section")
227
+ .find(".edit-page-thumbnail")
228
+ .find(".page-thumbnail")
229
+ .first()
230
+ .should("not.have.class", "selected");
231
+ });
232
+
233
+ it("Clicking thumbnail enables rotate selected buttons", () => {
234
+ cy.get("#document-edit")
235
+ .find(".pages-section")
236
+ .find(".edit-pages")
237
+ .find(".document-grid")
238
+ .find(".image-section")
239
+ .find(".top-section")
240
+ .find(".edit-page-thumbnail")
241
+ .find(".page-thumbnail")
242
+ .first()
243
+ .click();
244
+
245
+ cy.get("#document-edit")
246
+ .find(".sidebar")
247
+ .find(".edit-buttons")
248
+ .find(".sidebar-buttons")
249
+ .find(".edit-mode-btn")
250
+ .first()
251
+ .should("not.be.disabled");
252
+
253
+ cy.get("#document-edit")
254
+ .find(".pages-section")
255
+ .find(".edit-pages")
256
+ .find(".document-grid")
257
+ .find(".image-section")
258
+ .find(".top-section")
259
+ .find(".edit-page-thumbnail")
260
+ .find(".page-thumbnail")
261
+ .first()
262
+ .click();
263
+
264
+ cy.get("#document-edit")
265
+ .find(".sidebar")
266
+ .find(".edit-buttons")
267
+ .find(".sidebar-buttons")
268
+ .find(".edit-mode-btn")
269
+ .first()
270
+ .should("be.disabled");
271
+ });
272
+
273
+ it("Rotates the selected thumbnails", () => {
274
+ cy.get("#document-edit")
275
+ .find(".pages-section")
276
+ .find(".edit-pages")
277
+ .find(".document-grid")
278
+ .find(".image-section")
279
+ .find(".top-section")
280
+ .find(".edit-page-thumbnail")
281
+ .find(".page-thumbnail")
282
+ .first()
283
+ .click();
284
+
285
+ cy.get("#document-edit")
286
+ .find(".sidebar")
287
+ .find(".edit-buttons")
288
+ .find(".sidebar-buttons")
289
+ .find(".edit-mode-btn")
290
+ .first()
291
+ .click();
292
+
293
+ cy.getStore("edit").then($edit => {
294
+ expect($edit.pagesForPostprocess[0].angle).to.equal(-90);
295
+ })
296
+ });
297
+
298
+ it("Rotates all thumbnails", () => {
299
+ cy.get("#document-edit")
300
+ .find(".sidebar")
301
+ .find(".edit-buttons")
302
+ .find(".sidebar-buttons")
303
+ .find(".edit-mode-btn")
304
+ .last()
305
+ .click();
306
+
307
+ cy.getStore("edit").then($edit => {
308
+ $edit.pagesForPostprocess.map(page => {
309
+ expect(page.angle).to.equal(90);
310
+ })
311
+ });
312
+ });
313
+ });
@@ -39,7 +39,7 @@
39
39
  v-if="
40
40
  splittingLines && splittingLines[index].page === page.number
41
41
  "
42
- class="lines"
42
+ class="lines active-split"
43
43
  >
44
44
  <SplitZigZag
45
45
  :color="
@@ -52,7 +52,7 @@
52
52
  "
53
53
  />
54
54
  </div>
55
- <div v-else class="lines">
55
+ <div v-else class="lines not-active-split">
56
56
  <SplitLines />
57
57
  </div>
58
58
  </div>
@@ -46,7 +46,7 @@
46
46
  multilined
47
47
  :active="!documentHasProposedSplit(selectedDocument)"
48
48
  position="is-bottom"
49
- class="bottom-aligned"
49
+ class="bottom-aligned split-tooltip"
50
50
  :label="tooltipInfo"
51
51
  >
52
52
  <b-field>
@@ -55,6 +55,7 @@
55
55
  :value="true"
56
56
  size="is-small"
57
57
  :disabled="!documentHasProposedSplit(selectedDocument)"
58
+ class="split-switch"
58
59
  />
59
60
  <div class="switch-info">
60
61
  <span class="switch-text">{{ $t("smart_split") }}</span>
@@ -2,26 +2,25 @@ import DocumentTopBar from "./DocumentTopBar";
2
2
 
3
3
  describe("Document Top Bar", () => {
4
4
  let currentDocument;
5
- beforeEach(() => {
6
5
 
6
+ beforeEach(() => {
7
7
  cy.fetchDocument().then(() => {
8
8
  cy.getStore("document")
9
9
  .then($document => {
10
10
  currentDocument = $document.selectedDocument;
11
11
  });
12
-
13
-
12
+
14
13
  cy.getStore("project")
15
14
  .then($project => {
16
15
  cy.fetchCategories($project.projectId);
17
16
  });
18
17
  });
19
-
20
18
  cy.dispatchAction("document", "setPublicView", false);
19
+ cy.dispatchAction("edit", "disableEditMode");
20
+ cy.mount(DocumentTopBar);
21
21
  });
22
22
 
23
23
  it("Shows category dropdown if not edit mode or reviewed", () => {
24
- cy.mount(DocumentTopBar);
25
24
  cy.dispatchAction("edit", "disableEditMode");
26
25
 
27
26
  cy.get("#document-top-bar-component")
@@ -31,7 +30,6 @@ describe("Document Top Bar", () => {
31
30
  });
32
31
 
33
32
  it("Shows correct file name", () => {
34
- cy.mount(DocumentTopBar);
35
33
  const fileName = currentDocument.data_file_name
36
34
 
37
35
  cy.get("#document-top-bar-component")
@@ -46,42 +44,37 @@ describe("Document Top Bar", () => {
46
44
  .contains(fileName);
47
45
  });
48
46
 
49
- it("Shows arrows if available documents to navigate to", () => {
50
- cy.mount(DocumentTopBar);
47
+ it("Shows arrows if available documents to navigate to", () => {
51
48
  cy.fetchDocumentList();
52
49
  const assignee = currentDocument.assignee;
53
50
 
54
51
  cy.getStore("project")
55
52
  .then($project => {
56
- const filtered = $project.documentsInProject.filter(
57
- (document) =>
58
- (document.status_data === 41 || (document.status_data === 2 && document.labeling_available === 1)
59
- ) && document.assignee === assignee
60
- );
61
-
62
- if(filtered.length > 0) {
63
- cy.get("#document-top-bar-component")
64
- .find(".center-bar-components")
65
- .find(".navigation-arrow")
66
- .should("be.visible");
67
- }
53
+ cy.gettersStore().then(($getters) => {
54
+ const filtered = $project.documentsInProject.filter(
55
+ (document) =>
56
+ ($getters["document/waitingForSplittingConfirmation"](document) || $getters["document/isDocumentReadyToBeReviewed"](document)
57
+ ) && document.assignee === assignee
58
+ );
59
+
60
+ if(filtered.length > 0) {
61
+ cy.get("#document-top-bar-component")
62
+ .find(".center-bar-components")
63
+ .find(".navigation-arrow")
64
+ .should("be.visible");
65
+ }
68
66
  });
67
+ });
69
68
  });
70
69
 
71
70
  it("Shows keyboard icon", () => {
72
- cy.mount(DocumentTopBar);
73
- cy.dispatchAction("edit", "disableEditMode");
74
-
75
71
  cy.get("#document-top-bar-component")
76
72
  .find(".right-bar-components")
77
73
  .find(".keyboard-actions-info")
78
74
  .should("be.visible");
79
75
  });
80
76
 
81
- it("Shows disabled finish review button", () => {
82
- cy.mount(DocumentTopBar);
83
- cy.dispatchAction("edit", "disableEditMode");
84
-
77
+ it("Shows disabled finish review button", () => {
85
78
  cy.get("#document-top-bar-component")
86
79
  .find(".right-bar-components")
87
80
  .find(".top-bar-buttons")
@@ -97,7 +90,6 @@ describe("Document Top Bar", () => {
97
90
  });
98
91
 
99
92
  it("Shows edit mode buttons", () => {
100
- cy.mount(DocumentTopBar);
101
93
  cy.dispatchAction("edit", "enableEditMode");
102
94
 
103
95
  cy.get("#document-top-bar-component")
@@ -111,12 +103,9 @@ describe("Document Top Bar", () => {
111
103
  .find(".top-bar-buttons")
112
104
  .find(".edit-mode-buttons")
113
105
  .should("be.visible");
114
-
115
- cy.dispatchAction("edit", "disableEditMode");
116
106
  });
117
107
 
118
108
  it("Edits file name", () => {
119
- cy.mount(DocumentTopBar);
120
109
  const fileName = currentDocument.data_file_name.split(".").slice(0, -1).join(".");
121
110
 
122
111
  cy.get("#document-top-bar-component")
@@ -168,8 +157,6 @@ describe("Document Top Bar", () => {
168
157
  });
169
158
 
170
159
  it("Shows tooltip when hovering over keyboard info", () => {
171
- cy.mount(DocumentTopBar);
172
-
173
160
  cy.get("#document-top-bar-component")
174
161
  .find(".right-bar-components")
175
162
  .find(".keyboard-actions-info")
@@ -187,8 +174,7 @@ describe("Document Top Bar", () => {
187
174
  .trigger("mouseleave");
188
175
  });
189
176
 
190
- it("Closes edit mode when clicking 'back to annotaiton view' button", () => {
191
- cy.mount(DocumentTopBar);
177
+ it("Closes edit mode when clicking 'back to annotaiton view' button", () => {
192
178
  cy.dispatchAction("edit", "enableEditMode");
193
179
 
194
180
  cy.get("#document-top-bar-component")
@@ -211,7 +197,6 @@ describe("Document Top Bar", () => {
211
197
  });
212
198
 
213
199
  it("Shows rename and categorize section when clicking 'next' button", () => {
214
- cy.mount(DocumentTopBar);
215
200
  cy.dispatchAction("edit", "enableEditMode");
216
201
 
217
202
  cy.get("#document-top-bar-component")
@@ -226,6 +211,6 @@ describe("Document Top Bar", () => {
226
211
  .find(".right-bar-components")
227
212
  .find(".edit-mode-buttons")
228
213
  .find(".submit-btn")
229
- .should("be.visible")
214
+ .should("be.visible");
230
215
  });
231
216
  });
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div id="document-top-bar-component" ref="documentTopBar">
2
+ <div ref="documentTopBar" id="document-top-bar-component">
3
3
  <div
4
4
  v-if="selectedDocument && selectedDocument.pages.length > 0 && !loading"
5
5
  :class="['document-top-bar', editMode && 'edit-mode-top-bar']"