11import { describe , expect , it , vi } from "vite-plus/test" ;
22
3- import { resolveCloudPublicConfig } from "./publicConfig" ;
3+ import { hasMobileTracingPublicConfig , resolveCloudPublicConfig } from "./publicConfig" ;
44
55vi . mock ( "expo-constants" , ( ) => ( {
66 default : {
@@ -13,9 +13,18 @@ vi.mock("expo-constants", () => ({
1313describe ( "resolveCloudPublicConfig" , ( ) => {
1414 it ( "returns no cloud configuration for an unconfigured build" , ( ) => {
1515 expect ( resolveCloudPublicConfig ( { } ) ) . toEqual ( {
16- clerkPublishableKey : null ,
17- clerkJwtTemplate : null ,
18- relayUrl : null ,
16+ clerk : {
17+ publishableKey : null ,
18+ jwtTemplate : null ,
19+ } ,
20+ relay : {
21+ url : null ,
22+ } ,
23+ observability : {
24+ tracesUrl : null ,
25+ tracesDataset : null ,
26+ tracesToken : null ,
27+ } ,
1928 } ) ;
2029 } ) ;
2130
@@ -24,11 +33,25 @@ describe("resolveCloudPublicConfig", () => {
2433 resolveCloudPublicConfig ( {
2534 clerk : { publishableKey : " pk_test_example " , jwtTemplate : " t3-relay " } ,
2635 relay : { url : " https://relay.example.test/// " } ,
36+ observability : {
37+ tracesUrl : " https://api.axiom.co/v1/traces " ,
38+ tracesDataset : " mobile-traces " ,
39+ tracesToken : " public-ingest-token " ,
40+ } ,
2741 } ) ,
2842 ) . toEqual ( {
29- clerkPublishableKey : "pk_test_example" ,
30- clerkJwtTemplate : "t3-relay" ,
31- relayUrl : "https://relay.example.test" ,
43+ clerk : {
44+ publishableKey : "pk_test_example" ,
45+ jwtTemplate : "t3-relay" ,
46+ } ,
47+ relay : {
48+ url : "https://relay.example.test" ,
49+ } ,
50+ observability : {
51+ tracesUrl : "https://api.axiom.co/v1/traces" ,
52+ tracesDataset : "mobile-traces" ,
53+ tracesToken : "public-ingest-token" ,
54+ } ,
3255 } ) ;
3356 } ) ;
3457
@@ -39,9 +62,59 @@ describe("resolveCloudPublicConfig", () => {
3962 relay : { url : "http://relay.example.test" } ,
4063 } ) ,
4164 ) . toEqual ( {
42- clerkPublishableKey : "pk_test_example" ,
43- clerkJwtTemplate : "t3-relay" ,
44- relayUrl : null ,
65+ clerk : {
66+ publishableKey : "pk_test_example" ,
67+ jwtTemplate : "t3-relay" ,
68+ } ,
69+ relay : {
70+ url : null ,
71+ } ,
72+ observability : {
73+ tracesUrl : null ,
74+ tracesDataset : null ,
75+ tracesToken : null ,
76+ } ,
4577 } ) ;
4678 } ) ;
79+
80+ it ( "rejects an insecure traces URL" , ( ) => {
81+ expect (
82+ resolveCloudPublicConfig ( {
83+ observability : {
84+ tracesUrl : "http://api.axiom.co/v1/traces" ,
85+ tracesDataset : "mobile-traces" ,
86+ tracesToken : "public-ingest-token" ,
87+ } ,
88+ } ) . observability ,
89+ ) . toEqual ( {
90+ tracesUrl : null ,
91+ tracesDataset : "mobile-traces" ,
92+ tracesToken : "public-ingest-token" ,
93+ } ) ;
94+ } ) ;
95+
96+ it ( "keeps tracing disabled unless every public tracing value is configured" , ( ) => {
97+ expect ( hasMobileTracingPublicConfig ( resolveCloudPublicConfig ( { } ) ) ) . toBe ( false ) ;
98+ expect (
99+ hasMobileTracingPublicConfig (
100+ resolveCloudPublicConfig ( {
101+ observability : {
102+ tracesUrl : "https://api.axiom.co/v1/traces" ,
103+ tracesDataset : "mobile-traces" ,
104+ } ,
105+ } ) ,
106+ ) ,
107+ ) . toBe ( false ) ;
108+ expect (
109+ hasMobileTracingPublicConfig (
110+ resolveCloudPublicConfig ( {
111+ observability : {
112+ tracesUrl : "https://api.axiom.co/v1/traces" ,
113+ tracesDataset : "mobile-traces" ,
114+ tracesToken : "public-ingest-token" ,
115+ } ,
116+ } ) ,
117+ ) ,
118+ ) . toBe ( true ) ;
119+ } ) ;
47120} ) ;
0 commit comments