Skip to content

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

tests: pin & favorite

ammarahm-edbb27ebdd90e2
diff --git a/apps/mobile/e2e/tests/index.e2e.js b/apps/mobile/e2e/tests/index.e2e.js
index 8dff8bd7f..8b3307ab1 100644
--- a/apps/mobile/e2e/tests/index.e2e.js
+++ b/apps/mobile/e2e/tests/index.e2e.js
@@ -1,6 +1,3 @@
-const {beforeEach} = require('detox');
-const detox = require('detox');
-const {beforeAll, test, describe} = require('jest-circus');
const {notesnook} = require('../test.ids');
const {
LaunchApp,
@@ -11,12 +8,39 @@ const {
tapByText,
elementByText,
createNote,
- prepare
+ prepare,
+ visibleById
} = require('./misc.e2e');
describe('Basic tests', () => {
+ 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 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 LaunchApp();
+ await prepare();
});
it('Basic navigation should work', async () => {
diff --git a/apps/mobile/e2e/tests/misc.e2e.js b/apps/mobile/e2e/tests/misc.e2e.js
index 8bcfbbb17..5ea7a0910 100644
--- a/apps/mobile/e2e/tests/misc.e2e.js
+++ b/apps/mobile/e2e/tests/misc.e2e.js
@@ -51,6 +51,8 @@ export async function createNote() {
await tapById(notesnook.editor.back);
await sleep(500);
await expect(element(by.text(body))).toBeVisible();
+
+ return {title,body};
}
export async function navigate(screen) {
@@ -60,7 +62,16 @@ export async function navigate(screen) {
await elementByText(screen).tap();
}
+const testvars = {
+ isFirstTest:true
+}
+
export async function prepare() {
+ if (testvars.isFirstTest) {
+ console.log("Launching App Directly without reset");
+ testvars.isFirstTest = false;
+ return await LaunchApp();
+ }
await device.reverseTcpPort(8081);
await device.uninstallApp();
await device.installApp();
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.js
index 2ce855aa5..34b9bf558 100644
--- a/apps/mobile/src/components/NoteItem/index.js
+++ b/apps/mobile/src/components/NoteItem/index.js
@@ -189,6 +189,7 @@ const NoteItem = ({item, isTrash, tags, dateBy = 'dateCreated'}) => {
{item.pinned ? (
<Icon
+ testID="icon-pinned"
name="pin-outline"
size={SIZE.sm}
style={{
@@ -213,6 +214,7 @@ const NoteItem = ({item, isTrash, tags, dateBy = 'dateCreated'}) => {
{item.favorite ? (
<Icon
+ testID="icon-star"
name="star"
size={SIZE.md}
style={{