Remove restriction on maybeMergeContacts, combineConversations fixes

This commit is contained in:
Scott Nonnenberg 2022-08-09 16:46:01 -07:00 committed by GitHub
parent 0fc5976117
commit 5d45197fe2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 129 additions and 74 deletions

View file

@ -43,25 +43,13 @@ describe('ConversationController', () => {
};
});
// Verifying incoming data
describe('data validation', () => {
it('throws when provided no data', () => {
assert.throws(() => {
window.ConversationController.maybeMergeContacts({
mergeOldAndNew,
reason,
});
}, 'Need to provide at least one');
});
it('throws when provided a pni with no e164', () => {
assert.throws(() => {
window.ConversationController.maybeMergeContacts({
mergeOldAndNew,
pni: PNI_1,
reason,
});
}, 'Cannot provide pni without an e164');
});
it('throws when provided no data', () => {
assert.throws(() => {
window.ConversationController.maybeMergeContacts({
mergeOldAndNew,
reason,
});
}, 'Need to provide at least one');
});
function create(
@ -300,6 +288,32 @@ describe('ConversationController', () => {
assert.strictEqual(initial?.id, result?.id, 'result and initial match');
});
it('adds ACI (via ACI+PNI) to conversation with e164+PNI', () => {
const initial = create('initial', {
uuid: PNI_1,
e164: E164_1,
});
expectPropsAndLookups(initial, 'initial', {
uuid: PNI_1,
e164: E164_1,
});
const result = window.ConversationController.maybeMergeContacts({
mergeOldAndNew,
aci: ACI_1,
pni: PNI_1,
reason,
});
expectPropsAndLookups(result, 'result', {
uuid: ACI_1,
e164: E164_1,
pni: PNI_1,
});
assert.strictEqual(initial?.id, result?.id, 'result and initial match');
});
it('adds e164+PNI to conversation with just ACI', () => {
const initial = create('initial', {
uuid: ACI_1,