Skip to content

Commit

Permalink
fix OpenshiftConnector test
Browse files Browse the repository at this point in the history
  • Loading branch information
SkorikSergey committed Dec 10, 2020
1 parent 6e6b773 commit f4881c6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
5 changes: 5 additions & 0 deletions tests/e2e/TestConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ export const TestConstants = {
*/
TS_TEST_OPENSHIFT_PLUGIN_PROJECT: process.env.TS_TEST_OPENSHIFT_PLUGIN_PROJECT || '',

/**
* The name of project in the Openshidt plugin tree
*/
TS_TEST_OPENSHIFT_PLUGIN_COMPONENT_TYPE: process.env.TS_TEST_OPENSHIFT_PLUGIN_COMPONENT_TYPE || 'nodejs (s2i)',

/**
* Print all timeout variables when tests launch, defaulte to false
*/
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/TimeoutConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const TimeoutConstants = {
/**
* Wait for IDE showing project tree tab, "20 000" by default.
*/
TS_PROJECT_TREE_TIMEOUT: Number(process.env.TS_OPEN_PROJECT_TREE_TIMEOUT) || 20_000,
TS_PROJECT_TREE_TIMEOUT: Number(process.env.TS_OPEN_PROJECT_TREE_TIMEOUT) || 120_000,

/**
* Click on item timeout (project tree), "10 000" by default.
Expand Down Expand Up @@ -213,12 +213,12 @@ export const TimeoutConstants = {
/**
* Timeout for obtaining cluster IP, "10 000" by default.
*/
TS_GET_CLUSTER_IP_TIMEOUT: Number(process.env.TS_GET_CLUSTER_IP_TIMEOUT) || 10_000,
TS_GET_CLUSTER_IP_TIMEOUT: Number(process.env.TS_GET_CLUSTER_IP_TIMEOUT) || 120_000,

/**
* Timeout for waiting fr openshift connector tree, "10 000" by default.
*/
TS_WAIT_OPENSHIFT_CONNECTOR_TREE_TIMEOUT: Number(process.env.TS_WAIT_OPENSHIFT_CONNECTOR_TREE_TIMEOUT) || 10_000,
TS_WAIT_OPENSHIFT_CONNECTOR_TREE_TIMEOUT: Number(process.env.TS_WAIT_OPENSHIFT_CONNECTOR_TREE_TIMEOUT) || 40_000,

/**
* Timeout for creating CheCluster yaml, "10 000" by default.
Expand Down
7 changes: 6 additions & 1 deletion tests/e2e/pageobjects/ide/OpenshiftPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,19 @@ export class OpenshiftPlugin {

async clickOnOpenshiftToollBarIcon(timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM) {
Logger.debug(`OpenshiftPlugin.clickOnOpenshiftTollBar`);
await this.ide.waitAndClickLeftToolbarButton(LeftToolbarButton.Openshift, timeout);
await this.ide.waitAndClickLeftToolbarButton(LeftToolbarButton.Openshift, 60000);
}

async waitOpenshiftConnectorTree(timeout: number = TimeoutConstants.TS_WAIT_OPENSHIFT_CONNECTOR_TREE_TIMEOUT) {
Logger.debug(`OpenshiftPlugin.waitOpenshiftConnectorTree`);
await this.driverHelper.waitPresence(By.id('openshiftProjectExplorer'), timeout);
}

async clickOnOpenshiftConnectorTree(timeout: number = TimeoutConstants.TS_WAIT_OPENSHIFT_CONNECTOR_TREE_TIMEOUT) {
Logger.debug(`OpenshiftPlugin.waitOpenshiftConnectorTree`);
await this.driverHelper.waitAndClick(By.id('plugin-view:openshiftProjectExplorer'), timeout);
}

async clickOnApplicationToolbarItem(item: OpenshiftAppExplorerToolbar, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM) {
Logger.debug(`OpenshiftPlugin.clickOnApplicationToolbarItem`);
await this.driverHelper.waitAndClick(By.css(`div [title='${item}']`), timeout);
Expand Down
31 changes: 26 additions & 5 deletions tests/e2e/tests/e2e/OpenshiftConnector.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { TestConstants } from '../../TestConstants';
import { DriverHelper } from '../../utils/DriverHelper';
import { PreferencesHandler, TerminalRendererType } from '../../utils/PreferencesHandler';
import { TestWorkspaceUtil } from '../../utils/workspace/TestWorkspaceUtil';
import { WorkspaceNameHandler } from '../../utils/WorkspaceNameHandler';
import * as workspaceHandling from '../../testsLibrary/WorksapceHandlingTests';


const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper);
Expand Down Expand Up @@ -83,27 +85,34 @@ suite('Openshift connector user story', async () => {
const provideAuthenticationSuffix: string = `for basic authentication to the API server ${selectSugestionSuffix}`;
const loginIntoClusterMessage: string = 'You are already logged in the cluster. Do you want to login to a different cluster?';
const openshiftIP: string = await openshiftPlugin.getClusterIP();

await openshiftPlugin.clickOnOpenshiftConnectorTree();
await openshiftPlugin.clickOnApplicationToolbarItem(OpenshiftAppExplorerToolbar.LogIntoCluster);
await ide.clickOnNotificationButton(loginIntoClusterMessage, 'Yes');
await quickOpenContainer.clickOnContainerItem('Credentials');
await quickOpenContainer.clickOnContainerItem(`https://${openshiftIP}`);
await quickOpenContainer.clickOnContainerItem('$(plus) Add new user...');
await quickOpenContainer.typeAndSelectSuggestion(TestConstants.TS_TEST_OPENSHIFT_PLUGIN_USERNAME, `Provide Username ${provideAuthenticationSuffix}`);
await quickOpenContainer.typeAndSelectSuggestion(TestConstants.TS_TEST_OPENSHIFT_PLUGIN_PASSWORD, `Provide Password ${provideAuthenticationSuffix}`);

// change active folder
await topMenu.selectOption('View', 'Find Command...');
await quickOpenContainer.typeAndSelectSuggestion('OpenShift: Set Active Project', 'OpenShift: Set Active Project');
await quickOpenContainer.typeAndSelectSuggestion(TestConstants.TS_TEST_OPENSHIFT_PLUGIN_PROJECT, TestConstants.TS_TEST_OPENSHIFT_PLUGIN_PROJECT);
await openshiftPlugin.clickOnItemInTree(openshiftIP);
await openshiftPlugin.waitItemInTree(TestConstants.TS_TEST_OPENSHIFT_PLUGIN_PROJECT);
});

test('Create new component with application', async () => {
await topMenu.selectOption('View', 'Find Command...');
await quickOpenContainer.typeAndSelectSuggestion('OpenShift: New Component', 'OpenShift: New Component from local folder');
await quickOpenContainer.clickOnContainerItem(TestConstants.TS_TEST_OPENSHIFT_PLUGIN_PROJECT);
await quickOpenContainer.clickOnContainerItem('$(plus) Create new Application...');
await quickOpenContainer.typeAndSelectSuggestion('node-js-app', `Provide Application name ${selectSugestionSuffix}` );
await quickOpenContainer.clickOnContainerItem('$(plus) Add new context folder.');
await openDialogWidget.selectLocationAndAddContextFolder(Locations.Root, `projects/${projectName}`, Buttons.AddContext);
await quickOpenContainer.typeAndSelectSuggestion('component-node-js', `Provide Component name ${selectSugestionSuffix}`);

await quickOpenContainer.clickOnContainerItem('nodejs');
await quickOpenContainer.clickOnContainerItem(TestConstants.TS_TEST_OPENSHIFT_PLUGIN_COMPONENT_TYPE);
await quickOpenContainer.clickOnContainerItem('latest');

await openshiftPlugin.clickOnItemInTree(TestConstants.TS_TEST_OPENSHIFT_PLUGIN_PROJECT);
Expand All @@ -114,10 +123,22 @@ suite('Openshift connector user story', async () => {
test('Push new component', async () => {
driverHelper.getDriver().switchTo().activeElement().sendKeys(Key.F1);
await quickOpenContainer.typeAndSelectSuggestion(OpenshiftContextMenuItems.Push, 'OpenShift: Push Component');
await quickOpenContainer.clickOnContainerItem(TestConstants.TS_TEST_OPENSHIFT_PLUGIN_PROJECT);
await quickOpenContainer.clickOnContainerItem('node-js-app');
await quickOpenContainer.clickOnContainerItem('component-node-js');
await terminal.selectTabByPrefixAndWaitText('OpenShift: Push', 'Changes successfully pushed to component', 30_000);
await quickOpenContainer.clickOnContainerItem('component-node-js (s2i)');
await terminal.selectTabByPrefixAndWaitText('OpenShift: Push', 'Changes successfully pushed to component', 120_000);
});

suite ('Stopping and deleting the workspace', async () => {
let workspaceName = 'not defined';
suiteSetup( async () => {
workspaceName = await WorkspaceNameHandler.getNameFromUrl();
});
test (`Stop workspace`, async () => {
await workspaceHandling.stopWorkspace(workspaceName);
});
test (`Remove workspace`, async () => {
await workspaceHandling.removeWorkspace(workspaceName);
});
});

});

0 comments on commit f4881c6

Please sign in to comment.