-
Notifications
You must be signed in to change notification settings - Fork 558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding tests accessing app.currentUser
from App
and User
listeners
#6649
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to have this tracking the behavior 👍
@@ -235,6 +236,50 @@ describe("App", () => { | |||
expect(this.app.currentUser).to.be.null; | |||
}); | |||
|
|||
it("currentUser is available from an App listener", async function (this: Mocha.Context & AppContext & RealmContext) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint warning
it("currentUser is available from an App listener", async function (this: Mocha.Context & AppContext & RealmContext) { | |
it("currentUser is available from an App listener", async function (this: Mocha.Context & | |
AppContext & | |
RealmContext) { |
await handle; | ||
}); | ||
|
||
it.only("currentUser is available from a User listener", async function (this: Mocha.Context & AppContext & RealmContext) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint warning (and sweet ol' only
🙂)
it.only("currentUser is available from a User listener", async function (this: Mocha.Context & AppContext & RealmContext) { | |
it("currentUser is available from a User listener", async function (this: Mocha.Context & | |
AppContext & | |
RealmContext) { |
it.only("currentUser is available from a User listener", async function (this: Mocha.Context & AppContext & RealmContext) { | ||
expect(this.app.currentUser).to.be.null; | ||
|
||
const credentials = Realm.Credentials.anonymous(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the false
actually make a difference here? Or can it not be guaranteed that this is the only logged in user when this test is run? (The previous test used the default argument.)
const credentials = Realm.Credentials.anonymous(); | ||
|
||
const handle = createPromiseHandle(); | ||
const listener = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this function be called once or twice? If twice, you will resolve the promise too early.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect it to be called only once. It doesn't behave as collection and object listeners (where it fires initially).
What, How & Why?
This exercise realm/realm-core#7670 and realm/realm-core#7183 to ensure future regressions will be easier to debug.
We should hold back on merging this, until realm/realm-core#7670 is fixed and we've upgraded Core to include the fix.