Skip to content

Commit

Permalink
regression: Use visitor activity to define if its contact is unknown (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusbsilva137 authored Nov 26, 2024
1 parent bef9138 commit e72e9d6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const dataMap: [Partial<ILivechatVisitor>, IOmnichannelSource, CreateContactPara
{
_id: 'visitor1',
username: 'Username',
activity: ['2024-11'],
lastChat: {
_id: 'last-chat-id',
ts: testDate,
Expand Down Expand Up @@ -134,6 +135,41 @@ const dataMap: [Partial<ILivechatVisitor>, IOmnichannelSource, CreateContactPara
contactManager: undefined,
},
],

[
{
_id: 'visitor1',
username: 'Username',
activity: [],
},
{
type: OmnichannelSourceType.WIDGET,
},
{
name: 'Username',
emails: undefined,
phones: undefined,
unknown: true,
channels: [
{
name: 'sms',
visitor: {
visitorId: 'visitor1',
source: {
type: OmnichannelSourceType.WIDGET,
},
},
blocked: false,
verified: false,
details: {
type: OmnichannelSourceType.WIDGET,
},
},
],
customFields: undefined,
contactManager: undefined,
},
],
];

describe('mapVisitorToContact', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function mapVisitorToContact(visitor: ILivechatVisitor, source: IOm
name: visitor.name || visitor.username,
emails: visitor.visitorEmails?.map(({ address }) => address),
phones: visitor.phone?.map(({ phoneNumber }) => phoneNumber),
unknown: true,
unknown: !visitor.activity || visitor.activity.length === 0,
channels: [
{
name: source.label || source.type.toString(),
Expand Down

0 comments on commit e72e9d6

Please sign in to comment.