Skip to content

Commit

Permalink
Use unreleased core (#6667)
Browse files Browse the repository at this point in the history
* Adopting to the introduction of the `app_user_as_sync_user` helper
* Upgrade Realm Core
* Use app caching again
* [realm/react] Enable skipped tests
* [realm/react] enable UserProvider test

---------

Co-authored-by: Kræn Hansen <[email protected]>
Co-authored-by: LJ <[email protected]>
  • Loading branch information
3 people authored May 15, 2024
1 parent bf7c0c8 commit 52990c5
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 18 deletions.
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
* None

### Fixed
* <How to hit and notice issue? what was the impact?> ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?)
* None
* Fixed a crash experienced on React Native when accessing `Realm.deleteFile`, `Realm.exists`, `Realm.schemaVersion`, `Realm.determinePath`, `Realm.transformConfig` and `User#isLoggedIn`. ([#6662](https://github.com/realm/realm-js/pull/6662), since v12.8.0)
* Accessing `Realm.App#currentUser` from within a notification produced by `Realm.App.switchUser` (which includes notifications for a newly logged in user) would deadlock. ([realm/realm-core#7670](https://github.com/realm/realm-core/issues/7670), since v12.8.0)
* Fixed a bug when running an `IN` query on a `string`/`int`/`uuid`/`objectId` property that was indexed. ([realm/realm-core#7642](https://github.com/realm/realm-core/issues/7642) since v12.8.0)
* Fixed a bug when running an `IN` query on an `int` property where `double`/`float` parameters were ignored. ([realm/realm-core#7642](https://github.com/realm/realm-core/issues/7642) since v12.8.0)

### Compatibility
* React Native >= v0.71.4
* Realm Studio v15.0.0.
* File format: generates Realms with format v24 (reads and upgrades file format v10.

### Internal
<!-- * Either mention core version or upgrade -->
<!-- * Using Realm Core vX.Y.Z -->
<!-- * Upgraded Realm Core from vX.Y.Z to vA.B.C -->
* Upgraded Realm Core from v14.6.1 to v14.6.2 + commits `5ba02142131efa3d97eda770ce33a85a2a085202` and `5462d47998b86459d328648c8057790a7b92af20`.

## 12.8.0 (2024-05-01)

Expand Down
10 changes: 6 additions & 4 deletions packages/realm-react/src/__tests__/UserProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//
////////////////////////////////////////////////////////////////////////////

import { renderHook, waitFor } from "@testing-library/react-native";
import { act, renderHook, waitFor } from "@testing-library/react-native";
import { AppConfigBuilder } from "@realm/app-importer";
import Realm, { App } from "realm";
import React, { useEffect, useState } from "react";
Expand Down Expand Up @@ -69,7 +69,7 @@ function renderUserProvider(appId: string, baseUrl: string) {
return renderHook(() => useUser(), { wrapper });
}

describe.skip("UserProvider", () => {
describe("UserProvider", () => {
describe("with auto confirm", () => {
let appId: string;
beforeAll(async () => {
Expand Down Expand Up @@ -98,10 +98,12 @@ describe.skip("UserProvider", () => {
const creds = Realm.Credentials.emailPassword({ email: testEmail, password: testPassword });
const realmApp = new App({ id: appId, baseUrl });

await realmApp.logIn(creds);
await act(async () => {
realmApp.logIn(creds);
});

expect(id).toEqual(realmApp?.currentUser?.id);
expect(refreshToken).not.toEqual(realmApp?.currentUser?.refreshToken);
expect(refreshToken).toEqual(realmApp?.currentUser?.refreshToken);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function renderEmailPasswordAuth(appId: string, baseUrl: string) {
return renderHook(() => useEmailPasswordAuth(), { wrapper });
}

describe.skip("useEmailPassword", () => {
describe("useEmailPassword", () => {
describe("with auto confirm", () => {
let appId: string;
beforeAll(async () => {
Expand Down Expand Up @@ -72,8 +72,11 @@ describe.skip("useEmailPassword", () => {
const user = realmApp.currentUser;
expect(user).not.toBeNull();

await act(async () => {
await result.current.logOut();
await testAuthOperation({
authOperation: result.current.logOut,
expectedResult: () => {
expect(result.current.result.success).toEqual(true);
},
});
expect(realmApp.currentUser).toBeNull();
});
Expand Down
5 changes: 3 additions & 2 deletions packages/realm/bindgen/js_opt_in_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ classes:
- make_ssl_verify_callback
- needs_file_format_upgrade
- sync_user_as_app_user
- app_user_as_sync_user

LogCategoryRef:
methods:
Expand Down Expand Up @@ -446,7 +447,8 @@ classes:
- api_key

SyncUser:
methods: []
methods:
- is_logged_in

User:
methods:
Expand All @@ -459,7 +461,6 @@ classes:
- unsubscribe
- path_for_realm
- app
- is_logged_in
- user_id
- app_id
- legacy_identities
Expand Down
2 changes: 1 addition & 1 deletion packages/realm/src/app-services/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export class App<

fs.ensureDirectoryForFile(fs.joinPaths(baseFilePath || fs.getDefaultDirectoryPath(), "mongodb-realm"));
// TODO: This used getSharedApp in the legacy SDK, but it's failing AppTests
this.internal = binding.App.getApp(binding.AppCacheMode.Disabled, {
this.internal = binding.App.getApp(binding.AppCacheMode.Enabled, {
appId: id,
deviceInfo: App.deviceInfo,
transport: createNetworkTransport(fetch),
Expand Down
5 changes: 4 additions & 1 deletion packages/realm/src/app-services/SyncConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,11 @@ export function toBindingSyncConfig(config: SyncConfiguration): binding.SyncConf
proxyConfig,
} = config;

const syncUser = binding.Helpers.appUserAsSyncUser(user.internal);
assert(syncUser);

return {
user: user.internal,
user: syncUser,
partitionValue: flexible ? undefined : EJSON.stringify(partitionValue),
flxSyncRequested: !!flexible,
stopPolicy: _sessionStopPolicy
Expand Down
4 changes: 3 additions & 1 deletion packages/realm/src/app-services/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ export class User<
* @returns `true` if the user is logged in, `false` otherwise.
*/
get isLoggedIn(): boolean {
return this.internal.isLoggedIn;
const syncUser = binding.Helpers.appUserAsSyncUser(this.internal);
assert(syncUser);
return syncUser.isLoggedIn;
}

/**
Expand Down

0 comments on commit 52990c5

Please sign in to comment.