44 "context"
55 "os"
66 "path/filepath"
7+ "strings"
78 "testing"
89 "time"
910
@@ -39,24 +40,34 @@ func TestCodexParse(t *testing.T) {
3940 require .NoError (t , err )
4041 require .Len (t , got , 3 )
4142
42- assert .Equal (t , "Codex" , got [0 ].Entity )
43+ assert .Equal (t , filepath . Base ( transcriptPath ) , got [0 ].Entity )
4344 assert .Equal (t , heartbeat .AppType , got [0 ].EntityType )
4445 assert .Equal (t , heartbeat .AICodingCategory .String (), got [0 ].Category )
4546 assert .Nil (t , got [0 ].AILineChanges )
4647 require .NotNil (t , got [0 ].IsWrite )
4748 assert .False (t , * got [0 ].IsWrite )
4849 assert .Equal (t , float64 (time .Date (2026 , 3 , 28 , 11 , 33 , 14 , 289 , time .UTC ).Unix ()), got [0 ].Time )
49- assert .Contains (t , got [0 ].UserAgent , heartbeat .UserAgent (ctx , "plugin/0.0.1" ))
5050 assert .Contains (t , got [0 ].UserAgent , "Codex/0.116.0-alpha.1" )
51-
52- assert .Equal (t , "Codex" , got [1 ].Entity )
51+ assert .True (
52+ t ,
53+ strings .Index (got [0 ].UserAgent , "Codex/0.116.0-alpha.1" ) <
54+ strings .Index (got [0 ].UserAgent , "plugin/0.0.1" ),
55+ )
56+ assert .Contains (t , got [0 ].UserAgent , "plugin/0.0.1" )
57+
58+ assert .Equal (t , filepath .Base (transcriptPath ), got [1 ].Entity )
5359 assert .Equal (t , heartbeat .AppType , got [1 ].EntityType )
5460 assert .Nil (t , got [1 ].AILineChanges )
5561 require .NotNil (t , got [1 ].IsWrite )
5662 assert .False (t , * got [1 ].IsWrite )
5763 assert .Equal (t , float64 (time .Date (2026 , 3 , 28 , 11 , 33 , 18 , 535 , time .UTC ).Unix ()), got [1 ].Time )
58- assert .Contains (t , got [1 ].UserAgent , heartbeat .UserAgent (ctx , "plugin/0.0.1" ))
5964 assert .Contains (t , got [1 ].UserAgent , "Codex/0.116.0-alpha.1" )
65+ assert .True (
66+ t ,
67+ strings .Index (got [1 ].UserAgent , "Codex/0.116.0-alpha.1" ) <
68+ strings .Index (got [1 ].UserAgent , "plugin/0.0.1" ),
69+ )
70+ assert .Contains (t , got [1 ].UserAgent , "plugin/0.0.1" )
6071
6172 assert .Equal (t , "/home/user/projects/wakatime-cli/pkg/ai/claude.go" , got [2 ].Entity )
6273 assert .Equal (t , heartbeat .FileType , got [2 ].EntityType )
@@ -66,8 +77,13 @@ func TestCodexParse(t *testing.T) {
6677 require .NotNil (t , got [2 ].IsWrite )
6778 assert .True (t , * got [2 ].IsWrite )
6879 assert .Equal (t , float64 (time .Date (2026 , 3 , 28 , 11 , 33 , 34 , 952 , time .UTC ).Unix ()), got [2 ].Time )
69- assert .Contains (t , got [2 ].UserAgent , heartbeat .UserAgent (ctx , "editor/1.2.3" ))
7080 assert .Contains (t , got [2 ].UserAgent , "Codex/0.116.0-alpha.1" )
81+ assert .True (
82+ t ,
83+ strings .Index (got [2 ].UserAgent , "Codex/0.116.0-alpha.1" ) <
84+ strings .Index (got [2 ].UserAgent , "editor/1.2.3" ),
85+ )
86+ assert .Contains (t , got [2 ].UserAgent , "editor/1.2.3" )
7187}
7288
7389func TestCodexParse_ParsesTranscriptFromPreviousDayFolder (t * testing.T ) {
0 commit comments