11package connector
22
33import (
4+ "context"
45 "errors"
6+ "slices"
57 "testing"
68 "time"
79
@@ -10,6 +12,53 @@ import (
1012 "maunium.net/go/mautrix/event"
1113)
1214
15+ func TestCapabilitiesAdvertiseSupportedReactions (t * testing.T ) {
16+ infoVersion , capabilityVersion := (& LineConnector {}).GetBridgeInfoVersion ()
17+ if infoVersion != 1 || capabilityVersion != 2 {
18+ t .Fatalf ("bridge info/capability versions = %d/%d, want 1/2" , infoVersion , capabilityVersion )
19+ }
20+
21+ caps := (& LineClient {}).GetCapabilities (context .Background (), nil )
22+ if caps .Reaction != event .CapLevelPartialSupport {
23+ t .Fatalf ("Reaction = %d, want partial support" , caps .Reaction )
24+ }
25+ if caps .ReactionCount != 1 {
26+ t .Fatalf ("ReactionCount = %d, want 1" , caps .ReactionCount )
27+ }
28+ if len (caps .AllowedReactions ) != len (lineEmojiReactionURLs ) {
29+ t .Fatalf ("AllowedReactions has %d entries, want %d" , len (caps .AllowedReactions ), len (lineEmojiReactionURLs ))
30+ }
31+ if ! slices .IsSorted (caps .AllowedReactions ) {
32+ t .Fatal ("AllowedReactions must be sorted so room capability IDs are stable" )
33+ }
34+
35+ seen := make (map [string ]struct {}, len (caps .AllowedReactions ))
36+ for _ , reaction := range caps .AllowedReactions {
37+ if _ , duplicate := seen [reaction ]; duplicate {
38+ t .Fatalf ("AllowedReactions contains duplicate %q" , reaction )
39+ }
40+ seen [reaction ] = struct {}{}
41+ if _ , ok := linePaidReactionForMatrixEmoji (reaction ); ! ok {
42+ t .Fatalf ("advertised reaction %q is not accepted by the LINE reaction mapper" , reaction )
43+ }
44+ }
45+
46+ for _ , supported := range []string {"\U0001F44D \uFE0F " , "9\uFE0F \u20E3 " } {
47+ if ! slices .Contains (caps .AllowedReactions , supported ) {
48+ t .Fatalf ("supported reaction %q is not advertised" , supported )
49+ }
50+ }
51+ if slices .Contains (caps .AllowedReactions , "\U0001F625 " ) {
52+ t .Fatal ("unsupported reaction 😥 must not be advertised" )
53+ }
54+
55+ caps .AllowedReactions [0 ] = "mutated"
56+ freshCaps := (& LineClient {}).GetCapabilities (context .Background (), nil )
57+ if freshCaps .AllowedReactions [0 ] == "mutated" {
58+ t .Fatal ("GetCapabilities returned a shared mutable reaction list" )
59+ }
60+ }
61+
1362func TestNormalizeMatrixReactionKey (t * testing.T ) {
1463 tests := map [string ]string {
1564 "9\uFE0F \u20E3 " : "9" ,
0 commit comments