Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: enable testing in debug build

Ammar Ahmedea2bc359cb13
diff --git a/apps/mobile/e2e/globalSetup.ts b/apps/mobile/e2e/globalSetup.ts
index cdc3d0160..d66b68254 100644
--- a/apps/mobile/e2e/globalSetup.ts
+++ b/apps/mobile/e2e/globalSetup.ts
@@ -7,6 +7,8 @@ import { globalSetup } from "detox/runners/jest";
export default async function customGlobalSetup() {
const config = await resolveConfig();
+ //@ts-ignore
+ globalThis["DEBUG_MODE"] = config.configurationName;
if (config.device.type === "android.emulator") {
await downloadTestButlerAPK();
}
diff --git a/apps/mobile/e2e/tests/auth.e2e.js b/apps/mobile/e2e/tests/auth.e2e.ts
similarity index 72%
rename from apps/mobile/e2e/tests/auth.e2e.js
rename to apps/mobile/e2e/tests/auth.e2e.ts
index cd1363d6b..50c94049c 100644
--- a/apps/mobile/e2e/tests/auth.e2e.js
+++ b/apps/mobile/e2e/tests/auth.e2e.ts
@@ -18,14 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { authenticator } from "otplib";
-import {
- elementById,
- openSideMenu,
- prepare,
- sleep,
- tapByText,
- visibleByText
-} from "./utils";
+import { Tests } from "./utils";
import dotenv from "dotenv";
import path from "path";
@@ -42,16 +35,17 @@ const USER = {
};
async function login() {
- await tapByText("Login to sync your notes.");
- await elementById("input.email").typeText(USER.login.email);
- await tapByText("Login");
- await sleep(3000);
- await elementById("input.totp").typeText(
- authenticator.generate(USER.login.totpSecret)
+ await Tests.fromText("Login to encrypt and sync notes").tap();
+ await Tests.fromId("input.email").element.typeText(USER.login.email!);
+ await Tests.fromText("Continue").tap();
+ await Tests.sleep(3000);
+ await Tests.fromId("input.totp").element.typeText(
+ authenticator.generate(USER.login.totpSecret!)
);
- await sleep(3000);
- await elementById("input.password").typeText(USER.login.password);
- await elementById("input.password").tapReturnKey();
+ await Tests.fromText("Next").tap();
+ await Tests.sleep(3000);
+ await Tests.fromId("input.password").element.typeText(USER.login.password!);
+ await Tests.fromId("input.password").element.tapReturnKey();
}
// async function deleteAccount() {
@@ -74,12 +68,10 @@ async function login() {
// }
describe("AUTH", () => {
- it.skip("Login", async () => {
- await prepare();
- await openSideMenu();
+ it("Login", async () => {
+ await Tests.prepare();
await login();
- await sleep(10000);
- await openSideMenu();
- await visibleByText("Tap here to sync your notes.");
+ await Tests.sleep(10000);
+ await Tests.fromText("Login to encrypt and sync notes").isNotVisible();
});
});
diff --git a/apps/mobile/e2e/tests/tag.e2e.ts b/apps/mobile/e2e/tests/tag.e2e.ts
index 92fbc8fe5..de865602e 100644
--- a/apps/mobile/e2e/tests/tag.e2e.ts
+++ b/apps/mobile/e2e/tests/tag.e2e.ts
@@ -21,6 +21,20 @@ import { notesnook } from "../test.ids";
import { Tests } from "./utils";
describe("Tags", () => {
+ it("Create a tag", async () => {
+ await Tests.prepare();
+ await Tests.openSideMenu();
+ await Tests.fromId("tab-tags").waitAndTap();
+
+ await Tests.fromText("No tags").isVisible();
+ await Tests.fromId("sidebar-add-button").waitAndTap();
+
+ await Tests.fromId("input-value").element.typeText("testtag");
+
+ await Tests.fromText("Add").waitAndTap();
+ await Tests.fromText("testtag").isVisible();
+ });
+
it("Tag a note", async () => {
await Tests.prepare();
let note = await Tests.createNote();
diff --git a/apps/mobile/e2e/tests/utils.ts b/apps/mobile/e2e/tests/utils.ts
index 764d62388..9e0dc7905 100644
--- a/apps/mobile/e2e/tests/utils.ts
+++ b/apps/mobile/e2e/tests/utils.ts
@@ -74,7 +74,8 @@ const Tests = {
awaitLaunch: async () => {
await waitFor(element(by.id(notesnook.ids.default.root)))
.toBeVisible()
- .withTimeout(500);
+ //@ts-ignore
+ .withTimeout(globalThis["DEBUG_MODE"] ? 4000 : 500);
},
sleep: (duration: number) => {
return new Promise((resolve) =>
diff --git a/apps/mobile/native/globals.js b/apps/mobile/native/globals.js
index 9d7ed32fc..e4b8151b2 100644
--- a/apps/mobile/native/globals.js
+++ b/apps/mobile/native/globals.js
@@ -22,9 +22,10 @@ import {
import {
messages as $pseudo
} from "@notesnook/intl/dist/locales/$pseudo-LOCALE.json";
+import Config from "react-native-config";
i18n.load({
- en: __DEV__ ? $pseudo : $en
+ en: __DEV__ && Config.isTesting !== "true" ? $pseudo : $en
});
setI18nGlobal(i18n);
i18n.activate("en");