Skip to content

Commit 3e7f996

Browse files
committed
fix(tests): add dialog automation to cached authentication scenario
- Cached authentication was reaching callback but failing to click dialog - Added PowerShell UI automation to handle protocol dialogs in cached auth - Mirrors the dialog handling from fresh authentication flow - Should complete authentication for users with existing Auth0 sessions The cached auth path was missing the dialog automation that the fresh login path had, causing CI timeouts for returning users.
1 parent 7959475 commit 3e7f996

1 file changed

Lines changed: 46 additions & 4 deletions

File tree

sample/Tests/test/test_windows_helpers.py

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,48 @@ def handle_cached_authentication(driver):
123123

124124
if not auth_success:
125125
print("No authentication success detected - attempting automated dialog handling")
126-
# Add automated dialog clicking here if needed
126+
print("Looking for protocol permission dialog to click automatically...")
127+
128+
# Try to find and click the protocol dialog automatically
129+
try:
130+
ps_script = '''
131+
for ($i = 0; $i -lt 10; $i++) {
132+
$windows = Get-Process | Where-Object { $_.MainWindowTitle -like "*auth.immutable.com*" -or $_.MainWindowTitle -like "*Open*" }
133+
foreach ($window in $windows) {
134+
try {
135+
Add-Type -AssemblyName UIAutomationClient
136+
$element = [Windows.Automation.AutomationElement]::FromHandle($window.MainWindowHandle)
137+
if ($element) {
138+
$buttons = $element.FindAll([Windows.Automation.TreeScope]::Descendants,
139+
[Windows.Automation.Condition]::new([Windows.Automation.AutomationElement]::ControlTypeProperty,
140+
[Windows.Automation.ControlType]::Button))
141+
foreach ($button in $buttons) {
142+
$buttonText = $button.Current.Name
143+
if ($buttonText -like "*Open*" -or $buttonText -like "*Allow*" -or $buttonText -like "*Yes*") {
144+
$button.GetCurrentPattern([Windows.Automation.InvokePattern]::Pattern).Invoke()
145+
Write-Host "Clicked protocol dialog button: $buttonText"
146+
exit 0
147+
}
148+
}
149+
}
150+
} catch {}
151+
}
152+
Start-Sleep 1
153+
}
154+
Write-Host "No protocol dialog found"
155+
'''
156+
157+
result = subprocess.run(["powershell", "-Command", ps_script],
158+
capture_output=True, text=True, timeout=15)
159+
if "Clicked protocol dialog" in result.stdout:
160+
print("Successfully automated protocol dialog click in CI!")
161+
# Wait a bit more for Unity to process
162+
time.sleep(5)
163+
else:
164+
print("Could not find protocol dialog to automate")
165+
except Exception as e:
166+
print(f"CI dialog automation error: {e}")
167+
print("Protocol dialog may require manual setup in CI environment")
127168

128169
else:
129170
print("Local environment - cached authentication should work automatically")
@@ -134,11 +175,12 @@ def handle_cached_authentication(driver):
134175
return # Exit since cached auth is complete
135176

136177
def login():
137-
print("Connect to Chrome")
138-
# Set up Chrome options to connect to the existing Chrome instance
178+
print("Connect to Brave via Chrome WebDriver")
179+
# Set up Chrome WebDriver options to connect to the existing Brave instance
180+
# (Brave uses Chromium engine so Chrome WebDriver works)
139181
chrome_options = Options()
140182
chrome_options.add_experimental_option("debuggerAddress", "localhost:9222")
141-
# Connect to the existing Chrome instance
183+
# Connect to the existing Brave browser instance
142184
driver = webdriver.Chrome(options=chrome_options)
143185

144186
# HYBRID APPROACH: Try multi-window detection first (proven to work in CI),

0 commit comments

Comments
 (0)