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
+46 -2
View File
@@ -7,8 +7,9 @@ import (
"github.com/stretchr/testify/require"
)
func TestExtractExtensions(t *testing.T) {
path := createTestJSON(t, "Secure Preferences", `{
func setupExtensionJSON(t *testing.T) string {
t.Helper()
return createTestJSON(t, "Secure Preferences", `{
"extensions": {
"settings": {
"abc123": {
@@ -38,6 +39,10 @@ func TestExtractExtensions(t *testing.T) {
}
}
}`)
}
func TestExtractExtensions(t *testing.T) {
path := setupExtensionJSON(t)
got, err := extractExtensions(path)
require.NoError(t, err)
@@ -56,6 +61,45 @@ func TestExtractExtensions(t *testing.T) {
assert.False(t, ids["system-ext"])
}
func TestCountExtensions(t *testing.T) {
path := setupExtensionJSON(t)
count, err := countExtensions(path)
require.NoError(t, err)
assert.Equal(t, 2, count) // system (5) and component (10) skipped
}
func TestCountOperaExtensions(t *testing.T) {
path := createTestJSON(t, "Secure Preferences", `{
"extensions": {
"opsettings": {
"opera-ext-1": {
"location": 1,
"manifest": {"name": "Opera Ad Blocker", "version": "2.0.0"}
},
"system-ext": {
"location": 5,
"manifest": {"name": "System", "version": "1.0"}
}
}
}
}`)
count, err := countOperaExtensions(path)
require.NoError(t, err)
assert.Equal(t, 1, count)
}
func TestCountExtensions_Empty(t *testing.T) {
path := createTestJSON(t, "Secure Preferences", `{
"extensions": {"settings": {}}
}`)
count, err := countExtensions(path)
require.NoError(t, err)
assert.Equal(t, 0, count)
}
func TestExtractExtensions_NoManifestSkipped(t *testing.T) {
path := createTestJSON(t, "Secure Preferences", `{
"extensions": {