@webitel/api-services 26.8.46 → 26.8.47

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": "@webitel/api-services",
3
- "version": "26.8.46",
3
+ "version": "26.8.47",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,67 @@
1
+ import { getDefaultsFromZodSchema } from '@webitel/api-services/gen/utils';
2
+ import { describe, expect, it } from 'vitest';
3
+
4
+ import { agentSkillSchema } from '../agentSkill.validations';
5
+
6
+ const filledSkill = {
7
+ id: '1',
8
+ name: 'English',
9
+ };
10
+
11
+ describe('agentSkillSchema', () => {
12
+ it('seeds a new skill with the defaults the form expects', () => {
13
+ expect(getDefaultsFromZodSchema(agentSkillSchema, {})).toMatchObject({
14
+ capacity: 10,
15
+ enabled: true,
16
+ });
17
+ });
18
+
19
+ it('keeps values already on the draft', () => {
20
+ expect(
21
+ getDefaultsFromZodSchema(agentSkillSchema, {
22
+ skill: filledSkill,
23
+ capacity: 42,
24
+ enabled: false,
25
+ }),
26
+ ).toMatchObject({
27
+ skill: filledSkill,
28
+ capacity: 42,
29
+ enabled: false,
30
+ });
31
+ });
32
+
33
+ it('requires a skill', () => {
34
+ const result = agentSkillSchema.safeParse({
35
+ capacity: 10,
36
+ });
37
+
38
+ expect(result.success).toBe(false);
39
+ expect(result.error?.issues.map((issue) => issue.path.join('.'))).toContain(
40
+ 'skill',
41
+ );
42
+ });
43
+
44
+ it('rejects capacity outside 0-100', () => {
45
+ const tooHigh = agentSkillSchema.safeParse({
46
+ skill: filledSkill,
47
+ capacity: 101,
48
+ });
49
+ const tooLow = agentSkillSchema.safeParse({
50
+ skill: filledSkill,
51
+ capacity: -1,
52
+ });
53
+
54
+ expect(tooHigh.success).toBe(false);
55
+ expect(tooLow.success).toBe(false);
56
+ });
57
+
58
+ it('accepts a valid skill', () => {
59
+ expect(
60
+ agentSkillSchema.safeParse({
61
+ skill: filledSkill,
62
+ capacity: 50,
63
+ enabled: true,
64
+ }).success,
65
+ ).toBe(true);
66
+ });
67
+ });
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+
3
+ import { filledLookupSchema } from '../_shared/lookup.validations';
4
+
5
+ export const agentSkillSchema = z.object({
6
+ skill: filledLookupSchema,
7
+ capacity: z.number().min(0).max(100).default(10),
8
+ enabled: z.boolean().default(true),
9
+ });
@@ -5,6 +5,7 @@ export * from './_shared/lookup.validations';
5
5
  export * from './_shared/phoneNumber.validations';
6
6
  export * from './_shared/variablePair.validations';
7
7
  export * from './adjunctType/adjunctType.validations';
8
+ export * from './agentSkill/agentSkill.validations';
8
9
  export * from './auditForm/auditForm.validations';
9
10
  export * from './bucket/bucket.validations';
10
11
  export * from './calendar/calendar.validations';