Skip to content

Commit

Permalink
Added skipIf missingServer to non-local tests (#6290)
Browse files Browse the repository at this point in the history
  • Loading branch information
kraenhansen authored and takameyer committed Dec 4, 2023
1 parent 845b4f0 commit 3c61eff
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 56 deletions.
74 changes: 39 additions & 35 deletions integration-tests/tests/src/node/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,42 +123,46 @@ describe.skipIf(environment.missingServer, "path configuration (partition based
});
});

describe.skipIf(environment.skipFlexibleSync, "path configuration (flexible sync)", function () {
importAppBefore(buildAppConfig("with-flx").anonAuth().flexibleSync());
authenticateUserBefore();
describe.skipIf(
environment.skipFlexibleSync || environment.missingServer,
"path configuration (flexible sync)",
function () {
importAppBefore(buildAppConfig("with-flx").anonAuth().flexibleSync());
authenticateUserBefore();

it("absolute path", async function () {
this.longTimeout();
const filename = getAbsolutePath();
const realm = await Realm.open({
path: filename,
schema: [schema],
sync: {
flexible: true,
user: this.user,
},
it("absolute path", async function () {
this.longTimeout();
const filename = getAbsolutePath();
const realm = await Realm.open({
path: filename,
schema: [schema],
sync: {
flexible: true,
user: this.user,
},
});
expect(realm.path).to.equal(filename);
expect(Realm.exists({ path: filename })).to.be.true;
realm.close();
Realm.deleteFile({ path: filename });
});
expect(realm.path).to.equal(filename);
expect(Realm.exists({ path: filename })).to.be.true;
realm.close();
Realm.deleteFile({ path: filename });
});

it("relative path", async function () {
this.longTimeout();
const filename = getRelativePath();
const realm = await Realm.open({
path: filename,
schema: [schema],
sync: {
flexible: true,
user: this.user,
},
it("relative path", async function () {
this.longTimeout();
const filename = getRelativePath();
const realm = await Realm.open({
path: filename,
schema: [schema],
sync: {
flexible: true,
user: this.user,
},
});
// Realm Core will add a ".realm" suffix and url encode the path, if path is relative and sync is configured
const realmPath = realm.path;
expect(Realm.exists({ path: realmPath })).to.be.true;
realm.close();
Realm.deleteFile({ path: realmPath });
});
// Realm Core will add a ".realm" suffix and url encode the path, if path is relative and sync is configured
const realmPath = realm.path;
expect(Realm.exists({ path: realmPath })).to.be.true;
realm.close();
Realm.deleteFile({ path: realmPath });
});
});
},
);
8 changes: 4 additions & 4 deletions integration-tests/tests/src/tests/sync/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe("App", () => {
);
});

it("logging in throws on non existing app", async function () {
it.skipIf(environment.missingServer, "logging in throws on non existing app", async function () {
const app = new Realm.App(missingAppConfig);
const credentials = Realm.Credentials.anonymous();
await expect(app.logIn(credentials)).to.be.rejectedWith("cannot find app using Client App ID 'smurf'");
Expand Down Expand Up @@ -171,7 +171,7 @@ describe("App", () => {
});
});

describe("with valid app", async () => {
describe.skipIf(environment.missingServer, "with valid app", async () => {
importAppBefore(buildAppConfig("with-anon").anonAuth());

it("logins successfully ", async function (this: Mocha.Context & AppContext & RealmContext) {
Expand Down Expand Up @@ -264,7 +264,7 @@ describe("App", () => {
});
});

describe("with email-password auth", () => {
describe.skipIf(environment.missingServer, "with email-password auth", () => {
importAppBefore(
buildAppConfig("with-email-password").emailPasswordAuth({
autoConfirm: true,
Expand All @@ -285,7 +285,7 @@ describe("App", () => {
});
});

describe("with sync", () => {
describe.skipIf(environment.missingServer, "with sync", () => {
importAppBefore(buildAppConfig("with-pbs").anonAuth().partitionBasedSync());

it("migration while sync is enabled throws", async function (this: Mocha.Context & AppContext & RealmContext) {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/sync/encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe("Encryption", () => {
});
});

describe("with sync", () => {
describe.skipIf(environment.missingServer, "with sync", () => {
importAppBefore(buildAppConfig("with-pbs").anonAuth().partitionBasedSync());

it("can set property in config", async function (this: AppContext) {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/sync/open-behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function getRegisteredEmailPassCredentials(app: Realm.App<any, any>) {
return Realm.Credentials.emailPassword(email, password);
}

describe("OpenBehaviour", function () {
describe.skipIf(environment.missingServer, "OpenBehaviour", function () {
this.longTimeout();
importAppBefore(buildAppConfig("with-pbs").anonAuth().emailPasswordAuth().partitionBasedSync());
afterEach(() => Realm.clearTestState());
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/sync/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Realm from "realm";
import { authenticateUserBefore, importAppBefore } from "../../hooks";
import { buildAppConfig } from "../../utils/build-app-config";

describe("Realm.open on a sync Realm", () => {
describe.skipIf(environment.missingServer, "Realm.open on a sync Realm", () => {
importAppBefore(buildAppConfig("with-flx").anonAuth().flexibleSync());
authenticateUserBefore();

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/sync/partition-values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const createConfig = (schema: Realm.ObjectSchema, user: Realm.User, partitionVal
},
});

describe("Partition-values", () => {
describe.skipIf(environment.missingServer, "Partition-values", () => {
describe("setting partition value on config", () => {
importAppBefore(buildAppConfig("with-pbs").anonAuth().partitionBasedSync());
afterEach(() => Realm.clearTestState());
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/tests/src/tests/sync/realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ describe("Realmtest", () => {
});
});

describe("schemaVersion", () => {
describe.skipIf(environment.missingServer, "schemaVersion", () => {
importAppBefore(buildAppConfig("with-pbs").anonAuth().partitionBasedSync());

[true, false].forEach((encryption) => {
Expand All @@ -1380,7 +1380,7 @@ describe("Realmtest", () => {
});
});

describe("exists", () => {
describe.skipIf(environment.missingServer, "exists", () => {
importAppBefore(buildAppConfig("with-pbs").anonAuth().partitionBasedSync());

it("yields correct value on a local realm", () => {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/sync/sync-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async function seedDataWithExternalUser(app: Realm.App, partition: string) {
user.logOut();
}

describe("SessionTest", () => {
describe.skipIf(environment.missingServer, "SessionTest", () => {
importAppBefore(buildAppConfig("with-pbs").emailPasswordAuth().partitionBasedSync({ required: true }));

describe("invalid syncsessions", () => {
Expand Down
12 changes: 2 additions & 10 deletions packages/realm-react/src/__tests__/UserProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { App } from "realm";
const testEmail = "[email protected]";
const testPassword = "password";

// This is used to determine the initial state for user registrations.
// Ensures that subsequent tests do not register the test user again.
let userRegistered = false;

const Login = () => {
Expand All @@ -37,22 +39,19 @@ const Login = () => {

useEffect(() => {
if (!isUserRegistered && !result.pending && result.operation !== AuthOperationName.Register) {
console.log("registering user");
register({ email: testEmail, password: testPassword });
}
}, [register, isUserRegistered, result]);

useEffect(() => {
if (result.success && result.operation === AuthOperationName.Register) {
console.log("user registered");
userRegistered = true;
setIsUserRegistered(true);
}
}, [result]);

useEffect(() => {
if (isUserRegistered && !result.pending && result.operation !== AuthOperationName.LogInWithEmailPassword) {
console.log("logging in user");
logIn({ email: testEmail, password: testPassword });
}
}, [logIn, isUserRegistered]);
Expand Down Expand Up @@ -100,13 +99,6 @@ describe("UserProvider", () => {

await realmApp.logIn(creds);

console.log("testing results: ", {
id,
currentId: realmApp?.currentUser?.id,
refreshToken,
currentRefreshToken: realmApp?.currentUser?.refreshToken,
});

expect(id).toEqual(realmApp?.currentUser?.id);
expect(refreshToken).not.toEqual(realmApp?.currentUser?.refreshToken);
});
Expand Down

0 comments on commit 3c61eff

Please sign in to comment.