Migrate schema to service ids
This commit is contained in:
parent
71958f8a01
commit
8b0da36caa
258 changed files with 4795 additions and 2613 deletions
|
@ -19,7 +19,7 @@ const PNI_2 = generatePni();
|
|||
const reason = 'test';
|
||||
|
||||
type ParamsType = {
|
||||
uuid?: ServiceIdString;
|
||||
serviceId?: ServiceIdString;
|
||||
aci?: AciString;
|
||||
e164?: string;
|
||||
pni?: PniString;
|
||||
|
@ -54,19 +54,19 @@ describe('ConversationController', () => {
|
|||
|
||||
function create(
|
||||
name: string,
|
||||
{ uuid, aci, e164, pni }: ParamsType
|
||||
{ serviceId: maybeServiceId, aci, e164, pni }: ParamsType
|
||||
): ConversationModel {
|
||||
const identifier = aci || uuid || e164 || pni;
|
||||
const serviceId = aci || uuid || pni;
|
||||
const identifier = aci || maybeServiceId || e164 || pni;
|
||||
const serviceId = aci || maybeServiceId || pni;
|
||||
|
||||
strictAssert(identifier, 'create needs aci, e164, pni, or uuid');
|
||||
strictAssert(identifier, 'create needs aci, e164, pni, or serviceId');
|
||||
|
||||
const conversation = window.ConversationController.getOrCreate(
|
||||
identifier,
|
||||
'private',
|
||||
{ uuid: serviceId, e164, pni }
|
||||
{ serviceId, e164, pni }
|
||||
);
|
||||
expectLookups(conversation, name, { uuid, aci, e164, pni });
|
||||
expectLookups(conversation, name, { serviceId, aci, e164, pni });
|
||||
|
||||
return conversation;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ describe('ConversationController', () => {
|
|||
function expectLookups(
|
||||
conversation: ConversationModel | undefined,
|
||||
name: string,
|
||||
{ uuid, aci, e164, pni }: ParamsType
|
||||
{ serviceId, aci, e164, pni }: ParamsType
|
||||
) {
|
||||
assert.exists(conversation, `${name} conversation exists`);
|
||||
|
||||
|
@ -85,11 +85,11 @@ describe('ConversationController', () => {
|
|||
`${name} vs. lookup by id`
|
||||
);
|
||||
|
||||
if (uuid) {
|
||||
if (serviceId) {
|
||||
assert.strictEqual(
|
||||
window.ConversationController.get(uuid)?.id,
|
||||
window.ConversationController.get(serviceId)?.id,
|
||||
conversation?.id,
|
||||
`${name} vs. lookup by uuid`
|
||||
`${name} vs. lookup by serviceId`
|
||||
);
|
||||
}
|
||||
if (aci) {
|
||||
|
@ -118,22 +118,22 @@ describe('ConversationController', () => {
|
|||
function expectPropsAndLookups(
|
||||
conversation: ConversationModel | undefined,
|
||||
name: string,
|
||||
{ uuid, aci, e164, pni }: ParamsType
|
||||
{ serviceId, aci, e164, pni }: ParamsType
|
||||
) {
|
||||
assert.exists(conversation, `${name} conversation exists`);
|
||||
assert.strictEqual(
|
||||
conversation?.get('uuid'),
|
||||
aci || uuid,
|
||||
`${name} uuid matches`
|
||||
conversation?.getServiceId(),
|
||||
aci || serviceId,
|
||||
`${name} serviceId matches`
|
||||
);
|
||||
assert.strictEqual(
|
||||
conversation?.get('e164'),
|
||||
e164,
|
||||
`${name} e164 matches`
|
||||
);
|
||||
assert.strictEqual(conversation?.get('pni'), pni, `${name} pni matches`);
|
||||
assert.strictEqual(conversation?.getPni(), pni, `${name} pni matches`);
|
||||
|
||||
expectLookups(conversation, name, { uuid, e164, pni });
|
||||
expectLookups(conversation, name, { serviceId, e164, pni });
|
||||
}
|
||||
|
||||
function expectDeleted(conversation: ConversationModel, name: string) {
|
||||
|
@ -153,7 +153,7 @@ describe('ConversationController', () => {
|
|||
});
|
||||
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
});
|
||||
|
||||
const { conversation: second } =
|
||||
|
@ -204,7 +204,7 @@ describe('ConversationController', () => {
|
|||
});
|
||||
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: PNI_1,
|
||||
serviceId: PNI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -218,7 +218,7 @@ describe('ConversationController', () => {
|
|||
});
|
||||
|
||||
expectPropsAndLookups(second, 'second', {
|
||||
uuid: PNI_1,
|
||||
serviceId: PNI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -236,7 +236,7 @@ describe('ConversationController', () => {
|
|||
});
|
||||
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -251,7 +251,7 @@ describe('ConversationController', () => {
|
|||
});
|
||||
|
||||
expectPropsAndLookups(second, 'second', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -274,7 +274,7 @@ describe('ConversationController', () => {
|
|||
});
|
||||
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -298,7 +298,7 @@ describe('ConversationController', () => {
|
|||
});
|
||||
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -321,7 +321,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -330,12 +330,12 @@ describe('ConversationController', () => {
|
|||
});
|
||||
it('adds ACI (via ACI+PNI) to conversation with e164+PNI', () => {
|
||||
const initial = create('initial', {
|
||||
uuid: PNI_1,
|
||||
serviceId: PNI_1,
|
||||
e164: E164_1,
|
||||
});
|
||||
|
||||
expectPropsAndLookups(initial, 'initial', {
|
||||
uuid: PNI_1,
|
||||
serviceId: PNI_1,
|
||||
e164: E164_1,
|
||||
});
|
||||
|
||||
|
@ -347,7 +347,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -357,7 +357,7 @@ describe('ConversationController', () => {
|
|||
|
||||
it('adds e164+PNI to conversation with just ACI', () => {
|
||||
const initial = create('initial', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
});
|
||||
|
||||
const { conversation: result } =
|
||||
|
@ -369,7 +369,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -391,7 +391,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -413,7 +413,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -433,7 +433,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: PNI_1,
|
||||
serviceId: PNI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -483,13 +483,13 @@ describe('ConversationController', () => {
|
|||
assert.strictEqual(initial?.id, result?.id, 'result and initial match');
|
||||
});
|
||||
|
||||
it('promotes PNI used as generic UUID to be in the PNI field as well', () => {
|
||||
it('promotes PNI used as generic serviceId to be in the PNI field as well', () => {
|
||||
const initial = create('initial', {
|
||||
uuid: PNI_1,
|
||||
serviceId: PNI_1,
|
||||
e164: E164_1,
|
||||
});
|
||||
expectPropsAndLookups(initial, 'initial', {
|
||||
uuid: PNI_1,
|
||||
serviceId: PNI_1,
|
||||
e164: E164_1,
|
||||
});
|
||||
|
||||
|
@ -501,7 +501,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: PNI_1,
|
||||
serviceId: PNI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -513,7 +513,7 @@ describe('ConversationController', () => {
|
|||
describe('with destructive updates', () => {
|
||||
it('replaces e164+PNI in conversation with matching ACI', () => {
|
||||
const initial = create('initial', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -527,7 +527,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_2,
|
||||
pni: PNI_2,
|
||||
});
|
||||
|
@ -553,13 +553,12 @@ describe('ConversationController', () => {
|
|||
const { conversation: result } =
|
||||
window.ConversationController.maybeMergeContacts({
|
||||
mergeOldAndNew,
|
||||
aci: PNI_2,
|
||||
pni: PNI_2,
|
||||
e164: E164_1,
|
||||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: PNI_2,
|
||||
serviceId: PNI_2,
|
||||
e164: E164_1,
|
||||
pni: PNI_2,
|
||||
});
|
||||
|
@ -580,13 +579,12 @@ describe('ConversationController', () => {
|
|||
const { conversation: result } =
|
||||
window.ConversationController.maybeMergeContacts({
|
||||
mergeOldAndNew,
|
||||
aci: PNI_1,
|
||||
pni: PNI_1,
|
||||
e164: E164_1,
|
||||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -609,7 +607,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_2,
|
||||
});
|
||||
|
@ -624,7 +622,7 @@ describe('ConversationController', () => {
|
|||
|
||||
it('removes e164+PNI from previous conversation with an ACI, adds all data to new conversation', () => {
|
||||
const initial = create('initial', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -638,12 +636,12 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_2,
|
||||
serviceId: ACI_2,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
||||
expectPropsAndLookups(initial, 'initial', { uuid: ACI_1 });
|
||||
expectPropsAndLookups(initial, 'initial', { serviceId: ACI_1 });
|
||||
|
||||
assert.notStrictEqual(
|
||||
initial?.id,
|
||||
|
@ -653,12 +651,12 @@ describe('ConversationController', () => {
|
|||
});
|
||||
it('removes e164+PNI from previous conversation with an ACI, adds to ACI match', () => {
|
||||
const initial = create('initial', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
const aciOnly = create('aciOnly', {
|
||||
uuid: ACI_2,
|
||||
serviceId: ACI_2,
|
||||
});
|
||||
|
||||
const { conversation: result } =
|
||||
|
@ -670,12 +668,12 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(aciOnly, 'aciOnly', {
|
||||
uuid: ACI_2,
|
||||
serviceId: ACI_2,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
||||
expectPropsAndLookups(initial, 'initial', { uuid: ACI_1 });
|
||||
expectPropsAndLookups(initial, 'initial', { serviceId: ACI_1 });
|
||||
|
||||
assert.strictEqual(
|
||||
aciOnly?.id,
|
||||
|
@ -701,7 +699,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: PNI_1,
|
||||
serviceId: PNI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -728,7 +726,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: PNI_1,
|
||||
serviceId: PNI_1,
|
||||
e164: E164_2,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -762,7 +760,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: PNI_1,
|
||||
serviceId: PNI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -775,7 +773,7 @@ describe('ConversationController', () => {
|
|||
'result and initial should match'
|
||||
);
|
||||
});
|
||||
it('deletes previous conversation with PNI as UUID only, adds it to e164 match', () => {
|
||||
it('deletes previous conversation with PNI as serviceId only, adds it to e164 match', () => {
|
||||
mergeOldAndNew = ({ obsolete }) => {
|
||||
window.ConversationController.dangerouslyRemoveById(obsolete.id);
|
||||
return Promise.resolve();
|
||||
|
@ -785,7 +783,7 @@ describe('ConversationController', () => {
|
|||
e164: E164_1,
|
||||
});
|
||||
const withPNI = create('withPNI', {
|
||||
uuid: PNI_1,
|
||||
serviceId: PNI_1,
|
||||
});
|
||||
|
||||
const { conversation: result } =
|
||||
|
@ -796,7 +794,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: PNI_1,
|
||||
serviceId: PNI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -832,7 +830,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -868,7 +866,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -903,7 +901,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
@ -938,7 +936,7 @@ describe('ConversationController', () => {
|
|||
reason,
|
||||
});
|
||||
expectPropsAndLookups(result, 'result', {
|
||||
uuid: ACI_1,
|
||||
serviceId: ACI_1,
|
||||
e164: E164_1,
|
||||
pni: PNI_1,
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue