fix: do not ask for confirmation right after prompting for input

secret set, variable set, team create, webhook create and admin user
create asked a confirmation that defaults to No right after the user
typed the missing values, so pressing Enter discarded the input. They
now submit what the user entered; deletions still confirm.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-11 21:59:18 +02:00
1 parent fcfc497a77
commit b6b3ddc91b
6 files changed
+43 -29

No files matched your search

+35 -2
View File
@@ -257,8 +257,6 @@ func TestConfirmationsNameResolvedValues(t *testing.T) {
}{
{[]string{"wiki", "create"}, map[string]string{"title": "Home", "body": "text"}, "create wiki page Home on alice/project"},
{[]string{"release", "create"}, map[string]string{"tag": "v1.0.0"}, "create release v1.0.0 on alice/project"},
{[]string{"webhook", "create"}, map[string]string{"url": "https://hooks.test/path"}, "create webhook https://hooks.test/path"},
{[]string{"team", "create", "acme"}, map[string]string{"name": "Developers"}, "create team Developers in acme"},
{[]string{"time", "delete", "5", "7"}, nil, "delete tracked time entry 7 on alice/project #5"},
} {
t.Run(strings.Join(tc.args, " "), func(t *testing.T) {
@@ -280,6 +278,41 @@ func TestConfirmationsNameResolvedValues(t *testing.T) {
}
}
func TestPromptedCreateSubmitsWithoutConfirmation(t *testing.T) {
for _, tc := range []struct {
args []string
inputs map[string]string
secret, write string
}{
{[]string{"secret", "set", "TOKEN"}, nil, "private", "PUT /api/v1/repos/alice/project/actions/secrets/TOKEN"},
{[]string{"variable", "set", "MODE"}, map[string]string{"Variable value": "fast"}, "", "POST /api/v1/repos/alice/project/actions/variables/MODE"},
{[]string{"webhook", "create"}, map[string]string{"url": "https://hooks.test/path"}, "", "POST /api/v1/repos/alice/project/hooks"},
{[]string{"team", "create", "acme"}, map[string]string{"name": "Developers"}, "", "POST /api/v1/orgs/acme/teams"},
} {
t.Run(strings.Join(tc.args, " "), func(t *testing.T) {
var writes []string
server := newAuthenticatedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodGet {
w.WriteHeader(http.StatusNotFound)
return
}
writes = append(writes, r.Method+" "+r.URL.Path)
w.WriteHeader(http.StatusCreated)
_, _ = w.Write([]byte(`{"id":1}`))
}))
defer server.Close()
deps, _, _ := testDeps(t)
deps.Getenv = serverEnv(server.URL, map[string]string{"TEA_REPO": "alice/project"})
prompt := &scriptedPrompter{inputs: tc.inputs, secret: tc.secret}
deps.Prompter = prompt
deps.Streams.InTTY, deps.Streams.ErrTTY = true, true
require.NoError(t, Execute(context.Background(), deps, tc.args))
require.Empty(t, prompt.confirmations)
require.Equal(t, []string{tc.write}, writes)
})
}
}
type unexpectedForms struct{ t *testing.T }
func (f unexpectedForms) CreateIssue(context.Context, terminal.IssueFormChoices) (terminal.IssueFormValues, error) {