Skip to content

Commit

Permalink
fix tests for submit buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
madjid-asa committed Nov 6, 2023
1 parent bb5a1ac commit 88b527b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lemarche/www/auth/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SignupForm(UserCreationForm):
queryset=Sector.objects.form_filter_queryset(),
choices_groupby="group",
to_field_name="slug",
required=True,
required=False,
)

# help_text="Nous enverrons un e-mail de confirmation à cette adresse avant de valider le compte.")
Expand Down
20 changes: 9 additions & 11 deletions lemarche/www/auth/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _complete_form(self, user_profile: dict, signup_url=reverse("auth:signup"),
scroll_to_and_click_element(self.driver, accept_rgpd_element)

if with_submit:
submit_element = self.driver.find_element(By.CSS_SELECTOR, "form button")
submit_element = self.driver.find_element(By.CSS_SELECTOR, "form button[type='submit']")
scroll_to_and_click_element(self.driver, submit_element)

def _assert_signup_success(self, redirect_url: str) -> list:
Expand Down Expand Up @@ -182,10 +182,8 @@ def test_buyer_submits_signup_form_success_extra_data(self):
By.CSS_SELECTOR, f"input#id_nb_of_inclusive_provider_2022_{nb_of_inclusive}"
)
scroll_to_and_click_element(self.driver, nb_of_inclusive_provider_2022_element)

submit_element = self.driver.find_element(By.CSS_SELECTOR, "form button")
submit_element = self.driver.find_element(By.CSS_SELECTOR, "form button[type='submit']")
scroll_to_and_click_element(self.driver, submit_element)

# should get created User
user = User.objects.get(email=BUYER.get("email"))

Expand All @@ -209,7 +207,7 @@ def test_buyer_submits_signup_form_error(self):
# By.XPATH, "//select[@id='id_partner_kind']/option[text()='Réseaux IAE']"
# )
# scroll_to_and_click_element(self.driver, partner_kind_option_element, sleep_time=10)
# submit_element = self.driver.find_element(By.CSS_SELECTOR, "form button")
# submit_element = self.driver.find_element(By.CSS_SELECTOR, "form button[type='submit']")
# scroll_to_and_click_element(self.driver, submit_element)

# self._assert_signup_success(redirect_url=reverse("wagtail_serve", args=("",)))
Expand All @@ -230,7 +228,7 @@ def test_user_submits_signup_form_with_next_param_success_and_redirect(self):
signup_url=f"{reverse('auth:signup')}?next={next_url}",
with_submit=False,
)
submit_element = self.driver.find_element(By.CSS_SELECTOR, "form button")
submit_element = self.driver.find_element(By.CSS_SELECTOR, "form button[type='submit']")
scroll_to_and_click_element(self.driver, submit_element)

self._assert_signup_success(redirect_url=next_url)
Expand Down Expand Up @@ -258,7 +256,7 @@ def test_siae_user_can_sign_in_and_is_redirected_to_dashboard(self):
driver.find_element(By.CSS_SELECTOR, "input#id_username").send_keys(user_siae.email)
driver.find_element(By.CSS_SELECTOR, "input#id_password").send_keys(DEFAULT_PASSWORD)

driver.find_element(By.CSS_SELECTOR, "form button").click()
driver.find_element(By.CSS_SELECTOR, "form button[type='submit']").click()

# should redirect SIAE to dashboard
self.assertEqual(driver.current_url, f"{self.live_server_url}{reverse('dashboard:home')}")
Expand All @@ -271,7 +269,7 @@ def test_non_siae_user_can_sign_in_and_is_redirected_to_home(self):
driver.find_element(By.CSS_SELECTOR, "input#id_username").send_keys(user_buyer.email)
driver.find_element(By.CSS_SELECTOR, "input#id_password").send_keys(DEFAULT_PASSWORD)

driver.find_element(By.CSS_SELECTOR, "form button").click()
driver.find_element(By.CSS_SELECTOR, "form button[type='submit']").click()

# should redirect BUYER to search
self.assertEqual(driver.current_url, f"{self.live_server_url}{reverse('siae:search_results')}")
Expand All @@ -284,7 +282,7 @@ def test_user_can_sign_in_with_email_containing_capital_letters(self):
driver.find_element(By.CSS_SELECTOR, "input#id_username").send_keys("[email protected]")
driver.find_element(By.CSS_SELECTOR, "input#id_password").send_keys(DEFAULT_PASSWORD)

driver.find_element(By.CSS_SELECTOR, "form button").click()
driver.find_element(By.CSS_SELECTOR, "form button[type='submit']").click()

def test_user_wrong_credentials_should_see_error_message(self):
user_siae = UserFactory(email="[email protected]", kind=User.KIND_SIAE)
Expand All @@ -294,7 +292,7 @@ def test_user_wrong_credentials_should_see_error_message(self):
driver.find_element(By.CSS_SELECTOR, "input#id_username").send_keys(user_siae.email)
driver.find_element(By.CSS_SELECTOR, "input#id_password").send_keys("password")

driver.find_element(By.CSS_SELECTOR, "form button").click()
driver.find_element(By.CSS_SELECTOR, "form button[type='submit']").click()

# should not submit form
self.assertEqual(driver.current_url, f"{self.live_server_url}{reverse('auth:login')}")
Expand All @@ -312,7 +310,7 @@ def test_user_empty_credentials_should_see_password_reset_message(self):
driver.find_element(By.CSS_SELECTOR, "input#id_username").send_keys("[email protected]")
driver.find_element(By.CSS_SELECTOR, "input#id_password").send_keys("password")

driver.find_element(By.CSS_SELECTOR, "form button").click()
driver.find_element(By.CSS_SELECTOR, "form button[type='submit']").click()

# should not submit form
self.assertEqual(driver.current_url, f"{self.live_server_url}{reverse('auth:login')}")
Expand Down

0 comments on commit 88b527b

Please sign in to comment.