@@ -28,7 +28,7 @@ describe("getVisualBuilderRedirectionUrl", () => {
2828
2929 const result = getVisualBuilderRedirectionUrl ( ) ;
3030 expect ( result . toString ( ) ) . toBe (
31- "https://app.example.com/#!/stack/12345/visual-builder?branch=main&environment=production& target-url=https%3A%2F%2Fexample.com%2F &locale=en-US"
31+ "https://app.example.com/#!/stack/12345/visual-builder?target-url=https%3A%2F%2Fexample.com&branch=main&environment=production &locale=en-US"
3232 ) ;
3333 } ) ;
3434
@@ -47,7 +47,7 @@ describe("getVisualBuilderRedirectionUrl", () => {
4747
4848 const result = getVisualBuilderRedirectionUrl ( ) ;
4949 expect ( result . toString ( ) ) . toBe (
50- "https://app.example.com/#!/stack/12345/visual-builder?target-url=https%3A%2F%2Fexample.com%2F &locale=en-US"
50+ "https://app.example.com/#!/stack/12345/visual-builder?target-url=https%3A%2F%2Fexample.com&locale=en-US"
5151 ) ;
5252 } ) ;
5353
@@ -69,7 +69,7 @@ describe("getVisualBuilderRedirectionUrl", () => {
6969
7070 const result = getVisualBuilderRedirectionUrl ( ) ;
7171 expect ( result . toString ( ) ) . toBe (
72- "https://app.example.com/#!/stack/12345/visual-builder?branch=main&environment=production& target-url=https%3A%2F%2Fexample.com%2F &locale=fr-FR"
72+ "https://app.example.com/#!/stack/12345/visual-builder?target-url=https%3A%2F%2Fexample.com&branch=main&environment=production &locale=fr-FR"
7373 ) ;
7474 } ) ;
7575
@@ -89,7 +89,7 @@ describe("getVisualBuilderRedirectionUrl", () => {
8989
9090 const result = getVisualBuilderRedirectionUrl ( ) ;
9191 expect ( result . toString ( ) ) . toBe (
92- "https://app.example.com/#!/stack/12345/visual-builder?branch=main&environment=production& target-url=https%3A%2F%2Fexample.com%2F "
92+ "https://app.example.com/#!/stack/12345/visual-builder?target-url=https%3A%2F%2Fexample.com&branch=main&environment=production "
9393 ) ;
9494 } ) ;
9595
@@ -117,4 +117,94 @@ describe("getVisualBuilderRedirectionUrl", () => {
117117 ) ;
118118 expect ( result . toString ( ) ) . not . toContain ( "?query=test" ) ;
119119 } ) ;
120+ it ( "should return the correct URL with slash type hash routing" , ( ) => {
121+ Object . defineProperty ( window , "location" , {
122+ writable : true ,
123+ value : new URL ( "https://example.com/#/page" ) ,
124+ } ) ;
125+ Config . get . mockReturnValue ( {
126+ stackDetails : {
127+ branch : "main" ,
128+ apiKey : "12345" ,
129+ environment : "production" ,
130+ locale : "en-US" ,
131+ } ,
132+ clientUrlParams : {
133+ url : "https://app.example.com" ,
134+ } ,
135+ } ) ;
136+
137+ const result = getVisualBuilderRedirectionUrl ( ) ;
138+ expect ( result . toString ( ) ) . toBe (
139+ "https://app.example.com/#!/stack/12345/visual-builder?target-url=https%3A%2F%2Fexample.com%2Fpage&branch=main&environment=production&locale=en-US"
140+ ) ;
141+ } ) ;
142+
143+ it ( "should return the correct URL with no slash type hash routing" , ( ) => {
144+ Object . defineProperty ( window , "location" , {
145+ writable : true ,
146+ value : new URL ( "https://example.com/#page" ) ,
147+ } ) ;
148+ Config . get . mockReturnValue ( {
149+ stackDetails : {
150+ branch : "main" ,
151+ apiKey : "12345" ,
152+ environment : "production" ,
153+ locale : "en-US" ,
154+ } ,
155+ clientUrlParams : {
156+ url : "https://app.example.com" ,
157+ } ,
158+ } ) ;
159+
160+ const result = getVisualBuilderRedirectionUrl ( ) ;
161+ expect ( result . toString ( ) ) . toBe (
162+ "https://app.example.com/#!/stack/12345/visual-builder?target-url=https%3A%2F%2Fexample.com%2Fpage&branch=main&environment=production&locale=en-US"
163+ ) ;
164+ } ) ;
165+ it ( "should return the correct URL with hash bang type hash routing" , ( ) => {
166+ Object . defineProperty ( window , "location" , {
167+ writable : true ,
168+ value : new URL ( "https://example.com/#!/page" ) ,
169+ } ) ;
170+ Config . get . mockReturnValue ( {
171+ stackDetails : {
172+ branch : "main" ,
173+ apiKey : "12345" ,
174+ environment : "production" ,
175+ locale : "en-US" ,
176+ } ,
177+ clientUrlParams : {
178+ url : "https://app.example.com" ,
179+ } ,
180+ } ) ;
181+
182+ const result = getVisualBuilderRedirectionUrl ( ) ;
183+ expect ( result . toString ( ) ) . toBe (
184+ "https://app.example.com/#!/stack/12345/visual-builder?target-url=https%3A%2F%2Fexample.com%2Fpage&branch=main&environment=production&locale=en-US"
185+ ) ;
186+ } ) ;
187+
188+ it ( "should return the correct URL with hash bang type hash routing" , ( ) => {
189+ Object . defineProperty ( window , "location" , {
190+ writable : true ,
191+ value : new URL ( "https://example.com/#!/page?query=test" ) ,
192+ } ) ;
193+ Config . get . mockReturnValue ( {
194+ stackDetails : {
195+ branch : "main" ,
196+ apiKey : "12345" ,
197+ environment : "production" ,
198+ locale : "en-US" ,
199+ } ,
200+ clientUrlParams : {
201+ url : "https://app.example.com" ,
202+ } ,
203+ } ) ;
204+
205+ const result = getVisualBuilderRedirectionUrl ( ) ;
206+ expect ( result . toString ( ) ) . toBe (
207+ "https://app.example.com/#!/stack/12345/visual-builder?target-url=https%3A%2F%2Fexample.com%2Fpage&branch=main&environment=production&locale=en-US"
208+ ) ;
209+ } ) ;
120210} ) ;
0 commit comments