Skip to content

Commit

Permalink
[#901 #902] Added comments to the Selenium test case documenting enco…
Browse files Browse the repository at this point in the history
…untered issues
  • Loading branch information
Bart van der Schoor committed Dec 1, 2022
1 parent bc1560f commit 229efa0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/open_inwoner/accounts/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class StatusChoices(DjangoChoices):
approval = ChoiceItem("approval", _("Accordering"), icon="question_mark")
closed = ChoiceItem("closed", _("Afgerond"), icon="check")

# note the icons are names from Material Symbols and Icons - Google Fonts

@classmethod
def get_icon(cls, status, default="label"):
if status in cls.values:
Expand Down
23 changes: 15 additions & 8 deletions src/open_inwoner/accounts/tests/test_action_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,19 @@ def setUpClass(cls):
cls.selenium.implicitly_wait(10)

def test_action_status(self):
"""
note: there are some issues with both selenium and the threading in StaticLiveServerTestCase
that make it seemingly impossible to get this to pass with either implicit or explicit wait conditions
after trying everything in the docs and stackoverflow with inconsistent results on both the Firefox and Chrome
versions running both locally and on CI, the solution was to simply put time.sleep(1) after each async action
"""
self.force_login(self.user)

# wait for user and session to be visible from the server thread
# wait for user and session to be visible from the server thread (weirdly only a problem on CI)
time.sleep(1)

# use a big screen because scroll_into_view or JS scroll commands are problematic
self.selenium.set_window_size(1200, 1200)
self.selenium.get(self.live_server_url + self.action_list_url)

Expand Down Expand Up @@ -355,24 +363,24 @@ def test_action_status(self):
0, 200
).click(button).perform()

# wait for htmx to return (neither implicit or explicit wait/until nor ActionChains.pause will help)
# wait for htmx to return (neither implicit or explicit waits nor ActionChains.pause will help)
time.sleep(1)

self.assertIn(
f"dropdown--{StatusChoices.open}", dropdown.get_attribute("class")
)
self.assertTrue(dropdown_content.is_displayed())

# find and click the closed button
# find and click the close-state button
status_closed_button = dropdown_content.find_element(
By.CSS_SELECTOR, f".actions__status-{StatusChoices.closed}"
)
self.assertTrue(status_closed_button.is_displayed())

# click button and htmx should run
ActionChains(self.selenium).click(status_closed_button).perform()
status_closed_button.click()

# wait for htmx to return (neither implicit or explicit wait/until nor ActionChains.pause will help)
# wait for htmx to return
time.sleep(1)

# regrab and check our button is now Closed
Expand All @@ -388,19 +396,18 @@ def test_action_status(self):
f"actions__status-selector--{StatusChoices.closed}",
button.get_attribute("class"),
)
# check our action in the database

# check our action in the database is closed now
self.action.refresh_from_db()
self.assertEqual(self.action.status, StatusChoices.closed)


@temp_private_root()
class ActionStatusFirefoxSeleniumTests(
FirefoxSeleniumMixin, ActionStatusSeleniumBaseTests, StaticLiveServerTestCase
):
pass


@temp_private_root()
class ActionStatusChromeSeleniumTests(
ChromeSeleniumMixin, ActionStatusSeleniumBaseTests, StaticLiveServerTestCase
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<div class="actions">
{% render_form form=form method="GET" spaceless=True autosubmit=True form_action=form_action %}
<div class="actions__filters">
{% render_form form=form method="GET" spaceless=True autosubmit=True form_action=form_action %}
<div class="actions__filter-button">
{% button text=_("Filter") type="button" bordered=True %}
</div>
Expand All @@ -13,7 +12,6 @@
{% input action_form.is_for no_label=True no_help=True icon="person" %}
{% input action_form.status no_label=True no_help=True icon="expand_more" %}
</div>
{% endrender_form %}
</div>
{% endrender_form %}
<div class="actions__list">
Expand Down
3 changes: 1 addition & 2 deletions src/open_inwoner/plans/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,17 +523,16 @@ def setUp(self) -> None:
)


@temp_private_root()
class PlanActionStatusFirefoxSeleniumTests(
FirefoxSeleniumMixin,
_PlanActionStatusSeleniumMixin,
ActionStatusSeleniumBaseTests,
StaticLiveServerTestCase,
):
pass
# note these use the same ActionStatusSeleniumBaseTests as the Actions without Plan


@temp_private_root()
class PlanActionStatusChromeSeleniumTests(
ChromeSeleniumMixin,
_PlanActionStatusSeleniumMixin,
Expand Down

0 comments on commit 229efa0

Please sign in to comment.