@@ -77,6 +77,48 @@ describe('OCI Notifications operation contracts', () => {
7777 prepareDiscoveredEndpoint . mockReset ( ) . mockResolvedValue ( data )
7878 } )
7979
80+ it . each ( [ 200 , 201 ] ) (
81+ 'accepts CreateTopic status %i with an absent SMS identifier' ,
82+ async ( status ) => {
83+ request . mockResolvedValue ( response ( { ...topic , shortTopicId : null } , status ) )
84+ const output = await run ( 'create_topic' , { compartmentId : 'compartment' , name : 'Operations' } )
85+ expect ( output ) . toMatchObject ( { status, requestId : 'oracle-request' , topic } )
86+ expect ( output . topic ?. shortTopicId ) . toBeUndefined ( )
87+ expect ( request ) . toHaveBeenCalledTimes ( 1 )
88+ }
89+ )
90+
91+ it . each ( [ undefined , null , 'sms-code' ] ) (
92+ 'projects optional topic identifiers: %s' ,
93+ async ( shortTopicId ) => {
94+ request . mockResolvedValue ( response ( [ { ...topic , shortTopicId } ] ) )
95+ const output = await run ( 'list_topics' , { compartmentId : 'compartment' } )
96+ expect ( output . topics ?. [ 0 ] . shortTopicId ) . toBe ( shortTopicId ?? undefined )
97+ }
98+ )
99+
100+ it ( 'retains authenticated discovery with null SMS identifiers' , async ( ) => {
101+ const discovery = response ( { ...topic , shortTopicId : null } )
102+ request . mockResolvedValueOnce ( discovery ) . mockResolvedValueOnce ( response ( [ subscription ] ) )
103+ expect (
104+ ( await run ( 'list_subscriptions' , { compartmentId : 'compartment' } ) ) . subscriptions
105+ ) . toEqual ( [ subscription ] )
106+ expect ( prepareDiscoveredEndpoint ) . toHaveBeenCalledWith ( expect . anything ( ) , discovery )
107+ } )
108+
109+ it ( 'does not broaden other statuses or malformed topic identifiers' , async ( ) => {
110+ request . mockResolvedValue ( response ( topic , 201 ) )
111+ await expect ( run ( 'get_topic' ) ) . rejects . toThrow ( 'unexpected response status' )
112+ request . mockResolvedValue ( response ( topic , 202 ) )
113+ await expect (
114+ run ( 'create_topic' , { compartmentId : 'compartment' , name : 'Operations' } )
115+ ) . rejects . toThrow ( 'unexpected response status' )
116+ request . mockResolvedValue ( response ( [ { ...topic , shortTopicId : 42 } ] ) )
117+ await expect ( run ( 'list_topics' , { compartmentId : 'compartment' } ) ) . rejects . toThrow (
118+ 'invalid response'
119+ )
120+ } )
121+
80122 it ( 'lists one bare topic array and preserves opaque pagination without discovery' , async ( ) => {
81123 request . mockResolvedValue ( response ( [ topic ] , 200 , { 'opc-next-page' : 'next+/=' } ) )
82124 expect (
0 commit comments