feat: add CountEntries to skip decryption for list --detail (#562)

* feat: add CountEntries to skip decryption for list --detail (#549)
* test: add CountEntries and countCategory tests at browser level
* fix: address review feedback on CountRows and countLocalStorage
* test: add CountRows unit tests
This commit is contained in:
Roger
2026-04-07 22:28:39 +08:00
committed by GitHub
parent 5f42d4fe5f
commit b3bbc0dadf
40 changed files with 1009 additions and 101 deletions
+23 -2
View File
@@ -7,8 +7,9 @@ import (
"github.com/stretchr/testify/require"
)
func TestExtractBookmarks(t *testing.T) {
path := createTestJSON(t, "Bookmarks", `{
func setupBookmarkJSON(t *testing.T) string {
t.Helper()
return createTestJSON(t, "Bookmarks", `{
"roots": {
"bookmark_bar": {
"name": "Bookmarks Bar",
@@ -33,6 +34,10 @@ func TestExtractBookmarks(t *testing.T) {
}
}
}`)
}
func TestExtractBookmarks(t *testing.T) {
path := setupBookmarkJSON(t)
got, err := extractBookmarks(path)
require.NoError(t, err)
@@ -52,6 +57,22 @@ func TestExtractBookmarks(t *testing.T) {
assert.Equal(t, "News", got[2].Folder) // parent folder name
}
func TestCountBookmarks(t *testing.T) {
path := setupBookmarkJSON(t)
count, err := countBookmarks(path)
require.NoError(t, err)
assert.Equal(t, 3, count) // 3 URLs, folders not counted
}
func TestCountBookmarks_Empty(t *testing.T) {
path := createTestJSON(t, "Bookmarks", `{"roots": {}}`)
count, err := countBookmarks(path)
require.NoError(t, err)
assert.Equal(t, 0, count)
}
func TestExtractBookmarks_FoldersExcluded(t *testing.T) {
path := createTestJSON(t, "Bookmarks", `{
"roots": {