@webitel/api-services 26.8.7 → 26.8.8
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 +1 -1
- package/src/api/clients/queues/__tests__/queueHooksSkillsEnabled.spec.ts +84 -0
- package/src/api/clients/queues/queueHooks.ts +3 -0
- package/src/api/clients/queues/queueSkills.ts +3 -0
- package/src/validations/queueHook/__tests__/queueHook.validations.spec.ts +31 -0
- package/src/validations/queueHook/queueHook.validations.ts +1 -1
- package/src/validations/queueSkill/__tests__/queueSkill.validations.spec.ts +27 -0
- package/src/validations/queueSkill/queueSkill.validations.ts +1 -1
- package/types/.tsbuildinfo +1 -1
- package/types/validations/queueHook/queueHook.validations.d.ts +1 -1
- package/types/validations/queueSkill/queueSkill.validations.d.ts +2 -2
package/package.json
CHANGED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
const readQueueHook = vi.fn();
|
|
4
|
+
const readQueueSkill = vi.fn();
|
|
5
|
+
|
|
6
|
+
vi.mock('../../../../gen-wire', () => ({
|
|
7
|
+
getQueueHookService: () => ({
|
|
8
|
+
readQueueHook,
|
|
9
|
+
}),
|
|
10
|
+
getQueueSkillService: () => ({
|
|
11
|
+
readQueueSkill,
|
|
12
|
+
}),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
const { QueueHooksAPI } = await import('../queueHooks');
|
|
16
|
+
const { QueueSkillsAPI } = await import('../queueSkills');
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Protobuf omits `enabled` when it is false, so a disabled record reads back
|
|
20
|
+
* without the field. The card store seeds anything missing from the schema,
|
|
21
|
+
* where `enabled` defaults to `true` for newly added records — so `get` has to
|
|
22
|
+
* spell the false out, or an untouched save would re-enable the record.
|
|
23
|
+
*/
|
|
24
|
+
describe('reading a disabled queue hook / skill', () => {
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
readQueueHook.mockReset();
|
|
27
|
+
readQueueSkill.mockReset();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('spells out enabled: false for a hook that omits it', async () => {
|
|
31
|
+
readQueueHook.mockResolvedValue({
|
|
32
|
+
data: {
|
|
33
|
+
id: 40,
|
|
34
|
+
event: 'bridged',
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
await expect(
|
|
39
|
+
QueueHooksAPI.get({
|
|
40
|
+
parentId: '208',
|
|
41
|
+
itemId: '40',
|
|
42
|
+
}),
|
|
43
|
+
).resolves.toMatchObject({
|
|
44
|
+
enabled: false,
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('spells out enabled: false for a skill that omits it', async () => {
|
|
49
|
+
readQueueSkill.mockResolvedValue({
|
|
50
|
+
data: {
|
|
51
|
+
id: 7,
|
|
52
|
+
lvl: 10,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
await expect(
|
|
57
|
+
QueueSkillsAPI.get({
|
|
58
|
+
parentId: '208',
|
|
59
|
+
itemId: '7',
|
|
60
|
+
}),
|
|
61
|
+
).resolves.toMatchObject({
|
|
62
|
+
enabled: false,
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('keeps enabled: true as sent', async () => {
|
|
67
|
+
readQueueHook.mockResolvedValue({
|
|
68
|
+
data: {
|
|
69
|
+
id: 41,
|
|
70
|
+
event: 'missed',
|
|
71
|
+
enabled: true,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
await expect(
|
|
76
|
+
QueueHooksAPI.get({
|
|
77
|
+
parentId: '208',
|
|
78
|
+
itemId: '41',
|
|
79
|
+
}),
|
|
80
|
+
).resolves.toMatchObject({
|
|
81
|
+
enabled: true,
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getDefaultsFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { queueHookSchema } from '../queueHook.validations';
|
|
5
|
+
|
|
6
|
+
describe('queueHookSchema', () => {
|
|
7
|
+
/**
|
|
8
|
+
* The card store seeds a new item from the schema defaults, so a hook added
|
|
9
|
+
* from the queue card must come out enabled — as it did before the pinia
|
|
10
|
+
* migration replaced the vuex `resettableItemState`.
|
|
11
|
+
*/
|
|
12
|
+
it('defaults a new hook to enabled', () => {
|
|
13
|
+
expect(getDefaultsFromZodSchema(queueHookSchema, {})).toMatchObject({
|
|
14
|
+
enabled: true,
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('keeps a disabled hook disabled', () => {
|
|
19
|
+
const result = queueHookSchema.safeParse({
|
|
20
|
+
event: 'joined',
|
|
21
|
+
schema: {
|
|
22
|
+
id: '1',
|
|
23
|
+
name: 'flow',
|
|
24
|
+
},
|
|
25
|
+
enabled: false,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
expect(result.success).toBe(true);
|
|
29
|
+
expect(result.data?.enabled).toBe(false);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getDefaultsFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { queueSkillSchema } from '../queueSkill.validations';
|
|
5
|
+
|
|
6
|
+
describe('queueSkillSchema', () => {
|
|
7
|
+
/** see the hook schema spec — same pre-migration default */
|
|
8
|
+
it('defaults a new skill to enabled', () => {
|
|
9
|
+
expect(getDefaultsFromZodSchema(queueSkillSchema, {})).toMatchObject({
|
|
10
|
+
enabled: true,
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('keeps a disabled skill disabled', () => {
|
|
15
|
+
const result = queueSkillSchema.safeParse({
|
|
16
|
+
skill: {
|
|
17
|
+
id: '1',
|
|
18
|
+
name: 'skill',
|
|
19
|
+
},
|
|
20
|
+
lvl: 1,
|
|
21
|
+
enabled: false,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
expect(result.success).toBe(true);
|
|
25
|
+
expect(result.data?.enabled).toBe(false);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -11,7 +11,7 @@ export const queueSkillSchemaBase = z.object({
|
|
|
11
11
|
minCapacity: z.number().min(0).max(100).optional(),
|
|
12
12
|
maxCapacity: z.number().min(0).max(100).optional(),
|
|
13
13
|
buckets: z.array(flexibleLookupSchema).optional(),
|
|
14
|
-
enabled: z.boolean().
|
|
14
|
+
enabled: z.boolean().default(true),
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
/**
|