From 1a4415701516a4a1c557dfd3c2713b6c876e17e8 Mon Sep 17 00:00:00 2001 From: Natalie Bunduwongse Date: Wed, 20 Nov 2024 13:23:07 +1300 Subject: [PATCH] test: remove unused ui test files --- .github/workflows/ui-tests.yml | 2 +- sample/Tests/src/device_code_logout.py | 37 ------- sample/Tests/test/test_mac.py | 3 +- sample/Tests/test_mac.sh | 137 ------------------------- 4 files changed, 3 insertions(+), 176 deletions(-) delete mode 100644 sample/Tests/src/device_code_logout.py delete mode 100755 sample/Tests/test_mac.sh diff --git a/.github/workflows/ui-tests.yml b/.github/workflows/ui-tests.yml index feca9d71..4635078a 100644 --- a/.github/workflows/ui-tests.yml +++ b/.github/workflows/ui-tests.yml @@ -65,7 +65,7 @@ jobs: include: - targetPlatform: StandaloneOSX runs-on: [self-hosted, macOS] - test_script: ./test_mac.sh + test_script: pytest -xs test/test_mac.py::MacTest - targetPlatform: StandaloneWindows64 runs-on: [self-hosted, windows] test_script: pytest -xs test/test_windows.py::WindowsTest diff --git a/sample/Tests/src/device_code_logout.py b/sample/Tests/src/device_code_logout.py deleted file mode 100644 index e639b2c7..00000000 --- a/sample/Tests/src/device_code_logout.py +++ /dev/null @@ -1,37 +0,0 @@ - -from selenium import webdriver -from selenium.webdriver.chrome.service import Service -from selenium.webdriver.chrome.options import Options -from selenium.webdriver.common.by import By -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.common.keys import Keys - -def main(): - print("Connect to Chrome") - # Set up Chrome options to connect to the existing Chrome instance - chrome_options = Options() - chrome_options.add_argument('--remote-debugging-port=9222') - # Connect to the existing Chrome instance - driver = webdriver.Chrome(options=chrome_options) - - print("Open a window on Chrome") - # Get the original window handle - original_window = driver.current_window_handle - - print("Waiting for new window...") - WebDriverWait(driver, 60).until(EC.number_of_windows_to_be(2)) - - # Get all window handles - all_windows = driver.window_handles - - print("Find the new window") - new_window = [window for window in all_windows if window != driver.current_window_handle][0] - - print("Switch to the new window") - driver.switch_to.window(new_window) - - driver.quit() - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/sample/Tests/test/test_mac.py b/sample/Tests/test/test_mac.py index 6415ff1d..13cd5877 100644 --- a/sample/Tests/test/test_mac.py +++ b/sample/Tests/test/test_mac.py @@ -52,7 +52,8 @@ def login(cls): # Switch to the new window all_windows = cls.seleniumdriver.window_handles - new_window = next(window for window in all_windows if window != cls.seleniumdriver.current_window_handle) + new_window = [window for window in all_windows if window != cls.seleniumdriver.current_window_handle][0] + cls.seleniumdriver.switch_to.window(new_window) print("Switched to new window") # Wait for email input and enter email diff --git a/sample/Tests/test_mac.sh b/sample/Tests/test_mac.sh deleted file mode 100755 index aa00c476..00000000 --- a/sample/Tests/test_mac.sh +++ /dev/null @@ -1,137 +0,0 @@ -#!/bin/bash - -# Function to open the sample app -open_sample_app() { - local app_path="$1" - echo "Opening Unity sample app..." - open "$app_path" - echo "Unity sample app launched. Waiting for 5 seconds..." - sleep 5 -} - -# Function to close the sample app -close_sample_app() { - local app_path="$1" - echo "Closing sample app..." - local PID=$(ps aux | grep "$app_path" | grep -v grep | awk '{print $2}') - if [ -n "$PID" ]; then - kill $PID - echo "Sample app (PID $PID) has been terminated." - else - echo "Sample app is not running." - fi - echo "Waiting for 5 seconds..." - sleep 5 -} - -# Function to run Python scripts in the background -run_python_script() { - local script_path="$1" - echo "Running $script_path script..." - python3 "$script_path" & - echo "$script_path script running in the background..." -} - -# Function to bring the sample app to the foreground -activate_sample_app() { - local app_name="$1" - echo "Bringing Unity sample app to the foreground..." - osascript -e "tell application \"$app_name\" to activate" -} - -close_chrome() { - echo "Closing all Chrome instances..." - pkill -f chrome - if [ $? -eq 0 ]; then - echo "Chrome closed successfully." - else - echo "No Chrome instances were running." - fi -} - -# Main script execution -app_path="${UNITY_APP_PATH:-SampleApp.app}" -app_name="${UNITY_APP_NAME:-SampleApp}" - -# Capture the start time -start_time=$(date +%s) - -# Set permissions for the app bundle -chmod -R 755 "$app_path" - -echo "Starting Unity sample app..." -open_sample_app "$app_path" - -# Login -run_python_script "src/device_code_login.py" -sleep 5 -activate_sample_app "$app_name" -echo "Running Mac device code login test..." -pytest test/test_mac.py::MacTest::test_1_device_code_login -wait -close_chrome - -# SDK functions -echo "Running SDK functions tests..." -activate_sample_app "$app_name" -pytest test/test.py -wait - -# Relogin -close_sample_app "$app_path" -open_sample_app "$app_path" -echo "Running Mac relogin test..." -pytest test/test_mac.py::MacTest::test_3_device_code_relogin -wait - -# Reconnect -close_sample_app "$app_path" -open_sample_app "$app_path" -echo "Running Mac reconnect test..." -pytest test/test_mac.py::MacTest::test_4_device_code_reconnect -wait - -# Logout -run_python_script "src/device_code_logout.py" -sleep 5 -activate_sample_app "$app_name" -echo "Running Mac device code logout test..." -pytest test/test_device_code_logout.py -wait -close_chrome - -# Connect IMX -close_sample_app "$app_path" -open_sample_app "$app_path" -run_python_script "src/device_code_login.py" -sleep 5 -activate_sample_app "$app_name" -echo "Running Mac device code connect IMX test..." -pytest test/test_mac.py::MacTest::test_2_device_code_connect_imx -wait -close_chrome - -activate_sample_app "$app_name" - -# Logout -run_python_script "src/device_code_logout.py" -sleep 5 -activate_sample_app "$app_name" -echo "Running Mac device code logout test..." -pytest test/test_device_code_logout.py -wait -close_chrome - -# Final stop of Unity sample app -close_sample_app "$app_path" - -# Capture the end time -end_time=$(date +%s) - -# Calculate the duration -execution_time=$((end_time - start_time)) -minutes=$((execution_time / 60)) -seconds=$((execution_time % 60)) - -echo "All tests completed." -echo "Elapsed time: $minutes minutes and $seconds seconds." \ No newline at end of file