mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
mobile: make all tests pass
This commit is contained in:
committed by
Abdullah Atta
parent
12e6688f48
commit
a449c614ee
@@ -123,7 +123,7 @@ export const Properties = ({ close = () => {}, item, buttons = [] }) => {
|
||||
paddingHorizontal: 12
|
||||
}}
|
||||
>
|
||||
{item.notebooks ? <Notebooks note={item} close={close} /> : null}
|
||||
<Notebooks note={item} close={close} />
|
||||
</View>
|
||||
|
||||
<Items
|
||||
|
||||
@@ -35,8 +35,16 @@ export default function Notebooks({ note, close, full }) {
|
||||
const colors = useThemeStore((state) => state.colors);
|
||||
const notebooks = useNotebookStore((state) => state.notebooks);
|
||||
function getNotebooks(item) {
|
||||
if (!item.notebooks || item.notebooks.length < 1) return [];
|
||||
let filteredNotebooks = [];
|
||||
const relations = db.relations.to(note, "notebook");
|
||||
filteredNotebooks.push(
|
||||
...relations.map((notebook) => ({
|
||||
...notebook,
|
||||
topics: []
|
||||
}))
|
||||
);
|
||||
if (!item.notebooks || item.notebooks.length < 1) return filteredNotebooks;
|
||||
|
||||
for (let notebookReference of item.notebooks) {
|
||||
let notebook = {
|
||||
...(notebooks.find((item) => item.id === notebookReference.id) || {})
|
||||
@@ -45,7 +53,14 @@ export default function Notebooks({ note, close, full }) {
|
||||
notebook.topics = notebook.topics.filter((topic) => {
|
||||
return notebookReference.topics.findIndex((t) => t === topic.id) > -1;
|
||||
});
|
||||
filteredNotebooks.push(notebook);
|
||||
const index = filteredNotebooks.findIndex(
|
||||
(item) => item.id === notebook.id
|
||||
);
|
||||
if (index > -1) {
|
||||
filteredNotebooks[index].topics = notebook.topics;
|
||||
} else {
|
||||
filteredNotebooks.push(notebook);
|
||||
}
|
||||
}
|
||||
}
|
||||
return filteredNotebooks;
|
||||
@@ -63,7 +78,6 @@ export default function Notebooks({ note, close, full }) {
|
||||
if (!item) return;
|
||||
TopicNotes.navigate(item, true);
|
||||
};
|
||||
|
||||
const renderItem = (item) => (
|
||||
<View
|
||||
key={item.id}
|
||||
@@ -78,7 +92,8 @@ export default function Notebooks({ note, close, full }) {
|
||||
borderWidth: full ? 0 : 1,
|
||||
borderColor: colors.nav,
|
||||
borderRadius: 10,
|
||||
backgroundColor: full ? "transparent" : colors.nav
|
||||
backgroundColor: full ? "transparent" : colors.nav,
|
||||
minHeight: 42
|
||||
}}
|
||||
>
|
||||
<Icon
|
||||
@@ -160,7 +175,7 @@ export default function Notebooks({ note, close, full }) {
|
||||
</View>
|
||||
);
|
||||
|
||||
return !note.notebooks || note.notebooks.length === 0 ? null : (
|
||||
return noteNotebooks.length === 0 ? null : (
|
||||
<View
|
||||
style={{
|
||||
width: "100%",
|
||||
|
||||
@@ -93,7 +93,13 @@ NewFeature.present = () => {
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (version && version === getVersion()) return false;
|
||||
if (!version || version === getVersion()) {
|
||||
SettingsService.set({
|
||||
version: getVersion()
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
SettingsService.set({
|
||||
version: getVersion()
|
||||
});
|
||||
|
||||
@@ -53,6 +53,9 @@ import { getTotalNotes, history } from "../../../utils";
|
||||
import { Properties } from "../../properties";
|
||||
import { deleteItems } from "../../../utils/functions";
|
||||
import { presentDialog } from "../../dialog/functions";
|
||||
import Config from "react-native-config";
|
||||
import { notesnook } from "../../../../e2e/test.ids";
|
||||
|
||||
export const TopicsSheet = () => {
|
||||
const currentScreen = useNavigationStore((state) => state.currentScreen);
|
||||
const canShow =
|
||||
@@ -179,7 +182,7 @@ export const TopicsSheet = () => {
|
||||
backgroundColor: colors.nav
|
||||
}}
|
||||
keyboardHandlerEnabled={false}
|
||||
snapPoints={[15, 60, 100]}
|
||||
snapPoints={Config.isTesting === "true" ? [60, 100] : [15, 60, 100]}
|
||||
initialSnapIndex={0}
|
||||
backgroundInteractionEnabled
|
||||
onChange={(position, height) => {
|
||||
@@ -212,6 +215,7 @@ export const TopicsSheet = () => {
|
||||
}}
|
||||
>
|
||||
<PressableButton
|
||||
testID={notesnook.buttons.add}
|
||||
type="accent"
|
||||
accentColor={"accent"}
|
||||
accentText="light"
|
||||
@@ -423,6 +427,7 @@ const TopicItem = ({ item, index }: { item: TopicType; index: number }) => {
|
||||
width: 40,
|
||||
height: 40
|
||||
}}
|
||||
testID={notesnook.ids.notebook.menu}
|
||||
onPress={() => {
|
||||
Properties.present(item);
|
||||
}}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"html-to-text": "8.1.0",
|
||||
"phone": "^3.1.14",
|
||||
"qclone": "^1.2.0",
|
||||
"react-native-actions-sheet": "^0.9.0-alpha.8",
|
||||
"react-native-actions-sheet": "^0.9.0-alpha.9",
|
||||
"react-native-check-version": "https://github.com/flexible-agency/react-native-check-version",
|
||||
"react-native-drax": "^0.10.2",
|
||||
"react-native-image-zoom-viewer": "^3.0.1",
|
||||
|
||||
@@ -29,7 +29,8 @@ import {
|
||||
navigate,
|
||||
elementByText,
|
||||
sleep,
|
||||
notVisibleByText
|
||||
notVisibleByText,
|
||||
visibleById
|
||||
} from "./utils";
|
||||
|
||||
async function createNotebook(
|
||||
@@ -128,11 +129,11 @@ describe("NOTEBOOKS", () => {
|
||||
await device.pressBack();
|
||||
await sleep(500);
|
||||
await tapByText("Notebook 1");
|
||||
await tapById(notesnook.buttons.add);
|
||||
await tapById("add-topic-button");
|
||||
await elementById("input-title").typeText("Topic");
|
||||
await tapByText("Add");
|
||||
await sleep(500);
|
||||
await visibleByText("Topic");
|
||||
await visibleById("topic-sheet-item-0");
|
||||
});
|
||||
|
||||
it("Edit topic", async () => {
|
||||
@@ -145,12 +146,11 @@ describe("NOTEBOOKS", () => {
|
||||
await sleep(500);
|
||||
await tapByText("Notebook 1");
|
||||
await sleep(300);
|
||||
await visibleByText("Topic");
|
||||
await visibleById("topic-sheet-item-0");
|
||||
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 () => {
|
||||
@@ -175,12 +175,11 @@ describe("NOTEBOOKS", () => {
|
||||
await tapByText("Topic");
|
||||
let note = await createNote();
|
||||
await elementByText(note.body).longPress();
|
||||
await tapByText("Select");
|
||||
await tapById("select-minus");
|
||||
await notVisibleById(note.title);
|
||||
});
|
||||
|
||||
it.only("Add/Remove note to notebook from home", async () => {
|
||||
it("Add/Remove note to notebook from home", async () => {
|
||||
await prepare();
|
||||
await navigate("Notebooks");
|
||||
await sleep(500);
|
||||
@@ -192,31 +191,31 @@ describe("NOTEBOOKS", () => {
|
||||
await createNote();
|
||||
console.log("ADD TO A SINGLE TOPIC");
|
||||
await tapById(notesnook.listitem.menu);
|
||||
await tapById("icon-Add to notebook");
|
||||
await tapById("icon-notebooks");
|
||||
await sleep(500);
|
||||
await tapByText("Notebook 1");
|
||||
await tapByText("Topic");
|
||||
await tapByText("Save");
|
||||
await sleep(300);
|
||||
await visibleByText("Notebook 1 › Topic");
|
||||
await visibleByText("Topic");
|
||||
console.log("MOVE FROM ONE TOPIC TO ANOTHER");
|
||||
await tapById(notesnook.listitem.menu);
|
||||
await tapById("icon-Add to notebook");
|
||||
await tapById("icon-notebooks");
|
||||
await tapByText("Notebook 1");
|
||||
await tapByText("Topic 2");
|
||||
await tapByText("Save");
|
||||
await visibleByText("Notebook 1 › Topic 2");
|
||||
await visibleByText("Topic 2");
|
||||
console.log("REMOVE FROM TOPIC");
|
||||
await tapById(notesnook.listitem.menu);
|
||||
await tapById("icon-Add to notebook");
|
||||
await tapById("icon-notebooks");
|
||||
await tapByText("Notebook 1");
|
||||
await tapByText("Topic 2");
|
||||
await tapByText("Save");
|
||||
await sleep(300);
|
||||
await notVisibleByText("Notebook 1 › Topic 2");
|
||||
await notVisibleByText("Topic 2");
|
||||
console.log("MOVE TO MULTIPLE TOPICS");
|
||||
await tapById(notesnook.listitem.menu);
|
||||
await tapById("icon-Add to notebook");
|
||||
await tapById("icon-notebooks");
|
||||
await tapByText("Notebook 1");
|
||||
await elementByText("Topic").longPress();
|
||||
await visibleByText("Reset selection");
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"repack": "cd native && react-native webpack-start",
|
||||
"install-pods": "cd native/ios && pod install",
|
||||
"build-ios": "cd native && detox build -c ios.sim.release",
|
||||
"build-android": "cd native && detox build -c android.emu.release",
|
||||
"build-android": " cd native && detox build -c android.emu.release",
|
||||
"e2e-android": "cd native && detox test --configuration android.emu.release --detectOpenHandles",
|
||||
"e2e-ios": "cd native && detox test -c ios.sim.release --detectOpenHandles",
|
||||
"bump": "cd native && npx react-native bump-version --skip-semver-for android",
|
||||
@@ -36,4 +36,4 @@
|
||||
"react-native-fingerprint-scanner": "https://github.com/ammarahm-ed/react-native-fingerprint-scanner.git",
|
||||
"react-native-iap": "7.5.6"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user