@@ -5,15 +5,15 @@ using HTTP
5
5
6
6
7
7
8
- @testset " external_stylesheets" begin
8
+ @testset " external_stylesheets" begin
9
9
app = dash ()
10
- resources = ApplicationResources (app, main_registry ())
10
+ resources = ApplicationResources (app, main_registry ())
11
11
index_page = Dash. index_page (app, resources)
12
-
12
+
13
13
@test isnothing (findfirst (" link rel=\" stylesheet\" " , index_page))
14
-
14
+
15
15
app = dash (external_stylesheets = [" https://test.css" ])
16
- resources = ApplicationResources (app, main_registry ())
16
+ resources = ApplicationResources (app, main_registry ())
17
17
index_page = Dash. index_page (app, resources)
18
18
@test ! isnothing (findfirst (" <link rel=\" stylesheet\" href=\" https://test.css\" >" , index_page))
19
19
@@ -22,54 +22,57 @@ using HTTP
22
22
Dict (" href" => " https://test2.css" , " rel" => " stylesheet" )
23
23
]
24
24
)
25
- resources = ApplicationResources (app, main_registry ())
25
+ resources = ApplicationResources (app, main_registry ())
26
26
index_page = Dash. index_page (app, resources)
27
-
27
+
28
28
@test ! isnothing (findfirst (" <link rel=\" stylesheet\" href=\" https://test.css\" >" , index_page))
29
29
@test ! isnothing (findfirst (" href=\" https://test2.css\" " , index_page))
30
-
30
+
31
31
end
32
32
33
33
@testset " external_scripts" begin
34
-
35
-
34
+
35
+
36
36
app = dash (external_scripts = [" https://test.js" ])
37
- resources = ApplicationResources (app, main_registry ())
37
+ resources = ApplicationResources (app, main_registry ())
38
38
index_page = Dash. index_page (app, resources)
39
39
@test ! isnothing (findfirst (""" <script src="https://test.js"></script>""" , index_page))
40
40
41
41
app = dash (external_scripts = [
42
- " https://test.js" ,
42
+ " https://test.js" ,
43
43
Dict (" src" => " https://test2.js" , " crossorigin" => " anonymous" )
44
44
])
45
- resources = ApplicationResources (app, main_registry ())
45
+ resources = ApplicationResources (app, main_registry ())
46
46
index_page = Dash. index_page (app, resources)
47
47
48
48
@test ! isnothing (findfirst (""" <script src="https://test.js"></script>""" , index_page))
49
-
49
+
50
50
@test ! isnothing (findfirst (""" <script src="https://test2.js" crossorigin="anonymous"></script>""" , index_page))
51
51
52
52
end
53
53
54
54
@testset " url paths" begin
55
- #= app = dash(requests_pathname_prefix = "/reg/prefix/", routes_pathname_prefix = "/prefix/")
56
- resources = ApplicationResources(app, main_registry())
57
- index_page = Dash.index_page(app, resources)
58
-
59
- @test !isnothing(findfirst("""requests_pathname_prefix":"/reg/prefix/""", index_page))
60
- handler = Dash.make_handler(app)
61
- request = HTTP.Request("GET", "/prefix/")
62
- response = handler(request)
63
- @test response.status == 200
64
-
65
- request = HTTP.Request("GET", "/prefix/_dash-layout")
66
- response = handler(request)
67
- @test response.status == 200
68
-
69
- request = HTTP.Request("GET", "/prefix/_dash-dependencies")
70
- response = handler(request)
71
- @test response.status == 200=#
72
-
55
+ app = dash (requests_pathname_prefix = " /reg/prefix/" , routes_pathname_prefix = " /prefix/" )
56
+ @test app. config. requests_pathname_prefix == " /reg/prefix/"
57
+ @test app. config. routes_pathname_prefix == " /prefix/"
58
+
59
+ app = dash (routes_pathname_prefix = " /prefix/" )
60
+ @test app. config. routes_pathname_prefix == " /prefix/"
61
+ @test app. config. requests_pathname_prefix == " /prefix/"
62
+
63
+ app = dash ()
64
+ @test app. config. routes_pathname_prefix == " /"
65
+ @test app. config. requests_pathname_prefix == " /"
66
+
67
+ ENV [" DASH_APP_NAME" ] = " test-app"
68
+ app = dash (routes_pathname_prefix = " /prefix/" )
69
+ @test app. config. routes_pathname_prefix == " /prefix/"
70
+ @test app. config. requests_pathname_prefix == " /test-app/prefix/"
71
+
72
+ app = dash ()
73
+ @test app. config. routes_pathname_prefix == " /"
74
+ @test app. config. requests_pathname_prefix == " /test-app/"
75
+
73
76
end
74
77
75
78
@testset " assets paths" begin
@@ -131,23 +134,23 @@ end
131
134
132
135
@testset " suppress_callback_exceptions" begin
133
136
app = dash ()
134
- resources = ApplicationResources (app, main_registry ())
137
+ resources = ApplicationResources (app, main_registry ())
135
138
index_page = Dash. index_page (app, resources)
136
139
@test ! isnothing (findfirst (" \" suppress_callback_exceptions\" :false" , index_page))
137
140
@test isnothing (findfirst (" \" suppress_callback_exceptions\" :true" , index_page))
138
141
139
142
app = dash (suppress_callback_exceptions = true )
140
- resources = ApplicationResources (app, main_registry ())
143
+ resources = ApplicationResources (app, main_registry ())
141
144
index_page = Dash. index_page (app, resources)
142
145
@test isnothing (findfirst (" \" suppress_callback_exceptions\" :false" , index_page))
143
146
@test ! isnothing (findfirst (" \" suppress_callback_exceptions\" :true" , index_page))
144
147
end
145
148
146
149
@testset " meta_tags" begin
147
150
app = dash ()
148
- resources = ApplicationResources (app, main_registry ())
151
+ resources = ApplicationResources (app, main_registry ())
149
152
index_page = Dash. index_page (app, resources)
150
-
153
+
151
154
@test ! isnothing (
152
155
findfirst (
153
156
" <meta http-equiv=\" X-UA-Compatible\" content=\" IE=edge\" >" ,
@@ -161,29 +164,29 @@ end
161
164
)
162
165
163
166
app = dash (meta_tags = [Dict (" type" => " tst" , " rel" => " r" )])
164
- resources = ApplicationResources (app, main_registry ())
167
+ resources = ApplicationResources (app, main_registry ())
165
168
index_page = Dash. index_page (app, resources)
166
169
167
170
@test ! isnothing (
168
171
findfirst (
169
172
" <meta http-equiv=\" X-UA-Compatible\" content=\" IE=edge\" >" ,
170
173
index_page)
171
174
)
172
-
175
+
173
176
@test ! isnothing (
174
177
findfirst (
175
178
" <meta charset=\" UTF-8\" >" ,
176
179
index_page)
177
180
)
178
-
181
+
179
182
@test ! isnothing (
180
183
findfirst (
181
184
Dash. format_tag (" meta" , Dict (" type" => " tst" , " rel" => " r" ), opened = true ),
182
185
index_page)
183
186
)
184
187
185
188
app = dash (meta_tags = [Dict (" charset" => " Win1251" ), Dict (" type" => " tst" , " rel" => " r" )])
186
- resources = ApplicationResources (app, main_registry ())
189
+ resources = ApplicationResources (app, main_registry ())
187
190
index_page = Dash. index_page (app, resources)
188
191
189
192
@test isnothing (
204
207
)
205
208
206
209
app = dash (meta_tags = [Dict (" http-equiv" => " X-UA-Compatible" , " content" => " IE" ), Dict (" type" => " tst" , " rel" => " r" )])
207
- resources = ApplicationResources (app, main_registry ())
210
+ resources = ApplicationResources (app, main_registry ())
208
211
index_page = Dash. index_page (app, resources)
209
212
@test isnothing (
210
213
findfirst (
@@ -222,23 +225,23 @@ end
222
225
@testset " index_string" begin
223
226
index_string = " test test test, {%metas%},{%title%},{%favicon%},{%css%},{%app_entry%},{%config%},{%scripts%},{%renderer%}"
224
227
app = dash (index_string = index_string)
225
- resources = ApplicationResources (app, main_registry ())
228
+ resources = ApplicationResources (app, main_registry ())
226
229
index_page = Dash. index_page (app, resources)
227
- @test startswith (index_page, " test test test," )
228
-
230
+ @test startswith (index_page, " test test test," )
231
+
229
232
end
230
233
231
234
@testset " show_undo_redo" begin
232
-
235
+
233
236
app = dash ()
234
-
235
- resources = ApplicationResources (app, main_registry ())
237
+
238
+ resources = ApplicationResources (app, main_registry ())
236
239
index_page = Dash. index_page (app, resources)
237
240
@test ! isnothing (findfirst (" \" show_undo_redo\" :false" , index_page))
238
241
239
242
app = dash (show_undo_redo = true )
240
-
241
- resources = ApplicationResources (app, main_registry ())
243
+
244
+ resources = ApplicationResources (app, main_registry ())
242
245
index_page = Dash. index_page (app, resources)
243
246
@test ! isnothing (findfirst (" \" show_undo_redo\" :true" , index_page))
244
247
end
0 commit comments