layout basic e2e testing

This commit is contained in:
ammarahm-ed
2020-11-30 16:16:03 +05:00
parent c332d37680
commit 6206b3403f
26 changed files with 176 additions and 73 deletions

78
apps/mobile/e2e/firstTest Normal file
View File

@@ -0,0 +1,78 @@
/*
it('CHECK MENU NAVIGATION', async () => {
await expect(element(by.id('left_menu_button'))).toBeVisible();
menu = element(by.id('left_menu_button'));
await element(by.id('left_menu_button')).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('CHECK NIGHT MODE SWITCHING', async () => {
menu.tap();
await sleep(100);
await element(by.id('night_mode')).tap();
await sleep(100);
await element(by.id('night_mode')).tap();
await sleep(100);
menu.tap();
}); */
/*
it('OPEN EDITOR AND TAKE A NOTE', async () => {
await element(by.text('Add your First Note')).tap();
await sleep(500);
const editor = element(by.id('editor'));
await sleep(500);
await editor.typeText('This is the text of **the note. which is working');
await sleep(100);
await element(by.id("editor_back_key")).tap();
await sleep(200);
});
it('MAKE A NOTEBOOK', async () => {
await element(by.id('left_menu_button')).tap();
await sleep(100);
await element(by.text('Notebooks')).tap();
await sleep(100);
await element(by.text('Add a Notebook')).tap();
await sleep(100);
await element(by.id('notebook_title_input')).tap();
await sleep(100);
await element(by.id('notebook_title_input')).typeText("New Notebook");
await sleep(100);
await element(by.id('notebook_desc_input')).tap();
await sleep(100);
await element(by.id('notebook_desc_input')).typeText("notebook description");
await sleep(100);
await element(by.id('notebook_topic_input')).tap();
await sleep(100);
await element(by.id('notebook_topic_input')).typeText("new topic");
await sleep(100);
await element(by.id('notebook_topic_input')).tapReturnKey();
await element(by.text('Add')).tap();
await sleep(2000);
});
*/

View File

@@ -1,56 +0,0 @@
const sleep = (duration) =>
new Promise((resolve) => setTimeout(() => resolve(), duration));
let menu;
it('CHECK APP LOADED', async () => {
await expect(element(by.id('mobile_main_view'))).toBeVisible();
});
it('CHECK MENU NAVIGATION', async () => {
await expect(element(by.id('left_menu_button'))).toBeVisible();
/* await element(by.id('Notebooks')).tap();
menu.tap();
await sleep(200);
await element(by.id('Favorites')).tap();
menu.tap();
await sleep(200);
await element(by.id('Trash')).tap();
menu.tap();
await sleep(200);
await element(by.text('Tags')).tap();
menu.tap();
await sleep(200);
await element(by.id('Settings')).tap();
menu.tap();
await sleep(200); */
});
it('CHECK NIGHT MODE SWITCHING', async () => {
/* await element(by.id('night_mode')).tap();
await sleep(2000);
await element(by.id('night_mode')).tap(); */
});
/* it('Check if editor can be opened and edited', async () => {
await expect(element(by.id('container_bottom_btn'))).toBeVisible();
await sleep(200);
await element(by.id('container_bottom_btn')).tap();
await sleep(1000);
const editor = element(by.id('editor'));
await expect(editor).toBeVisible();
await editor.tap();
await sleep(200);
await editor.typeText('hello world, this an automated note creation');
});
*/

View File

@@ -0,0 +1,34 @@
export const notesnook = {
ids: {
default: {
root: '1',
menu: '2',
dialog: {
yes: '3',
no: '4',
},
editor: '5',
header: {
buttons: {
left: '6',
right: '7',
},
},
},
dialogs: {
notebook: {
inputs: {
title: '8',
description: '9',
topic: '10',
},
buttons: {
add: '11',
},
},
},
menu: {
nightmode:"12"
}
},
};

View File

View File

View File

@@ -0,0 +1,31 @@
const { notesnook } = require("../test.ids");
const { sleep } = require("./utils.test");
it('App initialization', async () => {
await expect(element(by.id(notesnook.ids.default.root))).toBeVisible();
});
it('Drawer Navigation', async () => {
let menu = element(by.id(notesnook.ids.default.header.buttons.left));
await menu.tap();
await element(by.text('Notebooks')).tap();
menu.tap();
await element(by.text('Favorites')).tap();
menu.tap();
await element(by.text('Trash')).tap();
menu.tap();
await element(by.text('Tags')).tap();
menu.tap();
await element(by.text('Settings')).tap();
});
it('Dark Mode', async () => {
let menu = element(by.id(notesnook.ids.default.header.buttons.left));
menu.tap();
let nightmode = element(by.id(notesnook.ids.menu.nightmode))
await nightmode.tap();
await nightmode.tap();
menu.tap();
});

View File

View File

View File

View File

View File

View File

View File

View File

@@ -0,0 +1,2 @@
export const sleep = (duration) =>
new Promise((resolve) => setTimeout(() => resolve(), duration));

View File

View File

@@ -2,6 +2,7 @@ import React, {useEffect, useState} from 'react';
import {Dimensions, View} from 'react-native'; import {Dimensions, View} from 'react-native';
import ScrollableTabView from 'react-native-scrollable-tab-view'; import ScrollableTabView from 'react-native-scrollable-tab-view';
import SplashScreen from 'react-native-splash-screen'; import SplashScreen from 'react-native-splash-screen';
import { notesnook } from './e2e/test.ids';
import ContextMenu from './src/components/ContextMenu'; import ContextMenu from './src/components/ContextMenu';
import {DialogManager} from './src/components/DialogManager'; import {DialogManager} from './src/components/DialogManager';
import {DummyText} from './src/components/DummyText'; import {DummyText} from './src/components/DummyText';
@@ -181,6 +182,7 @@ const AppStack = React.memo(
return ( return (
<View <View
onLayout={_onLayout} onLayout={_onLayout}
testID={notesnook.ids.default.root}
style={{ style={{
width: '100%', width: '100%',
height: '100%', height: '100%',

View File

@@ -11,6 +11,7 @@ import {
} from 'react-native'; } from 'react-native';
import {FlatList, TextInput} from 'react-native-gesture-handler'; import {FlatList, TextInput} from 'react-native-gesture-handler';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { notesnook } from '../../../e2e/test.ids';
import {Actions} from '../../provider/Actions'; import {Actions} from '../../provider/Actions';
import {DDS} from '../../services/DeviceDetection'; import {DDS} from '../../services/DeviceDetection';
import {ToastEvent} from '../../services/EventManager'; import {ToastEvent} from '../../services/EventManager';
@@ -283,6 +284,7 @@ export class AddNotebookDialog extends React.Component {
<TextInput <TextInput
ref={(ref) => (this.titleRef = ref)} ref={(ref) => (this.titleRef = ref)}
testID={notesnook.ids.dialogs.notebook.inputs.title}
style={[ style={[
styles.input, styles.input,
{ {
@@ -315,6 +317,7 @@ export class AddNotebookDialog extends React.Component {
/> />
<TextInput <TextInput
ref={(ref) => (this.descriptionRef = ref)} ref={(ref) => (this.descriptionRef = ref)}
testID={notesnook.ids.dialogs.notebook.inputs.description}
style={[ style={[
styles.input, styles.input,
{ {
@@ -348,6 +351,7 @@ export class AddNotebookDialog extends React.Component {
<View style={styles.topicContainer}> <View style={styles.topicContainer}>
<TextInput <TextInput
ref={(ref) => (this.topicInputRef = ref)} ref={(ref) => (this.topicInputRef = ref)}
testID={notesnook.ids.dialogs.notebook.inputs.topic}
onChangeText={(value) => { onChangeText={(value) => {
this.currentInputValue = value; this.currentInputValue = value;
if (this.prevItem !== null) { if (this.prevItem !== null) {
@@ -391,6 +395,7 @@ export class AddNotebookDialog extends React.Component {
/> />
<TouchableOpacity <TouchableOpacity
onPress={this.onSubmit} onPress={this.onSubmit}
testID={notesnook.ids.dialogs.notebook.buttons.add}
style={[ style={[
styles.addBtn, styles.addBtn,
{ {
@@ -436,6 +441,7 @@ export class AddNotebookDialog extends React.Component {
<DialogButtons <DialogButtons
negativeTitle="Cancel" negativeTitle="Cancel"
positiveTitle={toEdit && toEdit.dateCreated ? 'Save' : 'Add'} positiveTitle={toEdit && toEdit.dateCreated ? 'Save' : 'Add'}
onPressPositive={this.addNewNotebook} onPressPositive={this.addNewNotebook}
onPressNegative={this.close} onPressNegative={this.close}
/> />

View File

@@ -53,6 +53,7 @@ export const Button = ({
type = 'transparent', type = 'transparent',
iconSize = SIZE.md, iconSize = SIZE.md,
style = {}, style = {},
testID
}) => { }) => {
const [state] = useTracked(); const [state] = useTracked();
const {colors} = state; const {colors} = state;
@@ -61,6 +62,7 @@ export const Button = ({
<PressableButton <PressableButton
onPress={onPress} onPress={onPress}
disabled={loading} disabled={loading}
testID={testID}
color={colors[BUTTON_TYPES[type].primary]} color={colors[BUTTON_TYPES[type].primary]}
selectedColor={colors[BUTTON_TYPES[type].selected]} selectedColor={colors[BUTTON_TYPES[type].selected]}
alpha={!colors.night ? -0.04 : 0.04} alpha={!colors.night ? -0.04 : 0.04}

View File

@@ -5,6 +5,7 @@ import {SIZE} from '../../utils/SizeUtils';
import {Button} from '../Button'; import {Button} from '../Button';
import Paragraph from '../Typography/Paragraph'; import Paragraph from '../Typography/Paragraph';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {notesnook} from '../../../e2e/test.ids';
const DialogButtons = ({ const DialogButtons = ({
onPressPositive, onPressPositive,
@@ -46,6 +47,7 @@ const DialogButtons = ({
<Button <Button
onPress={onPressNegative} onPress={onPressNegative}
fontSize={SIZE.md} fontSize={SIZE.md}
testID={notesnook.ids.default.dialog.no}
type="gray" type="gray"
title={negativeTitle} title={negativeTitle}
/> />
@@ -53,6 +55,7 @@ const DialogButtons = ({
<Button <Button
onPress={onPressPositive} onPress={onPressPositive}
fontSize={SIZE.md} fontSize={SIZE.md}
testID={notesnook.ids.default.dialog.yes}
style={{ style={{
marginLeft: 10, marginLeft: 10,
}} }}

View File

@@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import { notesnook } from '../../../e2e/test.ids';
import { useTracked } from '../../provider'; import { useTracked } from '../../provider';
import Navigation from '../../services/Navigation'; import Navigation from '../../services/Navigation';
import { SIZE } from '../../utils/SizeUtils'; import { SIZE } from '../../utils/SizeUtils';
@@ -20,7 +21,7 @@ export const HeaderLeftMenu = () => {
<> <>
{deviceMode === 'mobile' || currentScreen === 'search' ? ( {deviceMode === 'mobile' || currentScreen === 'search' ? (
<ActionIcon <ActionIcon
testID="left_menu_button" testID={notesnook.ids.default.header.buttons.left}
customStyle={{ customStyle={{
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',

View File

@@ -1,6 +1,7 @@
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import {FlatList, ScrollView, View} from 'react-native'; import {FlatList, ScrollView, View} from 'react-native';
import {useSafeAreaInsets} from 'react-native-safe-area-context'; import {useSafeAreaInsets} from 'react-native-safe-area-context';
import { notesnook } from '../../../e2e/test.ids';
import {useTracked} from '../../provider'; import {useTracked} from '../../provider';
import {Actions} from '../../provider/Actions'; import {Actions} from '../../provider/Actions';
import {DDS} from '../../services/DeviceDetection'; import {DDS} from '../../services/DeviceDetection';
@@ -60,7 +61,7 @@ export const Menu = React.memo(
style={{ style={{
height: '100%', height: '100%',
width: '100%', width: '100%',
backgroundColor: "white", backgroundColor: colors.bg,
paddingTop: insets.top, paddingTop: insets.top,
}}> }}>
<FlatList <FlatList
@@ -76,6 +77,7 @@ export const Menu = React.memo(
{MenuItemsList.map((item, index) => ( {MenuItemsList.map((item, index) => (
<MenuListItem <MenuListItem
item={item} item={item}
testID={item.name}
index={index} index={index}
/> />
))} ))}
@@ -87,7 +89,7 @@ export const Menu = React.memo(
{BottomItemsList.map((item, index) => ( {BottomItemsList.map((item, index) => (
<MenuListItem <MenuListItem
testID={item.name == 'Night mode' ? 'night_mode' : item.name} testID={item.name == 'Night mode' ? notesnook.ids.menu.nightmode : item.name}
key={item.name} key={item.name}
item={item} item={item}
index={index} index={index}

View File

@@ -12,14 +12,14 @@ import {
eSubscribeEvent, eSubscribeEvent,
eUnSubscribeEvent, eUnSubscribeEvent,
} from '../../services/EventManager'; } from '../../services/EventManager';
import {dHeight, getElevation} from '../../utils'; import {dHeight} from '../../utils';
import {db} from '../../utils/DB'; import {db} from '../../utils/DB';
import { import {
eApplyChanges, eApplyChanges,
eShowMergeDialog, eShowMergeDialog,
refreshNotesPage, refreshNotesPage,
} from '../../utils/Events'; } from '../../utils/Events';
import {normalize, ph, pv, SIZE} from '../../utils/SizeUtils'; import {normalize, SIZE} from '../../utils/SizeUtils';
import {Button} from '../Button'; import {Button} from '../Button';
import BaseDialog from '../Dialog/base-dialog'; import BaseDialog from '../Dialog/base-dialog';
import DialogButtons from '../Dialog/dialog-buttons'; import DialogButtons from '../Dialog/dialog-buttons';

View File

@@ -35,7 +35,7 @@ export const NoteItemWrapper = ({item, index, isTrash = false}) => {
newNote.title === note.title && newNote.title === note.title &&
newNote.headline === note.headline newNote.headline === note.headline
) { ) {
console.log('returning from here',newNote.headline,note.headline); console.log('returning from here', newNote.headline, note.headline);
return; return;
} }
setNote(newNote); setNote(newNote);
@@ -60,9 +60,6 @@ export const NoteItemWrapper = ({item, index, isTrash = false}) => {
}; };
const onPress = async (event) => { const onPress = async (event) => {
eSendEvent(eShowMergeDialog, note);
return;
if (note.conflicted) { if (note.conflicted) {
eSendEvent(eShowMergeDialog, note); eSendEvent(eShowMergeDialog, note);
return; return;
@@ -72,11 +69,11 @@ export const NoteItemWrapper = ({item, index, isTrash = false}) => {
return; return;
} else if (note.locked) { } else if (note.locked) {
openVault({ openVault({
item:item, item: item,
novault:true, novault: true,
locked:true, locked: true,
goToEditor:true, goToEditor: true,
}) });
return; return;
} }
if (isTrash) { if (isTrash) {
@@ -86,7 +83,6 @@ export const NoteItemWrapper = ({item, index, isTrash = false}) => {
} }
if (DDS.isPhone || DDS.isSmallTab) { if (DDS.isPhone || DDS.isSmallTab) {
tabBarRef.current?.goToPage(1); tabBarRef.current?.goToPage(1);
//openEditorAnimation(event.nativeEvent);
} }
}; };

View File

@@ -17,7 +17,7 @@ export const defaultState = {
colorNotes: [], colorNotes: [],
user: null, user: null,
fullscreen:false, fullscreen:false,
premiumUser: false, premiumUser: true,
settings: { settings: {
showToolbarOnTop: false, showToolbarOnTop: false,
showKeyboardOnOpen: false, showKeyboardOnOpen: false,

View File

@@ -179,6 +179,7 @@ const EditorHeader = () => {
}}> }}>
{DDS.isLargeTablet() && !fullscreen ? null : ( {DDS.isLargeTablet() && !fullscreen ? null : (
<ActionIcon <ActionIcon
testID="editor_back_key"
name="arrow-left" name="arrow-left"
color={colors.heading} color={colors.heading}
onPress={_onBackPress} onPress={_onBackPress}

View File

@@ -1,6 +1,7 @@
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import {Platform, TextInput, View} from 'react-native'; import {Platform, TextInput, View} from 'react-native';
import WebView from 'react-native-webview'; import WebView from 'react-native-webview';
import { notesnook } from '../../../e2e/test.ids';
import {useTracked} from '../../provider'; import {useTracked} from '../../provider';
import EditorHeader from './EditorHeader'; import EditorHeader from './EditorHeader';
import { import {
@@ -29,7 +30,7 @@ const Editor = () => {
/> />
<EditorHeader /> <EditorHeader />
<WebView <WebView
testID="editor" testID={notesnook.ids.default.editor}
ref={EditorWebView} ref={EditorWebView}
onError={(error) => console.log(error)} onError={(error) => console.log(error)}
onLoad={async (event) => onLoad={async (event) =>