feat: unify account environments and work collection

This commit is contained in:
2026-10-06 13:00:29 +08:00
parent b72727451d
commit 950b23da32
22 changed files with 935 additions and 93 deletions
@@ -0,0 +1,14 @@
package api
import (
"testing"
hub "git.ipao.vip/rogee/creator-hub/internal/environment"
)
func TestAccountEnvironmentViewPreservesDatabaseOrderingID(t *testing.T) {
view := accountEnvironmentView(hub.EnvironmentContext{Env: hub.Env{ID: 42, Alias: "env-order"}})
if view["id"] != int64(42) {
t.Fatalf("account environment is missing its shared ordering ID: %#v", view)
}
}
@@ -243,7 +243,7 @@ func PhaseAError(c fiber.Ctx, err error) error {
func accountEnvironmentView(environment hub.EnvironmentContext) map[string]any {
scheduleStatus, scheduleBlockReason := environmentScheduleReadiness(environment)
return map[string]any{
"alias": environment.Alias, "name": environment.Name, "gateway": environment.Gateway,
"id": environment.ID, "alias": environment.Alias, "name": environment.Name, "gateway": environment.Gateway,
"binding_version": environment.BindingVersion, "runtime_id": environment.RuntimeID,
"runtime_cleanup_pending": environment.RuntimeCleanupPending,
"network_exit_id": environment.Exit.ID, "network_exit_health": environment.Exit.HealthStatus,
@@ -95,8 +95,8 @@ func TestPendingEnvironmentLoginRoutesKeepBrowserIdentity(t *testing.T) {
}
}
pending, err := hs.ListPendingEnvironments(ctx)
if err != nil || len(pending) != 1 {
t.Fatalf("pending browser created account: %v %v", pending, err)
if err != nil || len(pending) != 1 || pending[0].ID != env.ID || env.ID < 1 {
t.Fatalf("pending browser created account or lost its ordering ID: %v %v", pending, err)
}
logged = true
response := do(app, http.MethodPost, route+"/verify", `{}`)
@@ -108,7 +108,7 @@ func TestPendingEnvironmentLoginRoutesKeepBrowserIdentity(t *testing.T) {
t.Fatalf("login response: %#v %v", result, err)
}
bound, err := hs.GetEnvironmentContext(ctx, alias)
if err != nil || bound.AccountID != result.AccountID || bound.RuntimeID != "login-runtime" || bound.ProfileID != alias || bound.Fingerprint.Seed != env.Fingerprint.Seed {
if err != nil || bound.AccountID != result.AccountID || bound.RuntimeID != "login-runtime" || bound.ProfileID != alias || bound.Fingerprint.Seed != env.Fingerprint.Seed || bound.ID != env.ID {
t.Fatalf("binding changed browser: %#v %v", bound, err)
}
response = do(app, http.MethodPost, route+"/verify", `{}`)