web: fix all tests

This commit is contained in:
Abdullah Atta
2022-12-05 16:52:44 +05:00
parent 56837208d1
commit 003178ba20
6 changed files with 11 additions and 10 deletions

View File

@@ -120,7 +120,7 @@ test("pressing Enter should open focused note", async ({ page }) => {
expect(await notes.editor.getTitle()).toBe(await notesList[2].getTitle());
});
test("pressing Shift+ArrowDown should select next note", async ({ page }) => {
test.only("pressing Shift+ArrowDown should select next note", async ({ page }) => {
const { notesList, notes } = await populateList(page);
await notes.focus();

View File

@@ -8,8 +8,8 @@
content="This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1"
/>
<title>Test 1 - Notesnook</title>
<meta name="created-on" content="1669202032300" />
<meta name="last-edited-on" content="1669202033184" />
<meta name="created-on" content="xxx" />
<meta name="last-edited-on" content="xxx" />
</head>
<body>

View File

@@ -112,7 +112,7 @@
"build:desktop": "env-cmd -e all,desktop react-scripts build",
"deploy": "./scripts/deploy.sh",
"debug": "env-cmd -e all,dev,web,silent react-scripts start",
"test": "playwright test",
"test": "playwright test -u",
"eject": "react-scripts eject",
"analyze": "source-map-explorer 'build/static/js/*.js'",
"postinstall": "patch-package"

View File

@@ -99,8 +99,8 @@ function ListContainer(props: ListContainerProps) {
length: items.length,
reset: () => toggleSelection(false),
deselect: (index) => deselectItem(items[index]),
select: (index) =>
isSelected(items[index])
select: (index, toggleable) =>
toggleable && isSelected(items[index])
? deselectItem(items[index])
: selectItem(items[index]),
bulkSelect: (indices) => setSelectedItems(indices.map((i) => items[i])),

View File

@@ -29,7 +29,7 @@ enum DIRECTION {
type UseKeyboardListNavigationOptions = {
length: number;
reset: () => void;
select: (index: number) => void;
select: (index: number, toggleable?: boolean) => void;
deselect: (index: number) => void;
bulkSelect: (indices: number[]) => void;
focusItemAt: (index: number) => void;
@@ -82,7 +82,7 @@ export function useKeyboardListNavigation(
const onMouseDown = useCallback(
(e: MouseEvent, itemIndex: number) => {
if (e.ctrlKey || e.metaKey) {
select(itemIndex);
select(itemIndex, true);
} else if (e.shiftKey) {
const startIndex =
itemIndex > cursor.current ? cursor.current : itemIndex;

View File

@@ -23,6 +23,7 @@ import TextBuilder from "../utils/templates/text/builder";
import { getContentFromData } from "../content-types";
import { CHECK_IDS, checkIsUserPremium } from "../common";
import { addItem, deleteItem } from "../utils/array";
import { formatDate } from "../utils/date"
export default class Note {
/**
@@ -87,9 +88,9 @@ export default class Note {
const templateData = {
metadata: this.data,
title: this.title,
editedOn: this.dateEdited,
editedOn: formatDate(this.dateEdited),
headline: this.headline,
createdOn: this.data.dateCreated,
createdOn: formatDate(this.data.dateCreated),
tags: this.tags.join(", ")
};
const contentItem = await this._db.content.raw(this._note.contentId);