mirror of
https://github.com/larksuite/cli.git
synced 2026-09-14 18:42:53 +08:00
5919e861cc
* feat: accept frontend app-type in apps +create * feat: accept frontend app-type filter in apps +list * docs: clarify frontend app-type handling in apps +init * docs: note FRONTEND in queryAppType comment * docs: add frontend app-type guidance to lark-apps skill * docs: add frontend app-type to lark-apps command references SKILL.md's routing table already covered frontend, but the per-command reference docs still enumerated only html/full_stack. Update create/list/get enum values, add a frontend local-dev section, and note frontend in the release-create entry so agents document the third app type consistently. * docs: address CodeRabbit feedback on frontend app-type refs - create.md: state the app-type enum is matched exactly (lowercase), drop the incorrect claim that the CLI normalizes case - local-dev.md: scope database debugging to full_stack (frontend/html have no DB) and add the +release-get finished-status poll to the frontend flow * docs: align app-type enum in apps E2E coverage and test comments The E2E coverage table and two test comments still described the --app-type enum as html/full_stack after frontend was added. Update them to html/frontend/full_stack for consistency; assertions are unaffected (they match on substrings, not the full enum set). * docs(lark-apps): cloud-dev honors routed app_type instead of hardcoding full_stack The main SKILL.md router declares app_type and dev-method orthogonal and routes no-database interactive tools to frontend, but cloud-dev/create references still hardcoded `+create --app-type full_stack` for cloud generation. This forced a frontend-routed request into a full_stack app (unrecoverable since apps have no +delete). Align with the 2026-07-24 design decision: cloud generation also splits by database need — full_stack when persistence is required, frontend by default when unstated. Verified on BOE that a frontend app runs the full cloud session+chat pipeline to completed.
168 lines
5.0 KiB
Go
168 lines
5.0 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package apps
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
clie2e "github.com/larksuite/cli/tests/cli_e2e"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// TestAppsCreateDryRun pins the request shape and Validate behavior for
|
|
// `apps +create`. The shortcut is UAT-only and posts to the registered
|
|
// /open-apis/spark/v1 namespace; both are checked here.
|
|
func TestAppsCreateDryRun(t *testing.T) {
|
|
setAppsDryRunEnv(t)
|
|
|
|
t.Run("HappyPath_HTMLAppType", func(t *testing.T) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
t.Cleanup(cancel)
|
|
|
|
result, err := clie2e.RunCmd(ctx, clie2e.Request{
|
|
Args: []string{
|
|
"apps", "+create",
|
|
"--name", "Demo",
|
|
"--app-type", "html",
|
|
"--dry-run",
|
|
},
|
|
DefaultAs: "user",
|
|
})
|
|
require.NoError(t, err)
|
|
result.AssertExitCode(t, 0)
|
|
|
|
assert.Equal(t, "POST", clie2e.DryRunGet(result.Stdout, "api.0.method").String())
|
|
assert.Equal(t, "/open-apis/spark/v1/apps", clie2e.DryRunGet(result.Stdout, "api.0.url").String())
|
|
assert.Equal(t, "Demo", clie2e.DryRunGet(result.Stdout, "api.0.body.name").String())
|
|
assert.Equal(t, "html", clie2e.DryRunGet(result.Stdout, "api.0.body.app_type").String())
|
|
// Optional fields stay omitted when not provided.
|
|
assert.False(t, clie2e.DryRunGet(result.Stdout, "api.0.body.description").Exists())
|
|
assert.False(t, clie2e.DryRunGet(result.Stdout, "api.0.body.icon_url").Exists())
|
|
})
|
|
|
|
t.Run("AllFields", func(t *testing.T) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
t.Cleanup(cancel)
|
|
|
|
result, err := clie2e.RunCmd(ctx, clie2e.Request{
|
|
Args: []string{
|
|
"apps", "+create",
|
|
"--name", "Demo",
|
|
"--app-type", "html",
|
|
"--description", "survey app",
|
|
"--icon-url", "https://example.com/icon.svg",
|
|
"--dry-run",
|
|
},
|
|
DefaultAs: "user",
|
|
})
|
|
require.NoError(t, err)
|
|
result.AssertExitCode(t, 0)
|
|
|
|
assert.Equal(t, "Demo", clie2e.DryRunGet(result.Stdout, "api.0.body.name").String())
|
|
assert.Equal(t, "html", clie2e.DryRunGet(result.Stdout, "api.0.body.app_type").String())
|
|
assert.Equal(t, "survey app", clie2e.DryRunGet(result.Stdout, "api.0.body.description").String())
|
|
assert.Equal(t, "https://example.com/icon.svg", clie2e.DryRunGet(result.Stdout, "api.0.body.icon_url").String())
|
|
})
|
|
|
|
t.Run("RejectsMissingName", func(t *testing.T) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
t.Cleanup(cancel)
|
|
|
|
result, err := clie2e.RunCmd(ctx, clie2e.Request{
|
|
Args: []string{
|
|
"apps", "+create",
|
|
"--app-type", "html",
|
|
"--dry-run",
|
|
},
|
|
DefaultAs: "user",
|
|
})
|
|
require.NoError(t, err)
|
|
result.AssertExitCode(t, 2)
|
|
assert.Contains(t, validateErrorMessage(result), `required flag(s) "name" not set`)
|
|
})
|
|
|
|
t.Run("RejectsBlankName", func(t *testing.T) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
t.Cleanup(cancel)
|
|
|
|
result, err := clie2e.RunCmd(ctx, clie2e.Request{
|
|
Args: []string{
|
|
"apps", "+create",
|
|
"--name", " ",
|
|
"--app-type", "html",
|
|
"--dry-run",
|
|
},
|
|
DefaultAs: "user",
|
|
})
|
|
require.NoError(t, err)
|
|
result.AssertExitCode(t, 2)
|
|
msg := validateErrorMessage(result)
|
|
assert.Contains(t, msg, "--name is required")
|
|
})
|
|
|
|
t.Run("RejectsMissingAppType", func(t *testing.T) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
t.Cleanup(cancel)
|
|
|
|
result, err := clie2e.RunCmd(ctx, clie2e.Request{
|
|
Args: []string{
|
|
"apps", "+create",
|
|
"--name", "Demo",
|
|
"--dry-run",
|
|
},
|
|
DefaultAs: "user",
|
|
})
|
|
require.NoError(t, err)
|
|
result.AssertExitCode(t, 2)
|
|
assert.Contains(t, validateErrorMessage(result), `required flag(s) "app-type" not set`)
|
|
})
|
|
|
|
t.Run("RejectsInvalidAppType", func(t *testing.T) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
t.Cleanup(cancel)
|
|
|
|
result, err := clie2e.RunCmd(ctx, clie2e.Request{
|
|
Args: []string{
|
|
"apps", "+create",
|
|
"--name", "Demo",
|
|
"--app-type", "spa",
|
|
"--dry-run",
|
|
},
|
|
DefaultAs: "user",
|
|
})
|
|
require.NoError(t, err)
|
|
result.AssertExitCode(t, 2)
|
|
msg := validateErrorMessage(result)
|
|
assert.Contains(t, msg, "invalid value")
|
|
assert.Contains(t, msg, "full_stack")
|
|
})
|
|
|
|
t.Run("RejectsLegacyUppercaseAppType", func(t *testing.T) {
|
|
// --app-type is a strict lowercase enum (html / frontend / full_stack); the CLI does
|
|
// not normalize case. Legacy uppercase "HTML" is rejected — backend
|
|
// compatibility for legacy values is a server concern the client does not
|
|
// surface.
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
t.Cleanup(cancel)
|
|
|
|
result, err := clie2e.RunCmd(ctx, clie2e.Request{
|
|
Args: []string{
|
|
"apps", "+create",
|
|
"--name", "Demo",
|
|
"--app-type", "HTML",
|
|
"--dry-run",
|
|
},
|
|
DefaultAs: "user",
|
|
})
|
|
require.NoError(t, err)
|
|
result.AssertExitCode(t, 2)
|
|
msg := validateErrorMessage(result)
|
|
assert.Contains(t, msg, "invalid value")
|
|
assert.Contains(t, msg, "HTML")
|
|
})
|
|
}
|