Skip to content

Commit 39b29fc

Browse files
committed
prevent test pages from jumping around
1 parent 08fd30c commit 39b29fc

File tree

1 file changed

+52
-48
lines changed

1 file changed

+52
-48
lines changed

tests/test_app/tests/test_components.py

+52-48
Original file line numberDiff line numberDiff line change
@@ -19,46 +19,50 @@
1919
class ComponentTests(PlaywrightTestCase):
2020
databases = {"default"}
2121

22+
###########################
23+
# Generic Component Tests #
24+
###########################
25+
2226
@navigate_to_page("/")
23-
def test_hello_world(self):
27+
def test_component_hello_world(self):
2428
self.page.wait_for_selector("#hello-world")
2529

2630
@navigate_to_page("/")
27-
def test_counter(self):
31+
def test_component_counter(self):
2832
for i in range(5):
2933
self.page.locator(f"#counter-num[data-count={i}]")
3034
self.page.locator("#counter-inc").click()
3135

3236
@navigate_to_page("/")
33-
def test_parametrized_component(self):
37+
def test_component_parametrized_component(self):
3438
self.page.locator("#parametrized-component[data-value='579']").wait_for()
3539

3640
@navigate_to_page("/")
37-
def test_object_in_templatetag(self):
41+
def test_component_object_in_templatetag(self):
3842
self.page.locator("#object_in_templatetag[data-success=true]").wait_for()
3943

4044
@navigate_to_page("/")
4145
def test_component_from_web_module(self):
4246
self.page.wait_for_selector("#button-from-js-module")
4347

4448
@navigate_to_page("/")
45-
def test_use_connection(self):
49+
def test_component_use_connection(self):
4650
self.page.locator("#use-connection[data-success=true]").wait_for()
4751

4852
@navigate_to_page("/")
49-
def test_use_scope(self):
53+
def test_component_use_scope(self):
5054
self.page.locator("#use-scope[data-success=true]").wait_for()
5155

5256
@navigate_to_page("/")
53-
def test_use_location(self):
57+
def test_component_use_location(self):
5458
self.page.locator("#use-location[data-success=true]").wait_for()
5559

5660
@navigate_to_page("/")
57-
def test_use_origin(self):
61+
def test_component_use_origin(self):
5862
self.page.locator("#use-origin[data-success=true]").wait_for()
5963

6064
@navigate_to_page("/")
61-
def test_static_css(self):
65+
def test_component_static_css(self):
6266
assert (
6367
self.page.wait_for_selector("#django-css button").evaluate(
6468
"e => window.getComputedStyle(e).getPropertyValue('color')"
@@ -67,33 +71,33 @@ def test_static_css(self):
6771
)
6872

6973
@navigate_to_page("/")
70-
def test_static_js(self):
74+
def test_component_static_js(self):
7175
self.page.locator("#django-js[data-success=true]").wait_for()
7276

7377
@navigate_to_page("/")
74-
def test_unauthorized_user(self):
78+
def test_component_unauthorized_user(self):
7579
with pytest.raises(TimeoutError):
7680
self.page.wait_for_selector("#unauthorized-user", timeout=1)
7781
self.page.wait_for_selector("#unauthorized-user-fallback")
7882

7983
@navigate_to_page("/")
80-
def test_authorized_user(self):
84+
def test_component_authorized_user(self):
8185
with pytest.raises(TimeoutError):
8286
self.page.wait_for_selector("#authorized-user-fallback", timeout=1)
8387
self.page.wait_for_selector("#authorized-user")
8488

8589
@navigate_to_page("/")
86-
def test_relational_query(self):
90+
def test_component_relational_query(self):
8791
self.page.locator("#relational-query").wait_for()
8892
self.page.locator("#relational-query[data-success=true]").wait_for()
8993

9094
@navigate_to_page("/")
91-
def test_async_relational_query(self):
95+
def test_component_async_relational_query(self):
9296
self.page.locator("#async-relational-query").wait_for()
9397
self.page.locator("#async-relational-query[data-success=true]").wait_for()
9498

9599
@navigate_to_page("/")
96-
def test_use_query_and_mutation(self):
100+
def test_component_use_query_and_mutation(self):
97101
todo_input = self.page.wait_for_selector("#todo-input")
98102

99103
item_ids = list(range(5))
@@ -107,7 +111,7 @@ def test_use_query_and_mutation(self):
107111
self.page.wait_for_selector(f"#todo-list #todo-item-sample-{i}", timeout=1)
108112

109113
@navigate_to_page("/")
110-
def test_async_use_query_and_mutation(self):
114+
def test_component_async_use_query_and_mutation(self):
111115
todo_input = self.page.wait_for_selector("#async-todo-input")
112116

113117
item_ids = list(range(5))
@@ -121,23 +125,23 @@ def test_async_use_query_and_mutation(self):
121125
self.page.wait_for_selector(f"#async-todo-list #todo-item-sample-{i}", timeout=1)
122126

123127
@navigate_to_page("/")
124-
def test_view_to_component_sync_func(self):
128+
def test_component_view_to_component_sync_func(self):
125129
self.page.locator("#view_to_component_sync_func[data-success=true]").wait_for()
126130

127131
@navigate_to_page("/")
128-
def test_view_to_component_async_func(self):
132+
def test_component_view_to_component_async_func(self):
129133
self.page.locator("#view_to_component_async_func[data-success=true]").wait_for()
130134

131135
@navigate_to_page("/")
132-
def test_view_to_component_sync_class(self):
136+
def test_component_view_to_component_sync_class(self):
133137
self.page.locator("#ViewToComponentSyncClass[data-success=true]").wait_for()
134138

135139
@navigate_to_page("/")
136-
def test_view_to_component_async_class(self):
140+
def test_component_view_to_component_async_class(self):
137141
self.page.locator("#ViewToComponentAsyncClass[data-success=true]").wait_for()
138142

139143
@navigate_to_page("/")
140-
def test_view_to_component_template_view_class(self):
144+
def test_component_view_to_component_template_view_class(self):
141145
self.page.locator("#ViewToComponentTemplateViewClass[data-success=true]").wait_for()
142146

143147
@navigate_to_page("/")
@@ -147,53 +151,53 @@ def _click_btn_and_check_success(self, name):
147151
self.page.locator(f"#{name}[data-success=true]").wait_for()
148152

149153
@navigate_to_page("/")
150-
def test_view_to_component_script(self):
154+
def test_component_view_to_component_script(self):
151155
self._click_btn_and_check_success("view_to_component_script")
152156

153157
@navigate_to_page("/")
154-
def test_view_to_component_request(self):
158+
def test_component_view_to_component_request(self):
155159
self._click_btn_and_check_success("view_to_component_request")
156160

157161
@navigate_to_page("/")
158-
def test_view_to_component_args(self):
162+
def test_component_view_to_component_args(self):
159163
self._click_btn_and_check_success("view_to_component_args")
160164

161165
@navigate_to_page("/")
162-
def test_view_to_component_kwargs(self):
166+
def test_component_view_to_component_kwargs(self):
163167
self._click_btn_and_check_success("view_to_component_kwargs")
164168

165169
@navigate_to_page("/")
166-
def test_view_to_iframe_sync_func(self):
170+
def test_component_view_to_iframe_sync_func(self):
167171
self.page.frame_locator("#view_to_iframe_sync_func > iframe").locator(
168172
"#view_to_iframe_sync_func[data-success=true]"
169173
).wait_for()
170174

171175
@navigate_to_page("/")
172-
def test_view_to_iframe_async_func(self):
176+
def test_component_view_to_iframe_async_func(self):
173177
self.page.frame_locator("#view_to_iframe_async_func > iframe").locator(
174178
"#view_to_iframe_async_func[data-success=true]"
175179
).wait_for()
176180

177181
@navigate_to_page("/")
178-
def test_view_to_iframe_sync_class(self):
182+
def test_component_view_to_iframe_sync_class(self):
179183
self.page.frame_locator("#view_to_iframe_sync_class > iframe").locator(
180184
"#ViewToIframeSyncClass[data-success=true]"
181185
).wait_for()
182186

183187
@navigate_to_page("/")
184-
def test_view_to_iframe_async_class(self):
188+
def test_component_view_to_iframe_async_class(self):
185189
self.page.frame_locator("#view_to_iframe_async_class > iframe").locator(
186190
"#ViewToIframeAsyncClass[data-success=true]"
187191
).wait_for()
188192

189193
@navigate_to_page("/")
190-
def test_view_to_iframe_template_view_class(self):
194+
def test_component_view_to_iframe_template_view_class(self):
191195
self.page.frame_locator("#view_to_iframe_template_view_class > iframe").locator(
192196
"#ViewToIframeTemplateViewClass[data-success=true]"
193197
).wait_for()
194198

195199
@navigate_to_page("/")
196-
def test_view_to_iframe_args(self):
200+
def test_component_view_to_iframe_args(self):
197201
self.page.frame_locator("#view_to_iframe_args > iframe").locator(
198202
"#view_to_iframe_args[data-success=Success]"
199203
).wait_for()
@@ -225,7 +229,7 @@ def test_component_session_missing(self):
225229
assert not query_exists
226230

227231
@navigate_to_page("/")
228-
def test_use_user_data(self):
232+
def test_component_use_user_data(self):
229233
text_input = self.page.wait_for_selector("#use-user-data input")
230234
login_1 = self.page.wait_for_selector("#use-user-data .login-1")
231235
login_2 = self.page.wait_for_selector("#use-user-data .login-2")
@@ -281,7 +285,7 @@ def test_use_user_data(self):
281285
assert "Data: None" in user_data_div.text_content()
282286

283287
@navigate_to_page("/")
284-
def test_use_user_data_with_default(self):
288+
def test_component_use_user_data_with_default(self):
285289
text_input = self.page.wait_for_selector("#use-user-data-with-default input")
286290
login_3 = self.page.wait_for_selector("#use-user-data-with-default .login-3")
287291
clear = self.page.wait_for_selector("#use-user-data-with-default .clear")
@@ -357,37 +361,37 @@ def test_prerender(self):
357361
###############
358362

359363
@navigate_to_page("/errors/")
360-
def test_component_does_not_exist_error(self):
364+
def test_error_component_does_not_exist(self):
361365
broken_component = self.page.locator("#component_does_not_exist_error")
362366
broken_component.wait_for()
363367
assert "ComponentDoesNotExistError:" in broken_component.text_content()
364368

365369
@navigate_to_page("/errors/")
366-
def test_component_param_error(self):
370+
def test_error_component_param(self):
367371
broken_component = self.page.locator("#component_param_error")
368372
broken_component.wait_for()
369373
assert "ComponentParamError:" in broken_component.text_content()
370374

371375
@navigate_to_page("/errors/")
372-
def test_invalid_host_error(self):
376+
def test_error_invalid_host(self):
373377
broken_component = self.page.locator("#invalid_host_error")
374378
broken_component.wait_for()
375379
assert "InvalidHostError:" in broken_component.text_content()
376380

377381
@navigate_to_page("/errors/")
378-
def test_synchronous_only_operation_error(self):
382+
def test_error_synchronous_only_operation(self):
379383
broken_component = self.page.locator("#broken_postprocessor_query pre")
380384
broken_component.wait_for()
381385
assert "SynchronousOnlyOperation:" in broken_component.text_content()
382386

383387
@navigate_to_page("/errors/")
384-
def test_view_not_registered_error(self):
388+
def test_error_view_not_registered(self):
385389
broken_component = self.page.locator("#view_to_iframe_not_registered pre")
386390
broken_component.wait_for()
387391
assert "ViewNotRegisteredError:" in broken_component.text_content()
388392

389393
@navigate_to_page("/errors/")
390-
def test_decorator_param_error(self):
394+
def test_error_decorator_param(self):
391395
broken_component = self.page.locator("#incorrect_user_passes_test_decorator")
392396
broken_component.wait_for()
393397
assert "DecoratorParamError:" in broken_component.text_content()
@@ -551,7 +555,7 @@ def test_pyscript_1_javascript_module_execution_within_pyscript(self):
551555
# Distributed Computing Tests #
552556
###############################
553557

554-
def test_host_roundrobin(self):
558+
def test_distributed_host_roundrobin(self):
555559
"""Verify if round-robin host selection is working."""
556560
self.page.goto(f"{self.live_server_url}/roundrobin/{self._port_2}/{self._port_3}/8")
557561
elem0 = self.page.locator(".custom_host-0")
@@ -579,14 +583,14 @@ def test_host_roundrobin(self):
579583
assert current_ports == correct_ports
580584
assert len(current_ports) == 2
581585

582-
def test_custom_host(self):
586+
def test_distributed_custom_host(self):
583587
"""Make sure that the component is rendered by a separate server."""
584588
self.page.goto(f"{self.live_server_url}/port/{self._port_2}/")
585589
elem = self.page.locator(".custom_host-0")
586590
elem.wait_for()
587591
assert f"Server Port: {self._port_2}" in elem.text_content()
588592

589-
def test_custom_host_wrong_port(self):
593+
def test_distributed_custom_host_wrong_port(self):
590594
"""Make sure that other ports are not rendering components."""
591595
tmp_sock = socket.socket()
592596
tmp_sock.bind((self._server_process_0.host, 0))
@@ -600,7 +604,7 @@ def test_custom_host_wrong_port(self):
600604
#################
601605

602606
@navigate_to_page("/offline/", server_num=1)
603-
def test_offline_components(self):
607+
def test_offline_component(self):
604608
self.page.wait_for_selector("div:not([hidden]) > #online")
605609
assert self.page.query_selector("div[hidden] > #offline") is not None
606610
self._server_process_1.terminate()
@@ -613,7 +617,7 @@ def test_offline_components(self):
613617
##############
614618

615619
@navigate_to_page("/form/")
616-
def test_basic_form(self):
620+
def test_form_basic(self):
617621
try:
618622
from test_app.models import TodoItem
619623

@@ -709,7 +713,7 @@ def test_basic_form(self):
709713
assert len(self.page.query_selector_all(".errorlist")) == 0
710714

711715
@navigate_to_page("/form/bootstrap/")
712-
def test_bootstrap_form(self):
716+
def test_form_bootstrap(self):
713717
try:
714718
from test_app.models import TodoItem
715719

@@ -806,7 +810,7 @@ def test_bootstrap_form(self):
806810
assert len(self.page.query_selector_all(".invalid-feedback")) == 0
807811

808812
@navigate_to_page("/form/model/")
809-
def test_model_form(self):
813+
def test_form_orm_model(self):
810814
uuid = uuid4().hex
811815
self.page.wait_for_selector("form")
812816

@@ -844,7 +848,7 @@ def test_model_form(self):
844848
# https://github.com/reactive-python/reactpy-django/issues/272
845849
@pytest.mark.flaky(reruns=5)
846850
@navigate_to_page("/form/sync_event/")
847-
def test_sync_form_events(self):
851+
def test_form_sync_events(self):
848852
self.page.wait_for_selector("form")
849853

850854
# Check initial state
@@ -874,7 +878,7 @@ def test_sync_form_events(self):
874878
self.page.wait_for_selector("#change[data-value='true']")
875879

876880
@navigate_to_page("/form/async_event/")
877-
def test_async_form_events(self):
881+
def test_form_async_events(self):
878882
self.page.wait_for_selector("form")
879883

880884
# Check initial state

0 commit comments

Comments
 (0)