Skip to content

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

web: fix tests

Abdullah Attacc9e7e10b625
diff --git a/apps/web/src/components/editor/footer.tsx b/apps/web/src/components/editor/footer.tsx
index 19927a3ee..7d7675966 100644
--- a/apps/web/src/components/editor/footer.tsx
+++ b/apps/web/src/components/editor/footer.tsx
@@ -45,7 +45,13 @@ function EditorFooter() {
return (
<Flex sx={{ alignItems: "center", justifyContent: "center", gap: 2 }}>
- <Flex sx={{ alignItems: "center", justifyContent: "center" }}>
+ <Flex
+ sx={{
+ alignItems: "center",
+ justifyContent: "center",
+ flex: 1
+ }}
+ >
<Button
variant="icon"
onClick={() =>
@@ -57,12 +63,12 @@ function EditorFooter() {
})
}
disabled={editorConfig.zoom <= EDITOR_ZOOM.MIN}
+ sx={{ py: 0, height: "100%" }}
>
<b>-</b>
</Button>
<Text
className="selectable"
- data-test-id="editor-word-count"
variant="subBody"
sx={{ color: "paragraph" }}
>
@@ -79,6 +85,7 @@ function EditorFooter() {
})
}
disabled={editorConfig.zoom >= EDITOR_ZOOM.MAX}
+ sx={{ py: 0, height: "100%" }}
>
<b>+</b>
</Button>
diff --git a/apps/web/src/components/status-bar/index.tsx b/apps/web/src/components/status-bar/index.tsx
index 306dcaf60..7af2e1883 100644
--- a/apps/web/src/components/status-bar/index.tsx
+++ b/apps/web/src/components/status-bar/index.tsx
@@ -60,7 +60,8 @@ function StatusBar() {
borderTop: "1px solid",
borderTopColor: "separator",
justifyContent: "space-between",
- display: ["none", "none", "flex"]
+ display: ["none", "none", "flex"],
+ height: 24
}}
px={2}
>
diff --git a/apps/web/src/components/virtualized-tree/index.tsx b/apps/web/src/components/virtualized-tree/index.tsx
index f909abc16..2fce17841 100644
--- a/apps/web/src/components/virtualized-tree/index.tsx
+++ b/apps/web/src/components/virtualized-tree/index.tsx
@@ -49,6 +49,8 @@ type TreeViewProps<T> = {
}) => React.ReactNode;
saveKey?: string;
+ testId?: string;
+ placeholder?: () => React.ReactNode;
onSelect?: (id: string) => void;
onDeselect?: (id: string) => void;
bulkSelect?: (ids: string[]) => void;
@@ -64,11 +66,13 @@ export function VirtualizedTree<T>(props: TreeViewProps<T>) {
treeRef,
saveKey,
+ placeholder: Placeholder,
isSelected,
onDeselect,
onSelect,
deselectAll,
- bulkSelect
+ bulkSelect,
+ testId
} = props;
const [nodes, setNodes] = useState<TreeNode<T>[]>([]);
const [expandedIds, setExpandedIds] = usePersistentState<ExpandedIds>(
@@ -169,6 +173,7 @@ export function VirtualizedTree<T>(props: TreeViewProps<T>) {
return (
<Virtuoso
+ data-test-id={testId}
ref={list}
data={nodes}
computeItemKey={(i, item) => item.id}
@@ -179,7 +184,8 @@ export function VirtualizedTree<T>(props: TreeViewProps<T>) {
}}
components={{
Scroller: CustomScrollbarsVirtualList,
- Item: VirtuosoItem
+ Item: VirtuosoItem,
+ EmptyPlaceholder: Placeholder
}}
itemContent={(index, node) => (
<Node
diff --git a/apps/web/src/views/notebook.tsx b/apps/web/src/views/notebook.tsx
index 19b42ef03..55e50bf60 100644
--- a/apps/web/src/views/notebook.tsx
+++ b/apps/web/src/views/notebook.tsx
@@ -34,7 +34,7 @@ import { Plus } from "../components/icons";
import { useStore as useNotesStore } from "../stores/note-store";
import { useStore as useNotebookStore } from "../stores/notebook-store";
import { db } from "../common/db";
-import { getFormattedDate } from "@notesnook/common";
+import { getFormattedDate, usePromise } from "@notesnook/common";
import SubNotebook from "../components/sub-notebook";
import { NotebookContext } from "../components/list-container/types";
import { Menu } from "../hooks/use-menu";
@@ -149,6 +149,12 @@ function SubNotebooks({ rootId, isCollapsed, onClick }: SubNotebooksProps) {
const toggleSelection = useSelectionStore(
(store) => store.toggleSelectionMode
);
+ const rootNotebook = usePromise(() => db.notebooks.notebook(rootId));
+ const notebooks = useNotebookStore((store) => store.notebooks);
+
+ useEffect(() => {
+ treeRef.current?.refresh();
+ }, [notebooks]);
if (!rootId) return null;
@@ -183,7 +189,9 @@ function SubNotebooks({ rootId, isCollapsed, onClick }: SubNotebooksProps) {
<Flex sx={{ alignItems: "center" }}>
{isCollapsed ? <ChevronRight size={16} /> : <ChevronDown size={16} />}
<Text variant="subBody" sx={{ fontSize: 11 }}>
- {strings.notebooksAllCaps()}
+ {rootNotebook.status === "fulfilled" && rootNotebook.value
+ ? rootNotebook.value.title
+ : ""}
</Text>
</Flex>
<Flex sx={{ alignItems: "center" }}>
@@ -233,7 +241,13 @@ function SubNotebooks({ rootId, isCollapsed, onClick }: SubNotebooksProps) {
onDeselect={deselectItem}
onSelect={selectItem}
treeRef={treeRef}
+ placeholder={() => (
+ <Text variant="subBody" sx={{ mx: 2 }}>
+ {strings.emptyPlaceholders("notebook")}
+ </Text>
+ )}
saveKey={`${rootId}-subnotebooks`}
+ testId="subnotebooks-list"
renderItem={({ collapse, expand, expanded, index, item: node }) => (
<SubNotebook
depth={node.depth}