Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
onSentMessage: Create destination conversation before further processing
Co-authored-by: Scott Nonnenberg <scott@signal.org> Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
- Loading branch information
1 parent
3239e80
commit d77045b
Showing
5 changed files
with
184 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Copyright 2023 Signal Messenger, LLC | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
import { assert } from 'chai'; | ||
import createDebug from 'debug'; | ||
import Long from 'long'; | ||
|
||
import type { App } from '../playwright'; | ||
import * as durations from '../../util/durations'; | ||
import { Bootstrap } from '../bootstrap'; | ||
|
||
export const debug = createDebug('mock:test:sendSync'); | ||
|
||
describe('sendSync', function (this: Mocha.Suite) { | ||
this.timeout(durations.MINUTE); | ||
|
||
let bootstrap: Bootstrap; | ||
let app: App; | ||
|
||
beforeEach(async () => { | ||
bootstrap = new Bootstrap(); | ||
await bootstrap.init(); | ||
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('creates conversation for sendSync to PNI', async () => { | ||
const { desktop, phone, server } = bootstrap; | ||
|
||
debug('Creating stranger'); | ||
const STRANGER_NAME = 'Mysterious Stranger'; | ||
const stranger = await server.createPrimaryDevice({ | ||
profileName: STRANGER_NAME, | ||
}); | ||
|
||
const timestamp = Date.now(); | ||
const messageText = 'hey there, just reaching out'; | ||
const destinationServiceId = stranger.device.pni; | ||
const destination = stranger.device.number; | ||
const originalDataMessage = { | ||
body: messageText, | ||
timestamp: Long.fromNumber(timestamp), | ||
}; | ||
const content = { | ||
syncMessage: { | ||
sent: { | ||
destinationServiceId, | ||
destination, | ||
timestamp: Long.fromNumber(timestamp), | ||
message: originalDataMessage, | ||
}, | ||
}, | ||
}; | ||
const sendOptions = { | ||
timestamp, | ||
}; | ||
await phone.sendRaw(desktop, content, sendOptions); | ||
|
||
const page = await app.getWindow(); | ||
const leftPane = page.locator('#LeftPane'); | ||
|
||
debug('checking left pane for conversation'); | ||
const strangerName = await leftPane | ||
.locator( | ||
'.module-conversation-list__item--contact-or-conversation .module-contact-name' | ||
) | ||
.first() | ||
.innerText(); | ||
|
||
assert.equal( | ||
strangerName.slice(-4), | ||
destination?.slice(-4), | ||
'no profile, just phone number' | ||
); | ||
|
||
debug('opening conversation'); | ||
await leftPane | ||
.locator('.module-conversation-list__item--contact-or-conversation') | ||
.first() | ||
.click(); | ||
|
||
debug('checking for latest message'); | ||
await page.locator(`.module-message__text >> "${messageText}"`).waitFor(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters