mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
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>
29 lines
959 B
Go
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)
|
|
}
|