@@ -76,4 +76,69 @@ describe('Page component', () => {
7676
7777 await screen . findByText ( 'https://example.invalid/not-found' ) ;
7878 } ) ;
79+
80+ it ( 'does not implicitly allow the current domain when the allow list is configured' , async ( ) => {
81+ mockSdk . parameters . installation = {
82+ selectedContentTypeIds : [ 'article' ] ,
83+ baseUrl : 'https://contentful.com' ,
84+ allowedUrlPatterns : 'ally.com' ,
85+ } ;
86+ mockSdk . cma = {
87+ contentType : {
88+ getMany : jest . fn ( ) . mockResolvedValue ( {
89+ items : [
90+ {
91+ sys : { id : 'article' } ,
92+ name : 'Article' ,
93+ displayField : 'title' ,
94+ fields : [
95+ { id : 'title' , name : 'Title' , type : 'Symbol' } ,
96+ { id : 'body' , name : 'Body' , type : 'Text' } ,
97+ ] ,
98+ } ,
99+ ] ,
100+ } ) ,
101+ } ,
102+ entry : {
103+ getMany : jest . fn ( ) . mockResolvedValue ( {
104+ items : [
105+ {
106+ sys : {
107+ id : 'entry-1' ,
108+ contentType : { sys : { id : 'article' } } ,
109+ } ,
110+ fields : {
111+ title : { 'en-US' : 'Release Notes' } ,
112+ body : { 'en-US' : 'Visit /help' } ,
113+ } ,
114+ } ,
115+ ] ,
116+ } ) ,
117+ } ,
118+ appAction : {
119+ getMany : jest . fn ( ) . mockResolvedValue ( {
120+ items : [
121+ {
122+ sys : {
123+ id : 'check-link-action' ,
124+ appDefinition : { sys : { id : mockSdk . ids . app } } ,
125+ } ,
126+ function : { sys : { id : 'checkLink' } } ,
127+ } ,
128+ ] ,
129+ } ) ,
130+ } ,
131+ appActionCall : {
132+ createWithResponse : jest . fn ( ) ,
133+ } ,
134+ } ;
135+
136+ render ( < Page /> ) ;
137+ fireEvent . click ( screen . getByRole ( 'button' , { name : 'Run scan' } ) ) ;
138+
139+ await screen . findByText ( '/help' ) ;
140+ await screen . findByText ( / n o t o n a l l o w l i s t / i) ;
141+ expect ( screen . getByText ( / r e s o l v e s t o h t t p s : \/ \/ c o n t e n t f u l .c o m \/ h e l p / i) ) . toBeInTheDocument ( ) ;
142+ expect ( mockSdk . cma . appActionCall . createWithResponse ) . not . toHaveBeenCalled ( ) ;
143+ } ) ;
79144} ) ;
0 commit comments