feat(snjs): add sign in with recovery codes use case (#2130)
* feat(snjs): add sign in with recovery codes use case * fix(snjs): code review adjustments * fix(snjs): remove unnecessary exposed getter * fix(services): waiting for event handling * fix: preferences test Co-authored-by: Mo <mo@standardnotes.com>
This commit is contained in:
@@ -220,6 +220,16 @@ export class AppContext {
|
||||
})
|
||||
}
|
||||
|
||||
awaitUserPrefsSingletonResolution() {
|
||||
return new Promise((resolve) => {
|
||||
this.application.preferencesService.addEventObserver((eventName) => {
|
||||
if (eventName === PreferencesServiceEvent.PreferencesChanged) {
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async launch({ awaitDatabaseLoad = true, receiveChallenge } = { awaitDatabaseLoad: true }) {
|
||||
await this.application.prepareForLaunch({
|
||||
receiveChallenge: receiveChallenge || this.handleChallenge,
|
||||
|
||||
@@ -74,10 +74,16 @@ describe('preferences', function () {
|
||||
await register.call(this)
|
||||
await this.application.setPreference('editorLeft', 300)
|
||||
await this.application.sync.sync()
|
||||
this.application = await Factory.signOutApplicationAndReturnNew(this.application)
|
||||
|
||||
this.application = await this.context.signout()
|
||||
|
||||
await this.application.setPreference('editorLeft', 200)
|
||||
await this.application.signIn(this.email, this.password)
|
||||
|
||||
const promise = this.context.awaitUserPrefsSingletonResolution()
|
||||
await this.application.sync.sync({ awaitAll: true })
|
||||
await promise
|
||||
|
||||
const editorLeft = this.application.getPreference('editorLeft')
|
||||
expect(editorLeft).to.equal(300)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user