A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
add some basic e2e tests
ammarahm-edafc4871d9033
diff --git a/apps/mobile/.detoxrc.json b/apps/mobile/.detoxrc.jsonindex 52fb19191..b068f9403 100644--- a/apps/mobile/.detoxrc.json+++ b/apps/mobile/.detoxrc.json@@ -20,7 +20,7 @@"android.dev.debug": {"binaryPath": "android/app/build/outputs/apk/debug/app-arm64-v8a-debug.apk","testBinaryPath": "android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk",- "build": "cd android && ./gradlew app:assembleDebug app:assembleAndroidTest -DtestBuildType=debug && cd ..",+ "build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..","type": "android.attached","device": {"adbName": "LMG710ULM3d3678f0"@@ -28,10 +28,11 @@},"android.dev.release": {"binaryPath": "android/app/build/outputs/apk/release/app-arm64-v8a-release.apk",- "build": "cd android ; ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release ; cd -",- "type": "android.emulator",+ "testBinaryPath": "android/app/build/outputs/apk/androidTest/release/app-release-androidTest.apk",+ "build": "cd android ; ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release ; cd ..",+ "type": "android.attached","device": {- "avdName": "LMG710ULM3d3678f0"+ "adbName": "LMG710ULM3d3678f0"}}}diff --git a/apps/mobile/babel.config.js b/apps/mobile/babel.config.jsindex 7c6341171..8bb68016c 100644--- a/apps/mobile/babel.config.js+++ b/apps/mobile/babel.config.js@@ -1,6 +1,6 @@module.exports = {presets: ['module:metro-react-native-babel-preset'],plugins: [- "transform-remove-console"+ //"transform-remove-console"]};diff --git a/apps/mobile/e2e/config.json b/apps/mobile/e2e/config.jsonindex ee9e70105..128ef6dd3 100644--- a/apps/mobile/e2e/config.json+++ b/apps/mobile/e2e/config.json@@ -1,6 +1,7 @@{"testEnvironment": "./environment","testRunner": "jest-circus/runner",+ "setupFilesAfterEnv": ["./setup.ts"],"testTimeout": 120000,"testRegex": "\\index.e2e\\.js$","reporters": ["detox/runners/jest/streamlineReporter"],diff --git a/apps/mobile/e2e/setup.ts b/apps/mobile/e2e/setup.tsnew file mode 100644index 000000000..898beb5e9--- /dev/null+++ b/apps/mobile/e2e/setup.ts@@ -0,0 +1,3 @@+beforeAll(async () => {+ await device.launchApp();+});\ No newline at end of filediff --git a/apps/mobile/e2e/test.ids.js b/apps/mobile/e2e/test.ids.jsindex 2a7ab89ef..73d706408 100644--- a/apps/mobile/e2e/test.ids.js+++ b/apps/mobile/e2e/test.ids.js@@ -1,4 +1,11 @@export const notesnook = {+ editor:{+ back:"editor.back",+ id:"editor.id"+ },+ buttons:{+ add:"buttons.add"+ },ids: {default: {root: 'root',diff --git a/apps/mobile/e2e/tests/index.e2e.js b/apps/mobile/e2e/tests/index.e2e.jsindex 1a48800f8..96fc38aac 100644--- a/apps/mobile/e2e/tests/index.e2e.js+++ b/apps/mobile/e2e/tests/index.e2e.js@@ -1,15 +1,52 @@-const detox = require("detox");-const { LaunchApp } = require("./misc.e2e");+const detox = require('detox');+const {beforeAll} = require('jest-circus');+const {notesnook} = require('../test.ids');+const {+ LaunchApp,+ navigate,+ tapById,+ elementById,+ visibleByText,+ tapByText+} = require('./misc.e2e');+const {sleep} = require('./utils.test');+beforeAll(async () => {+ await device.reloadReactNative();+});-beforeAll(- async () => {- await detox.init();- await detox.device.launchApp();- },- 30 * 1000,-);+describe('Basic tests', () => {+ it('App should launch successfully & hide welcome screen', async () => {+ await LaunchApp();+ });-it('App should launch successfully', async () => {- await LaunchApp();-});\ No newline at end of file+ it('Basic navigation should work', async () => {+ await sleep(500);+ await navigate('Notebooks');+ await navigate('Favorites');+ await navigate('Trash');+ await navigate('Tags');+ await navigate('Settings');+ await navigate('Monographs');+ await navigate('Notes');+ });++ it('App should create a note successfully', async () => {+ await sleep(100);+ await tapById(notesnook.buttons.add);+ await sleep(200);+ await elementById(notesnook.editor.id).tap({+ x: 15,+ y: 15+ });+ await elementById(notesnook.editor.id).typeText('Test note description that is very long and should not fit in text.');+ await sleep(200);+ await tapById(notesnook.editor.back);+ await sleep(300);+ await visibleByText('Test note description that ');+ await tapById(notesnook.ids.note.get(1));+ await tapById(notesnook.editor.back);+ });+++});diff --git a/apps/mobile/e2e/tests/misc.e2e.js b/apps/mobile/e2e/tests/misc.e2e.jsindex aa1db84ac..2370c7e31 100644--- a/apps/mobile/e2e/tests/misc.e2e.js+++ b/apps/mobile/e2e/tests/misc.e2e.js@@ -3,37 +3,43 @@ const {sleep} = require('./utils.test');export async function LaunchApp() {await expect(element(by.id(notesnook.ids.default.root))).toBeVisible();+ await expect(element(by.id('notesnook.splashscreen'))).toBeVisible();+ await element(by.text('Next')).tap();+ await element(by.text('Next')).tap();+ await element(by.text('Next')).tap();+ await element(by.text('Next')).tap();+ await element(by.text('Next')).tap();+ await element(by.text('Next')).tap();+ await element(by.text('I want to try the app first')).tap();}-/*-it('Drawer Navigation', async () => {- let menu = element(by.id(notesnook.ids.default.header.buttons.left));- await menu.tap();- await sleep(100);- await element(by.text('Notebooks')).tap();- menu.tap();- await sleep(100);- await element(by.text('Favorites')).tap();- menu.tap();- await sleep(100);- await element(by.text('Trash')).tap();- menu.tap();- await sleep(100);- await element(by.text('Tags')).tap();- menu.tap();- await sleep(100);- await element(by.text('Settings')).tap();-});-it('Dark Mode', async () => {- let menu = element(by.id(notesnook.ids.default.header.buttons.left));- menu.tap();- await sleep(100);- let nightmode = element(by.id(notesnook.ids.menu.nightmode));- await sleep(100);- await nightmode.tap();- await sleep(100);- await nightmode.tap();+export function elementById(id) {+ return element(by.id(id));+}++export function elementByText(text) {+ return element(by.text(text));+}++export async function tapById(id) {+ await elementById(id).tap();+}++export async function tapByText(text) {+ await elementByText(text).tap();+}++export async function visibleByText(text) {+ await expect(elementByText(text)).toBeVisible();+}++export async function visibleById(id) {+ await expect(elementById(id)).toBeVisible();+}++export async function navigate(screen) {+ let menu = elementById(notesnook.ids.default.header.buttons.left);+ await menu.tap();await sleep(100);- menu.tap();-});- */\ No newline at end of file+ await elementByText(screen).tap();+}diff --git a/apps/mobile/e2e/tests/notes.e2e.js b/apps/mobile/e2e/tests/notes.e2e.jsindex be8378706..d768a8774 100644--- a/apps/mobile/e2e/tests/notes.e2e.js+++ b/apps/mobile/e2e/tests/notes.e2e.js@@ -4,7 +4,7 @@ const {sleep} = require('./utils.test');async function makeNote() {await element(by.text('Add your First Note')).tap();await sleep(100);- const editor = element(by.id(notesnook.ids.default.editor));+ const editor = element(by.id(notesnook.editor.id));await sleep(100);await editor.typeText('This is the text of **the note. which is working');await sleep(100);diff --git a/apps/mobile/index.js b/apps/mobile/index.jsindex 546c4e59e..41c68e27b 100644--- a/apps/mobile/index.js+++ b/apps/mobile/index.js@@ -1,6 +1,6 @@import 'react-native-gesture-handler';import React from 'react';-import {AppRegistry, Platform} from 'react-native';+import {AppRegistry, LogBox, Platform} from 'react-native';import {name as appName} from './app.json';import {enableScreens} from 'react-native-screens';import Notifications from './src/services/Notifications';@@ -8,6 +8,8 @@ import {SafeAreaProvider} from 'react-native-safe-area-context';global.Buffer = require('buffer').Buffer;enableScreens(true);+LogBox.ignoreAllLogs();+let Provider;let App;let NotesnookShare;diff --git a/apps/mobile/src/components/Button/index.js b/apps/mobile/src/components/Button/index.jsindex af380e7a0..e3838d424 100644--- a/apps/mobile/src/components/Button/index.js+++ b/apps/mobile/src/components/Button/index.js@@ -32,7 +32,7 @@ export const Button = ({iconPosition = 'left',hitSlop,buttonType = {},- bold+ bold,}) => {const [state] = useTracked();const {colors} = state;diff --git a/apps/mobile/src/components/Container/ContainerBottomButton.js b/apps/mobile/src/components/Container/ContainerBottomButton.jsindex 052c89f0b..db8c21174 100644--- a/apps/mobile/src/components/Container/ContainerBottomButton.js+++ b/apps/mobile/src/components/Container/ContainerBottomButton.js@@ -75,7 +75,7 @@ export const ContainerBottomButton = ({],}}><PressableButton- testID={notesnook.ids.default.addBtn}+ testID={notesnook.buttons.add}type="accent"accentColor={color || 'accent'}accentText="light"diff --git a/apps/mobile/src/components/Header/HeaderRightMenu.js b/apps/mobile/src/components/Header/HeaderRightMenu.jsindex 4e41e18dc..7b611e08c 100644--- a/apps/mobile/src/components/Header/HeaderRightMenu.js+++ b/apps/mobile/src/components/Header/HeaderRightMenu.js@@ -25,7 +25,7 @@ export const HeaderRightMenu = ({currentScreen, action, rightButtons}) => {menu: false});}}- testID={notesnook.ids.default.header.buttons.left}+ //testID={notesnook.ids.default.header.buttons.left}name="magnify"color={colors.pri}customStyle={styles.rightBtn}@@ -62,7 +62,7 @@ export const HeaderRightMenu = ({currentScreen, action, rightButtons}) => {onPress={() => {menuRef.current?.show();}}- testID={notesnook.ids.default.header.buttons.left}+ //testID={notesnook.ids.default.header.buttons.left}name="dots-vertical"color={colors.pri}customStyle={styles.rightBtn}diff --git a/apps/mobile/src/components/SimpleList/empty.js b/apps/mobile/src/components/SimpleList/empty.jsindex b0154f82e..eb04e5a89 100644--- a/apps/mobile/src/components/SimpleList/empty.js+++ b/apps/mobile/src/components/SimpleList/empty.js@@ -1,6 +1,7 @@import React from 'react';import {ActivityIndicator, useWindowDimensions, View} from 'react-native';import {useSafeAreaInsets} from 'react-native-safe-area-context';+import { notesnook } from '../../../e2e/test.ids';import {useTracked} from '../../provider';import {COLORS_NOTE} from '../../utils/Colors';import {normalize, SIZE} from '../../utils/SizeUtils';@@ -64,6 +65,7 @@ export const Empty = ({onPress={placeholderData.action}title={placeholderData.button}icon={placeholderData.buttonIcon || 'plus'}+ testID={notesnook.buttons.add}type="accent"fontSize={SIZE.md}accentColor="bg"diff --git a/apps/mobile/src/components/SplashScreen/index.js b/apps/mobile/src/components/SplashScreen/index.jsindex c3650ca07..d90534a28 100644--- a/apps/mobile/src/components/SplashScreen/index.js+++ b/apps/mobile/src/components/SplashScreen/index.js@@ -127,6 +127,7 @@ const SplashScreen = () => {return (!isIntroCompleted && (<Animated.View+ testID="notesnook.splashscreen"style={{zIndex: 999,...getElevation(10),diff --git a/apps/mobile/src/views/Editor/EditorHeader.js b/apps/mobile/src/views/Editor/EditorHeader.jsindex dbac84807..61cc2960c 100644--- a/apps/mobile/src/views/Editor/EditorHeader.js+++ b/apps/mobile/src/views/Editor/EditorHeader.js@@ -299,7 +299,7 @@ const EditorHeader = () => {}}top={50}left={50}- testID={notesnook.ids.default.header.buttons.back}+ testID={notesnook.editor.back}name="arrow-left"color={colors.pri}onPress={_onBackPress}diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.jsindex 07806446e..173383664 100755--- a/apps/mobile/src/views/Editor/index.js+++ b/apps/mobile/src/views/Editor/index.js@@ -93,7 +93,7 @@ const Editor = React.memo(}}><EditorHeader /><WebView- testID={notesnook.ids.default.editor}+ testID={notesnook.editor.id}ref={EditorWebView}onLoad={onLoad}scrollEnabled={true}