Skip to content

[ID-3586] test: mac pkce UI test #491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: remove device code auth from windows test
  • Loading branch information
nattb8 committed Jun 17, 2025
commit 6c195b47763c6f1aec853f3bb24bad862743f8d3
28 changes: 6 additions & 22 deletions sample/Tests/test/test_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ def restart_app_and_altdriver(self):
time.sleep(5) # Give time for the app to open
self.start_altdriver()

def select_auth_type(self, use_pkce: bool):
auth_type = "PKCE" if use_pkce else "DeviceCodeAuth"
self.get_altdriver().find_object(By.NAME, auth_type).tap()

def login(self, use_pkce: bool):
self.select_auth_type(use_pkce)

def login(self):
# Wait for unauthenticated screen
self.get_altdriver().wait_for_current_scene_to_be("UnauthenticatedScene")

Expand All @@ -46,7 +40,7 @@ def login(self, use_pkce: bool):
launch_browser()
bring_sample_app_to_foreground()
login_button.tap()
login(use_pkce)
login()
bring_sample_app_to_foreground()

# Wait for authenticated screen
Expand Down Expand Up @@ -88,12 +82,8 @@ def login(self, use_pkce: bool):
else:
raise SystemExit(f"Failed to reset app {err}")

def test_1a_pkce_login(self):
self.login(True)

def test_1b_device_code_login(self):
self.restart_app_and_altdriver()
self.login(False)
def test_1_login(self):
self.login()

def test_2_other_functions(self):
self.test_0_other_functions()
Expand All @@ -110,9 +100,6 @@ def test_5_zkevm_functions(self):
def test_6_relogin(self):
self.restart_app_and_altdriver()

# Select use device code auth
self.select_auth_type(use_pkce=False)

# Relogin
print("Re-logging in...")
self.get_altdriver().wait_for_object(By.NAME, "ReloginBtn").tap()
Expand All @@ -130,12 +117,9 @@ def test_6_relogin(self):
self.get_altdriver().find_object(By.NAME, "ConnectBtn").tap()
self.assertEqual("Connected to IMX", output.get_text())

def test_7_reconnect_device_code_connect_imx(self):
def test_7_reconnect_connect_imx(self):
self.restart_app_and_altdriver()

use_pkce = False
self.select_auth_type(use_pkce)

# Reconnect
print("Reconnecting...")
self.get_altdriver().wait_for_object(By.NAME, "ReconnectBtn").tap()
Expand Down Expand Up @@ -171,7 +155,7 @@ def test_7_reconnect_device_code_connect_imx(self):
launch_browser()
bring_sample_app_to_foreground()
self.get_altdriver().wait_for_object(By.NAME, "ConnectBtn").tap()
login(use_pkce)
login()
bring_sample_app_to_foreground()

# Wait for authenticated screen
Expand Down
11 changes: 2 additions & 9 deletions sample/Tests/test/test_windows_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_product_name():
# If regex fails, return default
return "SampleApp"

def login(use_pkce: bool):
def login():
print("Connect to Chrome")
# Set up Chrome options to connect to the existing Chrome instance
chrome_options = Options()
Expand All @@ -65,12 +65,6 @@ def login(use_pkce: bool):

wait = WebDriverWait(driver, 60)

if not use_pkce:
print("Wait for device confirmation...")
contine_button = wait.until(EC.element_to_be_clickable((By.XPATH, "//button[span[text()='Continue']]")))
contine_button.click()
print("Confirmed device")

print("Wait for email input...")
email_field = wait.until(EC.presence_of_element_located((By.ID, ':r1:')))
print("Enter email...")
Expand All @@ -96,8 +90,7 @@ def login(use_pkce: bool):
otp_field.send_keys(code)

print("Wait for success page...")
success_title = 'h1[data-testid="checking_title"]' if use_pkce else 'h1[data-testid="device_success_title"]'
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, success_title)))
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, 'h1[data-testid="checking_title"]')))
print("Connected to Passport!")

driver.quit()
Expand Down
Loading