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

Enable all tests after bad rebase #5595

Merged
merged 38 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
152816a
Importing all tests
kraenhansen Mar 20, 2023
d55245c
Temporarily skipping "open-behavior" as they crash
kraenhansen Mar 20, 2023
6d056b4
Updating error messages to match the new SDK
kraenhansen Mar 20, 2023
2a8a500
Throw when setting length of Results
kraenhansen Mar 20, 2023
6eea9b6
Correct error when assigning to OrderedCollection
kraenhansen Mar 20, 2023
f402d84
Updated tests to use new error codes
kraenhansen Mar 23, 2023
4f7e42f
Adding a missing Realm import
kraenhansen Mar 23, 2023
cc62c45
Re-arming the Realm.open tests
kraenhansen Mar 23, 2023
0414587
Cancel unresolved tasks when clearing test state
kraenhansen Mar 23, 2023
c7f22c8
Clear test state after compensating writes test
kraenhansen Mar 28, 2023
41938c5
Moved clearTestState up
kraenhansen Mar 29, 2023
b5fc63f
nit
kraenhansen Mar 29, 2023
f81e37c
Using isValid to assert object deletion
kraenhansen Mar 29, 2023
a99eb1a
Adding a fast-track for common types
kraenhansen Mar 29, 2023
2b887ab
Convert typed arrays to arraybuffer
kraenhansen Mar 29, 2023
d5d3fc5
Fixing nested lists test
kraenhansen Mar 29, 2023
5bfef21
Fixing api-key client test
kraenhansen Mar 29, 2023
abb53b9
Fixed timeout test
kraenhansen Mar 29, 2023
83afc11
Fixing test to avoid mutating object schema when normalizing
kraenhansen Mar 29, 2023
0ae2d0e
Fixed flexible sync clearTestState
kraenhansen Mar 30, 2023
38e5e0a
Fixed ProgressRealmPromise TSR race
kraenhansen Mar 30, 2023
e7d28e9
Fixed invalid sync config tests
kraenhansen Mar 30, 2023
9a265a5
Made PromiseHandle directly awaitable and tested
kraenhansen Mar 30, 2023
8c0fe4d
Renamed "RealmListeners#callback" to "notify"
kraenhansen Mar 30, 2023
ae82a2d
Spreading RealmListeners#listeners when notifying
kraenhansen Mar 30, 2023
dd8df6e
Fixed linkingObjects assert
kraenhansen Mar 30, 2023
25d0d00
Fixed "Bad changeset (UPLOAD)" by passing partition
kraenhansen Mar 30, 2023
3a62181
Asserting a valid object after thrown from defaultGet and defaultSet
kraenhansen Mar 31, 2023
f3f40b6
Updated type asserts on OrderedCollection#sorted
kraenhansen Mar 31, 2023
08afce6
Updated expected message from prohibited upgrades
kraenhansen Mar 31, 2023
c0f6f9f
Adding ORG_GRADLE_PROJECT_* to test:android
kraenhansen Apr 1, 2023
f407288
Fix bigIntToI64 and bigIntToU64 on JSC
kraenhansen Apr 3, 2023
4815409
Throw from _objectForObjectKey if objectKey is not numeric
kraenhansen Apr 3, 2023
2410d2d
Transform colKey to string before storing and looking it up
kraenhansen Apr 3, 2023
63e8f96
Made stackTrace test less platform dependent
kraenhansen Apr 3, 2023
353a12c
Update integration-tests/tests/src/tests.ts
kraenhansen Apr 3, 2023
faf18c1
Update integration-tests/tests/src/tests/sync/sync-session.ts
kraenhansen Apr 3, 2023
c7eddda
Apply suggestions from code review
kraenhansen Apr 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion integration-tests/environments/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@
],
"env": {
"PLATFORM": "android",
"WATCH": "false"
"WATCH": "false",
"ORG_GRADLE_PROJECT_newArchEnabled": {
"external": true
},
"ORG_GRADLE_PROJECT_hermesEnabled": {
"external": true
}
}
},
"test:ios": {
Expand Down
1 change: 1 addition & 0 deletions integration-tests/tests/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ afterEach(() => {

import "./utils/import-app.test.ts";
import "./utils/chai-plugin.test.ts";
import "./utils/promise-handle.test.ts";
import "./mocha-internals.test.ts";

import "./tests";
Expand Down
22 changes: 20 additions & 2 deletions integration-tests/tests/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,45 @@ import "./tests/credentials/jwt";
import "./tests/sync/app";
import "./tests/sync/asymmetric";
import "./tests/sync/client-reset";
import "./tests/sync/dictionary";
import "./tests/sync/encryption";
import "./tests/sync/flexible";
import "./tests/sync/mixed";
import "./tests/sync/sync-as-local";
import "./tests/sync/upload-delete-download";
import "./tests/sync/mongo-db-client";
import "./tests/sync/open-behavior";
import "./tests/sync/open";
import "./tests/sync/partition-values";
import "./tests/sync/realm-conversions";
import "./tests/sync/realm";
import "./tests/sync/set";
import "./tests/sync/sync-as-local";
import "./tests/sync/sync-session";
import "./tests/sync/upload-delete-download";
import "./tests/sync/user";
import "./tests/sync/uuid";

import "./tests/alias";
import "./tests/array-buffer";
import "./tests/bson";
import "./tests/class-models";
import "./tests/dictionary";
import "./tests/dynamic-schema-updates";
import "./tests/enums";
import "./tests/iterators";
import "./tests/linking-objects";
import "./tests/list";
import "./tests/listeners";
import "./tests/migrations";
import "./tests/mixed";
import "./tests/notifications";
import "./tests/objects";
import "./tests/queries";
import "./tests/realm-constructor";
import "./tests/results";
import "./tests/schema";
import "./tests/serialization";
import "./tests/set";
import "./tests/sets";
import "./tests/shared-realms";
import "./tests/transaction";
import "./tests/types";
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/array-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ describe("ArrayBuffer type", () => {
it("handles wrong input", function (this: RealmContext) {
expect(() => {
this.realm.write(() => this.realm.create(SingleSchema.name, { a: {} }));
}).throws(Error, "PrimitiveData.a must be of type 'binary?', got 'object' ([object Object])");
}).throws("Expected value to be an instance of ArrayBuffer, got an object");
});
});
9 changes: 3 additions & 6 deletions integration-tests/tests/src/tests/linking-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,13 @@ describe("Linking objects", () => {
person = this.realm.create<IPersonSchema>(PersonSchema.name, { name: "Person 1", age: 50 });
});
expect(() => person.linkingObjects("NoSuchSchema", "noSuchProperty")).throws(
Error,
"Could not find schema for type 'NoSuchSchema'",
"Object type 'NoSuchSchema' not found in schema.",
);
expect(() => person.linkingObjects("PersonObject", "noSuchProperty")).throws(
Error,
"Type 'PersonObject' does not contain property 'noSuchProperty'",
"Property 'noSuchProperty' does not exist on 'PersonObject' objects",
);
expect(() => person.linkingObjects("PersonObject", "name")).throws(
Error,
"'PersonObject.name' is not a relationship to 'PersonObject'",
"'PersonObject#name' is not a relationship to 'PersonObject'",
);
let olivier: Person;
let oliviersParents: Realm.Results<IPersonSchema>;
Expand Down
14 changes: 10 additions & 4 deletions integration-tests/tests/src/tests/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1838,10 +1838,10 @@ describe("Lists", () => {
});

// Test that we can push a created object on a list
const name = this.realm.create<INameObjectSchema>(NameObjectLocalSchema.name, {
const name = this.realm.create<INameObjectSchema>(NameObjectSchema.name, {
_id: new BSON.ObjectId(),
family: "Petersen",
given: ["Gurli", "Margrete"],
family: "Larsen",
given: ["Lars"],
prefix: [],
});
const person = this.realm.create<IParentObjectSchema>(ParentObjectSchema.name, {
Expand All @@ -1853,7 +1853,7 @@ describe("Lists", () => {
});

const objects = this.realm.objects<IParentObjectSchema>(ParentObjectSchema.name).sorted([["id", false]]);
expect(objects.length).equals(2);
expect(objects.length).equals(3);
expect(objects[0].name.length).equals(2);
expect(objects[0].name[0].given.length).equals(2);
expect(objects[0].name[0].prefix.length).equals(0);
Expand All @@ -1868,6 +1868,12 @@ describe("Lists", () => {
expect(objects[1].name[0].prefix.length).equals(0);
expect(objects[1].name[0].given[0]).equals("Gurli");
expect(objects[1].name[0].given[1]).equals("Margrete");

expect(objects[2].name.length).equals(1);
expect(objects[2].name[0].given.length).equals(1);
expect(objects[2].name[0].prefix.length).equals(0);
expect(objects[2].name[0].given[0]).equals("Lars");
expect(objects[2].name[0].family).equals("Larsen");
});
it("supports nested lists from parsed JSON", function (this: RealmContext) {
const json =
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/tests/src/tests/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe("Migrations", () => {
expect(function () {
//@ts-expect-error This is an invalid function.
new Realm({ schema: [], schemaVersion: 2, onMigration: "invalid", inMemory: true });
}).throws("onMigration must be of type 'function'");
}).throws("Expected 'onMigration' on realm configuration to be a function, got a string");
});

it("should propogate exceptions", () => {
Expand Down Expand Up @@ -437,7 +437,7 @@ describe("Migrations", () => {
expect(() => {
// Deleting a model which is target of linkingObjects results in an exception
newRealm.deleteModel("Person");
}).throws("Table is target of cross-table link columns");
}).throws("Cannot remove class_Person that is target of outside links");
},
});

Expand Down
11 changes: 6 additions & 5 deletions integration-tests/tests/src/tests/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1064,9 +1064,9 @@ describe("Realm.Object", () => {
this.realm.delete(obj);
expect(obj.isValid()).to.be.false;
// Reading a column from deleted object should fail
expect(() => obj.doubleCol).to.throw("No object with key");
expect(() => obj.doubleCol).to.throw("Accessing object which has been invalidated or deleted");
// Writing to a column from deleted object should fail
expect(() => (obj.doubleCol = 0)).to.throw("No object with key");
expect(() => (obj.doubleCol = 0)).to.throw("Accessing object which has been invalidated or deleted");
return obj;
});

Expand Down Expand Up @@ -1113,10 +1113,11 @@ describe("Realm.Object", () => {
const freeKey = obj._objectKey();
//@ts-expect-error uses private method.
const obj1 = this.realm._objectForObjectKey(AgeSchema.name, "1" + freeKey);
//@ts-expect-error uses private method.
const obj2 = this.realm._objectForObjectKey(AgeSchema.name, "invalid int64_t");
expect(obj1).to.be.undefined;
expect(obj2).to.be.undefined;
expect(() => {
//@ts-expect-error uses private method.
this.realm._objectForObjectKey(AgeSchema.name, "invalid int64_t");
}).throws("Expected value to be a numeric string, got a string");
});

it("modifying object fetched from key propagates", async function (this: Mocha.Context & RealmContext) {
Expand Down
36 changes: 20 additions & 16 deletions integration-tests/tests/src/tests/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ const NullableBasicTypesSchema = {
};

describe("Results", () => {
afterEach(() => {
Realm.clearTestState();
});

describe("General functionality", () => {
openRealmBeforeEach({ schema: [TestObject] });

Expand Down Expand Up @@ -169,7 +173,7 @@ describe("Results", () => {

expect(() => {
objects.indexOf(object4);
}).throws("Realm object is from another Realm");
}).throws("Object of type 'TestObject' does not match Results type 'TestObject'");
});

it("should be read-only", function (this: RealmContext) {
Expand All @@ -186,11 +190,11 @@ describe("Results", () => {
expect(() => {
//@ts-expect-error Should be an invalid write to read-only object.
objects[0] = { doubleCol: 0 };
}).throws(select({ reactNative: "Cannot assign to index", default: "Cannot assign to read only index 0" }));
}).throws("Assigning into a Results is not supported");
expect(() => {
//@ts-expect-error Should be an invalid write to read-only object.
objects[1] = { doubleCol: 0 };
}).throws(select({ reactNative: "Cannot assign to index", default: "Cannot assign to read only index 1" }));
}).throws("Assigning into a Results is not supported");
expect(() => {
//@ts-expect-error Should be an invalid write to read-only object.
objects.length = 0;
Expand Down Expand Up @@ -511,11 +515,11 @@ describe("Results", () => {
expect(() => {
//@ts-expect-error Expected to be an invalid sorted argument.
objects.sorted(1);
}).throws("JS value must be of type 'string'");
}).throws("Expected 'argument' to be property name and optional bool or an array of descriptors, got a number");
expect(() => {
//@ts-expect-error Expected to be an invalid sorted argument.
objects.sorted([1]);
}).throws("JS value must be of type 'string'");
}).throws("Expected 'descriptor[0]' to be string or array with two elements [string, boolean], got a number");

expect(() => {
objects.sorted("fish");
Expand All @@ -527,7 +531,7 @@ describe("Results", () => {
expect(() => {
//@ts-expect-error Expected to be an invalid sorted argument.
objects.sorted(["valueCol", "primaryCol"], true);
}).throws("Second argument is not allowed if passed an array of sort descriptors");
}).throws("Expected second 'argument' to be undefined, got a boolean");

realm.close();
});
Expand Down Expand Up @@ -752,28 +756,28 @@ describe("Results", () => {
["boolCol", "stringCol", "dataCol"].forEach((colName) => {
expect(() => {
results.min(colName);
}).throws(`Cannot min property '${colName}'`);
}).throws("Operation 'min' not supported for");
});

// bool, string & data columns don't support 'max'
["boolCol", "stringCol", "dataCol"].forEach((colName) => {
expect(() => {
results.max(colName);
}).throws(`Cannot max property '${colName}'`);
}).throws(`Operation 'max' not supported for`);
});

// bool, string, date & data columns don't support 'avg'
["boolCol", "stringCol", "dateCol", "dataCol"].forEach((colName) => {
expect(() => {
results.avg(colName);
}).throws(`Cannot avg property '${colName}'`);
}).throws(`Operation 'average' not supported for`);
});

// bool, string, date & data columns don't support 'sum'
["boolCol", "stringCol", "dateCol", "dataCol"].forEach((colName) => {
expect(() => {
results.sum(colName);
}).throws(`Cannot sum property '${colName}'`);
}).throws(`Operation 'sum' not supported for`);
});
});

Expand All @@ -784,16 +788,16 @@ describe("Results", () => {
const results = this.realm.objects("NullableBasicTypesObject");
expect(() => {
results.min("foo");
}).throws("Property 'foo' does not exist on object 'NullableBasicTypesObject'");
}).throws("Property 'foo' does not exist on 'NullableBasicTypesObject' objects");
expect(() => {
results.max("foo");
}).throws("Property 'foo' does not exist on object 'NullableBasicTypesObject'");
}).throws("Property 'foo' does not exist on 'NullableBasicTypesObject' objects");
expect(() => {
results.sum("foo");
}).throws("Property 'foo' does not exist on object 'NullableBasicTypesObject'");
}).throws("Property 'foo' does not exist on 'NullableBasicTypesObject' objects");
expect(() => {
results.avg("foo");
}).throws("Property 'foo' does not exist on object 'NullableBasicTypesObject'");
}).throws("Property 'foo' does not exist on 'NullableBasicTypesObject' objects");
});
});

Expand Down Expand Up @@ -979,11 +983,11 @@ describe("Results", () => {
this.realm.write(() => {
results.update("unknownCol", "world");
});
}).throws("No such property: unknownCol");
}).throws("Property 'unknownCol' does not exist on 'NullableBasicTypesObject' objects");

expect(() => {
results.update("stringCol", "world");
}).throws("Can only 'update' objects within a transaction.");
}).throws("Cannot modify managed objects outside of a write transaction.");
});
});
});
8 changes: 4 additions & 4 deletions integration-tests/tests/src/tests/sync/client-reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async function waitServerSideClientResetDiscardUnsyncedChangesCallbacks(

await realm.syncSession?.uploadAllLocalChanges();
await triggerClientReset(app, user);
await resetHandle.promise;
await resetHandle;
}

async function waitServerSideClientResetRecoveryCallbacks(
Expand Down Expand Up @@ -139,7 +139,7 @@ async function waitServerSideClientResetRecoveryCallbacks(

await realm.syncSession?.uploadAllLocalChanges();
await triggerClientReset(app, user);
await resetHandle.promise;
await resetHandle;
}

async function waitSimulatedClientResetDiscardUnsyncedChangesCallbacks(
Expand Down Expand Up @@ -189,7 +189,7 @@ async function waitSimulatedClientResetDiscardUnsyncedChangesCallbacks(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore calling undocumented method _simulateError
realm.syncSession?._simulateError(211, "Simulate Client Reset", "realm::sync::ProtocolError", false); // 211 -> diverging histories
await resetHandle.promise;
await resetHandle;
}

async function waitSimulatedClientResetRecoverCallbacks(
Expand Down Expand Up @@ -243,7 +243,7 @@ async function waitSimulatedClientResetRecoverCallbacks(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore calling undocumented method _simulateError
session._simulateError(211, "Simulate Client Reset", "realm::sync::ProtocolError", false); // 211 -> diverging histories; 217 -> synchronization no longer possible for client-side file
await resetHandle.promise;
await resetHandle;
}

/**
Expand Down
20 changes: 10 additions & 10 deletions integration-tests/tests/src/tests/sync/flexible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,11 @@ describe.skipIf(environment.missingServer, "Flexible sync", function () {
this.timeout(60_000); // TODO: Temporarily hardcoded until envs are set up.
importAppBefore("with-db-flx");
authenticateUserBefore();
afterEach(() => {
Realm.clearTestState();
});

describe("Configuration", () => {
afterEach(() => {
Realm.clearTestState();
});

describe("flexible sync Realm config", function () {
it.skip("respects cancelWaitOnNonFatalError", async function () {
this.timeout(2_000);
Expand Down Expand Up @@ -477,11 +476,11 @@ describe.skipIf(environment.missingServer, "Flexible sync", function () {
});

await realm.syncSession?.uploadAllLocalChanges();
await callbackHandle.promise;
await callbackHandle;
});
});

describe("With realm opened before", function () {
describe("with realm opened before", function () {
openRealmBeforeEach({
schema: [FlexiblePersonSchema, DogSchema],
sync: {
Expand Down Expand Up @@ -1769,16 +1768,17 @@ describe.skipIf(environment.missingServer, "Flexible sync", function () {
it("deletes the item if an item not matching the filter is created", async function (this: RealmContext) {
await addSubscriptionAndSync(this.realm, this.realm.objects(FlexiblePersonSchema.name).filtered("age < 30"));

this.realm.write(() => {
const tom = this.realm.write(() =>
this.realm.create<IPerson>(FlexiblePersonSchema.name, {
_id: new BSON.ObjectId(),
name: "Tom Old",
age: 99,
});
});
}),
);

expect(tom.isValid()).equals(true);
await this.realm.syncSession?.downloadAllServerChanges();
expect(this.realm.objects(FlexiblePersonSchema.name)).to.have.length(0);
expect(tom.isValid()).equals(false);
});

it("throw an exception if you remove a subscription without waiting for server acknowledgement, then modify objects that were only matched by the now removed subscription", async function (this: RealmContext) {
Expand Down
Loading