f99010fae1
CI / lint (push) Failing after 1s
CI / frontend (push) Failing after 1s
CI / scripts (push) Failing after 1s
CI / Go Test (ubuntu-latest) (push) Failing after 0s
CI / frontend-node-25 (push) Failing after 1s
CI / docs (push) Failing after 0s
CI / coverage (push) Failing after 0s
CI / e2e (push) Failing after 0s
Docker / build-and-push (push) Failing after 1s
CI / integration (push) Failing after 4m43s
CI / Go Test (windows-latest) (push) Has been cancelled
CI / Desktop Unit Tests (Windows) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Linux (arm64)) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Linux) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Windows) (push) Has been cancelled
Desktop Artifacts (macOS) / Desktop Build (macOS (aarch64)) (push) Has been cancelled
Desktop Artifacts (macOS) / Desktop Build (macOS (x86_64)) (push) Has been cancelled
48 lines
1.7 KiB
Go
48 lines
1.7 KiB
Go
package server
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// TestActivityAutomationFilter locks in the mapping from the activity
|
|
// endpoint's automation query value to the AnalyticsFilter class exclusions:
|
|
// empty and "all" keep both classes, "interactive" drops automated sessions,
|
|
// "automated" drops interactive ones, and any other value is a 400-worthy
|
|
// error. The two exclude flags are never both true (that would match nothing),
|
|
// and the error case returns the safe no-exclusion default so a typo never
|
|
// silently filters the report.
|
|
func TestActivityAutomationFilter(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
automation string
|
|
wantExcludeAuto bool
|
|
wantExcludeInter bool
|
|
wantErr bool
|
|
}{
|
|
{"empty treated as all", "", false, false, false},
|
|
{"all keeps both", "all", false, false, false},
|
|
{"interactive excludes automated", "interactive", true, false, false},
|
|
{"automated excludes interactive", "automated", false, true, false},
|
|
{"unknown value errors", "bogus", false, false, true},
|
|
}
|
|
for _, tc := range tests {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
excludeAuto, excludeInter, err := activityAutomationFilter(tc.automation)
|
|
if tc.wantErr {
|
|
require.Error(t, err)
|
|
assert.False(t, excludeAuto, "error must not exclude automated")
|
|
assert.False(t, excludeInter, "error must not exclude interactive")
|
|
return
|
|
}
|
|
require.NoError(t, err)
|
|
assert.Equal(t, tc.wantExcludeAuto, excludeAuto)
|
|
assert.Equal(t, tc.wantExcludeInter, excludeInter)
|
|
assert.False(t, excludeAuto && excludeInter,
|
|
"the two exclusions are mutually exclusive")
|
|
})
|
|
}
|
|
}
|