|
1 | | -// import { logWithBreaks } from './utils/config'; |
2 | | -// import { Client } from 'intercom-client'; |
3 | | - |
4 | | -// // TIP: get client_matches > user_id field from ping request here: https://app.intercom.io/client/test/ecahpwf5 |
5 | | - |
6 | | -// const visitorForDelete = { |
7 | | -// visitorId: '6202ae4c4caf6a35860f843c', // those has to be updated every time before running QA script |
8 | | -// userId: '0a5c7c01-db82-4794-96ef-ab26c855a88f', // those has to be updated every time before running QA script |
9 | | -// }; |
10 | | - |
11 | | -// const visitorForConvertingToContact = { |
12 | | -// visitorId: '6202ae94928cb83fbca343f1', // those has to be updated every time before running QA script |
13 | | -// }; |
14 | | - |
15 | | -// const testVisitors = async (client: Client) => { |
16 | | -// const actions = actionsWithData( |
17 | | -// client, |
18 | | -// data( |
19 | | -// visitorForDelete.visitorId, |
20 | | -// visitorForDelete.userId, |
21 | | -// visitorForConvertingToContact.visitorId |
22 | | -// ) |
23 | | -// ); |
24 | | - |
25 | | -// for (const action of actions) { |
26 | | -// try { |
27 | | -// const response = await action.promise; |
28 | | -// logWithBreaks(response, action.name); |
29 | | -// } catch (e) { |
30 | | -// logWithBreaks(e, action.name); |
31 | | -// throw e; |
32 | | -// } |
33 | | -// } |
34 | | -// }; |
35 | | - |
36 | | -// const data = ( |
37 | | -// idForDelete: string, |
38 | | -// userIdForDelete: string, |
39 | | -// idForConvertingToContact: string |
40 | | -// ) => ({ |
41 | | -// findById: { id: idForDelete }, |
42 | | -// findByUserId: { userId: userIdForDelete }, |
43 | | -// update: { |
44 | | -// userId: userIdForDelete, |
45 | | -// name: 'Winston Smith', |
46 | | -// custom_attributes: {}, |
47 | | -// }, |
48 | | -// delete: { |
49 | | -// id: idForDelete, |
50 | | -// }, |
51 | | -// mergeToContact: { |
52 | | -// visitor: { |
53 | | -// id: idForConvertingToContact, |
54 | | -// }, |
55 | | -// user: { |
56 | | - |
57 | | -// }, |
58 | | -// type: 'user', |
59 | | -// }, |
60 | | -// }); |
61 | | - |
62 | | -// const actionsWithData = (client: Client, data: any) => [ |
63 | | -// { promise: client.visitors.find(data.findById), name: 'find by id' }, |
64 | | -// { |
65 | | -// promise: client.visitors.find(data.findByUserId), |
66 | | -// name: 'find by user id', |
67 | | -// }, |
68 | | -// { promise: client.visitors.update(data.update), name: 'update' }, |
69 | | -// { promise: client.visitors.delete(data.delete), name: 'delete' }, |
70 | | -// { |
71 | | -// promise: client.visitors.mergeToContact(data.mergeToContact), |
72 | | -// name: 'merge to contaact', |
73 | | -// }, |
74 | | -// ]; |
75 | | - |
76 | | -// (async () => { |
77 | | -// const token = |
78 | | - |
79 | | -// const client = new Client({ tokenAuth: { token } }); |
80 | | - |
81 | | -// try { |
82 | | -// await testVisitors(client); |
83 | | -// } catch (e) { |
84 | | -// console.dir(e, { depth: null }); |
85 | | -// return; |
86 | | -// } |
87 | | -// })(); |
| 1 | +import { Client, Role } from '../../dist'; |
| 2 | +import assert from 'assert'; |
| 3 | +import { token } from './utils/config'; |
| 4 | + |
| 5 | +// Skip by default, because there is no automation yet |
| 6 | +describe.skip('Visitors', () => { |
| 7 | + // Info: should be set manually. Find a way to automate it. |
| 8 | + // Tip: headless browser to visit test application and get visitorId from ping request. |
| 9 | + const visitorId = '0'; |
| 10 | + const userId = '0'; |
| 11 | + |
| 12 | + const client = new Client({ tokenAuth: { token } }); |
| 13 | + |
| 14 | + it('find by id', async () => { |
| 15 | + const response = await client.visitors.find({ id: visitorId }); |
| 16 | + |
| 17 | + assert.notEqual(response, undefined); |
| 18 | + }); |
| 19 | + it('find by user id', async () => { |
| 20 | + const response = await client.visitors.find({ userId }); |
| 21 | + |
| 22 | + assert.notEqual(response, undefined); |
| 23 | + }); |
| 24 | + it('update', async () => { |
| 25 | + const response = await client.visitors.update({ |
| 26 | + userId, |
| 27 | + name: 'Winston Smith', |
| 28 | + }); |
| 29 | + |
| 30 | + assert.notEqual(response, undefined); |
| 31 | + }); |
| 32 | + it('delete', async () => { |
| 33 | + const response = await client.visitors.delete({ |
| 34 | + id: visitorId, |
| 35 | + }); |
| 36 | + |
| 37 | + assert.notEqual(response, undefined); |
| 38 | + }); |
| 39 | + it('mergeToContact', async () => { |
| 40 | + const response = await client.visitors.mergeToContact({ |
| 41 | + visitor: { |
| 42 | + id: visitorId, |
| 43 | + }, |
| 44 | + user: { |
| 45 | + |
| 46 | + } as any, |
| 47 | + type: Role.USER, |
| 48 | + }); |
| 49 | + |
| 50 | + assert.notEqual(response, undefined); |
| 51 | + }); |
| 52 | +}); |
0 commit comments