Skip to content
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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kraenhansen
Copy link
Member

@kraenhansen kraenhansen commented May 2, 2024

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.

@kraenhansen kraenhansen added T-Test no-changelog no-jira-ticket Skip checking the PR title for Jira reference labels May 2, 2024
@kraenhansen kraenhansen self-assigned this May 2, 2024
@cla-bot cla-bot bot added the cla: yes label May 2, 2024
@kraenhansen kraenhansen requested review from kneth and elle-j May 2, 2024 14:07
@kraenhansen kraenhansen marked this pull request as draft May 2, 2024 14:08
Copy link
Member

@elle-j elle-j left a 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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint warning

Suggested change
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) {
Copy link
Member

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 🙂)

Suggested change
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);
Copy link
Member

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 = () => {
Copy link
Member

@kneth kneth May 3, 2024

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.

Copy link
Member Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes no-changelog no-jira-ticket Skip checking the PR title for Jira reference T-Test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants