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:
Karol Sójko
2023-01-09 06:52:56 +01:00
committed by GitHub
parent 5f09fc74da
commit be028ff87b
37 changed files with 838 additions and 81 deletions

View File

@@ -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,

View File

@@ -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)
})