@webitel/ui-sdk 3.0.4 → 3.0.6

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 (31) hide show
  1. package/dist/ui-sdk.common.js +2 -2
  2. package/dist/ui-sdk.common.js.map +1 -1
  3. package/dist/ui-sdk.umd.js +2 -2
  4. package/dist/ui-sdk.umd.js.map +1 -1
  5. package/dist/ui-sdk.umd.min.js +1 -1
  6. package/dist/ui-sdk.umd.min.js.map +1 -1
  7. package/package.json +4 -1
  8. package/src/locale/en/en.js +13 -0
  9. package/src/locale/es/es.js +282 -0
  10. package/src/locale/i18n.js +2 -0
  11. package/src/locale/ru/ru.js +13 -0
  12. package/src/locale/ua/ua.js +13 -0
  13. package/src/mixins/validationMixin/validationMixin.js +12 -12
  14. package/src/modules/AuditForm/components/__tests__/audit-form-question-read-wrapper.spec.js +14 -0
  15. package/src/modules/AuditForm/components/__tests__/audit-form-question-write-wrapper.spec.js +59 -0
  16. package/src/modules/AuditForm/components/__tests__/audit-form-question.spec.js +14 -0
  17. package/src/modules/AuditForm/components/__tests__/audit-form.spec.js +66 -0
  18. package/src/modules/AuditForm/components/audit-form-question-read-wrapper.vue +100 -0
  19. package/src/modules/AuditForm/components/audit-form-question-write-wrapper.vue +151 -0
  20. package/src/modules/AuditForm/components/audit-form-question.vue +102 -0
  21. package/src/modules/AuditForm/components/audit-form.vue +142 -0
  22. package/src/modules/AuditForm/components/questions/__tests__/audit-form-question-options.spec.js +46 -0
  23. package/src/modules/AuditForm/components/questions/__tests__/audit-form-question-score.spec.js +30 -0
  24. package/src/modules/AuditForm/components/questions/audit-form-question-options.vue +124 -0
  25. package/src/modules/AuditForm/components/questions/audit-form-question-score.vue +89 -0
  26. package/src/modules/AuditForm/composables/useDestroyableSortable.js +66 -0
  27. package/src/modules/AuditForm/schemas/AuditFormQuestionOptionsSchema.js +11 -0
  28. package/src/modules/AuditForm/schemas/AuditFormQuestionSchema.js +8 -0
  29. package/src/modules/AuditForm/schemas/AuditFormQuestionScoreSchema.js +6 -0
  30. package/src/scripts/__tests__/updateObject.spec.js +19 -0
  31. package/src/scripts/updateObject.js +6 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-sdk",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve-lib": "vue-cli-service serve",
@@ -28,6 +28,8 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "@vue/compat": "^3.2.47",
31
+ "@vuelidate/core": "^2.0.0",
32
+ "@vuelidate/validators": "^2.0.0",
31
33
  "clipboard-copy": "^4.0.1",
32
34
  "core-js": "^3.6.5",
33
35
  "csv-stringify": "^5.5.3",
@@ -39,6 +41,7 @@
39
41
  "jszip-utils": "^0.1.0",
40
42
  "node-polyfill-webpack-plugin": "^1.1.4",
41
43
  "plyr": "3.6.2",
44
+ "sortablejs": "^1.15.0",
42
45
  "tiny-emitter": "^2.1.0",
43
46
  "vue": "^3.2.47",
44
47
  "vue-i18n": "^9.2.2",
@@ -34,6 +34,7 @@ export default {
34
34
  generate: 'Generate',
35
35
  lang: {
36
36
  en: 'English',
37
+ es: 'Español',
37
38
  ru: 'Русский',
38
39
  ua: 'Українська',
39
40
  },
@@ -46,6 +47,8 @@ export default {
46
47
  downloadAll: 'Download all',
47
48
  warning: 'Warning',
48
49
  doNotSave: 'Don\'t save',
50
+ required: 'Required',
51
+ copy: 'Copy',
49
52
  },
50
53
  // yak zhe ya zaebalsya povtoriaty odni i ti sami slova!!!!
51
54
  vocabulary: {
@@ -280,5 +283,15 @@ export default {
280
283
  copy: 'Copy',
281
284
  copied: 'Copied to clipboard!',
282
285
  },
286
+ auditForm: {
287
+ question: 'Criteria',
288
+ option: 'Option | Options',
289
+ score: 'Score | Scores',
290
+ addQuestion: 'Add criteria',
291
+ type: {
292
+ options: 'Options',
293
+ score: 'Score',
294
+ },
295
+ },
283
296
  },
284
297
  };
@@ -0,0 +1,282 @@
1
+ import {
2
+ AgentStatus,
3
+ CallDirection,
4
+ ChannelState,
5
+ ChannelType, EngineRoutingSchemaType,
6
+ } from 'webitel-sdk';
7
+ import { QueueType } from 'webitel-sdk/esm2015/enums';
8
+ import AdminSections from '../../enums/WebitelApplications/AdminSections.enum';
9
+ import SupervisorSections from '../../enums/WebitelApplications/SupervisorSections.enum';
10
+ import WebitelApplications from '../../enums/WebitelApplications/WebitelApplications.enum';
11
+ import AuditorSections
12
+ from '../../enums/WebitelApplications/AuditorSections.enum';
13
+ import { snakeToCamel } from '../../scripts/caseConverters';
14
+
15
+ export default {
16
+ // describes reusable buttons, actions, default titles, and other ui elements
17
+ reusable: {
18
+ total: 'Total',
19
+ ok: 'Ok',
20
+ save: 'Guardar',
21
+ close: 'Cerrar',
22
+ add: 'Agregar',
23
+ cancel: 'Cancelar',
24
+ import: 'Importación',
25
+ export: 'Exportación',
26
+ true: 'Sí',
27
+ delete: 'Eliminar',
28
+ search: 'Búsqueda',
29
+ open: 'Abrir',
30
+ name: 'Nombre',
31
+ expand: 'Expandir',
32
+ collapse: 'Reducir',
33
+ generate: 'Generar',
34
+ lang: {
35
+ en: 'English',
36
+ es: 'Español',
37
+ ru: 'Русский',
38
+ ua: 'Українська',
39
+ },
40
+ from: 'De',
41
+ to: 'Hasta',
42
+ tts: 'Text-to-Speech',
43
+ state: 'Estado',
44
+ refresh: 'Actualizar',
45
+ retry: 'Repetir',
46
+ reset: 'Reiniciar',
47
+ downloadAll: 'Descargar todo',
48
+ warning: 'Aviso',
49
+ doNotSave: 'No guardar',
50
+ },
51
+ vocabulary: {
52
+ language: 'Idioma',
53
+ voice: 'Voz',
54
+ format: 'Formáto',
55
+ text: 'Texto',
56
+ yes: 'Sí',
57
+ no: 'No',
58
+ description: 'Descripción',
59
+ login: 'Acceso',
60
+ host: 'Host',
61
+ time: 'Tiempo',
62
+ channel: 'Canal',
63
+ file: 'Archivo',
64
+ logout: 'Salir',
65
+ priority: 'Prioridad',
66
+ variables: 'Intercambiable | Intercambiables',
67
+ type: 'Tipo',
68
+ tag: 'Etiqueta | Etiquetas',
69
+ output: 'Salida | Salidas',
70
+ values: 'Valor | Valores',
71
+ keys: 'Clave | Claves',
72
+ duration: 'Duración',
73
+ errors: 'Error | Errores',
74
+ },
75
+ // date-related texts
76
+ date: {
77
+ sec: 'Seg',
78
+ timezone: 'Zona horaria | Zonas horarias',
79
+ },
80
+ // describes Webitel system entities
81
+ objects: {
82
+ team: 'Equipo | Equipos',
83
+ supervisor: 'Supervisor | Supervisores',
84
+ auditor: 'Auditor | Auditores',
85
+ region: 'Región | Regiones',
86
+ queue: {
87
+ type: {
88
+ [QueueType.INBOUND_QUEUE]: 'Cola entrante',
89
+ [QueueType.OFFLINE_QUEUE]: 'Cola fuera de línea',
90
+ [QueueType.OUTBOUND_IVR_QUEUE]: 'IVR saliente',
91
+ [QueueType.PREDICTIVE_DIALER]: 'Marcador predictivo',
92
+ [QueueType.PROGRESSIVE_DIALER]: 'Marcador progresivo',
93
+ [QueueType.PREVIEW_DIALER]: 'Vista previa de llamadas',
94
+ [QueueType.CHAT_INBOUND_QUEUE]: 'Cola de chats',
95
+ [QueueType.INBOUND_JOB_QUEUE]: 'Cola de tareas entrante',
96
+ [QueueType.OUTBOUND_JOB_QUEUE]: 'Cola de tareas saliente',
97
+ },
98
+ },
99
+ agent: {
100
+ status: {
101
+ [AgentStatus.Online]: 'En línea',
102
+ [AgentStatus.Pause]: 'Pausa',
103
+ [AgentStatus.Offline]: 'Desconectado',
104
+ [snakeToCamel(AgentStatus.BreakOut)]: 'Pausa forzada',
105
+ },
106
+ },
107
+ flow: {
108
+ type: {
109
+ [EngineRoutingSchemaType.Chat]: 'Chat',
110
+ [EngineRoutingSchemaType.Voice]: 'Voz',
111
+ [EngineRoutingSchemaType.Service]: 'Servicio',
112
+ [EngineRoutingSchemaType.Processing]: 'Procesamiento',
113
+ },
114
+ },
115
+ },
116
+ channel: {
117
+ state: {
118
+ [ChannelState.Waiting]: 'Espera',
119
+ [ChannelState.Distribute]: 'Reservado',
120
+ [ChannelState.Offering]: 'Distribución',
121
+ [ChannelState.Answered]: 'Respondida',
122
+ [ChannelState.Active]: 'Activo',
123
+ [ChannelState.Bridged]: 'Conectado',
124
+ [ChannelState.Hold]: 'Espera',
125
+ [ChannelState.Missed]: 'Perdida',
126
+ [snakeToCamel(ChannelState.WrapTime)]: 'Post-procesamiento',
127
+ [ChannelState.Processing]: 'Procesamiento',
128
+ [ChannelState.Transfer]: 'Transferencia',
129
+ },
130
+ type: {
131
+ [ChannelType.Call]: 'Llamada',
132
+ [ChannelType.Email]: 'Correo electrónico',
133
+ [ChannelType.Chat]: 'Chat',
134
+ },
135
+ },
136
+ calls: {
137
+ direction: {
138
+ [CallDirection.Inbound]: 'Entrante | Entrantes',
139
+ [CallDirection.Outbound]: 'Saliente | Salientes',
140
+ },
141
+ },
142
+ // describes Webitel FRONTEND applications + their navs
143
+ WebitelApplications: {
144
+ [WebitelApplications.AGENT]: { name: 'Agent Workspace' },
145
+ [WebitelApplications.AUDIT]: {
146
+ name: 'Audit',
147
+ section: {
148
+ [AuditorSections.SCORECARDS]: 'Formularios',
149
+ },
150
+ },
151
+ [WebitelApplications.HISTORY]: { name: 'Call History' },
152
+ [WebitelApplications.ANALYTICS]: { name: 'Data Visualisation Tool' },
153
+ [WebitelApplications.SUPERVISOR]: {
154
+ name: 'Supervisor Workspace',
155
+ sections: {
156
+ [SupervisorSections.QUEUES]: 'Colas',
157
+ [SupervisorSections.AGENTS]: 'Operadores',
158
+ [SupervisorSections.ACTIVE_CALLS]: 'Llamadas activas',
159
+ },
160
+ },
161
+ [WebitelApplications.ADMIN]: {
162
+ name: 'Admin',
163
+ sections: {
164
+ [AdminSections.USERS]: 'Usuarios',
165
+ [AdminSections.LICENSE]: 'Licencias',
166
+ [AdminSections.DEVICES]: 'Dispositivos',
167
+ [AdminSections.FLOW]: 'Esquemas',
168
+ [AdminSections.DIALPLAN]: 'Reglas de la marcación saliente',
169
+ [AdminSections.GATEWAYS]: 'Puertas de enlace',
170
+ [AdminSections.CHATPLAN]: 'Reglas de enrutamiento de mensajes de texto',
171
+ [AdminSections.CHAT_GATEWAYS]: 'Puertas de enlace de texto',
172
+ [AdminSections.SKILLS]: 'Habilidades del operador',
173
+ [AdminSections.BUCKETS]: 'Cestas',
174
+ [AdminSections.MEDIA]: 'Archivos multimedia',
175
+ [AdminSections.BLACKLIST]: 'Listas de llamadas',
176
+ [AdminSections.CALENDARS]: 'Calendarios',
177
+ [AdminSections.REGIONS]: 'Ubicación',
178
+ [AdminSections.COMMUNICATIONS]: 'Tipos de comunicación',
179
+ [AdminSections.PAUSE_CAUSE]: 'Estados del operador',
180
+ [AdminSections.AGENTS]: 'Operadores',
181
+ [AdminSections.TEAMS]: 'Equipos',
182
+ [AdminSections.RESOURCES]: 'Recursos',
183
+ [AdminSections.RESOURCE_GROUPS]: 'Grupos de recursos',
184
+ [AdminSections.QUEUES]: 'Colas',
185
+ [AdminSections.STORAGE]: 'Almacenamiento',
186
+ [AdminSections.COGNITIVE_PROFILES]: 'Perfiles de voz',
187
+ [AdminSections.EMAIL_PROFILES]: 'Perfiles de correo electrónico',
188
+ [AdminSections.IMPORT_CSV]: 'Importación de datos de archivos CSV',
189
+ [AdminSections.TRIGGERS]: 'Activadores',
190
+ [AdminSections.ROLES]: 'Funciones',
191
+ [AdminSections.OBJECTS]: 'Secciones',
192
+ },
193
+ },
194
+ },
195
+ validation: {
196
+ required: 'Campo requerido',
197
+ numeric: 'Valores numéricos requeridos',
198
+ email: 'Correo electrónico requerido',
199
+ gatewayHostValidator: 'IPv4 o FQDN requerido',
200
+ sipAccountValidator: 'Cuenta SIP requerida',
201
+ ipValidator: 'IPv4 requerido',
202
+ macValidator: 'dirección MAC requerida',
203
+ minValue: 'El valor no debe ser menor que',
204
+ maxValue: 'El valor no debe ser mayor que',
205
+ sameAs: 'Contraseña no válida',
206
+ requiredArrayValue: 'El campo no debe estar vacío',
207
+ minLength: 'El número de caracteres no debe ser menor que',
208
+ url: 'Se debe ingresar una URL válida',
209
+ },
210
+ webitelUI: {
211
+ searchBar: {
212
+ placeholder: 'Búsqueda',
213
+ },
214
+ timepicker: {
215
+ hour: 'Hora:',
216
+ min: 'Min:',
217
+ sec: 'Seg:',
218
+ },
219
+ datetimepicker: {
220
+ lastHour: 'Última hora',
221
+ lastDay: 'Último día',
222
+ },
223
+ pagination: {
224
+ sizeText: 'Registros en la página:',
225
+ prev: 'Atrás',
226
+ next: 'Adelante',
227
+ },
228
+ appNavigator: {
229
+ title: 'Aplicaciones de Webitel',
230
+ admin: 'Admin',
231
+ agent: 'Agent Workspace',
232
+ supervisor: 'Supervisor Workspace',
233
+ audit: 'Audit',
234
+ history: 'Call History',
235
+ grafana: 'Grafana',
236
+ },
237
+ headerActions: {
238
+ account: 'Cuenta',
239
+ docs: 'Documentación',
240
+ settings: 'Ajustes',
241
+ logout: 'Salir',
242
+ buildVersion: 'Versión de compilación',
243
+ },
244
+ tableActions: {
245
+ filterReset: 'Reiniciar filtros',
246
+ columnSelect: 'Agregar columnas',
247
+ refreshTable: 'Actualizar',
248
+ expandFilters: 'Expandir filtros',
249
+ },
250
+ tableColumnSelect: {
251
+ title: 'Seleccione columnas mostradas',
252
+ },
253
+ statusSelect: {
254
+ online: 'En línea',
255
+ pause: 'Pausa',
256
+ offline: 'Desconectado',
257
+ breakOut: 'Pausa forzada',
258
+ },
259
+ table: {
260
+ tableCells: {
261
+ deleteActionHint: 'Eliminar',
262
+ editActionHint: 'Editar',
263
+ },
264
+ },
265
+ errorPages: {
266
+ goBack: 'Regresar',
267
+ page403: {
268
+ title: 'Sin acceso',
269
+ text: 'Lo sentimos, no tiene suficientes derechos de acceso para ver esta página',
270
+ },
271
+ page404: {
272
+ title: 'Parece que se ha perdido',
273
+ text: 'Lo sentimos, no podemos encontrar lo que está buscando',
274
+ },
275
+ },
276
+ copyAction: {
277
+ copy: 'Copiar',
278
+ copied: '¡Copiado!',
279
+ },
280
+ },
281
+ };
282
+
@@ -1,10 +1,12 @@
1
1
  import { createI18n } from 'vue-i18n';
2
2
  import en from './en/en';
3
+ import en from './es/es';
3
4
  import ru from './ru/ru';
4
5
  import ua from './ua/ua';
5
6
 
6
7
  const messages = {
7
8
  en,
9
+ es,
8
10
  ru,
9
11
  ua,
10
12
  };
@@ -33,6 +33,7 @@ export default {
33
33
  generate: 'Сгенерировать',
34
34
  lang: {
35
35
  en: 'English',
36
+ es: 'Español',
36
37
  ru: 'Русский',
37
38
  ua: 'Українська',
38
39
  },
@@ -45,6 +46,8 @@ export default {
45
46
  downloadAll: 'Скачать всё',
46
47
  warning: 'Предупреждение',
47
48
  doNotSave: 'Не сохранять',
49
+ required: 'Обязательный',
50
+ copy: 'Скопировать',
48
51
  },
49
52
  vocabulary: {
50
53
  language: 'Язык',
@@ -276,5 +279,15 @@ export default {
276
279
  copy: 'Копировать',
277
280
  copied: 'Скопировано!',
278
281
  },
282
+ auditForm: {
283
+ question: 'Критерий',
284
+ option: 'Вариант | Варианты',
285
+ score: 'Бал | Балы',
286
+ addQuestion: 'Добавить критерий',
287
+ type: {
288
+ options: 'Критерии',
289
+ score: 'Бал',
290
+ },
291
+ },
279
292
  },
280
293
  };
@@ -33,6 +33,7 @@ export default {
33
33
  generate: 'Згенерувати',
34
34
  lang: {
35
35
  en: 'English',
36
+ es: 'Español',
36
37
  ru: 'Русский',
37
38
  ua: 'Українська',
38
39
  },
@@ -46,6 +47,8 @@ export default {
46
47
  downloadAll: 'Завантажити все',
47
48
  warning: 'Попередження',
48
49
  doNotSave: 'Не зберігати',
50
+ required: 'Обов\'язковий',
51
+ copy: 'Скопіювати',
49
52
  },
50
53
  vocabulary: {
51
54
  language: 'Мова',
@@ -276,5 +279,15 @@ export default {
276
279
  copy: 'Копіювати',
277
280
  copied: 'Скопійовано!',
278
281
  },
282
+ auditForm: {
283
+ question: 'Критерій',
284
+ option: 'Варіант | Варіанти',
285
+ score: 'Бал | Бали',
286
+ addQuestion: 'Додати критерій',
287
+ type: {
288
+ options: 'Критерії',
289
+ score: 'Бал',
290
+ },
291
+ },
279
292
  },
280
293
  };
@@ -19,21 +19,21 @@ export default {
19
19
  validationText() {
20
20
  let validationText = '';
21
21
  if (this.isValidation && this.invalid) {
22
- if (this.v.required === false) validationText = this.$t('validation.required');
23
- else if (this.v.numeric === false) validationText = this.$t('validation.numeric');
24
- else if (this.v.email === false) validationText = this.$t('validation.email');
25
- else if (this.v.gatewayHostValidator === false) validationText = this.$t('validation.gatewayHostValidator');
26
- else if (this.v.ipValidator === false) validationText = this.$t('validation.ipValidator');
27
- else if (this.v.macValidator === false) validationText = this.$t('validation.macValidator');
28
- else if (this.v.minValue === false) validationText = `${this.$t('validation.minValue')} ${this.v.$params.minValue.min}`;
29
- else if (this.v.maxValue === false) validationText = `${this.$t('validation.maxValue')} ${this.v.$params.maxValue.max}`;
30
- else if (this.v.sipAccountValidator === false) validationText = this.$t('validation.sipAccountValidator');
31
- else if (this.v.minLength === false) validationText = `${this.$t('validation.minLength')} ${this.v.$params.minLength.min}`;
32
- else if (this.v.url === false) validationText = `${this.$t('validation.url')}`;
22
+ if (this.v.required.$invalid) validationText = this.$t('validation.required');
23
+ else if (this.v.numeric.$invalid) validationText = this.$t('validation.numeric');
24
+ else if (this.v.email.$invalid) validationText = this.$t('validation.email');
25
+ else if (this.v.gatewayHostValidator.$invalid) validationText = this.$t('validation.gatewayHostValidator');
26
+ else if (this.v.ipValidator.$invalid) validationText = this.$t('validation.ipValidator');
27
+ else if (this.v.macValidator.$invalid) validationText = this.$t('validation.macValidator');
28
+ else if (this.v.minValue.$invalid) validationText = `${this.$t('validation.minValue')} ${this.v.$params.minValue.min}`;
29
+ else if (this.v.maxValue.$invalid) validationText = `${this.$t('validation.maxValue')} ${this.v.$params.maxValue.max}`;
30
+ else if (this.v.sipAccountValidator.$invalid) validationText = this.$t('validation.sipAccountValidator');
31
+ else if (this.v.minLength.$invalid) validationText = `${this.$t('validation.minLength')} ${this.v.$params.minLength.min}`;
32
+ else if (this.v.url.$invalid) validationText = `${this.$t('validation.url')}`;
33
33
  }
34
34
  // eslint-disable-next-line no-restricted-syntax
35
35
  for (const { name, text } of this.customValidators) {
36
- if (this.v[name] === false) validationText = text;
36
+ if (this.v[name].$invalid) validationText = text;
37
37
  }
38
38
  return validationText;
39
39
  },
@@ -0,0 +1,14 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import AuditFormQuestionReadWrapper from '../audit-form-question-read-wrapper.vue';
3
+
4
+ describe('AuditFormQuestionReadWrapper', () => {
5
+ it('renders a component', () => {
6
+ const wrapper = shallowMount(AuditFormQuestionReadWrapper, {
7
+ props: {
8
+ question: {},
9
+ result: {},
10
+ },
11
+ });
12
+ expect(wrapper.isVisible()).toBe(true);
13
+ });
14
+ });
@@ -0,0 +1,59 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import {
3
+ generateQuestionOptionsSchema
4
+ } from '../../schemas/AuditFormQuestionOptionsSchema';
5
+ import AuditFormQuestionWriteWrapper from '../audit-form-question-write-wrapper.vue';
6
+ import { generateQuestionSchema } from '../../schemas/AuditFormQuestionSchema';
7
+ import { generateQuestionScoreSchema } from '../../schemas/AuditFormQuestionScoreSchema';
8
+
9
+ const v = { question: {} };
10
+
11
+ describe('AuditFormQuestionWriteWrapper', () => {
12
+ it('renders a component', () => {
13
+ const wrapper = shallowMount(AuditFormQuestionWriteWrapper, {
14
+ props: {
15
+ question: {},
16
+ v,
17
+ },
18
+ });
19
+ expect(wrapper.isVisible()).toBe(true);
20
+ });
21
+ it('correctly changes question', () => {
22
+ const question = generateQuestionSchema();
23
+ const wrapper = shallowMount(AuditFormQuestionWriteWrapper, {
24
+ props: {
25
+ question,
26
+ v,
27
+ },
28
+ });
29
+ wrapper.findComponent({ name: 'wt-switcher' }).vm.$emit('change', !question.required);
30
+ expect(wrapper.emitted()['change:question'][0][0].required)
31
+ .toBe(!question.required);
32
+ });
33
+ it('correctly changes question type to Score', () => {
34
+ const question = {};
35
+ const wrapper = shallowMount(AuditFormQuestionWriteWrapper, {
36
+ props: {
37
+ question,
38
+ v,
39
+ },
40
+ });
41
+ wrapper.find('.audit-form-question-write-content-question')
42
+ .findComponent({ name: 'wt-select' }).vm.$emit('input', { value: 'score' });
43
+ expect(wrapper.emitted()['change:question'][0][0])
44
+ .toEqual(generateQuestionScoreSchema());
45
+ });
46
+ it('correctly changes question type to Options', () => {
47
+ const question = {};
48
+ const wrapper = shallowMount(AuditFormQuestionWriteWrapper, {
49
+ props: {
50
+ question,
51
+ v,
52
+ },
53
+ });
54
+ wrapper.find('.audit-form-question-write-content-question')
55
+ .findComponent({ name: 'wt-select' }).vm.$emit('input', { value: 'options' });
56
+ expect(wrapper.emitted()['change:question'][0][0])
57
+ .toEqual(generateQuestionOptionsSchema());
58
+ });
59
+ });
@@ -0,0 +1,14 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import AuditFormQuestion from '../audit-form-question.vue';
3
+
4
+ describe('AuditFormQuestion', () => {
5
+ it('renders a component', () => {
6
+ const wrapper = shallowMount(AuditFormQuestion, {
7
+ props: {
8
+ question: {},
9
+ result: {},
10
+ },
11
+ });
12
+ expect(wrapper.isVisible()).toBe(true);
13
+ });
14
+ });
@@ -0,0 +1,66 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import AuditForm from '../audit-form.vue';
3
+ import { generateQuestionSchema } from '../../schemas/AuditFormQuestionSchema';
4
+
5
+ import {
6
+ useDestroyableSortable,
7
+ } from '../../composables/useDestroyableSortable';
8
+
9
+ jest.mock('../../composables/useDestroyableSortable');
10
+
11
+ useDestroyableSortable.mockImplementation(() => ({}));
12
+
13
+ describe('AuditForm', () => {
14
+ it('renders a component', () => {
15
+ const wrapper = shallowMount(AuditForm, {
16
+ props: {
17
+ mode: '',
18
+ questions: [],
19
+ },
20
+ });
21
+ expect(wrapper.isVisible()).toBe(true);
22
+ });
23
+ it('add question button triggers update question event', () => {
24
+ const wrapper = shallowMount(AuditForm, {
25
+ props: {
26
+ mode: 'create',
27
+ questions: [],
28
+ },
29
+ });
30
+ wrapper.findComponent('.audit-form__add-button').vm.$emit('click');
31
+ expect(wrapper.emitted()['update:questions'][0][0])
32
+ .toEqual([generateQuestionSchema()]);
33
+ });
34
+ it('delete event from child question emits update without passed question', () => {
35
+ const wrapper = shallowMount(AuditForm, {
36
+ props: {
37
+ mode: 'create',
38
+ questions: [generateQuestionSchema()],
39
+ },
40
+ });
41
+ wrapper.findComponent({ name: 'audit-form-question' }).vm.$emit('delete', { key: 0 });
42
+ expect(wrapper.emitted()['update:questions'][0][0])
43
+ .toEqual([]);
44
+ });
45
+ it('copy event from child question emits update with duplicated questions', () => {
46
+ const question = generateQuestionSchema();
47
+ const wrapper = shallowMount(AuditForm, {
48
+ props: {
49
+ mode: 'create',
50
+ questions: [question],
51
+ },
52
+ });
53
+ wrapper.findComponent({ name: 'audit-form-question' }).vm.$emit('copy', { question, key: 0 });
54
+ expect(wrapper.emitted()['update:questions'][0][0])
55
+ .toEqual([question, question]);
56
+ });
57
+ it('initializes result depending on passed questions', () => {
58
+ const wrapper = shallowMount(AuditForm, {
59
+ props: {
60
+ mode: 'fill',
61
+ questions: [generateQuestionSchema(), generateQuestionSchema(), generateQuestionSchema()],
62
+ },
63
+ });
64
+ expect(wrapper.emitted()['update:result'][0][0]).toEqual([null, null, null]);
65
+ });
66
+ });