@@ -5,7 +5,7 @@ import sinon from 'sinon';
55
66const modelsMock = {
77 LivechatContacts : {
8- findOneById : sinon . stub ( ) ,
8+ findOneEnabledById : sinon . stub ( ) ,
99 updateContact : sinon . stub ( ) ,
1010 } ,
1111 Settings : {
@@ -24,13 +24,13 @@ const { resolveContactConflicts } = proxyquire.noCallThru().load('./resolveConta
2424
2525describe ( 'resolveContactConflicts' , ( ) => {
2626 beforeEach ( ( ) => {
27- modelsMock . LivechatContacts . findOneById . reset ( ) ;
27+ modelsMock . LivechatContacts . findOneEnabledById . reset ( ) ;
2828 modelsMock . Settings . incrementValueById . reset ( ) ;
2929 modelsMock . LivechatContacts . updateContact . reset ( ) ;
3030 } ) ;
3131
3232 it ( 'should update the contact with the resolved custom field' , async ( ) => {
33- modelsMock . LivechatContacts . findOneById . resolves ( {
33+ modelsMock . LivechatContacts . findOneEnabledById . resolves ( {
3434 _id : 'contactId' ,
3535 customFields : { customField : 'newValue' } ,
3636 conflictingFields : [ { field : 'customFields.customField' , value : 'oldValue' } ] ,
@@ -44,7 +44,7 @@ describe('resolveContactConflicts', () => {
4444
4545 const result = await resolveContactConflicts ( { contactId : 'contactId' , customField : { customField : 'newValue' } } ) ;
4646
47- expect ( modelsMock . LivechatContacts . findOneById . getCall ( 0 ) . args [ 0 ] ) . to . be . equal ( 'contactId' ) ;
47+ expect ( modelsMock . LivechatContacts . findOneEnabledById . getCall ( 0 ) . args [ 0 ] ) . to . be . equal ( 'contactId' ) ;
4848
4949 expect ( modelsMock . Settings . incrementValueById . getCall ( 0 ) . args [ 0 ] ) . to . be . equal ( 'Livechat_conflicting_fields_counter' ) ;
5050 expect ( modelsMock . Settings . incrementValueById . getCall ( 0 ) . args [ 1 ] ) . to . be . equal ( 1 ) ;
@@ -59,7 +59,7 @@ describe('resolveContactConflicts', () => {
5959 } ) ;
6060
6161 it ( 'should update the contact with the resolved name' , async ( ) => {
62- modelsMock . LivechatContacts . findOneById . resolves ( {
62+ modelsMock . LivechatContacts . findOneEnabledById . resolves ( {
6363 _id : 'contactId' ,
6464 name : 'Old Name' ,
6565 customFields : { customField : 'newValue' } ,
@@ -75,7 +75,7 @@ describe('resolveContactConflicts', () => {
7575
7676 const result = await resolveContactConflicts ( { contactId : 'contactId' , name : 'New Name' } ) ;
7777
78- expect ( modelsMock . LivechatContacts . findOneById . getCall ( 0 ) . args [ 0 ] ) . to . be . equal ( 'contactId' ) ;
78+ expect ( modelsMock . LivechatContacts . findOneEnabledById . getCall ( 0 ) . args [ 0 ] ) . to . be . equal ( 'contactId' ) ;
7979
8080 expect ( modelsMock . Settings . incrementValueById . getCall ( 0 ) . args [ 0 ] ) . to . be . equal ( 'Livechat_conflicting_fields_counter' ) ;
8181 expect ( modelsMock . Settings . incrementValueById . getCall ( 0 ) . args [ 1 ] ) . to . be . equal ( 1 ) ;
@@ -91,7 +91,7 @@ describe('resolveContactConflicts', () => {
9191 } ) ;
9292
9393 it ( 'should update the contact with the resolved contact manager' , async ( ) => {
94- modelsMock . LivechatContacts . findOneById . resolves ( {
94+ modelsMock . LivechatContacts . findOneEnabledById . resolves ( {
9595 _id : 'contactId' ,
9696 name : 'Name' ,
9797 contactManager : 'contactManagerId' ,
@@ -109,7 +109,7 @@ describe('resolveContactConflicts', () => {
109109
110110 const result = await resolveContactConflicts ( { contactId : 'contactId' , name : 'New Name' } ) ;
111111
112- expect ( modelsMock . LivechatContacts . findOneById . getCall ( 0 ) . args [ 0 ] ) . to . be . equal ( 'contactId' ) ;
112+ expect ( modelsMock . LivechatContacts . findOneEnabledById . getCall ( 0 ) . args [ 0 ] ) . to . be . equal ( 'contactId' ) ;
113113
114114 expect ( modelsMock . Settings . incrementValueById . getCall ( 0 ) . args [ 0 ] ) . to . be . equal ( 'Livechat_conflicting_fields_counter' ) ;
115115 expect ( modelsMock . Settings . incrementValueById . getCall ( 0 ) . args [ 1 ] ) . to . be . equal ( 1 ) ;
@@ -126,7 +126,7 @@ describe('resolveContactConflicts', () => {
126126
127127 it ( 'should wipe conflicts if wipeConflicts = true' , async ( ) => {
128128 it ( 'should update the contact with the resolved name' , async ( ) => {
129- modelsMock . LivechatContacts . findOneById . resolves ( {
129+ modelsMock . LivechatContacts . findOneEnabledById . resolves ( {
130130 _id : 'contactId' ,
131131 name : 'Name' ,
132132 customFields : { customField : 'newValue' } ,
@@ -145,7 +145,7 @@ describe('resolveContactConflicts', () => {
145145
146146 const result = await resolveContactConflicts ( { contactId : 'contactId' , name : 'New Name' , wipeConflicts : true } ) ;
147147
148- expect ( modelsMock . LivechatContacts . findOneById . getCall ( 0 ) . args [ 0 ] ) . to . be . equal ( 'contactId' ) ;
148+ expect ( modelsMock . LivechatContacts . findOneEnabledById . getCall ( 0 ) . args [ 0 ] ) . to . be . equal ( 'contactId' ) ;
149149
150150 expect ( modelsMock . Settings . incrementValueById . getCall ( 0 ) . args [ 0 ] ) . to . be . equal ( 'Livechat_conflicting_fields_counter' ) ;
151151 expect ( modelsMock . Settings . incrementValueById . getCall ( 0 ) . args [ 1 ] ) . to . be . equal ( 2 ) ;
@@ -163,7 +163,7 @@ describe('resolveContactConflicts', () => {
163163
164164 it ( 'should wipe conflicts if wipeConflicts = true' , async ( ) => {
165165 it ( 'should update the contact with the resolved name' , async ( ) => {
166- modelsMock . LivechatContacts . findOneById . resolves ( {
166+ modelsMock . LivechatContacts . findOneEnabledById . resolves ( {
167167 _id : 'contactId' ,
168168 name : 'Name' ,
169169 customFields : { customField : 'newValue' } ,
@@ -182,7 +182,7 @@ describe('resolveContactConflicts', () => {
182182
183183 const result = await resolveContactConflicts ( { contactId : 'contactId' , name : 'New Name' , wipeConflicts : false } ) ;
184184
185- expect ( modelsMock . LivechatContacts . findOneById . getCall ( 0 ) . args [ 0 ] ) . to . be . equal ( 'contactId' ) ;
185+ expect ( modelsMock . LivechatContacts . findOneEnabledById . getCall ( 0 ) . args [ 0 ] ) . to . be . equal ( 'contactId' ) ;
186186
187187 expect ( modelsMock . Settings . incrementValueById . getCall ( 0 ) . args [ 0 ] ) . to . be . equal ( 'Livechat_conflicting_fields_counter' ) ;
188188 expect ( modelsMock . Settings . incrementValueById . getCall ( 0 ) . args [ 1 ] ) . to . be . equal ( 1 ) ;
@@ -199,15 +199,15 @@ describe('resolveContactConflicts', () => {
199199 } ) ;
200200
201201 it ( 'should throw an error if the contact does not exist' , async ( ) => {
202- modelsMock . LivechatContacts . findOneById . resolves ( undefined ) ;
202+ modelsMock . LivechatContacts . findOneEnabledById . resolves ( undefined ) ;
203203 await expect ( resolveContactConflicts ( { contactId : 'id' , customField : { customField : 'newValue' } } ) ) . to . be . rejectedWith (
204204 'error-contact-not-found' ,
205205 ) ;
206206 expect ( modelsMock . LivechatContacts . updateContact . getCall ( 0 ) ) . to . be . null ;
207207 } ) ;
208208
209209 it ( 'should throw an error if the contact has no conflicting fields' , async ( ) => {
210- modelsMock . LivechatContacts . findOneById . resolves ( {
210+ modelsMock . LivechatContacts . findOneEnabledById . resolves ( {
211211 _id : 'contactId' ,
212212 name : 'Name' ,
213213 contactManager : 'contactManagerId' ,
@@ -221,7 +221,7 @@ describe('resolveContactConflicts', () => {
221221 } ) ;
222222
223223 it ( 'should throw an error if the contact manager is invalid' , async ( ) => {
224- modelsMock . LivechatContacts . findOneById . resolves ( {
224+ modelsMock . LivechatContacts . findOneEnabledById . resolves ( {
225225 _id : 'contactId' ,
226226 name : 'Name' ,
227227 contactManager : 'contactManagerId' ,
0 commit comments