chore: vault tests refactors and lint (#2374)
This commit is contained in:
54
packages/snjs/mocha/lib/VaultsContext.js
Normal file
54
packages/snjs/mocha/lib/VaultsContext.js
Normal file
@@ -0,0 +1,54 @@
|
||||
import { AppContext } from './AppContext.js'
|
||||
|
||||
export class VaultsContext extends AppContext {
|
||||
constructor(params) {
|
||||
super(params)
|
||||
}
|
||||
|
||||
async changeVaultName(vault, nameAndDesc) {
|
||||
const sendDataChangePromise = this.resolveWhenAsyncFunctionCompletes(
|
||||
this.sharedVaults._sendVaultDataChangeMessage,
|
||||
'execute',
|
||||
)
|
||||
|
||||
await this.vaults.changeVaultNameAndDescription(vault, {
|
||||
name: nameAndDesc.name,
|
||||
description: nameAndDesc.description,
|
||||
})
|
||||
|
||||
await this.awaitPromiseOrThrow(sendDataChangePromise, undefined, 'Waiting for vault data change message to process')
|
||||
}
|
||||
|
||||
async changePassword(password) {
|
||||
const promise = this.resolveWhenAsyncFunctionCompletes(this.sharedVaults._handleKeyPairChange, 'execute')
|
||||
|
||||
await super.changePassword(password)
|
||||
|
||||
await this.awaitPromiseOrThrow(promise, undefined, 'Waiting for keypair change message to process')
|
||||
}
|
||||
|
||||
async syncAndAwaitMessageProcessing() {
|
||||
const promise = this.resolveWhenAsyncFunctionCompletes(this.asymmetric, 'handleRemoteReceivedAsymmetricMessages')
|
||||
|
||||
await this.sync()
|
||||
|
||||
await this.awaitPromiseOrThrow(promise, undefined, 'Waiting for messages to process')
|
||||
}
|
||||
|
||||
async syncAndAwaitInviteProcessing() {
|
||||
const promise = this.resolveWhenAsyncFunctionCompletes(this.vaultInvites, 'processInboundInvites')
|
||||
|
||||
await this.sync()
|
||||
|
||||
await this.awaitPromiseOrThrow(promise, undefined, 'Waiting for invites to process')
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* on CI environment may be time consuming.
|
||||
*/
|
||||
async runAnyRequestToPreventRefreshTokenFromExpiring() {
|
||||
await this.asymmetric.getInboundMessages()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user