Skip to content

Commit

Permalink
Add version to plugin.
Browse files Browse the repository at this point in the history
Signed-off-by: kkanova <[email protected]>
  • Loading branch information
Katka92 committed Jun 10, 2019
1 parent 5fd9715 commit 4b0254d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ export class WorkspaceDetailsPlugins {
await this.driverHelper.waitVisibility(pluginListItemLocator, timeout);
}

async enablePlugin(pluginName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
await this.waitPluginDisabling(pluginName, timeout);
await this.clickOnPluginListItemSwitcher(pluginName, undefined, timeout);
await this.waitPluginEnabling(pluginName, timeout);
async enablePlugin(pluginName: string, pluginVersion?: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
await this.waitPluginDisabling(pluginName, pluginVersion, timeout);
await this.clickOnPluginListItemSwitcher(pluginName, pluginVersion, timeout);
await this.waitPluginEnabling(pluginName, pluginVersion, timeout);
}

async disablePlugin(pluginName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
await this.waitPluginEnabling(pluginName, timeout);
await this.clickOnPluginListItemSwitcher(pluginName, undefined, timeout);
await this.waitPluginDisabling(pluginName, timeout);
async disablePlugin(pluginName: string, pluginVersion?: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
await this.waitPluginEnabling(pluginName, pluginVersion, timeout);
await this.clickOnPluginListItemSwitcher(pluginName, pluginVersion, timeout);
await this.waitPluginDisabling(pluginName, pluginVersion, timeout);
}

async addPluginAndOpenWorkspace(namespace: string, workspaceName: string, pluginName: string, pluginId: string) {
async addPluginAndOpenWorkspace(namespace: string, workspaceName: string, pluginName: string, pluginId: string, pluginVersion?: string) {
await this.workspaceDetails.selectTab('Plugins');
await this.enablePlugin(pluginName);
await this.enablePlugin(pluginName, pluginVersion);
await this.workspaceDetails.saveChanges();
await this.workspaceDetails.openWorkspace(namespace, workspaceName);
await this.testWorkspaceUtil.waitWorkspaceStatus(namespace, workspaceName, WorkspaceStatus.RUNNING);
Expand All @@ -52,10 +52,10 @@ export class WorkspaceDetailsPlugins {

private getPluginListItemCssLocator(pluginName: string, pluginVersion?: string): string {
if (pluginVersion) {
return `.plugin-item div[plugin-item-name='${pluginName}'][plugin-item-version='${pluginVersion}']`;
return `.plugin-item div[plugin-item-name*='${pluginName}'][plugin-item-version='${pluginVersion}']`;
}

return `.plugin-item div[plugin-item-name='${pluginName}']`;
return `.plugin-item div[plugin-item-name*='${pluginName}']`;
}

private getPluginListItemSwitcherCssLocator(pluginName: string, pluginVersion?: string): string {
Expand All @@ -71,14 +71,14 @@ export class WorkspaceDetailsPlugins {
await this.driverHelper.waitAndClick(pluginListItemSwitcherLocator, timeout);
}

private async waitPluginEnabling(pluginName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
const enabledPluginSwitcherLocator: By = By.css(`${this.getPluginListItemCssLocator(pluginName)} md-switch[aria-checked='true']`);
private async waitPluginEnabling(pluginName: string, pluginVersion?: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
const enabledPluginSwitcherLocator: By = By.css(`${this.getPluginListItemCssLocator(pluginName, pluginVersion)} md-switch[aria-checked='true']`);

await this.driverHelper.waitVisibility(enabledPluginSwitcherLocator, timeout);
}

private async waitPluginDisabling(pluginName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
const disabledPluginSwitcherLocator: By = By.css(`${this.getPluginListItemCssLocator(pluginName)} md-switch[aria-checked='false']`);
private async waitPluginDisabling(pluginName: string, pluginVersion?: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
const disabledPluginSwitcherLocator: By = By.css(`${this.getPluginListItemCssLocator(pluginName, pluginVersion)} md-switch[aria-checked='false']`);

await this.driverHelper.waitVisibility(disabledPluginSwitcherLocator, timeout);
}
Expand Down
7 changes: 4 additions & 3 deletions e2e/tests/e2e/WorkspaceCreationAndLsInitialization.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import { Editor } from '../../pageobjects/ide/Editor';
const workspaceName: string = NameGenerator.generate('wksp-test-', 5);
const namespace: string = 'che';
const sampleName: string = 'console-java-simple';
const pluginId: string = 'redhat/java/0.38.0';
const javaPluginName: string = 'Language Support for Java(TM)';
const pluginId: string = 'redhat/java/0.45.0';
const pluginVersion: string = '0.45.0';
const javaPluginName: string = `Language Support for Java`;
const fileFolderPath: string = `${sampleName}/src/main/java/org/eclipse/che/examples`;
const tabTitle: string = 'HelloWorld.java';

Expand Down Expand Up @@ -53,7 +54,7 @@ suite('E2E', async () => {
});

test('Add \'Java Language Support\' plugin to workspace', async () => {
await workspaceDetailsPlugins.addPluginAndOpenWorkspace(namespace, workspaceName, javaPluginName, pluginId);
await workspaceDetailsPlugins.addPluginAndOpenWorkspace(namespace, workspaceName, javaPluginName, pluginId, pluginVersion);
});

});
Expand Down
6 changes: 3 additions & 3 deletions e2e/utils/workspace/TestWorkspaceUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class TestWorkspaceUtil {
throw new Error(`Exceeded the maximum number of checking attempts, workspace status is different to '${expectedWorkspaceStatus}'`);
}

public async waitPluginAdding(namespace: string, workspaceName: string, pluginName: string) {
public async waitPluginAdding(namespace: string, workspaceName: string, pluginId: string) {
const workspaceStatusApiUrl: string = `${TestConstants.TS_SELENIUM_BASE_URL}/api/workspace/${namespace}:${workspaceName}`;
const attempts: number = TestConstants.TS_SELENIUM_PLUGIN_PRECENCE_ATTEMPTS;
const polling: number = TestConstants.TS_SELENIUM_PLUGIN_PRECENCE_POLLING;
Expand All @@ -65,14 +65,14 @@ export class TestWorkspaceUtil {
}

const machines: string = JSON.stringify(response.result.runtime.machines);
const isPluginPresent: boolean = machines.search(pluginName) > 0;
const isPluginPresent: boolean = machines.search(pluginId) > 0;

if (isPluginPresent) {
break;
}

if (i === attempts - 1) {
throw new Error(`Exceeded maximum tries attempts, the '${pluginName}' plugin is not present in the workspace runtime.`);
throw new Error(`Exceeded maximum tries attempts, the '${pluginId}' plugin is not present in the workspace runtime.`);
}

await this.driverHelper.wait(polling);
Expand Down

0 comments on commit 4b0254d

Please sign in to comment.