@webitel/ui-datalist 26.8.26 → 26.8.27
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,9 +1,14 @@
|
|
|
1
1
|
import { useRegleSchema } from '@regle/schemas';
|
|
2
2
|
import { getQueueDefaults } from '@webitel/api-services/api';
|
|
3
3
|
import { QueueType } from '@webitel/api-services/enums';
|
|
4
|
-
import {
|
|
4
|
+
import { getDefaultsFromZodSchema } from '@webitel/api-services/utils';
|
|
5
|
+
import {
|
|
6
|
+
caseCloseFieldsChecks,
|
|
7
|
+
caseSchema,
|
|
8
|
+
queueSchema,
|
|
9
|
+
} from '@webitel/api-services/validations';
|
|
5
10
|
import { describe, expect, it } from 'vitest';
|
|
6
|
-
import { effectScope, ref } from 'vue';
|
|
11
|
+
import { effectScope, nextTick, ref } from 'vue';
|
|
7
12
|
|
|
8
13
|
/**
|
|
9
14
|
* A card whose required-ness comes from a root `superRefine` — the queue, whose
|
|
@@ -93,3 +98,39 @@ describe('card validation of a root-level required rule', () => {
|
|
|
93
98
|
expect(rootError).toBe(false);
|
|
94
99
|
});
|
|
95
100
|
});
|
|
101
|
+
|
|
102
|
+
describe('card validation of the close reason on a new final case', () => {
|
|
103
|
+
const caseCardSchema = caseSchema
|
|
104
|
+
.passthrough()
|
|
105
|
+
.check(...caseCloseFieldsChecks);
|
|
106
|
+
|
|
107
|
+
it('reports the missing close reason on the field', async () => {
|
|
108
|
+
const state = ref(getDefaultsFromZodSchema(caseCardSchema, {}) as never);
|
|
109
|
+
const scope = effectScope(true);
|
|
110
|
+
// biome-ignore lint/suspicious/noExplicitAny: regle's inferred state type
|
|
111
|
+
let r$: any;
|
|
112
|
+
|
|
113
|
+
scope.run(() => {
|
|
114
|
+
({ r$ } = useRegleSchema(state, caseCardSchema as never, {
|
|
115
|
+
autoDirty: true,
|
|
116
|
+
syncState: {
|
|
117
|
+
onValidate: true,
|
|
118
|
+
},
|
|
119
|
+
}));
|
|
120
|
+
});
|
|
121
|
+
await nextTick();
|
|
122
|
+
|
|
123
|
+
(state.value as Record<string, unknown>).statusCondition = {
|
|
124
|
+
id: '1',
|
|
125
|
+
final: true,
|
|
126
|
+
};
|
|
127
|
+
await nextTick();
|
|
128
|
+
|
|
129
|
+
const result = await r$.$validate();
|
|
130
|
+
|
|
131
|
+
expect(result.valid).toBe(false);
|
|
132
|
+
expect(r$.$fields.closeReason.$error).toBe(true);
|
|
133
|
+
expect(r$.$fields.closeReason.$errors).toHaveLength(1);
|
|
134
|
+
expect(r$.$fields.closeResult.$error).toBe(true);
|
|
135
|
+
});
|
|
136
|
+
});
|