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
e2e: add tests
ammarahm-ed7f27f4d59b98
diff --git a/apps/mobile/e2e/config.json b/apps/mobile/e2e/config.jsonindex 128ef6dd3..4bbdf635f 100644--- a/apps/mobile/e2e/config.json+++ b/apps/mobile/e2e/config.json@@ -1,10 +1,9 @@{- "testEnvironment": "./environment",- "testRunner": "jest-circus/runner",- "setupFilesAfterEnv": ["./setup.ts"],- "testTimeout": 120000,- "testRegex": "\\index.e2e\\.js$",- "reporters": ["detox/runners/jest/streamlineReporter"],- "verbose": true+ "testEnvironment": "./environment",+ "testRunner": "jest-circus/runner",+ "setupFilesAfterEnv": ["./setup.ts"],+ "testTimeout": 120000,+ "testRegex": "\\.e2e\\.js$",+ "reporters": ["detox/runners/jest/streamlineReporter"],+ "verbose": true}-diff --git a/apps/mobile/e2e/setup.ts b/apps/mobile/e2e/setup.tsindex 898beb5e9..eb13e978e 100644--- a/apps/mobile/e2e/setup.ts+++ b/apps/mobile/e2e/setup.ts@@ -1,3 +1,3 @@beforeAll(async () => {- await device.launchApp();-});\ No newline at end of file+ await device.launchApp();+});diff --git a/apps/mobile/e2e/tests/__image_snapshots__/vault-e-2-e-js-basic-tests-add-a-note-to-vault-1-snap.png b/apps/mobile/e2e/tests/__image_snapshots__/vault-e-2-e-js-basic-tests-add-a-note-to-vault-1-snap.pngnew file mode 100644index 000000000..5e36c5e0bBinary files /dev/null and b/apps/mobile/e2e/tests/__image_snapshots__/vault-e-2-e-js-basic-tests-add-a-note-to-vault-1-snap.png differdiff --git a/apps/mobile/e2e/tests/__image_snapshots__/vault-e-2-e-js-vault-change-vault-password-1-snap.png b/apps/mobile/e2e/tests/__image_snapshots__/vault-e-2-e-js-vault-change-vault-password-1-snap.pngnew file mode 100644index 000000000..5e36c5e0bBinary files /dev/null and b/apps/mobile/e2e/tests/__image_snapshots__/vault-e-2-e-js-vault-change-vault-password-1-snap.png differdiff --git a/apps/mobile/e2e/tests/__image_snapshots__/vault-e-2-e-js-vault-tests-add-a-note-to-vault-1-snap.png b/apps/mobile/e2e/tests/__image_snapshots__/vault-e-2-e-js-vault-tests-add-a-note-to-vault-1-snap.pngnew file mode 100644index 000000000..5e36c5e0bBinary files /dev/null and b/apps/mobile/e2e/tests/__image_snapshots__/vault-e-2-e-js-vault-tests-add-a-note-to-vault-1-snap.png differdiff --git a/apps/mobile/e2e/tests/auth.e2e.js b/apps/mobile/e2e/tests/auth.e2e.jsnew file mode 100644index 000000000..a4d2b8603--- /dev/null+++ b/apps/mobile/e2e/tests/auth.e2e.js@@ -0,0 +1,23 @@+const { notesnook } = require('../test.ids');+const {+ navigate,+ tapByText,+ prepare,+ openSideMenu,+ elementById,+ visibleByText+} = require('./utils');+const { sleep } = require('./utils');++describe('AUTH', () => {+ it('Login to account', async () => {+ await prepare();+ await openSideMenu();+ await tapByText('Login to sync your notes.');+ await elementById('input.email').typeText('[email protected]');+ await elementById('input.password').typeText('testaccount@123');+ await elementById('input.password').tapReturnKey();+ await sleep(5000);+ await visibleByText('Tap here to sync your notes.');+ });+});diff --git a/apps/mobile/e2e/tests/index.e2e.js b/apps/mobile/e2e/tests/index.e2e.jsindex 8b3307ab1..2ca95a272 100644--- a/apps/mobile/e2e/tests/index.e2e.js+++ b/apps/mobile/e2e/tests/index.e2e.js@@ -1,51 +1,17 @@-const {notesnook} = require('../test.ids');-const {- LaunchApp,- navigate,- tapById,- elementById,- visibleByText,- tapByText,- elementByText,- createNote,- prepare,- visibleById-} = require('./misc.e2e');+const { notesnook } = require('../test.ids');+const { navigate, tapByText, prepare } = require('./utils');+const { sleep } = require('./utils');-describe('Basic tests', () => {- it('Favorite and unfavorite a note', async () => {+describe('APP LAUNCH AND NAVIGATION', () => {+ it('App should launch successfully & hide welcome screen', async done => {await prepare();- let note = await createNote();- await tapById(notesnook.listitem.menu);- await tapById('icon-Favorite');- await visibleById('icon-star');- await navigate('Favorites');- await visibleByText(note.body);- await tapById(notesnook.listitem.menu);- await tapById('icon-Favorite');- await expect(element(by.text(note.body))).not.toBeVisible();- await navigate('Notes');- });-- it('Pin and upin a note', async () => {- await prepare();- await createNote();- await tapById(notesnook.listitem.menu);- await tapById('icon-Pin');- await visibleByText('Pinned');- await visibleById('icon-pinned');- await tapById(notesnook.listitem.menu);- await tapById('icon-Pin');- expect(element(by.id('icon-pinned'))).not.toBeVisible();});- it('App should launch successfully & hide welcome screen', async () => {- await prepare();- });-- it('Basic navigation should work', async () => {+ it('Basic navigation should work', async done => {await prepare();await navigate('Notebooks');+ await tapByText('Skip introduction');+ await sleep(500);await navigate('Favorites');await navigate('Trash');await navigate('Tags');@@ -53,35 +19,4 @@ describe('Basic tests', () => {await navigate('Monographs');await navigate('Notes');});-- it('Create a note in editor', async () => {- await prepare();- await createNote();- });-- it('Open and close a note', async () => {- await prepare();- await createNote();- await tapById(notesnook.ids.note.get(1));- await tapById(notesnook.editor.back);- });-- it('Export note dialog should show', async () => {- await prepare();- await createNote();- await tapById(notesnook.listitem.menu);- await tapById('icon-Export');- await visibleByText('PDF');- });-- it('Delete & restore a note', async () => {- await prepare();- await createNote();- await tapById(notesnook.listitem.menu);- await tapById('icon-Delete');- await tapById(notesnook.toast.button);- await visibleByText(- 'Test note description that is very long and should not fit in text.'- );- });});diff --git a/apps/mobile/e2e/tests/note.e2e.js b/apps/mobile/e2e/tests/note.e2e.jsnew file mode 100644index 000000000..542598095--- /dev/null+++ b/apps/mobile/e2e/tests/note.e2e.js@@ -0,0 +1,86 @@+const { notesnook } = require('../test.ids');+const { navigate, tapById, visibleByText, createNote, prepare, visibleById } = require('./utils');+const { sleep } = require('./utils');++describe('NOTE TESTS', () => {+ it('Create a note in editor', async () => {+ await prepare();+ await createNote();+ });++ it('Open and close a note', async () => {+ await prepare();+ await createNote();+ await tapById(notesnook.ids.note.get(1));+ await tapById(notesnook.editor.back);+ });++ it('Notes properties should show', async () => {+ await prepare();+ let note = await createNote();+ await tapById(notesnook.listitem.menu);+ await visibleByText(note.body);+ });++ it('Favorite and unfavorite a note', async () => {+ await prepare();+ let note = await createNote();+ await tapById(notesnook.listitem.menu);+ await tapById('icon-Favorite');+ await visibleById('icon-star');+ await navigate('Favorites');+ await visibleByText(note.body);+ await tapById(notesnook.listitem.menu);+ await tapById('icon-Favorite');+ await expect(element(by.text(note.body))).not.toBeVisible();+ await navigate('Notes');+ });++ it('Pin a note to top', async () => {+ await prepare();+ await createNote();+ await tapById(notesnook.listitem.menu);+ await tapById('icon-Pin');+ await visibleByText('Pinned');+ await visibleById('icon-pinned');+ await tapById(notesnook.listitem.menu);+ await tapById('icon-Pin');+ expect(element(by.id('icon-pinned'))).not.toBeVisible();+ });++ it('Pin a note in notifications', async () => {+ await prepare();+ await createNote();+ await tapById(notesnook.listitem.menu);+ await tapById('icon-PinToNotif');+ await visibleByText('Unpin from Notifications');+ await sleep(500);+ await tapById('icon-PinToNotif');+ await visibleByText('Pin to Notifications');+ });++ it('Copy note', async () => {+ await prepare();+ await createNote();+ await tapById(notesnook.listitem.menu);+ await tapById('icon-Copy');+ await visibleByText('Note copied to clipboard');+ });++ it('Export note dialog should show', async () => {+ await prepare();+ await createNote();+ await tapById(notesnook.listitem.menu);+ await tapById('icon-Export');+ await visibleByText('PDF');+ });++ it('Delete & restore a note', async () => {+ await prepare();+ await createNote();+ await tapById(notesnook.listitem.menu);+ await tapById('icon-Delete');+ await tapById(notesnook.toast.button);+ await visibleByText('Test note description that is very long and should not fit in text.');+ });+});diff --git a/apps/mobile/e2e/tests/notebook.e2e.js b/apps/mobile/e2e/tests/notebook.e2e.jsnew file mode 100644index 000000000..c92cf182e--- /dev/null+++ b/apps/mobile/e2e/tests/notebook.e2e.js@@ -0,0 +1,162 @@+const detox = require('detox');+const { notesnook } = require('../test.ids');+const {+ tapById,+ elementById,+ visibleByText,+ tapByText,+ createNote,+ prepare,+ visibleById,+ expectBitmapsToBeEqual,+ matchSnapshot,+ notVisibleById,+ navigate,+ elementByText+} = require('./utils');+const { sleep } = require('./utils');++async function createNotebook(title = 'Notebook 1', description = true, topic = true) {+ await tapByText('Add your first notebook');+ await elementById(notesnook.ids.dialogs.notebook.inputs.title).typeText(title);+ if (description) {+ await elementById(notesnook.ids.dialogs.notebook.inputs.description).typeText(+ `Description of ${title}`+ );+ }+ if (topic) {+ await elementById(notesnook.ids.dialogs.notebook.inputs.topic).typeText('Topic');+ await tapById('topic-add-button');+ }+ await tapByText('Create notebook');+ await sleep(500);+}++async function addTopic(title = 'Topic') {+ await tapById(notesnook.buttons.add);+ await elementById('input-title').typeText(title);+ await tapByText('Add');+ await sleep(500);+}++describe('NOTEBOOKS', () => {+ it('Create a notebook with title only', async () => {+ await prepare();+ await navigate('Notebooks');+ await tapByText('Skip introduction');+ await sleep(500);+ await createNotebook('Notebook 1', false, false);+ await elementById('sheet-backdrop').tap();+ await sleep(500);+ await visibleByText('Notebook 1');+ });++ it('Create a notebook title & description', async () => {+ await prepare();+ await navigate('Notebooks');+ await tapByText('Skip introduction');+ await sleep(500);+ await createNotebook('Notebook 1', true, false);+ await elementById('sheet-backdrop').tap();+ await sleep(500);+ await visibleByText('Notebook 1');+ });++ it('Create a notebook with description and topics', async () => {+ await prepare();+ await navigate('Notebooks');+ await tapByText('Skip introduction');+ await sleep(500);+ await createNotebook('Notebook 1', false, false);+ await elementById('sheet-backdrop').tap();+ await sleep(500);+ await visibleByText('Notebook 1');+ });++ it('Create a notebook, add topic, move notes', async () => {+ await prepare();+ let note = await createNote();+ await navigate('Notebooks');+ await tapByText('Skip introduction');+ await sleep(500);+ await createNotebook('Notebook 1', true, true);+ await tapByText('Topic');+ await sleep(500);+ await tapById('listitem.select');+ await tapByText('Move selected notes');+ await sleep(500);+ await tapByText('Topic');+ await sleep(500);+ await visibleByText(note.body);+ });++ it('Add new topic to notebook', async () => {+ await prepare();+ await navigate('Notebooks');+ await tapByText('Skip introduction');+ await sleep(500);+ await createNotebook('Notebook 1', true, false);+ await elementById('sheet-backdrop').tap();+ await sleep(500);+ await tapByText('Notebook 1');+ await tapById(notesnook.buttons.add);+ await elementById('input-title').typeText('Topic');+ await tapByText('Add');+ await sleep(500);+ await visibleByText('Topic');+ });++ it('Edit topic', async () => {+ await prepare();+ await navigate('Notebooks');+ await tapByText('Skip introduction');+ await sleep(500);+ await createNotebook('Notebook 1', true, true);+ await elementById('sheet-backdrop').tap();+ await sleep(500);+ await tapByText('Notebook 1');+ await sleep(300);+ await visibleByText('Topic');+ await tapById(notesnook.ids.notebook.menu);+ await tapByText('Edit topic');+ await elementById('input-title').typeText(' (edited)');+ await tapByText('Save');+ await visibleByText('Topic (edited)');+ });++ it('Add new note to topic', async () => {+ await prepare();+ await navigate('Notebooks');+ await tapByText('Skip introduction');+ await sleep(500);+ await createNotebook('Notebook 1', true, true);+ await elementById('sheet-backdrop').tap();+ await sleep(500);+ await tapByText('Topic');+ await createNote();+ });++ it('Remove note from topic', async () => {+ await prepare();+ await navigate('Notebooks');+ await tapByText('Skip introduction');+ await sleep(500);+ await createNotebook('Notebook 1', true, true);+ await elementById('sheet-backdrop').tap();+ await sleep(500);+ await tapByText('Topic');+ let note = await createNote();+ await elementByText(note.body).longPress();+ await tapByText('Select');+ await tapById('select-minus');+ await notVisibleById(note.title);+ });++ //todo+ // add note to notebook from home+ // remove note from a notebook from add-notebook sheet+ // edit notebook title+ // edit notebook description+ // add a topic from edit-notebook sheet+ //+});diff --git a/apps/mobile/e2e/tests/misc.e2e.js b/apps/mobile/e2e/tests/utils.jssimilarity index 53%rename from apps/mobile/e2e/tests/misc.e2e.jsrename to apps/mobile/e2e/tests/utils.jsindex 5ea7a0910..3378a31d4 100644--- a/apps/mobile/e2e/tests/misc.e2e.js+++ b/apps/mobile/e2e/tests/utils.js@@ -1,16 +1,26 @@-const {notesnook} = require('../test.ids');-const {sleep} = require('./utils.test');+const { notesnook } = require('../test.ids');+const fs = require('fs');++export const sleep = duration =>+ new Promise(resolve =>+ setTimeout(() => {+ console.log('Sleeping for ' + duration / 1000 + ' secs');+ resolve();+ }, duration)+ );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('Get started')).tap();+ await sleep(500);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();++ await sleep(500);+ await element(by.text('Create your account')).tap();+ await sleep(500);+ await element(by.text('Skip for now')).tap();+ await sleep(300);}export function elementById(id) {@@ -37,10 +47,13 @@ export async function visibleById(id) {await expect(elementById(id)).toBeVisible();}+export async function notVisibleById(id) {+ await expect(elementById(id)).not.toBeVisible();+}+export async function createNote() {let title = 'Test note description that ';- let body =- 'Test note description that is very long and should not fit in text.';+ let body = 'Test note description that is very long and should not fit in text.';await tapById(notesnook.buttons.add);await elementById(notesnook.editor.id).tap({@@ -52,10 +65,17 @@ export async function createNote() {await sleep(500);await expect(element(by.text(body))).toBeVisible();- return {title,body};+ return { title, body };+}++export async function openSideMenu() {+ let menu = elementById(notesnook.ids.default.header.buttons.left);+ await menu.tap();+ await sleep(100);}export async function navigate(screen) {+ await sleep(500);let menu = elementById(notesnook.ids.default.header.buttons.left);await menu.tap();await sleep(100);@@ -63,18 +83,28 @@ export async function navigate(screen) {}const testvars = {- isFirstTest:true-}+ isFirstTest: true+};export async function prepare() {if (testvars.isFirstTest) {- console.log("Launching App Directly without reset");+ console.log('Launching App Directly without reset');testvars.isFirstTest = false;return await LaunchApp();}await device.reverseTcpPort(8081);await device.uninstallApp();await device.installApp();- await device.launchApp({newInstance: true});+ await device.launchApp({ newInstance: true });await LaunchApp();}++const jestExpect = require('expect');+const { toMatchImageSnapshot } = require('jest-image-snapshot');+jestExpect.extend({ toMatchImageSnapshot });++export async function matchSnapshot(element, name) {+ let path = await element.takeScreenshot(name);+ const bitmapBuffer = fs.readFileSync(path);+ jestExpect(bitmapBuffer).toMatchImageSnapshot();+}diff --git a/apps/mobile/e2e/tests/utils.test.js b/apps/mobile/e2e/tests/utils.test.jsdeleted file mode 100644index 9e5626bc3..000000000--- a/apps/mobile/e2e/tests/utils.test.js+++ /dev/null@@ -1,7 +0,0 @@-export const sleep = (duration) =>-new Promise((resolve) => setTimeout(() => {- console.log('Sleeping for ' + (duration/1000) + " secs");- resolve();-}, duration));--//"\\.e2e\\.js$",\ No newline at end of filediff --git a/apps/mobile/e2e/tests/vault.e2e.js b/apps/mobile/e2e/tests/vault.e2e.jsnew file mode 100644index 000000000..a72d35c88--- /dev/null+++ b/apps/mobile/e2e/tests/vault.e2e.js@@ -0,0 +1,122 @@+const { notesnook } = require('../test.ids');+const {+ tapById,+ elementById,+ visibleByText,+ tapByText,+ createNote,+ prepare,+ visibleById,+ expectBitmapsToBeEqual,+ matchSnapshot,+ notVisibleById,+ navigate+} = require('./utils');+const { sleep } = require('./utils');++async function lockNote() {+ await tapById(notesnook.listitem.menu);+ await tapById('icon-Vault');+ await sleep(1000);+ await visibleByText('Lock');+ await elementById(notesnook.ids.dialogs.vault.pwd).typeText('1234');+ await elementById(notesnook.ids.dialogs.vault.pwdAlt).typeText('1234');+ await tapByText('Lock');+ await sleep(500);+ await visibleById('note-locked-icon');+}++async function removeFromVault() {+ await tapById(notesnook.listitem.menu);+ await tapById('icon-Vault');+ await sleep(1000);+ await elementById(notesnook.ids.dialogs.vault.pwd).typeText('1234');+ await tapByText('Unlock');+ await sleep(1000);+ await notVisibleById('note-locked-icon');+}++async function openLockedNote(pwd) {+ await tapById(notesnook.ids.note.get(1));+ await sleep(1000);+ await visibleByText('Open');+ await elementById(notesnook.ids.dialogs.vault.pwd).typeText(pwd || '1234');+ await tapByText('Open');+ await sleep(1000);+ await matchSnapshot(elementById('editor-wrapper'), `note-after-vault-unlock`);+}++async function goToPrivacySecuritySettings() {+ await navigate('Settings');+ await tapByText('Privacy & security');+}++describe('VAULT', () => {+ it('Create vault from settings', async () => {+ await prepare();+ await goToPrivacySecuritySettings();+ await tapByText('Create vault');+ await elementById(notesnook.ids.dialogs.vault.pwd).typeText('1234');+ await elementById(notesnook.ids.dialogs.vault.pwdAlt).typeText('1234');+ await tapByText('Create');+ await sleep(500);+ await visibleByText('Clear vault');+ });++ it('Change vault password', async () => {+ await prepare();+ await createNote();+ await lockNote();+ await goToPrivacySecuritySettings();+ await tapByText('Change vault password');+ await elementById(notesnook.ids.dialogs.vault.pwd).typeText('1234');+ await elementById(notesnook.ids.dialogs.vault.changePwd).typeText('2362');+ await tapByText('Change');+ await sleep(100);+ await navigate('Notes');+ await openLockedNote('2362');+ });++ it('Delete vault', async () => {+ await prepare();+ await createNote();+ await lockNote();+ await goToPrivacySecuritySettings();+ await tapByText('Delete vault');+ await elementById(notesnook.ids.dialogs.vault.pwd).typeText('1234');+ await tapByText('Delete');+ await sleep(500);+ await visibleByText('Create vault');+ await navigate('Notes');+ await visibleById(notesnook.listitem.menu);+ });++ it.only('Delete vault with locked notes', async () => {+ await prepare();+ await createNote();+ await lockNote();+ await goToPrivacySecuritySettings();+ await tapByText('Delete vault');+ await elementById(notesnook.ids.dialogs.vault.pwd).typeText('1234');+ await tapByText('Delete all notes');+ await tapByText('Delete');+ await sleep(500);+ await visibleByText('Create vault');+ await navigate('Notes');+ await notVisibleById(notesnook.listitem.menu);+ });++ it('Add a note to vault', async () => {+ await prepare();+ await createNote();+ await lockNote();+ await openLockedNote();+ });++ it('Remove note from vault', async () => {+ await prepare();+ await createNote();+ await lockNote();+ await removeFromVault();+ });+});