2023-05-15 23:15:43 +00:00
|
|
|
// Copyright 2023 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import createDebug from 'debug';
|
|
|
|
import { StorageState } from '@signalapp/mock-server';
|
|
|
|
import type { Group } from '@signalapp/mock-server';
|
|
|
|
|
|
|
|
import * as durations from '../../util/durations';
|
|
|
|
import type { App } from '../playwright';
|
|
|
|
import { Bootstrap } from '../bootstrap';
|
|
|
|
|
|
|
|
export const debug = createDebug('mock:test:senderKey');
|
|
|
|
|
2023-10-11 19:06:43 +00:00
|
|
|
describe('senderKey', function (this: Mocha.Suite) {
|
2023-05-15 23:15:43 +00:00
|
|
|
this.timeout(durations.MINUTE);
|
2023-09-19 17:02:37 +00:00
|
|
|
this.retries(4);
|
2023-05-15 23:15:43 +00:00
|
|
|
|
|
|
|
let bootstrap: Bootstrap;
|
|
|
|
let app: App;
|
|
|
|
let group: Group;
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
bootstrap = new Bootstrap();
|
|
|
|
await bootstrap.init();
|
|
|
|
|
|
|
|
const { contacts, phone } = bootstrap;
|
|
|
|
const [first] = contacts;
|
|
|
|
|
|
|
|
group = await first.createGroup({
|
|
|
|
title: 'Group',
|
|
|
|
members: [first, phone],
|
|
|
|
});
|
|
|
|
|
|
|
|
let state = StorageState.getEmpty();
|
|
|
|
|
|
|
|
state = state.updateAccount({
|
|
|
|
profileKey: phone.profileKey.serialize(),
|
|
|
|
e164: phone.device.number,
|
|
|
|
givenName: phone.profileName,
|
|
|
|
});
|
|
|
|
|
|
|
|
state = state
|
|
|
|
.addGroup(group, {
|
|
|
|
whitelisted: true,
|
|
|
|
})
|
|
|
|
.pinGroup(group);
|
|
|
|
|
|
|
|
await phone.setStorageState(state);
|
|
|
|
|
|
|
|
app = await bootstrap.link();
|
|
|
|
});
|
|
|
|
|
2023-10-11 19:06:43 +00:00
|
|
|
afterEach(async function (this: Mocha.Context) {
|
2023-05-15 23:15:43 +00:00
|
|
|
if (!bootstrap) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-07-14 16:53:20 +00:00
|
|
|
await bootstrap.maybeSaveLogs(this.currentTest, app);
|
2023-05-15 23:15:43 +00:00
|
|
|
await app.close();
|
|
|
|
await bootstrap.teardown();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('handles incoming senderKey distributions and messages', async () => {
|
|
|
|
const { desktop, contacts } = bootstrap;
|
|
|
|
const [first] = contacts;
|
|
|
|
|
|
|
|
const window = await app.getWindow();
|
|
|
|
|
|
|
|
const distributionId = await first.sendSenderKey(desktop, {
|
|
|
|
timestamp: bootstrap.getTimestamp(),
|
|
|
|
});
|
|
|
|
|
|
|
|
await first.sendText(desktop, 'hello', {
|
|
|
|
timestamp: bootstrap.getTimestamp(),
|
|
|
|
group,
|
|
|
|
distributionId,
|
|
|
|
});
|
|
|
|
|
2023-07-26 22:23:32 +00:00
|
|
|
const leftPane = window.locator('#LeftPane');
|
2023-05-15 23:15:43 +00:00
|
|
|
|
|
|
|
debug('Opening group');
|
|
|
|
await leftPane.locator(`[data-testid="${group.id}"]`).click();
|
|
|
|
|
2023-07-26 22:23:32 +00:00
|
|
|
const conversationStack = window.locator('.Inbox__conversation-stack');
|
2023-05-15 23:15:43 +00:00
|
|
|
|
|
|
|
debug('Verifying message');
|
|
|
|
await conversationStack
|
|
|
|
.locator('.module-message--incoming >> "hello"')
|
|
|
|
.waitFor();
|
|
|
|
});
|
|
|
|
});
|