chore: fix test
This commit is contained in:
@@ -49,6 +49,21 @@ export class VaultsContext extends AppContext {
|
|||||||
await this.awaitPromiseOrThrow(promise, undefined, 'Waiting for invites to process')
|
await this.awaitPromiseOrThrow(promise, undefined, 'Waiting for invites to process')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async syncAndAwaitInviteAndMessageProcessing() {
|
||||||
|
const invitePromise = this.resolveWhenAsyncFunctionCompletes(this.vaultInvites, 'processInboundInvites')
|
||||||
|
const messagePromise = this.resolveWhenAsyncFunctionCompletes(
|
||||||
|
this.asymmetric,
|
||||||
|
'handleRemoteReceivedAsymmetricMessages',
|
||||||
|
)
|
||||||
|
|
||||||
|
await this.sync()
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
this.awaitPromiseOrThrow(invitePromise, undefined, 'Waiting for invites to process'),
|
||||||
|
this.awaitPromiseOrThrow(messagePromise, undefined, 'Waiting for messages to process'),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run a request to keep refresh token from expiring due to long bouts of inactivity for contact context
|
* Run a request to keep refresh token from expiring due to long bouts of inactivity for contact context
|
||||||
* while main context changes password. Tests have a refresh token age of 10s typically, and changing password
|
* while main context changes password. Tests have a refresh token age of 10s typically, and changing password
|
||||||
@@ -58,6 +73,11 @@ export class VaultsContext extends AppContext {
|
|||||||
await this.asymmetric.getInboundMessages()
|
await this.asymmetric.getInboundMessages()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Used for long running tests to avoid 498 responses */
|
||||||
|
async forceRefreshSession() {
|
||||||
|
await this.application.http.refreshSession()
|
||||||
|
}
|
||||||
|
|
||||||
async createSharedPasswordVault(password) {
|
async createSharedPasswordVault(password) {
|
||||||
const privateVault = await this.vaults.createUserInputtedPasswordVault({
|
const privateVault = await this.vaults.createUserInputtedPasswordVault({
|
||||||
name: 'Our Vault',
|
name: 'Our Vault',
|
||||||
|
|||||||
@@ -437,11 +437,12 @@ describe('asymmetric messages', function () {
|
|||||||
SharedVaultUserPermission.PERMISSIONS.Write,
|
SharedVaultUserPermission.PERMISSIONS.Write,
|
||||||
)
|
)
|
||||||
|
|
||||||
await contactContext.runAnyRequestToPreventRefreshTokenFromExpiring()
|
await context.forceRefreshSession()
|
||||||
|
await contactContext.forceRefreshSession()
|
||||||
|
|
||||||
await context.changePassword('new password')
|
await context.changePassword('new password')
|
||||||
|
|
||||||
await contactContext.runAnyRequestToPreventRefreshTokenFromExpiring()
|
await contactContext.forceRefreshSession()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When resending keypair changed messages here, we expect that one of their previous messages will fail to decrypt.
|
* When resending keypair changed messages here, we expect that one of their previous messages will fail to decrypt.
|
||||||
@@ -453,6 +454,8 @@ describe('asymmetric messages', function () {
|
|||||||
|
|
||||||
await context.changePassword('new password 2')
|
await context.changePassword('new password 2')
|
||||||
|
|
||||||
|
await contactContext.forceRefreshSession()
|
||||||
|
|
||||||
const messages = await contactContext.asymmetric.getInboundMessages()
|
const messages = await contactContext.asymmetric.getInboundMessages()
|
||||||
if (messages.isFailed()) {
|
if (messages.isFailed()) {
|
||||||
console.error(messages.getError())
|
console.error(messages.getError())
|
||||||
@@ -462,7 +465,7 @@ describe('asymmetric messages', function () {
|
|||||||
expect(messages.getValue().length).to.equal(2)
|
expect(messages.getValue().length).to.equal(2)
|
||||||
|
|
||||||
contactContext.unlockSyncing()
|
contactContext.unlockSyncing()
|
||||||
await contactContext.syncAndAwaitInviteProcessing()
|
await contactContext.syncAndAwaitInviteAndMessageProcessing()
|
||||||
|
|
||||||
const invites = contactContext.vaultInvites.getCachedPendingInviteRecords()
|
const invites = contactContext.vaultInvites.getCachedPendingInviteRecords()
|
||||||
expect(invites.length).to.equal(1)
|
expect(invites.length).to.equal(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user