@@ -216,7 +216,51 @@ describe("EventEnvelope schema validation", () => {
216216 } ) ;
217217 } ) ;
218218
219- describe ( "edge cases" , ( ) => {
219+ describe ( "source validation" , ( ) => {
220+ it ( "should accept source with letter-rendering plane" , ( ) => {
221+ const envelope = {
222+ ...baseValidEnvelope ,
223+ source : "/data-plane/letter-rendering/ordering" ,
224+ } ;
225+
226+ const result = $Envelope . safeParse ( envelope ) ;
227+ expect ( result . error ) . toBeUndefined ( ) ;
228+ expect ( result . success ) . toBe ( true ) ;
229+ } ) ;
230+
231+ it ( "should accept source with digital-letters domain" , ( ) => {
232+ const envelope = {
233+ ...baseValidEnvelope ,
234+ source : "/data-plane/digital-letters/ordering" ,
235+ } ;
236+
237+ const result = $Envelope . safeParse ( envelope ) ;
238+ expect ( result . error ) . toBeUndefined ( ) ;
239+ expect ( result . success ) . toBe ( true ) ;
240+ } ) ;
241+
242+ it ( "should accept source with digital-letters domain and additional path" , ( ) => {
243+ const envelope = {
244+ ...baseValidEnvelope ,
245+ source : "/data-plane/digital-letters/ordering/sub-path" ,
246+ } ;
247+
248+ const result = $Envelope . safeParse ( envelope ) ;
249+ expect ( result . error ) . toBeUndefined ( ) ;
250+ expect ( result . success ) . toBe ( true ) ;
251+ } ) ;
252+
253+ it ( "should accept source with letter-rendering plane and additional path" , ( ) => {
254+ const envelope = {
255+ ...baseValidEnvelope ,
256+ source : "/data-plane/letter-rendering/ordering/sub-path/more" ,
257+ } ;
258+
259+ const result = $Envelope . safeParse ( envelope ) ;
260+ expect ( result . error ) . toBeUndefined ( ) ;
261+ expect ( result . success ) . toBe ( true ) ;
262+ } ) ;
263+
220264 it ( "should reject invalid source pattern" , ( ) => {
221265 const envelope = {
222266 ...baseValidEnvelope ,
@@ -226,6 +270,16 @@ describe("EventEnvelope schema validation", () => {
226270 const result = $Envelope . safeParse ( envelope ) ;
227271 expect ( result . success ) . toBe ( false ) ;
228272 } ) ;
273+
274+ it ( "should reject source without data-plane prefix" , ( ) => {
275+ const envelope = {
276+ ...baseValidEnvelope ,
277+ source : "/digital-letters/ordering" ,
278+ } ;
279+
280+ const result = $Envelope . safeParse ( envelope ) ;
281+ expect ( result . success ) . toBe ( false ) ;
282+ } ) ;
229283 } ) ;
230284
231285 describe ( "subject prefix validation" , ( ) => {
0 commit comments