Test more contact splitting scenarios

This commit is contained in:
Fedor Indutny 2024-01-31 09:51:09 -08:00 committed by GitHub
parent 304287efef
commit 900b40381c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 93 additions and 81 deletions

View file

@ -1515,7 +1515,7 @@ async function processRemoteRecords(
});
// Find remote contact records that:
// - Have `remote.pni === remote.serviceUuid` and have `remote.serviceE164`
// - Have `remote.pni` and have `remote.serviceE164`
// - Match local contact that has `aci`.
const splitPNIContacts = new Array<MergeableItemType>();
prunedStorageItems = prunedStorageItems.filter(item => {

View file

@ -229,7 +229,13 @@ describe('pnp/merge', function (this: Mocha.Suite) {
});
}
it('accepts storage service contact splitting', async () => {
for (const withPniContact of [false, true]) {
const testName =
'accepts storage service contact splitting ' +
`${withPniContact ? 'with PNI contact' : 'without PNI contact'}`;
// eslint-disable-next-line no-loop-func
it(testName, async () => {
const { phone } = bootstrap;
debug(
@ -281,6 +287,7 @@ describe('pnp/merge', function (this: Mocha.Suite) {
unregisteredAtTimestamp: Long.fromNumber(bootstrap.getTimestamp()),
});
if (withPniContact) {
state = state.addContact(
pniContact,
{
@ -294,6 +301,7 @@ describe('pnp/merge', function (this: Mocha.Suite) {
},
ServiceIdKind.PNI
);
}
state = state.pin(pniContact, ServiceIdKind.PNI);
@ -311,14 +319,18 @@ describe('pnp/merge', function (this: Mocha.Suite) {
debug('Verify that the message is in the ACI conversation');
{
// Should have both PNI and ACI messages
await window.locator('.module-message__text >> "Hello merged"').waitFor();
await window
.locator('.module-message__text >> "Hello merged"')
.waitFor();
const messages = window.locator('.module-message__text');
assert.strictEqual(await messages.count(), 1, 'message count');
}
debug('Open PNI conversation');
await leftPane.locator(`[data-testid="${pniContact.device.pni}"]`).click();
await leftPane
.locator(`[data-testid="${pniContact.device.pni}"]`)
.click();
debug('Verify absence of messages in the PNI conversation');
{
@ -326,6 +338,7 @@ describe('pnp/merge', function (this: Mocha.Suite) {
assert.strictEqual(await messages.count(), 0, 'message count');
}
});
}
it('splits contact when ACI becomes unregistered', async () => {
const { phone, server } = bootstrap;

View file

@ -640,8 +640,7 @@ export type CapabilitiesType = {
pni: boolean;
};
export type CapabilitiesUploadType = {
// true in staging, false in production
pni: boolean;
pni: true;
};
type StickerPackManifestType = Uint8Array;