-
Notifications
You must be signed in to change notification settings - Fork 0
Console Redesign Batch 1: dark-chrome shell, Tenants list, Dashboard #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
57b241d
docs: Console Redesign Batch 1 implementation plan
93fb92b
feat(backend): optional reason on lifecycle + impersonation, persiste…
595b3f7
chore(web): add vitest + Testing Library test infrastructure
27a0be4
fix(web): vitest passWithNoTests for bootstrap commit, tsc coverage f…
b884846
fix(web): narrow vitest.config.ts plugins cast from any to Plugin[] (…
edb3b22
feat(web): shared meter tone/percent utility for usage-vs-limit displays
874acfe
feat(web): add trial status to StatusBadge's 4-way status system
9a38a22
feat(web): add shadcn Sheet primitive (for Batch 2's Archive side-sheet)
71bb260
feat(web): add console dark-chrome and trial-status design tokens
d651f5a
feat(web): dark-chrome top-nav shell for the Platform Console
f276c4e
feat(web): shared tenant-queue filters and promote BarRow to a shared…
53d139d
feat(web): reskin Tenants list — saved-queue chips, usage meters, cus…
46c04d0
feat(web): reskin Platform Console dashboard — real KPI tiles, queues…
b308565
fix(web): Dashboard load() error handling + scope over-limit queue te…
973cd0e
fix(web): console header toggle buttons stay visible in light mode (f…
f177443
test(backend): assert audit callback actually ran in no-body test
9f76cf9
fix(web): isActiveNavPath prefix-collision + move for fast-refresh
3a57887
fix(web): meterPercent zero-limit consistency + overLimitTenants cove…
9bd8a3e
fix(web): localize Sheet's close button accessible label
8a60f88
fix(web): drop false "recently" claim from suspended-tenants queue label
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| package handler | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "encoding/json" | ||
| "net/http" | ||
| "net/http/httptest" | ||
| "testing" | ||
|
|
||
| "idento/backend/internal/models" | ||
|
|
||
| "github.com/google/uuid" | ||
| "github.com/labstack/echo/v4" | ||
| ) | ||
|
|
||
| func TestSetTenantStatus_ReasonPersistedToAuditChanges(t *testing.T) { | ||
| e := echo.New() | ||
| tenantID := uuid.New() | ||
| adminID := uuid.New() | ||
| var capturedChanges map[string]interface{} | ||
|
|
||
| fs := &fakeStore{ | ||
| getTenantStatus: func(id uuid.UUID) (string, error) { | ||
| if id == tenantID { | ||
| return "active", nil | ||
| } | ||
| return "", nil | ||
| }, | ||
| updateTenantStatus: func(id uuid.UUID, status string) error { | ||
| return nil | ||
| }, | ||
| logAdminAction: func(audID uuid.UUID, action, targetType string, targetID uuid.UUID, changes interface{}, ip, userAgent string) error { | ||
| capturedChanges = changes.(map[string]interface{}) | ||
| return nil | ||
| }, | ||
| } | ||
|
|
||
| h := &Handler{Store: fs} | ||
| body, _ := json.Marshal(map[string]string{"reason": "Spring Summit 2026, approved by JR"}) | ||
| req := httptest.NewRequest(http.MethodPost, "/api/super-admin/tenants/"+tenantID.String()+"/suspend", bytes.NewReader(body)) | ||
| req.Header.Set("Content-Type", "application/json") | ||
| rec := httptest.NewRecorder() | ||
| c := e.NewContext(req, rec) | ||
| c.SetParamNames("id") | ||
| c.SetParamValues(tenantID.String()) | ||
| c.Set("user", &models.JWTCustomClaims{ | ||
| UserID: adminID.String(), | ||
| TenantID: uuid.New().String(), | ||
| Role: "admin", | ||
| }) | ||
|
|
||
| if err := h.SuspendTenant(c); err != nil { | ||
| t.Fatalf("SuspendTenant returned error: %v", err) | ||
| } | ||
| if rec.Code != http.StatusOK { | ||
| t.Fatalf("expected 200, got %d: %s", rec.Code, rec.Body.String()) | ||
| } | ||
| if capturedChanges == nil { | ||
| t.Fatalf("expected changes to be captured, got nil") | ||
| } | ||
| if capturedChanges["reason"] != "Spring Summit 2026, approved by JR" { | ||
| t.Fatalf("expected reason in audit changes, got %#v", capturedChanges) | ||
| } | ||
| if capturedChanges["from"] != "active" || capturedChanges["to"] != "suspended" { | ||
| t.Fatalf("expected from/to preserved alongside reason, got %#v", capturedChanges) | ||
| } | ||
| } | ||
|
|
||
| func TestSetTenantStatus_NoBodyStillWorks(t *testing.T) { | ||
| e := echo.New() | ||
| tenantID := uuid.New() | ||
| adminID := uuid.New() | ||
| var capturedChanges map[string]interface{} | ||
|
|
||
| fs := &fakeStore{ | ||
| getTenantStatus: func(id uuid.UUID) (string, error) { | ||
| if id == tenantID { | ||
| return "suspended", nil | ||
| } | ||
| return "", nil | ||
| }, | ||
| updateTenantStatus: func(id uuid.UUID, status string) error { | ||
| return nil | ||
| }, | ||
| logAdminAction: func(audID uuid.UUID, action, targetType string, targetID uuid.UUID, changes interface{}, ip, userAgent string) error { | ||
| capturedChanges = changes.(map[string]interface{}) | ||
| return nil | ||
| }, | ||
| } | ||
|
|
||
| h := &Handler{Store: fs} | ||
| req := httptest.NewRequest(http.MethodPost, "/api/super-admin/tenants/"+tenantID.String()+"/reactivate", nil) | ||
| rec := httptest.NewRecorder() | ||
| c := e.NewContext(req, rec) | ||
| c.SetParamNames("id") | ||
| c.SetParamValues(tenantID.String()) | ||
| c.Set("user", &models.JWTCustomClaims{ | ||
| UserID: adminID.String(), | ||
| TenantID: uuid.New().String(), | ||
| Role: "admin", | ||
| }) | ||
|
|
||
| if err := h.ReactivateTenant(c); err != nil { | ||
| t.Fatalf("ReactivateTenant returned error: %v", err) | ||
| } | ||
| if rec.Code != http.StatusOK { | ||
| t.Fatalf("expected 200, got %d: %s", rec.Code, rec.Body.String()) | ||
| } | ||
| if capturedChanges == nil { | ||
| t.Fatalf("expected logAdminAction to be invoked with captured changes, got nil") | ||
| } | ||
| if _, hasReason := capturedChanges["reason"]; hasReason { | ||
| t.Fatalf("expected no reason key when body omits it, got %#v", capturedChanges) | ||
| } | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| func TestImpersonateTenant_ReasonPersistedToAuditChanges(t *testing.T) { | ||
| t.Setenv("JWT_SECRET", "test-secret") | ||
| e := echo.New() | ||
| tenantID := uuid.New() | ||
| adminID := uuid.New() | ||
| var capturedChanges map[string]interface{} | ||
|
|
||
| fs := &fakeStore{ | ||
| getTenantStatus: func(id uuid.UUID) (string, error) { | ||
| if id == tenantID { | ||
| return "active", nil | ||
| } | ||
| return "", nil | ||
| }, | ||
| logAdminAction: func(audID uuid.UUID, action, targetType string, targetID uuid.UUID, changes interface{}, ip, userAgent string) error { | ||
| capturedChanges = changes.(map[string]interface{}) | ||
| return nil | ||
| }, | ||
| } | ||
|
|
||
| h := &Handler{Store: fs} | ||
| body, _ := json.Marshal(map[string]string{"reason": "Reproduce badge-print bug for support ticket #4821"}) | ||
| req := httptest.NewRequest(http.MethodPost, "/api/super-admin/tenants/"+tenantID.String()+"/impersonate", bytes.NewReader(body)) | ||
| req.Header.Set("Content-Type", "application/json") | ||
| rec := httptest.NewRecorder() | ||
| c := e.NewContext(req, rec) | ||
| c.SetParamNames("id") | ||
| c.SetParamValues(tenantID.String()) | ||
| c.Set("user", &models.JWTCustomClaims{ | ||
| UserID: adminID.String(), | ||
| TenantID: uuid.New().String(), | ||
| Role: "admin", | ||
| }) | ||
|
|
||
| if err := h.ImpersonateTenant(c); err != nil { | ||
| t.Fatalf("ImpersonateTenant returned error: %v", err) | ||
| } | ||
| if rec.Code != http.StatusOK { | ||
| t.Fatalf("expected 200, got %d: %s", rec.Code, rec.Body.String()) | ||
| } | ||
| if capturedChanges == nil { | ||
| t.Fatalf("expected changes to be captured, got nil") | ||
| } | ||
| if capturedChanges["reason"] != "Reproduce badge-print bug for support ticket #4821" { | ||
| t.Fatalf("expected reason in audit changes, got %#v", capturedChanges) | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Use table-driven subtests and parallel execution.
These three cases duplicate the same Echo/fake-store setup and none uses
t.Parallel(). Consolidate the scenarios into table-driven subtests; hoist shared JWT-secret setup before parallel subtests becauset.Setenvcannot be called from a parallel test.As per coding guidelines: Write unit tests using table-driven patterns and parallel execution.
Also applies to: 69-112, 114-160
🤖 Prompt for AI Agents
Source: Coding guidelines