Test SenderKey receive
This commit is contained in:
parent
11456d100f
commit
110683fb37
1 changed files with 93 additions and 0 deletions
93
ts/test-mock/messaging/sender_key_test.ts
Normal file
93
ts/test-mock/messaging/sender_key_test.ts
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
// 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');
|
||||||
|
|
||||||
|
describe('senderKey', function needsName() {
|
||||||
|
this.timeout(durations.MINUTE);
|
||||||
|
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async function after() {
|
||||||
|
if (!bootstrap) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.currentTest?.state !== 'passed') {
|
||||||
|
await bootstrap.saveLogs(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
|
||||||
|
const leftPane = window.locator('.left-pane-wrapper');
|
||||||
|
|
||||||
|
debug('Opening group');
|
||||||
|
await leftPane.locator(`[data-testid="${group.id}"]`).click();
|
||||||
|
|
||||||
|
const conversationStack = window.locator('.conversation-stack');
|
||||||
|
|
||||||
|
debug('Verifying message');
|
||||||
|
await conversationStack
|
||||||
|
.locator('.module-message--incoming >> "hello"')
|
||||||
|
.waitFor();
|
||||||
|
});
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue