Skip to content

Commit

Permalink
set UI version directly - not UI
Browse files Browse the repository at this point in the history
  • Loading branch information
pospisilf committed Jan 12, 2024
1 parent 6cb5627 commit 3dae953
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/ui-test/tests/env/set.camel.version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@
*/
import {
CATALOG_VERSION_ID,
CATALOG_VERSION_UI,
RESOURCES,
closeEditor,
readUserSetting,
setUserSettingsDirectly,
waitUntilExtensionIsActivated
} from '../../utils/testUtils';
import {
ActivityBar,
before,
VSBrowser,
WebDriver,
TextSetting,
Workbench
WebDriver
} from 'vscode-uitests-tooling';
import * as pjson from '../../../../package.json';
import { assert } from 'chai';

describe('Camel version', function () {
this.timeout(150000);
Expand All @@ -55,15 +53,10 @@ describe('Camel version', function () {
this.skip();
}

// set version in ui
const settings = await new Workbench().openSettings();
const textSetting = await settings.findSetting(CATALOG_VERSION_UI, 'Camel') as TextSetting;
await textSetting.setValue(process.env.CAMEL_VERSION);
await closeEditor('Settings', true);
// set version directly
await setUserSettingsDirectly(CATALOG_VERSION_ID, process.env.CAMEL_VERSION);

// wait until change is available in settings file
await driver.wait(async function () {
return readUserSetting(CATALOG_VERSION_ID) === process.env.CAMEL_VERSION;
}, 15000, `Camel Version - '${process.env.CAMEL_VERSION}' not set in time limit.`, 1500);
// check if version was set
assert.equal(readUserSetting(CATALOG_VERSION_ID), process.env.CAMEL_VERSION)
});
});
13 changes: 13 additions & 0 deletions src/ui-test/utils/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,19 @@ export function readUserSetting(id: string): string | null {
}
}

/**
* Set user setting directly inside settings.json
*
* @param id ID of setting.
* @param value Value of setting.
*/
export async function setUserSettingsDirectly(id: string, value: string): Promise<void> {
const settingsPath = path.resolve(storageFolder, 'settings', 'User', 'settings.json');
const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
settings[id] = value;
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 4), 'utf-8');
}

/**
* Delete file from folder.
*
Expand Down

0 comments on commit 3dae953

Please sign in to comment.