Skip to content

Commit 95a59f4

Browse files
BagToadCopilot
authored andcommitted
fix(accessible prompter): update test expectations for huh v2
Fix accessible prompter tests that broke with the huh v2 upgrade: - Replace 'Input a number' with 'Enter a number' (huh v2 changed text) - Remove trailing CRLF from ExpectString calls that now fail due to ANSI color codes wrapping the title text - Allow ANSI escape codes in password masking regex assertions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4d74e05 commit 95a59f4

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

internal/prompter/accessible_prompter_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func TestAccessiblePrompter(t *testing.T) {
109109

110110
go func() {
111111
// Wait for prompt to appear without the invalid default value
112-
_, err := console.ExpectString("Select a number \r\n")
112+
_, err := console.ExpectString("Select a number")
113113
require.NoError(t, err)
114114

115115
// Select option 2
@@ -128,7 +128,7 @@ func TestAccessiblePrompter(t *testing.T) {
128128

129129
go func() {
130130
// Wait for prompt to appear
131-
_, err := console.ExpectString("Input a number between 0 and 3:")
131+
_, err := console.ExpectString("Enter a number between 0 and 3:")
132132
require.NoError(t, err)
133133

134134
// Select options 1 and 2
@@ -207,7 +207,7 @@ func TestAccessiblePrompter(t *testing.T) {
207207

208208
go func() {
209209
// Wait for prompt to appear without the invalid default values
210-
_, err := console.ExpectString("Select a number \r\n")
210+
_, err := console.ExpectString("Select a number")
211211
require.NoError(t, err)
212212

213213
// Not selecting anything will fail because there are no defaults.
@@ -259,7 +259,7 @@ func TestAccessiblePrompter(t *testing.T) {
259259

260260
go func() {
261261
// Wait for prompt to appear
262-
_, err := console.ExpectString("Select an option \r\n")
262+
_, err := console.ExpectString("Select an option")
263263
require.NoError(t, err)
264264

265265
// Select the search option, which will always be the first option
@@ -279,7 +279,7 @@ func TestAccessiblePrompter(t *testing.T) {
279279
require.NoError(t, err)
280280

281281
// Wait for the multiselect prompt to re-appear after search
282-
_, err = console.ExpectString("Select an option \r\n")
282+
_, err = console.ExpectString("Select an option")
283283
require.NoError(t, err)
284284

285285
// Select the first search result
@@ -325,7 +325,7 @@ func TestAccessiblePrompter(t *testing.T) {
325325

326326
go func() {
327327
// Wait for prompt to appear
328-
_, err := console.ExpectString("Select an option (default: Initial Result Label 1) \r\n")
328+
_, err := console.ExpectString("Select an option (default: Initial Result Label 1)")
329329
require.NoError(t, err)
330330

331331
// This confirms default selections
@@ -379,7 +379,7 @@ func TestAccessiblePrompter(t *testing.T) {
379379

380380
go func() {
381381
// Wait for prompt to appear
382-
_, err := console.ExpectString("Select an option \r\n")
382+
_, err := console.ExpectString("Select an option")
383383
require.NoError(t, err)
384384

385385
// Select one of our initial search results
@@ -524,7 +524,7 @@ func TestAccessiblePrompter(t *testing.T) {
524524
// expected string matches any part of the stream, we have to use an
525525
// anchored regexp (i.e., with ^ and $) to make sure the password/token
526526
// is not printed at all.
527-
_, err = console.Expect(expect.RegexpPattern("^ \r\n\r\n$"))
527+
_, err = console.Expect(expect.RegexpPattern(`^(\x1b\[[\d;]*m)* \r\n\r\n$`))
528528
require.NoError(t, err)
529529
})
530530

@@ -615,7 +615,7 @@ func TestAccessiblePrompter(t *testing.T) {
615615
// expected string matches any part of the stream, we have to use an
616616
// anchored regexp (i.e., with ^ and $) to make sure the password/token
617617
// is not printed at all.
618-
_, err = console.Expect(expect.RegexpPattern("^ \r\n\r\n$"))
618+
_, err = console.Expect(expect.RegexpPattern(`^(\x1b\[[\d;]*m)* \r\n\r\n$`))
619619
require.NoError(t, err)
620620
})
621621

@@ -660,7 +660,7 @@ func TestAccessiblePrompter(t *testing.T) {
660660
// expected string matches any part of the stream, we have to use an
661661
// anchored regexp (i.e., with ^ and $) to make sure the password/token
662662
// is not printed at all.
663-
_, err = console.Expect(expect.RegexpPattern("^ \r\n\r\n$"))
663+
_, err = console.Expect(expect.RegexpPattern(`^(\x1b\[[\d;]*m)* \r\n\r\n$`))
664664
require.NoError(t, err)
665665
})
666666

0 commit comments

Comments
 (0)