Files
gitea-tea/internal/terminal/label_form_test.go
T
bircni 5d2f2d83eb feat(label): edit a label in a form without flags
label edit without flags on a terminal now opens a form with the label's
name, color, description and flags, like milestone edit and issue edit,
instead of failing; without a terminal it reports the shared "nothing to
edit" error. The help of issue and milestone close and reopen names its
commands without generating the text from the verb.

Signed-off-by: bircni <bircni@icloud.com>
2026-10-12 00:17:08 +02:00

29 lines
959 B
Go

// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package terminal
import (
"context"
"strings"
"testing"
"github.com/stretchr/testify/require"
)
func TestLabelFormStartsFromCurrentValues(t *testing.T) {
p, _ := testPrompter(strings.NewReader("\r\r\r\r\r"))
current := LabelFormValues{Name: "bug", Color: "#EE0701", Description: "Broken", Exclusive: true}
values, err := p.EditLabel(context.Background(), `Editing label "bug" in alice/x`, current)
require.NoError(t, err)
require.Equal(t, LabelFormValues{Name: "bug", Color: "EE0701", Description: "Broken", Exclusive: true}, values)
}
func TestLabelFormMarksNameRequired(t *testing.T) {
p, rendered := accessiblePrompter(t, "bug\nee0701\n\nn\nn\n")
values, err := p.EditLabel(context.Background(), "", LabelFormValues{})
require.NoError(t, err)
require.Contains(t, rendered.String(), "Label name (required):")
require.Equal(t, "bug", values.Name)
}