-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add back button to settings/enable-2fa page to allow user to abort
- Loading branch information
Showing
6 changed files
with
173 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import re | ||
|
||
from playwright.sync_api import Page, expect | ||
from tenacity import RetryCallState, retry, stop_after_attempt, wait_random_exponential | ||
|
||
BASE_URL = "http://127.0.0.1:8080" | ||
|
||
|
||
def log_retry_error(retry_state: RetryCallState) -> None: | ||
if retry_state is None or retry_state.outcome is None: | ||
return | ||
print(f"Retrying due to error: {retry_state.outcome.exception()}") | ||
|
||
|
||
@retry( | ||
wait=wait_random_exponential(min=1, max=60), | ||
stop=stop_after_attempt(3), | ||
retry_error_callback=log_retry_error, | ||
) | ||
def test_enable_2fa_has_back_button(page: Page, user_password: str) -> None: | ||
page.goto(f"{BASE_URL}/login", wait_until="domcontentloaded") | ||
page.get_by_label("Username").fill("test") | ||
page.get_by_label("Password").fill(user_password) | ||
page.get_by_role("button", name="Login").click() | ||
|
||
page.goto(f"{BASE_URL}/settings/enable-2fa", wait_until="domcontentloaded") | ||
expect(page.get_by_text("Back to Authentication")).to_be_visible() | ||
|
||
|
||
@retry( | ||
wait=wait_random_exponential(min=1, max=60), | ||
stop=stop_after_attempt(3), | ||
retry_error_callback=log_retry_error, | ||
) | ||
def test_enable_2fa_back_button_returns(page: Page, user_password: str) -> None: | ||
page.goto(f"{BASE_URL}/login", wait_until="domcontentloaded") | ||
page.get_by_label("Username").fill("test") | ||
page.get_by_label("Password").fill(user_password) | ||
page.get_by_role("button", name="Login").click() | ||
|
||
page.goto(f"{BASE_URL}/settings/enable-2fa", wait_until="domcontentloaded") | ||
page.get_by_text("Back to Authentication").click() | ||
expect(page).to_have_url(re.compile(".*auth")) |