Test processing of unprocessed envelopes
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
parent
2c01e6f4b8
commit
83b076b5c4
7 changed files with 113 additions and 10 deletions
96
ts/test-mock/messaging/unprocessed_test.ts
Normal file
96
ts/test-mock/messaging/unprocessed_test.ts
Normal file
|
@ -0,0 +1,96 @@
|
|||
// Copyright 2025 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import createDebug from 'debug';
|
||||
import { StorageState } 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:unprocessed');
|
||||
|
||||
describe('unprocessed', function (this: Mocha.Suite) {
|
||||
this.timeout(durations.MINUTE);
|
||||
|
||||
let bootstrap: Bootstrap;
|
||||
let app: App;
|
||||
|
||||
beforeEach(async () => {
|
||||
bootstrap = new Bootstrap({ contactCount: 1 });
|
||||
|
||||
await bootstrap.init();
|
||||
|
||||
let state = StorageState.getEmpty();
|
||||
|
||||
const {
|
||||
phone,
|
||||
contacts: [alice],
|
||||
} = bootstrap;
|
||||
|
||||
state = state.addContact(alice, {
|
||||
identityKey: alice.publicKey.serialize(),
|
||||
profileKey: alice.profileKey.serialize(),
|
||||
whitelisted: true,
|
||||
});
|
||||
|
||||
state = state.pin(alice);
|
||||
await phone.setStorageState(state);
|
||||
|
||||
app = await bootstrap.link();
|
||||
});
|
||||
|
||||
afterEach(async function (this: Mocha.Context) {
|
||||
if (!bootstrap) {
|
||||
return;
|
||||
}
|
||||
|
||||
await bootstrap.maybeSaveLogs(this.currentTest, app);
|
||||
await app.close();
|
||||
await bootstrap.teardown();
|
||||
});
|
||||
|
||||
it('generates and loads unprocessed envelopes', async () => {
|
||||
const {
|
||||
desktop,
|
||||
contacts: [alice],
|
||||
} = bootstrap;
|
||||
|
||||
debug('closing');
|
||||
await app.close();
|
||||
|
||||
debug('queueing messages');
|
||||
const sends = new Array<Promise<void>>();
|
||||
for (let i = 0; i < 100; i += 1) {
|
||||
sends.push(
|
||||
alice.sendText(desktop, `hello: ${i}`, {
|
||||
timestamp: bootstrap.getTimestamp(),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
debug('starting app with unprocessed forced');
|
||||
[app] = await Promise.all([
|
||||
bootstrap.startApp({
|
||||
ciForceUnprocessed: true,
|
||||
}),
|
||||
...sends,
|
||||
]);
|
||||
|
||||
debug('waiting for the window');
|
||||
await app.getWindow();
|
||||
|
||||
debug('restarting normally');
|
||||
await app.close();
|
||||
app = await bootstrap.startApp();
|
||||
|
||||
const page = await app.getWindow();
|
||||
|
||||
debug('opening conversation');
|
||||
await page
|
||||
.locator(`[data-testid="${alice.device.aci}"] >> "${alice.profileName}"`)
|
||||
.click();
|
||||
|
||||
await page.locator('.module-message__text >> "hello: 5"').waitFor();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue