Skip to content

Commit

Permalink
Merge pull request #53 from konveyor/debug_tests
Browse files Browse the repository at this point in the history
[RFR] Debug tests
  • Loading branch information
sshveta authored Jan 28, 2025
2 parents 85c555b + aa550e7 commit 999edf6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
8 changes: 4 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
# Instead, copy it, remove the .example extension and provide your custom values
# For git password please use your generated git token, not a clear text password

VSIX_FILE_NAME='konveyor-v0.0.5.vsix'
DEFAULT_VSIX_DOWNLOAD_URL= 'https://github.com/konveyor/editor-extensions/releases/download/v0.0.5/konveyor-v0.0.5.vsix'
VSIX_FILE_NAME='konveyor-v0.0.6.vsix'
DEFAULT_VSIX_DOWNLOAD_URL= 'https://github.com/konveyor/editor-extensions/releases/download/v0.0.6/konveyor-v0.0.6.vsix'
PLUGIN_URL= 'https://github.com/konveyor/editor-extensions/releases/download/'
PLUGIN_VERSION= 'v0.0.5'
PLUGIN_VERSION= 'v0.0.6'

# For Windows Path needs to be given in below format
WINDOWS_VSCODE_EXECUTABLE_PATH='C:/Users/nonadmin/AppData/Local/Programs/Microsoft VS Code/Code.exe'
WINDOWS_VSCODE_EXECUTABLE_PATH='C:/Program Files/Microsoft VS Code/Code.exe'

# For Linux
VSCODE_EXECUTABLE_PATH='/usr/share/code/code'
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/windows-nightly-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ jobs:
run: choco install maven -y
shell: powershell

- name: Install VSCode as admin
run: choco install vscode -y
shell: powershell

run-test-as-nonadmin:
needs: [ start-ec2-instance, install-requirements-as-admin]
runs-on: ubuntu-latest
Expand All @@ -60,7 +64,7 @@ jobs:
echo "set PATH=%PATH%;%nodePath%" >> execute-tests.bat
echo "cd C:\\Users\\nonadmin\\kai-ci" >> execute-tests.bat
echo "copy .env.example .env" >> execute-tests.bat
echo "npx playwright test" >> execute-tests.bat
echo "npx playwright test --reporter=list" >> execute-tests.bat
shell: bash

- name: Copy batch file to Windows EC2 instance
Expand Down
16 changes: 8 additions & 8 deletions e2e/pages/vscode.pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import {
} from 'playwright';
import { execSync } from 'child_process';
import { downloadLatestKAIPlugin } from '../utilities/download.utils';
import { getKAIPluginName, getOSInfo } from '../utilities/utils';
import {
getKAIPluginName,
getOSInfo,
getVscodeExecutablePath,
} from '../utilities/utils';
import * as path from 'path';

class VSCode {
Expand All @@ -20,15 +24,10 @@ class VSCode {

/**
* launches VSCode with KAI plugin installed and coolstore app opened.
* @param executablePath path to the vscode binary
* @param repoUrl coolstore app to be cloned
* @param cloneDir path to repo
*/
public static async init(
executablePath: string,
repoUrl: string,
cloneDir: string
): Promise<VSCode> {
public static async init(repoUrl: string, cloneDir: string): Promise<VSCode> {
try {
console.log('Cloning repo');
execSync(`git clone ${repoUrl}`);
Expand All @@ -51,10 +50,11 @@ class VSCode {
'VSIX_FILE_PATH environment variable is not set. Skipping extension installation.'
);
}

console.log('launching vscode ... ');
// Launch VSCode as an Electron app
const vscodeApp = await electron.launch({
executablePath: executablePath,
executablePath: getVscodeExecutablePath(),
args: [path.resolve(cloneDir), '--disable-workspace-trust'],
});

Expand Down
7 changes: 1 addition & 6 deletions e2e/tests/vscode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ test.describe('VSCode Tests', () => {

test.beforeAll(async () => {
test.setTimeout(60000);
const executablePath =
getOSInfo() == 'windows'
? process.env.WINDOWS_VSCODE_EXECUTABLE_PATH
: process.env.VSCODE_EXECUTABLE_PATH;
console.log(`VSCode executable path: ${executablePath}`);
vscodeApp = await VSCode.init(executablePath, repoUrl, 'coolstore');
vscodeApp = await VSCode.init(repoUrl, 'coolstore');
});

test('Should launch VSCode and check window title', async () => {
Expand Down
11 changes: 10 additions & 1 deletion e2e/utilities/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function getOSInfo(): string {
}

export function getKAIPluginName(): string {
const vsixFileName = process.env.VSIX_FILE_NAME || 'konveyor-v0.0.4.vsix';
const vsixFileName = process.env.VSIX_FILE_NAME || 'konveyor-v0.0.6.vsix';
return vsixFileName;
}

Expand All @@ -50,3 +50,12 @@ export async function uninstallExtension() {
console.error('Error uninstalling Konveyor extension:', error);
}
}

export function getVscodeExecutablePath() {
const executablePath =
getOSInfo() == 'windows'
? process.env.WINDOWS_VSCODE_EXECUTABLE_PATH
: process.env.VSCODE_EXECUTABLE_PATH || '/usr/share/code/code';
console.log(`VSCode executable path: ${executablePath}`);
return executablePath;
}

0 comments on commit 999edf6

Please sign in to comment.