Files
workspace/apps/go-crm/internal/handlers/customers_test.go
gabspereira 9c3bfd131d feat(go-crm): industrial terminal-core UI redesign
Complete visual overhaul of the go-crm web interface:

- New shared layout system (internal/templates/ui.go) with dark zinc
  industrial theme, JetBrains Mono typography, grid/noise textures
- Redesigned all pages: Dashboard, Login/Signup, Clients, Customers,
  Services, Scheduling, Payments, Questions, Answers, Leads,
  Review Queue, Report, Keyword Mapping
- Tailwind CSS via CDN with custom color palette (amber/emerald/rose/sky)
- HTMX-powered interactions with CSS swap animations
- Status pills, KPI cards, data tables, empty states, inline forms
- Mobile-responsive sidebar with collapsible navigation
- All existing tests updated and passing
- Zero new build dependencies — works with existing go run/air workflow
2026-05-23 18:00:32 -03:00

50 lines
1.4 KiB
Go

package handlers
import (
"net/http"
"net/http/httptest"
"testing"
"time"
"golang.org/x/crypto/bcrypt"
)
func TestCreateCustomerInternalSecret(t *testing.T) {
testDB, cleanup := SetupTestDB(t)
defer cleanup()
DB = testDB
hashedPassword, _ := bcrypt.GenerateFromPassword([]byte("password"), bcrypt.DefaultCost)
testDB.Exec(
"INSERT INTO accounts (email, name, password, created_at) VALUES (?, ?, ?, ?)",
"test@example.com", "Test Account", string(hashedPassword), time.Now().Unix(),
)
var accountID int64
testDB.QueryRow("SELECT account_id FROM accounts WHERE email = ?", "test@example.com").Scan(&accountID)
var clientID int64
testDB.QueryRow(
"INSERT INTO clients (account_id, name, phone, created_at) VALUES (?, ?, ?, ?) RETURNING client_id",
accountID, "Test Client", "+5521987654321", time.Now().Unix(),
).Scan(&clientID)
req := httptest.NewRequest(http.MethodPost, "/customers", nil)
req.PostForm = map[string][]string{
"name": {"+5521987654321"},
"phone": {"+5521987654321"},
"client_id": {string(rune(clientID))},
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("X-Internal-Secret", "internal-secret")
w := httptest.NewRecorder()
CreateCustomer(w, req)
if w.Code != http.StatusOK && w.Code != http.StatusFound {
t.Fatalf("expected success with internal secret, got %d", w.Code)
}
}