Skip to content

Add Query Preview Integration Tests and Update Package Configuration #1495

Add Query Preview Integration Tests and Update Package Configuration

Add Query Preview Integration Tests and Update Package Configuration #1495

Workflow file for this run

name: Test
on:
pull_request:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Set minimal permissions for security
permissions:
contents: read
actions: read
checks: write
pull-requests: write
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js with cache
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: npm-ci
run: npm ci
- name: Allow unprivileged user namespace (ubuntu)
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
- name: Setup Chrome browser (Ubuntu)
if: ${{ startsWith(matrix.os, 'ubuntu') }}
uses: browser-actions/setup-chrome@v1
- name: Setup Chrome browser (macOS)
if: ${{ startsWith(matrix.os, 'macos') }}
uses: browser-actions/setup-chrome@v1
- name: Setup Chrome browser (Windows)
if: ${{ startsWith(matrix.os, 'windows') }}
uses: browser-actions/setup-chrome@v1
- name: Install dependencies
run: npm run install:all
# install bruin cli for linux, mac and windows
- name: Install Bruin CLI
run: |
if [ "${{ runner.os }}" = "Windows" ]; then
curl -LsSf https://raw.githubusercontent.com/bruin-data/bruin/refs/heads/main/install.sh | sh
else
curl -LsSL https://raw.githubusercontent.com/bruin-data/bruin/refs/heads/main/install.sh | sh
fi
shell: bash
- name: Compile
run: npm run compile
- name: Build Webview
run: npm run build:webview
- name: Run extension tests
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
xvfb-run -a npm run test
else
npm run test
fi
shell: bash
- name: Run webview tests
run: npm run test:webview
- name: Run all integration tests
run: |
# Function to run selenium tests with proper Chrome setup
run_selenium_test() {
local test_name="$1"
local test_command="$2"
local user_data_suffix="$3"
echo "Running $test_name..."
# Set Chrome-related environment variables and unique user data dir
if [ "${{ runner.os }}" = "Linux" ]; then
export CHROME_BIN=$(which google-chrome || which chromium-browser || which chromium)
export CHROME_USER_DATA_DIR="/tmp/chrome-user-data-$user_data_suffix-$$"
echo "Using Chrome at: $CHROME_BIN"
echo "Using user data dir: $CHROME_USER_DATA_DIR"
xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' $test_command
elif [ "${{ runner.os }}" = "macOS" ]; then
# Try different Chrome locations on macOS
if [ -f "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ]; then
export CHROME_BIN="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
elif [ -f "/Applications/Chromium.app/Contents/MacOS/Chromium" ]; then
export CHROME_BIN="/Applications/Chromium.app/Contents/MacOS/Chromium"
fi
export CHROME_USER_DATA_DIR="/tmp/chrome-user-data-$user_data_suffix-$$"
echo "Using Chrome at: $CHROME_BIN"
echo "Using user data dir: $CHROME_USER_DATA_DIR"
$test_command
else
# Windows - let extension tester handle Chrome detection
export CHROME_USER_DATA_DIR="C:\\temp\\chrome-user-data-$user_data_suffix-$$"
$test_command
fi
echo "$test_name completed"
}
# Run all integration tests
run_selenium_test "connections and ingestr tests" "npm run selenium:run-tests:connections && npm run selenium:run-tests:ingestr" "basic"
run_selenium_test "webview tests" "npm run selenium:run-tests:webview" "webview"
run_selenium_test "lineage tests" "npm run selenium:run-tests:lineage" "lineage"
run_selenium_test "query preview tests" "npm run selenium:run-tests:query-preview" "query-preview"
shell: bash
- name: Store UI test logs
uses: actions/upload-artifact@v4
if: failure() || cancelled()
with:
name: logs-${{ matrix.os }}
path: test-resources/settings/logs/*
- name: Store UI Test screenshots
uses: actions/upload-artifact@v4
if: failure() || cancelled()
with:
name: screenshots-${{ matrix.os }}
path: test-resources/screenshots/*.png