66
77from reflex import constants
88from reflex .compiler import compiler , utils
9+ from reflex .constants .compiler import PageNames
910from reflex .utils .imports import ImportVar , ParsedImportDict
1011
1112
@@ -127,7 +128,7 @@ def test_compile_stylesheets(tmp_path: Path, mocker):
127128 assets_dir = project / "assets"
128129 assets_dir .mkdir ()
129130
130- (assets_dir / "styles .css" ).write_text (
131+ (assets_dir / "style .css" ).write_text (
131132 "button.rt-Button {\n \t border-radius:unset !important;\n }"
132133 )
133134 mocker .patch ("reflex.compiler.compiler.Path.cwd" , return_value = project )
@@ -142,21 +143,26 @@ def test_compile_stylesheets(tmp_path: Path, mocker):
142143 stylesheets = [
143144 "https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple" ,
144145 "https://cdn.jsdelivr.net/npm/[email protected] /dist/css/bootstrap.min.css" ,
145- "/styles .css" ,
146+ "/style .css" ,
146147 "https://cdn.jsdelivr.net/npm/[email protected] /dist/css/bootstrap-theme.min.css" ,
147148 ]
148149
149150 assert compiler .compile_root_stylesheet (stylesheets ) == (
150- str (project / constants .Dirs .WEB / "styles" / "styles.css" ),
151+ str (
152+ project
153+ / constants .Dirs .WEB
154+ / "styles"
155+ / (PageNames .STYLESHEET_ROOT + ".css" )
156+ ),
151157 "@import url('./tailwind.css'); \n "
152158 "@import url('https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple'); \n "
153159 "@import url('https://cdn.jsdelivr.net/npm/[email protected] /dist/css/bootstrap.min.css'); \n " 154- "@import url('./styles .css'); \n "
155- "@import url('https://cdn.jsdelivr.net/npm/[email protected] /dist/css/bootstrap-theme.min .css'); \n " ,
160+ "@import url('https://cdn.jsdelivr.net/npm/[email protected] /dist/css/bootstrap-theme.min .css'); \n " 161+ "@import url('./style .css'); \n " ,
156162 )
157163
158- assert (project / constants .Dirs .WEB / "styles" / "styles .css" ).read_text () == (
159- assets_dir / "styles .css"
164+ assert (project / constants .Dirs .WEB / "styles" / "style .css" ).read_text () == (
165+ assets_dir / "style .css"
160166 ).read_text ()
161167
162168
@@ -177,7 +183,7 @@ def test_compile_stylesheets_scss_sass(tmp_path: Path, mocker):
177183 assets_preprocess_dir = assets_dir / "preprocess"
178184 assets_preprocess_dir .mkdir ()
179185
180- (assets_dir / "styles .css" ).write_text (
186+ (assets_dir / "style .css" ).write_text (
181187 "button.rt-Button {\n \t border-radius:unset !important;\n }"
182188 )
183189 (assets_preprocess_dir / "styles_a.sass" ).write_text (
@@ -196,34 +202,44 @@ def test_compile_stylesheets_scss_sass(tmp_path: Path, mocker):
196202 )
197203
198204 stylesheets = [
199- "/styles .css" ,
205+ "/style .css" ,
200206 "/preprocess/styles_a.sass" ,
201207 "/preprocess/styles_b.scss" ,
202208 ]
203209
204210 assert compiler .compile_root_stylesheet (stylesheets ) == (
205- str (project / constants .Dirs .WEB / "styles" / "styles.css" ),
211+ str (
212+ project
213+ / constants .Dirs .WEB
214+ / "styles"
215+ / (PageNames .STYLESHEET_ROOT + ".css" )
216+ ),
206217 "@import url('./tailwind.css'); \n "
207- "@import url('./styles .css'); \n "
218+ "@import url('./style .css'); \n "
208219 f"@import url('./{ Path ('preprocess' ) / Path ('styles_a.css' )!s} '); \n "
209220 f"@import url('./{ Path ('preprocess' ) / Path ('styles_b.css' )!s} '); \n " ,
210221 )
211222
212223 stylesheets = [
213- "/styles .css" ,
224+ "/style .css" ,
214225 "/preprocess" , # this is a folder containing "styles_a.sass" and "styles_b.scss"
215226 ]
216227
217228 assert compiler .compile_root_stylesheet (stylesheets ) == (
218- str (project / constants .Dirs .WEB / "styles" / "styles.css" ),
229+ str (
230+ project
231+ / constants .Dirs .WEB
232+ / "styles"
233+ / (PageNames .STYLESHEET_ROOT + ".css" )
234+ ),
219235 "@import url('./tailwind.css'); \n "
220- "@import url('./styles .css'); \n "
221- f"@import url('./{ Path ('preprocess' ) / Path ('styles_b .css' )!s} '); \n "
222- f"@import url('./{ Path ('preprocess' ) / Path ('styles_a .css' )!s} '); \n " ,
236+ "@import url('./style .css'); \n "
237+ f"@import url('./{ Path ('preprocess' ) / Path ('styles_a .css' )!s} '); \n "
238+ f"@import url('./{ Path ('preprocess' ) / Path ('styles_b .css' )!s} '); \n " ,
223239 )
224240
225- assert (project / constants .Dirs .WEB / "styles" / "styles .css" ).read_text () == (
226- assets_dir / "styles .css"
241+ assert (project / constants .Dirs .WEB / "styles" / "style .css" ).read_text () == (
242+ assets_dir / "style .css"
227243 ).read_text ()
228244
229245 expected_result = "button.rt-Button{border-radius:unset !important}\n "
@@ -252,16 +268,16 @@ def test_compile_stylesheets_exclude_tailwind(tmp_path, mocker):
252268 mocker .patch .object (mock , "tailwind" , None )
253269 mocker .patch ("reflex.compiler.compiler.get_config" , return_value = mock )
254270
255- (assets_dir / "styles .css" ).touch ()
271+ (assets_dir / "style .css" ).touch ()
256272 mocker .patch ("reflex.compiler.compiler.Path.cwd" , return_value = project )
257273
258274 stylesheets = [
259- "/styles .css" ,
275+ "/style .css" ,
260276 ]
261277
262278 assert compiler .compile_root_stylesheet (stylesheets ) == (
263- str (Path (".web" ) / "styles" / "styles .css" ),
264- "@import url('./styles .css'); \n " ,
279+ str (Path (".web" ) / "styles" / ( PageNames . STYLESHEET_ROOT + " .css") ),
280+ "@import url('./style .css'); \n " ,
265281 )
266282
267283
@@ -280,7 +296,7 @@ def test_compile_nonexistent_stylesheet(tmp_path, mocker):
280296
281297 mocker .patch ("reflex.compiler.compiler.Path.cwd" , return_value = project )
282298
283- stylesheets = ["/styles .css" ]
299+ stylesheets = ["/style .css" ]
284300
285301 with pytest .raises (FileNotFoundError ):
286302 compiler .compile_root_stylesheet (stylesheets )
0 commit comments