Add extra colored assertion for removing duplicate rows to debug an interesting test failure for highlighting search matches

This commit is contained in:
David Dworken 2023-12-19 21:05:27 -08:00
parent 3c33513fa3
commit 4c89010874
2 changed files with 50 additions and 0 deletions

View File

@ -2540,13 +2540,31 @@ echo foo`)
// And change the config to filter out duplicate rows
tester.RunInteractiveShell(t, `hishtory config-set filter-duplicate-commands true`)
// Check export
out = tester.RunInteractiveShell(t, `hishtory export -pipefail`)
testutils.CompareGoldens(t, out, "testRemoveDuplicateRows-enabled-export")
// Check query
out = tester.RunInteractiveShell(t, `hishtory query -pipefail`)
testutils.CompareGoldens(t, out, "testRemoveDuplicateRows-enabled-query")
// Check tquery
out = captureTerminalOutput(t, tester, []string{"hishtory SPACE tquery SPACE -pipefail ENTER"})
out = stripRequiredPrefix(t, out, "hishtory tquery -pipefail")
testutils.CompareGoldens(t, out, "testRemoveDuplicateRows-enabled-tquery")
// Check scrolling with query (with colors so we can confirm it, though this part is MacOS only)
if runtime.GOOS == "darwin" {
out = captureTerminalOutputComplex(t, TmuxCaptureConfig{tester: tester, complexCommands: []TmuxCommand{
{Keys: "hishtory SPACE tquery SPACE -pipefail ENTER", ExtraDelay: 1.0},
{Keys: "Down Down"},
}, includeEscapeSequences: true})
out = stripTuiCommandPrefix(t, out)
testutils.CompareGoldens(t, out, "testRemoveDuplicateRows-enabled-tquery-scrolled")
}
// Check actually selecting it with query
out = captureTerminalOutputWithComplexCommands(t, tester, []TmuxCommand{
{Keys: "hishtory SPACE tquery SPACE -pipefail ENTER", ExtraDelay: 1.0},
{Keys: "Down Down"},
@ -2554,6 +2572,7 @@ echo foo`)
})
out = stripTuiCommandPrefix(t, out)
require.Contains(t, out, "\n")
fmt.Printf("TODO: Debug: out=%#v", out)
out = strings.Split(out, "\n")[1]
testutils.CompareGoldens(t, out, "testRemoveDuplicateRows-enabled-tquery-select")
}

View File

@ -0,0 +1,31 @@
-pipefail
Search Query: > -pipefail 
┌───────────────────────────────────────────────────────────────────────────┐
 Exit Code Command │
│───────────────────────────────────────────────────────────────────────────│
 0 hishtory config-set filter-duplicate-commands true │
 0 hishtory config-set displayed-columns 'Exit Code' Command │
 0 echo foo │
 0 echo baz │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
└───────────────────────────────────────────────────────────────────────────┘
hiSHtory: Search your shell history  • ctrl+h help