From 29519e92f20d6ea25a33c48a3a9bc6dd85b15984 Mon Sep 17 00:00:00 2001 From: sunmingda Date: Wed, 23 Sep 2026 16:24:32 +0800 Subject: [PATCH] test(projects): cover Call Agent list and detail compatibility --- docs/automation.md | 2 ++ internal/cli/integration_project_test.go | 43 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/docs/automation.md b/docs/automation.md index f9a99e2..3e7cf51 100644 --- a/docs/automation.md +++ b/docs/automation.md @@ -1000,6 +1000,8 @@ Required `data` fields: Each item includes: `projectId`, `name`, `appId`, `projectType`, `status`, `createdAt`, `updatedAt`. +The API `projectType` is preserved as a string, including `paas`, `apaas`, `meeting`, `game-voice`, and `call-agent` for existing Call Agent projects. Consumers should allow additional types. This API field is distinct from the local `.agora/project.json` framework field; `project create` continues to create `paas` projects. + Safe branch fields: - `items[].projectId` - `items[].name` diff --git a/internal/cli/integration_project_test.go b/internal/cli/integration_project_test.go index 45e2b43..1821d0b 100644 --- a/internal/cli/integration_project_test.go +++ b/internal/cli/integration_project_test.go @@ -13,6 +13,49 @@ import ( "testing" ) +func TestCLIProjectListAndShowCallAgent(t *testing.T) { + configHome := t.TempDir() + api := newFakeCLIBFF() + defer api.server.Close() + project := buildFakeProject("Call Agent Project", "callAgent123", "app_call_agent", "cn") + project.ProjectType = "call-agent" + api.projects[project.ProjectID] = &project + persistSessionForIntegration(t, configHome) + opts := cliRunOptions{env: map[string]string{ + "XDG_CONFIG_HOME": configHome, + "AGORA_API_BASE_URL": api.baseURL, + "AGORA_LOG_LEVEL": "error", + }} + + list := runCLI(t, []string{"project", "list", "--json"}, opts) + var envelope struct { + OK bool `json:"ok"` + Data projectListResponse `json:"data"` + } + if err := json.Unmarshal([]byte(list.stdout), &envelope); err != nil { + t.Fatal(err) + } + if list.exitCode != 0 || !envelope.OK || len(envelope.Data.Items) != 1 || envelope.Data.Items[0].ProjectType != "call-agent" { + t.Fatalf("expected call-agent project in list: %+v", list) + } + + for _, selector := range []string{project.ProjectID, project.Name} { + show := runCLI(t, []string{"project", "show", selector, "--json"}, opts) + var detail struct { + OK bool `json:"ok"` + Data struct { + ProjectID string `json:"projectId"` + } `json:"data"` + } + if err := json.Unmarshal([]byte(show.stdout), &detail); err != nil { + t.Fatal(err) + } + if show.exitCode != 0 || !detail.OK || detail.Data.ProjectID != project.ProjectID { + t.Fatalf("expected call-agent project resolved by %q: %+v", selector, show) + } + } +} + func TestCLIProjectEnvAndDoctor(t *testing.T) { configHome := t.TempDir() projectDir := t.TempDir()