alertmanager/ui/app/tests/GroupBar.elm

62 lines
1.8 KiB
Elm
Raw Normal View History

Merge GroupBy alerts (#775) * Create set of labelKeys * Wip (compiling) * Add naive levenshtein distance Need to check out the fzf fuzzy algo, this is just a place holder for now. https://github.com/junegunn/fzf/blob/master/src/algo/algo.go * Hack a groupBy into the code This needs massive cleanup and is just a late-night spike. Everything in this commit needs to be re-organized, most likely. * Update some html/css * Set input validation for label filtering * Add Jaro-Winkler string comparison * remove levenshtein stuff * Fix match tests * Read actual Jaro definition if ml == 0, then the distance == 0 * Use correct searchLength implementation * Limit searching string to matchRange Only search matchRange when looking for matches, instead of going through every value and then deciding if it should be checked based on its position. Data generated from https://ellie-app.com/38cXFnRLjcga1/1 matchCharmatchChar2delta mean ops/sec 346,928.55 (stddev: 12,306.94, 3.55%) 364,551.61 (stddev: 10,561.94, 2.9%) +5.08% mean runtime 2.886ns (stddev: 103.748µs, 3.59%) 2.745ns (stddev: 80.856µs, 2.95%) -4.87% total runtime 5.022s 5.052s sampling 48 runs of 30,000 calls 46 runs of 40,000 calls * Fix off-by-one error in List slicing * Simplify transition calculation * Keyboard controls for the autocomplete * Fix clicking on the results * Rename AutoComplete to GroupBar * Broke apart the view function * Fix the layout * Change button style * Synchronize grouping with URL * Fix tests * Added toggle silenced alerts * Remove comment * Roll back the labelButton * Always fetch the alerts * Disable show silenced * Extract alert groups * Rename tests * Use more generic number instead of int * Restore showSilenced * Update ui/bindata.go * Update template/internal/deftmpl/bindata.go * Update bindata.go * Reformat with updated elm-format
2017-05-15 22:10:30 +00:00
module GroupBar exposing (all)
import Test exposing (..)
import Expect
import Views.GroupBar.Match exposing (jaroWinkler, commonPrefix)
all : Test
all =
describe "Filter"
[ testJaroWinkler
, testCommonPrefix
]
testJaroWinkler : Test
testJaroWinkler =
describe "jaroWinkler"
[ test "should find the right values" <|
\() ->
Expect.greaterThan (jaroWinkler "zi" "zone")
(jaroWinkler "zo" "zone")
, test "should find the right values" <|
\() ->
Expect.greaterThan (jaroWinkler "de" "alertname")
(jaroWinkler "de" "dev")
, test "should find the right values" <|
\() ->
Expect.equal 0.0
(jaroWinkler "l" "zone")
, test "should find the right values" <|
\() ->
Expect.equal 1.0
(jaroWinkler "zone" "zone")
, test "should find the right values" <|
\() ->
Expect.greaterThan 0.688
(jaroWinkler "atleio3tefdoisahdf" "attributefdoiashfoihfeowfh9w8f9afaw9fahw")
]
testCommonPrefix : Test
testCommonPrefix =
describe "commonPrefix"
[ test "should find the commonPrefix" <|
\() ->
Expect.equal "zo"
(commonPrefix "zo" "zone")
, test "should find the commonPrefix" <|
\() ->
Expect.equal "zo"
(commonPrefix "zol" "zone")
, test "should find the commonPrefix" <|
\() ->
Expect.equal ""
(commonPrefix "oon" "zone")
, test "should find the commonPrefix" <|
\() ->
Expect.equal "zone"
(commonPrefix "zone123" "zone123")
]