refactor: remove banned imports from test files
Some checks failed
Security Scan / security (push) Failing after 27s

- window/persistence_test.go: path/filepath → core.JoinPath
- display/display_test.go: path/filepath → core.JoinPath/PathDir
- browser/service_test.go: errors → core.NewError
- notification/service_test.go: errors → core.NewError

Zero banned imports in ALL gui files — production AND test.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude 2026-03-31 16:53:40 +01:00
parent f1f7fcfab9
commit 9bd0e7b025
No known key found for this signature in database
GPG key ID: AF404715446AEB41
4 changed files with 13 additions and 16 deletions

View file

@ -3,10 +3,9 @@ package browser
import (
"context"
"errors"
core "dappco.re/go/core"
"testing"
core "dappco.re/go/core"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@ -58,7 +57,7 @@ func TestTaskOpenURL_Good(t *testing.T) {
}
func TestTaskOpenURL_Bad_PlatformError(t *testing.T) {
mp := &mockPlatform{urlErr: errors.New("browser not found")}
mp := &mockPlatform{urlErr: core.NewError("browser not found")}
_, c := newTestBrowserService(t, mp)
r := c.Action("browser.openURL").Run(context.Background(), core.NewOptions(
@ -79,7 +78,7 @@ func TestTaskOpenFile_Good(t *testing.T) {
}
func TestTaskOpenFile_Bad_PlatformError(t *testing.T) {
mp := &mockPlatform{fileErr: errors.New("file not found")}
mp := &mockPlatform{fileErr: core.NewError("file not found")}
_, c := newTestBrowserService(t, mp)
r := c.Action("browser.openFile").Run(context.Background(), core.NewOptions(

View file

@ -3,7 +3,6 @@ package display
import (
"context"
"os"
"path/filepath"
"testing"
core "dappco.re/go/core"
@ -437,8 +436,8 @@ func TestWSEventManager_Good(t *testing.T) {
func TestLoadConfig_Good(t *testing.T) {
// Create temp config file
dir := t.TempDir()
cfgPath := filepath.Join(dir, ".core", "gui", "config.yaml")
require.NoError(t, os.MkdirAll(filepath.Dir(cfgPath), 0o755))
cfgPath := core.JoinPath(dir, ".core", "gui", "config.yaml")
require.NoError(t, os.MkdirAll(core.PathDir(cfgPath), 0o755))
require.NoError(t, os.WriteFile(cfgPath, []byte(`
window:
default_width: 1280
@ -460,7 +459,7 @@ menu:
func TestLoadConfig_Bad_MissingFile(t *testing.T) {
s, _ := New()
s.loadConfigFrom(filepath.Join(t.TempDir(), "nonexistent.yaml"))
s.loadConfigFrom(core.JoinPath(t.TempDir(), "nonexistent.yaml"))
// Should not panic, configData stays at empty defaults
assert.Empty(t, s.configData["window"])
@ -470,7 +469,7 @@ func TestLoadConfig_Bad_MissingFile(t *testing.T) {
func TestHandleConfigTask_Persists_Good(t *testing.T) {
dir := t.TempDir()
cfgPath := filepath.Join(dir, "config.yaml")
cfgPath := core.JoinPath(dir, "config.yaml")
s, _ := New()
s.loadConfigFrom(cfgPath) // Creates empty config (file doesn't exist yet)

View file

@ -3,10 +3,9 @@ package notification
import (
"context"
"errors"
core "dappco.re/go/core"
"testing"
core "dappco.re/go/core"
"forge.lthn.ai/core/gui/pkg/dialog"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -86,7 +85,7 @@ func TestTaskSend_Good(t *testing.T) {
func TestTaskSend_Fallback_Good(t *testing.T) {
// Platform fails -> falls back to dialog via IPC
mockNotify := &mockPlatform{sendErr: errors.New("no permission")}
mockNotify := &mockPlatform{sendErr: core.NewError("no permission")}
mockDlg := &mockDialogPlatform{}
c := core.New(
core.WithService(dialog.Register(mockDlg)),
@ -135,7 +134,7 @@ func TestTaskRevokePermission_Good(t *testing.T) {
func TestTaskRevokePermission_Bad(t *testing.T) {
mock, c := newTestService(t)
mock.revokeErr = errors.New("cannot revoke")
mock.revokeErr = core.NewError("cannot revoke")
r := c.Action("notification.revokePermission").Run(context.Background(), core.NewOptions())
assert.False(t, r.OK)
}
@ -250,7 +249,7 @@ func TestQueryPermission_Bad(t *testing.T) {
func TestQueryPermission_Ugly(t *testing.T) {
// Platform returns error — QUERY returns OK=false (framework does not propagate Value for failed queries)
mock := &mockPlatform{permErr: errors.New("platform error")}
mock := &mockPlatform{permErr: core.NewError("platform error")}
c := core.New(
core.WithService(Register(mock)),
core.WithServiceLock(),

View file

@ -3,7 +3,7 @@ package window
import (
"os"
"path/filepath"
core "dappco.re/go/core"
"testing"
"time"
@ -181,7 +181,7 @@ func TestStateManager_Persistence_Good(t *testing.T) {
func TestStateManager_SetPath_Good(t *testing.T) {
dir := t.TempDir()
path := filepath.Join(dir, "custom", "window-state.json")
path := core.JoinPath(dir, "custom", "window-state.json")
sm := NewStateManagerWithDir(dir)
sm.SetPath(path)