diff --git a/tests/e2e/test_flows_enroll.py b/tests/e2e/test_flows_enroll.py index 6a76645d0..372506477 100644 --- a/tests/e2e/test_flows_enroll.py +++ b/tests/e2e/test_flows_enroll.py @@ -90,43 +90,7 @@ class TestFlowsEnroll(SeleniumTestCase): self.driver.get(self.live_server_url) - flow_executor = self.get_shadow_root("ak-flow-executor") - identification_stage = self.get_shadow_root( - "ak-stage-identification", flow_executor - ) - wait = WebDriverWait(identification_stage, self.wait_timeout) - - wait.until(ec.presence_of_element_located((By.CSS_SELECTOR, "#enroll"))) - identification_stage.find_element(By.CSS_SELECTOR, "#enroll").click() - - flow_executor = self.get_shadow_root("ak-flow-executor") - prompt_stage = self.get_shadow_root("ak-stage-prompt", flow_executor) - wait = WebDriverWait(prompt_stage, self.wait_timeout) - - wait.until( - ec.presence_of_element_located((By.CSS_SELECTOR, "input[name=username]")) - ) - prompt_stage.find_element(By.CSS_SELECTOR, "input[name=username]").send_keys( - "foo" - ) - prompt_stage.find_element(By.CSS_SELECTOR, "input[name=password]").send_keys( - USER().username - ) - prompt_stage.find_element( - By.CSS_SELECTOR, "input[name=password_repeat]" - ).send_keys(USER().username) - prompt_stage.find_element(By.CSS_SELECTOR, ".pf-c-button").click() - - flow_executor = self.get_shadow_root("ak-flow-executor") - prompt_stage = self.get_shadow_root("ak-stage-prompt", flow_executor) - - prompt_stage.find_element(By.CSS_SELECTOR, "input[name=name]").send_keys( - "some name" - ) - prompt_stage.find_element(By.CSS_SELECTOR, "input[name=email]").send_keys( - "foo@bar.baz" - ) - prompt_stage.find_element(By.CSS_SELECTOR, ".pf-c-button").click() + self.initial_stages() self.wait.until(ec.presence_of_element_located((By.CSS_SELECTOR, "ak-sidebar"))) self.driver.get(self.shell_url("authentik_core:user-settings")) @@ -196,18 +160,16 @@ class TestFlowsEnroll(SeleniumTestCase): FlowStageBinding.objects.create(target=flow, stage=user_login, order=4) self.driver.get(self.live_server_url) - self.driver.find_element(By.CSS_SELECTOR, "#enroll").click() - self.driver.find_element(By.ID, "id_username").send_keys("foo") - self.driver.find_element(By.ID, "id_password").send_keys(USER().username) - self.driver.find_element(By.ID, "id_password_repeat").send_keys(USER().username) - self.driver.find_element(By.CSS_SELECTOR, ".pf-c-button").click() - self.driver.find_element(By.ID, "id_name").send_keys("some name") - self.driver.find_element(By.ID, "id_email").send_keys("foo@bar.baz") - self.driver.find_element(By.CSS_SELECTOR, ".pf-c-button").click() + self.initial_stages() + + # Email stage + flow_executor = self.get_shadow_root("ak-flow-executor") + email_stage = self.get_shadow_root("ak-stage-email", flow_executor) + + wait = WebDriverWait(email_stage, self.wait_timeout) + # Wait for the success message so we know the email is sent - self.wait.until( - ec.presence_of_element_located((By.CSS_SELECTOR, ".pf-c-form > p")) - ) + wait.until(ec.presence_of_element_located((By.CSS_SELECTOR, ".pf-c-form p"))) # Open Mailhog self.driver.get("http://localhost:8025") @@ -227,3 +189,46 @@ class TestFlowsEnroll(SeleniumTestCase): self.driver.get(self.shell_url("authentik_core:user-settings")) self.assert_user(User.objects.get(username="foo")) + + def initial_stages(self): + """Fill out initial stages""" + # Identification stage, click enroll + flow_executor = self.get_shadow_root("ak-flow-executor") + identification_stage = self.get_shadow_root( + "ak-stage-identification", flow_executor + ) + wait = WebDriverWait(identification_stage, self.wait_timeout) + + wait.until(ec.presence_of_element_located((By.CSS_SELECTOR, "#enroll"))) + identification_stage.find_element(By.CSS_SELECTOR, "#enroll").click() + + # First prompt stage + flow_executor = self.get_shadow_root("ak-flow-executor") + prompt_stage = self.get_shadow_root("ak-stage-prompt", flow_executor) + wait = WebDriverWait(prompt_stage, self.wait_timeout) + + wait.until( + ec.presence_of_element_located((By.CSS_SELECTOR, "input[name=username]")) + ) + prompt_stage.find_element(By.CSS_SELECTOR, "input[name=username]").send_keys( + "foo" + ) + prompt_stage.find_element(By.CSS_SELECTOR, "input[name=password]").send_keys( + USER().username + ) + prompt_stage.find_element( + By.CSS_SELECTOR, "input[name=password_repeat]" + ).send_keys(USER().username) + prompt_stage.find_element(By.CSS_SELECTOR, ".pf-c-button").click() + + # Second prompt stage + flow_executor = self.get_shadow_root("ak-flow-executor") + prompt_stage = self.get_shadow_root("ak-stage-prompt", flow_executor) + + prompt_stage.find_element(By.CSS_SELECTOR, "input[name=name]").send_keys( + "some name" + ) + prompt_stage.find_element(By.CSS_SELECTOR, "input[name=email]").send_keys( + "foo@bar.baz" + ) + prompt_stage.find_element(By.CSS_SELECTOR, ".pf-c-button").click() diff --git a/tests/e2e/utils.py b/tests/e2e/utils.py index 1cc481221..25c360487 100644 --- a/tests/e2e/utils.py +++ b/tests/e2e/utils.py @@ -220,7 +220,7 @@ def apply_migration(app_name: str, migration_name: str): return wrapper_outter -def retry(max_retires=1, exceptions=None): +def retry(max_retires=3, exceptions=None): """Retry test multiple times. Default to catching Selenium Timeout Exception""" if not exceptions: