Skip to content

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

update test for checking delete & restore note

ammarahm-ed551dce8ab7ba
diff --git a/apps/mobile/e2e/test.ids.js b/apps/mobile/e2e/test.ids.js
index 73d706408..ce67fa32c 100644
--- a/apps/mobile/e2e/test.ids.js
+++ b/apps/mobile/e2e/test.ids.js
@@ -6,6 +6,15 @@ export const notesnook = {
buttons:{
add:"buttons.add"
},
+ toast: {
+ button:"toast.button"
+ },
+ listitem:{
+ menu:"listitem.menu"
+ },
+ list:{
+ id:"list.id"
+ },
ids: {
default: {
root: 'root',
diff --git a/apps/mobile/e2e/tests/index.e2e.js b/apps/mobile/e2e/tests/index.e2e.js
index 41c0fb33f..8cebf3cce 100644
--- a/apps/mobile/e2e/tests/index.e2e.js
+++ b/apps/mobile/e2e/tests/index.e2e.js
@@ -13,7 +13,7 @@ const {
const {sleep} = require('./utils.test');
beforeAll(async () => {
- await device.reloadReactNative();
+ await device.launchApp();
});
describe('Basic tests', () => {
@@ -32,13 +32,14 @@ describe('Basic tests', () => {
await navigate('Notes');
});
- it('Create 10 notes', async () => {
- let numOfnotes = 10;
+ it('Create 3 notes', async () => {
+ let numOfnotes = 3;
for (let i = 0; i < numOfnotes; i++) {
let title = 'Test note description that ';
let body =
- 'Test note description that is very long and should not fit in text.' + i;
+ 'Test note description that is very long and should not fit in text.' +
+ i;
await tapById(notesnook.buttons.add);
await elementById(notesnook.editor.id).tap({
@@ -49,11 +50,22 @@ describe('Basic tests', () => {
await tapById(notesnook.editor.back);
await expect(elementByText(title).atIndex(0)).toBeVisible();
}
+ });
- for (let i = 0; i < 10; i++) {
- await tapById(notesnook.ids.note.get(1));
- await tapById(notesnook.editor.back);
- };
+ it('Open and close a note', async () => {
+ await tapById(notesnook.ids.note.get(1));
+ await tapById(notesnook.editor.back);
+
+ });
+ it('Delete & restore a note', async () => {
+ 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.2");
});
+
+
+
+
});
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.js
index 7b6b9a461..ff2c2278f 100644
--- a/apps/mobile/src/components/NoteItem/index.js
+++ b/apps/mobile/src/components/NoteItem/index.js
@@ -1,6 +1,7 @@
import React, { useEffect } from 'react';
import {Platform, View} from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
+import { notesnook } from '../../../e2e/test.ids';
import {useTracked} from '../../provider';
import {useSettingStore, useTagStore} from '../../provider/stores';
import {eSendEvent} from '../../services/EventManager';
@@ -294,6 +295,7 @@ const NoteItem = ({item, isTrash, tags}) => {
</View>
</View>
<ActionIcon
+ testID={notesnook.listitem.menu}
color={colors.pri}
name="dots-horizontal"
size={SIZE.xl}
diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.js
index 1c19f108b..c2c84e19a 100644
--- a/apps/mobile/src/components/SimpleList/index.js
+++ b/apps/mobile/src/components/SimpleList/index.js
@@ -1,5 +1,6 @@
import React, { useEffect, useRef, useState } from 'react';
import { FlatList, RefreshControl, View } from 'react-native';
+import { notesnook } from '../../../e2e/test.ids';
import { useTracked } from '../../provider';
import { eSendEvent } from '../../services/EventManager';
import Sync from '../../services/Sync';
@@ -133,6 +134,7 @@ const SimpleList = ({
style={styles}
keyExtractor={_keyExtractor}
ref={scrollRef}
+ testID={notesnook.list.id}
data={_loading ? listData.slice(0, 9) : listData}
renderItem={renderItem}
onScroll={_onScroll}
diff --git a/apps/mobile/src/components/Toast/index.js b/apps/mobile/src/components/Toast/index.js
index 24111c3dc..ceee65428 100644
--- a/apps/mobile/src/components/Toast/index.js
+++ b/apps/mobile/src/components/Toast/index.js
@@ -3,6 +3,7 @@ import {Keyboard, View} from 'react-native';
import Animated, {Easing, useValue} from 'react-native-reanimated';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
+import { notesnook } from '../../../e2e/test.ids';
import {useTracked} from '../../provider';
import {DDS} from '../../services/DeviceDetection';
import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';
@@ -243,6 +244,7 @@ export const Toast = ({context = 'global'}) => {
{data.func ? (
<Button
+ testID={notesnook.toast.button}
fontSize={SIZE.md}
type={data.type === 'error' ? 'errorShade' : 'transparent'}
onPress={data.func}