Skip to content

Commit 22629cc

Browse files
Merge pull request #611 from bruin-data/tests/integration-tests-connections-environement
Add Integration Tests for Connections and Environments
2 parents b0e8b1c + 0f0a60c commit 22629cc

File tree

11 files changed

+2258
-66
lines changed

11 files changed

+2258
-66
lines changed

.github/workflows/tests.yml

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -85,47 +85,64 @@ jobs:
8585

8686
- name: Run integration tests
8787
run: |
88-
# Try to run integration tests, but don't fail the build if they fail
89-
echo "Attempting to run integration tests..."
88+
echo "Running integration tests..."
9089
91-
# Set Chrome-related environment variables
90+
# Set Chrome-related environment variables and unique user data dir
9291
if [ "${{ runner.os }}" = "Linux" ]; then
9392
export CHROME_BIN=$(which google-chrome || which chromium-browser || which chromium)
93+
export CHROME_USER_DATA_DIR="/tmp/chrome-user-data-$$"
9494
echo "Using Chrome at: $CHROME_BIN"
95-
if xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' npm run selenium:run-tests; then
96-
echo "✅ Integration tests passed successfully!"
97-
else
98-
echo "❌ Integration tests failed - likely due to ChromeDriver 404 download issue"
99-
echo "This is a known issue with vscode-extension-tester ChromeDriver downloads"
100-
echo "Unit tests and webview tests are still passing ✅"
101-
fi
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
10298
elif [ "${{ runner.os }}" = "macOS" ]; then
10399
# Try different Chrome locations on macOS
104100
if [ -f "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ]; then
105101
export CHROME_BIN="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
106102
elif [ -f "/Applications/Chromium.app/Contents/MacOS/Chromium" ]; then
107103
export CHROME_BIN="/Applications/Chromium.app/Contents/MacOS/Chromium"
108104
fi
105+
export CHROME_USER_DATA_DIR="/tmp/chrome-user-data-$$"
109106
echo "Using Chrome at: $CHROME_BIN"
110-
if npm run selenium:run-tests; then
111-
echo "✅ Integration tests passed successfully!"
112-
else
113-
echo "❌ Integration tests failed - likely due to ChromeDriver 404 download issue"
114-
echo "This is a known issue with vscode-extension-tester ChromeDriver downloads"
115-
echo "Unit tests and webview tests are still passing ✅"
116-
fi
107+
echo "Using user data dir: $CHROME_USER_DATA_DIR"
108+
npm run selenium:run-tests:connections
109+
npm run selenium:run-tests:ingestr
117110
else
118111
# Windows - let extension tester handle Chrome detection
119-
if npm run selenium:run-tests; then
120-
echo "✅ Integration tests passed successfully!"
121-
else
122-
echo "❌ Integration tests failed - likely due to ChromeDriver 404 download issue"
123-
echo "This is a known issue with vscode-extension-tester ChromeDriver downloads"
124-
echo "Unit tests and webview tests are still passing ✅"
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 webview integration tests
119+
run: |
120+
echo "Running webview integration tests..."
121+
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"
125135
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
126144
fi
127145
shell: bash
128-
continue-on-error: true
129146

130147
- name: Store UI test logs
131148
uses: actions/upload-artifact@v4

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ node_modules
77
.bruin.yml
88
bruinPythonAsset.py
99
example.txt
10-
integration-test-coverage-analysis.csv
10+
integration-test-coverage-analysis.csv
11+
generate-coverage-analysis.js
12+
real-coverage-calculator.js

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,10 @@
538538
"build:webview": "cd webview-ui && npm run build-only && node scripts/copy-codicons.js",
539539
"vscode:prepublish": "npm run compile",
540540
"selenium:setup-tests": "extest setup-tests",
541-
"selenium:run-tests": "node webview-ui/scripts/copy-test-assets.js && extest setup-and-run './out/ui-test/*.test.js' --code_version 1.103.0 --code_settings settings.json",
542-
"selenium:run-tests-coordinated": "node webview-ui/scripts/copy-test-assets.js && extest setup-and-run './out/ui-test/{ingestr-asset-ui-integration,webview-tests}.test.js' --code_version 1.103.0 --code_settings settings.json",
541+
"selenium:run-tests:connections": "node webview-ui/scripts/copy-test-assets.js && extest setup-and-run './out/ui-test/connections-integration.test.js' --code_version 1.103.0 --code_settings settings.json",
543542
"selenium:run-tests:ingestr": "node webview-ui/scripts/copy-test-assets.js && extest setup-and-run './out/ui-test/ingestr-asset-ui-integration.test.js' --code_version 1.103.0 --code_settings settings.json",
543+
"selenium:run-tests:webview": "node webview-ui/scripts/copy-test-assets.js && extest setup-and-run './out/ui-test/webview-tests.test.js' --code_version 1.103.0 --code_settings settings.json",
544+
"selenium:run-tests:all": "npm run selenium:run-tests:connections && npm run selenium:run-tests:ingestr && npm run selenium:run-tests:webview",
544545
"test": "node ./out/test/runTest.js",
545546
"test:webview": "cd webview-ui && npm run test",
546547
"compile": "tsc -p ./",

src/extension/extension.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -661,21 +661,31 @@ export async function activate(context: ExtensionContext) {
661661
console.debug(`Bruin activated successfully in ${activationTime}ms`);
662662
console.timeEnd("Bruin Activation Total");
663663

664-
// Show walkthrough on first activation
664+
// Show walkthrough on first activation (unless in test environment)
665665
if (isFirstActivation) {
666666
await context.globalState.update('bruin.hasActivated', true);
667667

668-
// Show walkthrough when extension is first installed
669-
// Use a longer delay to ensure VS Code is fully loaded
670-
setTimeout(() => {
671-
vscode.commands.executeCommand('workbench.action.openWalkthrough', 'bruin.bruin-getting-started', true);
672-
}, 3000);
668+
// Check if we're in a test environment by looking for test-specific settings
669+
const workbenchConfig = workspace.getConfiguration("workbench");
670+
const walkthroughsDisabled = workbenchConfig.get<boolean>("welcomePage.walkthroughs.openOnInstall") === false;
671+
const startupEditorNone = workbenchConfig.get<string>("startupEditor") === "none";
672+
const isTestEnvironment = walkthroughsDisabled || startupEditorNone || process.env.NODE_ENV === 'test';
673673

674-
// Also show immediately if welcome tab is active
675-
if (vscode.window.tabGroups.activeTabGroup.activeTab?.label === 'Welcome') {
674+
if (!isTestEnvironment) {
675+
// Show walkthrough when extension is first installed
676+
// Use a longer delay to ensure VS Code is fully loaded
676677
setTimeout(() => {
677678
vscode.commands.executeCommand('workbench.action.openWalkthrough', 'bruin.bruin-getting-started', true);
678-
}, 500);
679+
}, 3000);
680+
681+
// Also show immediately if welcome tab is active
682+
if (vscode.window.tabGroups.activeTabGroup.activeTab?.label === 'Welcome') {
683+
setTimeout(() => {
684+
vscode.commands.executeCommand('workbench.action.openWalkthrough', 'bruin.bruin-getting-started', true);
685+
}, 500);
686+
}
687+
} else {
688+
console.log('Skipping walkthrough in test environment');
679689
}
680690
}
681691

0 commit comments

Comments
 (0)