Skip to content

Commit c432422

Browse files
refactor integration tests in workflow to use a unified function for running Selenium tests
1 parent f7e3f88 commit c432422

File tree

1 file changed

+38
-82
lines changed

1 file changed

+38
-82
lines changed

.github/workflows/tests.yml

Lines changed: 38 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -83,91 +83,47 @@ jobs:
8383
- name: Run webview tests
8484
run: npm run test:webview
8585

86-
- name: Run basic integration tests
86+
- name: Run all integration tests
8787
run: |
88-
echo "Running integration tests..."
89-
90-
# Set Chrome-related environment variables and unique user data dir
91-
if [ "${{ runner.os }}" = "Linux" ]; then
92-
export CHROME_BIN=$(which google-chrome || which chromium-browser || which chromium)
93-
export CHROME_USER_DATA_DIR="/tmp/chrome-user-data-$$"
94-
echo "Using Chrome at: $CHROME_BIN"
95-
echo "Using user data dir: $CHROME_USER_DATA_DIR"
96-
xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' npm run selenium:run-tests:connections
97-
xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' npm run selenium:run-tests:ingestr
98-
elif [ "${{ runner.os }}" = "macOS" ]; then
99-
# Try different Chrome locations on macOS
100-
if [ -f "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ]; then
101-
export CHROME_BIN="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
102-
elif [ -f "/Applications/Chromium.app/Contents/MacOS/Chromium" ]; then
103-
export CHROME_BIN="/Applications/Chromium.app/Contents/MacOS/Chromium"
88+
# Function to run selenium tests with proper Chrome setup
89+
run_selenium_test() {
90+
local test_name="$1"
91+
local test_command="$2"
92+
local user_data_suffix="$3"
93+
94+
echo "Running $test_name..."
95+
96+
# Set Chrome-related environment variables and unique user data dir
97+
if [ "${{ runner.os }}" = "Linux" ]; then
98+
export CHROME_BIN=$(which google-chrome || which chromium-browser || which chromium)
99+
export CHROME_USER_DATA_DIR="/tmp/chrome-user-data-$user_data_suffix-$$"
100+
echo "Using Chrome at: $CHROME_BIN"
101+
echo "Using user data dir: $CHROME_USER_DATA_DIR"
102+
xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' $test_command
103+
elif [ "${{ runner.os }}" = "macOS" ]; then
104+
# Try different Chrome locations on macOS
105+
if [ -f "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ]; then
106+
export CHROME_BIN="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
107+
elif [ -f "/Applications/Chromium.app/Contents/MacOS/Chromium" ]; then
108+
export CHROME_BIN="/Applications/Chromium.app/Contents/MacOS/Chromium"
109+
fi
110+
export CHROME_USER_DATA_DIR="/tmp/chrome-user-data-$user_data_suffix-$$"
111+
echo "Using Chrome at: $CHROME_BIN"
112+
echo "Using user data dir: $CHROME_USER_DATA_DIR"
113+
$test_command
114+
else
115+
# Windows - let extension tester handle Chrome detection
116+
export CHROME_USER_DATA_DIR="C:\\temp\\chrome-user-data-$user_data_suffix-$$"
117+
$test_command
104118
fi
105-
export CHROME_USER_DATA_DIR="/tmp/chrome-user-data-$$"
106-
echo "Using Chrome at: $CHROME_BIN"
107-
echo "Using user data dir: $CHROME_USER_DATA_DIR"
108-
npm run selenium:run-tests:connections
109-
npm run selenium:run-tests:ingestr
110-
else
111-
# Windows - let extension tester handle Chrome detection
112-
export CHROME_USER_DATA_DIR="C:\\temp\\chrome-user-data-$$"
113-
npm run selenium:run-tests:connections
114-
npm run selenium:run-tests:ingestr
115-
fi
116-
shell: bash
117-
118-
- name: Run advanced integration tests
119-
run: |
120-
echo "Running webview integration tests..."
119+
echo "$test_name completed"
120+
}
121121
122-
# Set Chrome-related environment variables and unique user data dir
123-
if [ "${{ runner.os }}" = "Linux" ]; then
124-
export CHROME_BIN=$(which google-chrome || which chromium-browser || which chromium)
125-
export CHROME_USER_DATA_DIR="/tmp/chrome-user-data-webview-$$"
126-
echo "Using Chrome at: $CHROME_BIN"
127-
echo "Using user data dir: $CHROME_USER_DATA_DIR"
128-
xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' npm run selenium:run-tests:webview
129-
elif [ "${{ runner.os }}" = "macOS" ]; then
130-
# Try different Chrome locations on macOS
131-
if [ -f "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ]; then
132-
export CHROME_BIN="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
133-
elif [ -f "/Applications/Chromium.app/Contents/MacOS/Chromium" ]; then
134-
export CHROME_BIN="/Applications/Chromium.app/Contents/MacOS/Chromium"
135-
fi
136-
export CHROME_USER_DATA_DIR="/tmp/chrome-user-data-webview-$$"
137-
echo "Using Chrome at: $CHROME_BIN"
138-
echo "Using user data dir: $CHROME_USER_DATA_DIR"
139-
npm run selenium:run-tests:webview
140-
else
141-
# Windows - let extension tester handle Chrome detection
142-
export CHROME_USER_DATA_DIR="C:\\temp\\chrome-user-data-webview-$$"
143-
npm run selenium:run-tests:webview
144-
fi
145-
shell: bash
146-
147-
- name: Run lineage integration tests
148-
run: |
149-
echo "Running lineage integration tests..."
150-
# Set Chrome-related environment variables and unique user data dir
151-
if [ "${{ runner.os }}" = "Linux" ]; then
152-
export CHROME_BIN=$(which google-chrome || which chromium-browser || which chromium)
153-
export CHROME_USER_DATA_DIR="/tmp/chrome-user-data-lineage-$$"
154-
echo "Using Chrome at: $CHROME_BIN"
155-
echo "Using user data dir: $CHROME_USER_DATA_DIR"
156-
xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' npm run selenium:run-tests:lineage
157-
elif [ "${{ runner.os }}" = "macOS" ]; then
158-
# Try different Chrome locations on macOS
159-
if [ -f "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ]; then
160-
export CHROME_BIN="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
161-
elif [ -f "/Applications/Chromium.app/Contents/MacOS/Chromium" ]; then
162-
export CHROME_BIN="/Applications/Chromium.app/Contents/MacOS/Chromium"
163-
fi
164-
npm run selenium:run-tests:lineage
165-
else
166-
# Windows - let extension tester handle Chrome detection
167-
export CHROME_USER_DATA_DIR="C:\\temp\\chrome-user-data-lineage-$$"
168-
npm run selenium:run-tests:lineage
169-
fi
170-
echo "Lineage integration tests completed"
122+
# Run all integration tests
123+
run_selenium_test "connections and ingestr tests" "npm run selenium:run-tests:connections && npm run selenium:run-tests:ingestr" "basic"
124+
run_selenium_test "webview tests" "npm run selenium:run-tests:webview" "webview"
125+
run_selenium_test "lineage tests" "npm run selenium:run-tests:lineage" "lineage"
126+
run_selenium_test "query preview tests" "npm run selenium:run-tests:query-preview" "query-preview"
171127
shell: bash
172128

173129
- name: Store UI test logs

0 commit comments

Comments
 (0)