Skip to content

Commit

Permalink
fix: import project test
Browse files Browse the repository at this point in the history
Signed-off-by: mdolhalo <[email protected]>
  • Loading branch information
mdolhalo committed Sep 29, 2023
1 parent d0388b1 commit a49cec7
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 82 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/pageobjects/dashboard/Dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class Dashboard {
await this.driverHelper.waitAndClick(Dashboard.ABOUT_DIALOG_WINDOW_CLOSE_BUTTON);
}

async waitExistingWorkspaceFoundAlert(timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
async waitExistingWorkspaceFoundAlert(timeout: number = TIMEOUT_CONSTANTS.TS_WAIT_LOADER_PRESENCE_TIMEOUT): Promise<void> {
Logger.debug();

await this.driverHelper.waitVisibility(Dashboard.EXISTING_WORKSPACE_FOUND_ALERT, timeout);
Expand Down
17 changes: 8 additions & 9 deletions tests/e2e/specs/SmokeTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import { SideBarView, ViewItem, ViewSection } from 'monaco-page-objects';
import { ViewSection } from 'monaco-page-objects';
import { ProjectAndFileTests } from '../tests-library/ProjectAndFileTests';
import { CLASSES } from '../configs/inversify.types';
import { e2eContainer } from '../configs/inversify.config';
import { WorkspaceHandlingTests } from '../tests-library/WorkspaceHandlingTests';
import { registerRunningWorkspace } from './MochaHooks';
import { Logger } from '../utils/Logger';
import { LoginTests } from '../tests-library/LoginTests';
import { StringUtil } from '../utils/StringUtil';
import { FACTORY_TEST_CONSTANTS } from '../constants/FACTORY_TEST_CONSTANTS';
Expand Down Expand Up @@ -45,15 +44,15 @@ suite('The SmokeTest userstory', function (): void {
});
test('Check a project folder has been created', async function (): Promise<void> {
const projectName: string = FACTORY_TEST_CONSTANTS.TS_SELENIUM_PROJECT_NAME || StringUtil.getProjectNameFromGitUrl(factoryUrl);
projectSection = (await new SideBarView().getContent().getSections())[0]; // get the (WORKSPACE) section from the sidebar - contains project content
expect(await projectSection.findItem(projectName)).not.eqls(undefined);
projectSection = await projectAndFileTests.getProjectViewSession();
expect(await projectAndFileTests.getProjectTreeItem(projectSection, projectName), 'Project folder was not imported').not
.undefined;
});
test('Check the project files was imported', async function (): Promise<void> {
Logger.debug(`projectSection.findItem: find ${BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME}`);
const isFileImported: ViewItem | undefined = await projectSection.findItem(
BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME
);
expect(isFileImported).not.eqls(undefined);
expect(
await projectAndFileTests.getProjectTreeItem(projectSection, BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME),
'Project files were not imported'
).not.undefined;
});
test('Stop the workspace', async function (): Promise<void> {
await workspaceHandlingTests.stopWorkspace(WorkspaceHandlingTests.getWorkspaceName());
Expand Down
20 changes: 13 additions & 7 deletions tests/e2e/specs/dashboard-samples/Quarkus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/

import { SideBarView, ViewSection } from 'monaco-page-objects';
import { ViewSection } from 'monaco-page-objects';
import { registerRunningWorkspace } from '../MochaHooks';
import { LoginTests } from '../../tests-library/LoginTests';
import { e2eContainer } from '../../configs/inversify.config';
import { CLASSES } from '../../configs/inversify.types';
import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests';
import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests';
import { Logger } from '../../utils/Logger';
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
import { expect } from 'chai';

const stackName: string = 'Java 11 with Quarkus';

Expand All @@ -28,7 +28,6 @@ suite(`The ${stackName} userstory`, function (): void {
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);

let projectSection: ViewSection;

const projectName: string = 'quarkus-quickstarts';

loginTests.loginIntoChe();
Expand All @@ -50,13 +49,19 @@ suite(`The ${stackName} userstory`, function (): void {
});

test('Check a project folder has been created', async function (): Promise<void> {
projectSection = await new SideBarView().getContent().getSection(projectName);
Logger.debug(`new SideBarView().getContent().getSection: get ${projectName}`);
projectSection = await projectAndFileTests.getProjectViewSession();
expect(await projectAndFileTests.getProjectTreeItem(projectSection, projectName), 'Project folder was not imported').not.undefined;
});

test('Accept the project as a trusted one', async function (): Promise<void> {
await projectAndFileTests.performTrustAuthorDialog();
});

test('Check the project files was imported', async function (): Promise<void> {
await projectSection.findItem(BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME);
Logger.debug(`projectSection.findItem: find ${BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME}`);
expect(
await projectAndFileTests.getProjectTreeItem(projectSection, BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME, 2),
'Project files were not imported'
).not.undefined;
});

test('Stop the workspace', async function (): Promise<void> {
Expand All @@ -67,5 +72,6 @@ suite(`The ${stackName} userstory`, function (): void {
test('Delete the workspace', async function (): Promise<void> {
await workspaceHandlingTests.removeWorkspace(WorkspaceHandlingTests.getWorkspaceName());
});

loginTests.logoutFromChe();
});
14 changes: 6 additions & 8 deletions tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,18 @@ for (const sample of samples) {
});

test('Check the project files were imported', async function (): Promise<void> {
const [projectSection]: ViewSection[] = await new SideBarView().getContent().getSections();
expect(await projectSection.findItem(pathToExtensionsListFileName), 'Files not imported').not.undefined;
projectSection = await projectAndFileTests.getProjectViewSession();
expect(await projectAndFileTests.getProjectTreeItem(projectSection, pathToExtensionsListFileName), 'Files not imported').not
.undefined;
});

test('Accept the project as a trusted one', async function (): Promise<void> {
await projectAndFileTests.performTrustAuthorDialog();
});

test(`Get recommended extensions list from ${extensionsListFileName}`, async function (): Promise<void> {
Logger.debug('projectSection.findItem(item))?.select(): expand .vscode folder and open extensions.json.');
[projectSection] = await new SideBarView().getContent().getSections();
await (await projectSection.findItem(pathToExtensionsListFileName))?.select();
await driverHelper.waitVisibility(webCheCodeLocators.DefaultTreeItem.ctor(extensionsListFileName));
await (await projectSection.findItem(extensionsListFileName))?.select();
await (await projectAndFileTests.getProjectTreeItem(projectSection, pathToExtensionsListFileName))?.select();
await (await projectAndFileTests.getProjectTreeItem(projectSection, extensionsListFileName, 3))?.select();
Logger.debug(`EditorView().openEditor(${extensionsListFileName})`);
const editor: TextEditor = (await new EditorView().openEditor(extensionsListFileName)) as TextEditor;
await driverHelper.waitVisibility(webCheCodeLocators.Editor.inputArea);
Expand Down Expand Up @@ -185,7 +183,7 @@ for (const sample of samples) {
const isInstalled: boolean = (await itemWithRightNameAndPublisher?.isInstalled()) as boolean;

Logger.debug(`itemWithRightNameAndPublisher?.isInstalled(): ${isInstalled}.`);
expect(isInstalled, `Extension ${extension.name} not installed`).is.true;
expect(isInstalled, `Extension ${extension.name} not installed`).to.be.true;

Logger.debug('itemWithRightNameAndPublisher.manage(): get context menu.');
const extensionManageMenu: ContextMenu = await (itemWithRightNameAndPublisher as ExtensionsViewItem).manage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/

import { SideBarView, ViewItem, ViewSection } from 'monaco-page-objects';
import { ViewSection } from 'monaco-page-objects';
import { registerRunningWorkspace } from '../MochaHooks';
import { LoginTests } from '../../tests-library/LoginTests';
import { e2eContainer } from '../../configs/inversify.config';
Expand Down Expand Up @@ -88,9 +88,15 @@ suite('DevConsole Integration', function (): void {

test('Check if project and files imported', async function (): Promise<void> {
const applicationSourceProjectName: string = StringUtil.getProjectNameFromGitUrl(gitImportRepo);
const projectSection: ViewSection = await new SideBarView().getContent().getSection(applicationSourceProjectName);
const isFileImported: ViewItem | undefined = await projectSection.findItem(BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME);
expect(isFileImported).not.eqls(undefined);
const projectSection: ViewSection = await projectAndFileTests.getProjectViewSession();
expect(
await projectAndFileTests.getProjectTreeItem(projectSection, applicationSourceProjectName),
'Project folder was not imported'
).not.undefined;
expect(
await projectAndFileTests.getProjectTreeItem(projectSection, BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME),
'Project files were not imported'
).not.undefined;
});

test('Stop and delete the workspace by API', async function (): Promise<void> {
Expand Down
20 changes: 9 additions & 11 deletions tests/e2e/specs/factory/Factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ import {
EditorView,
Locators,
NewScmView,
SideBarView,
SingleScmProvider,
TextEditor,
ViewControl,
ViewItem,
ViewSection
} from 'monaco-page-objects';
import { expect } from 'chai';
Expand Down Expand Up @@ -92,20 +90,20 @@ suite(
test('Check if a project folder has been created', async function (): Promise<void> {
testRepoProjectName = StringUtil.getProjectNameFromGitUrl(FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL);
Logger.debug(`new SideBarView().getContent().getSection: get ${testRepoProjectName}`);
projectSection = await new SideBarView().getContent().getSection(testRepoProjectName);
});

test('Check if the project files were imported', async function (): Promise<void> {
const label: string = BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME;
Logger.debug(`projectSection.findItem: find ${label}`);
const isFileImported: ViewItem | undefined = await projectSection.findItem(label);
expect(isFileImported).not.eqls(undefined);
projectSection = await projectAndFileTests.getProjectViewSession();
expect(await projectAndFileTests.getProjectTreeItem(projectSection, testRepoProjectName), 'Project folder was not imported').not
.undefined;
});

test('Accept the project as a trusted one', async function (): Promise<void> {
await projectAndFileTests.performTrustAuthorDialog();
});

test('Check if the project files were imported', async function (): Promise<void> {
const label: string = BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME;
expect(await projectAndFileTests.getProjectTreeItem(projectSection, label), 'Project files were not imported').not.undefined;
});

test('Make changes to the file', async function (): Promise<void> {
Logger.debug(`projectSection.openItem: "${fileToChange}"`);
await projectSection.openItem(fileToChange);
Expand Down Expand Up @@ -186,7 +184,7 @@ suite(
webCheCodeLocators.ScmView.actionConstructor(commitChangesButtonLabel),
'aria-disabled'
);
expect(isCommitButtonDisabled).eql('true');
expect(isCommitButtonDisabled).to.be.true;
});

test('Stop the workspace', async function (): Promise<void> {
Expand Down
15 changes: 6 additions & 9 deletions tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ import {
Locators,
ModalDialog,
NewScmView,
SideBarView,
SingleScmProvider,
TextEditor,
ViewControl,
ViewItem,
ViewSection
} from 'monaco-page-objects';
import { expect } from 'chai';
Expand Down Expand Up @@ -116,19 +114,18 @@ suite(

test('Check if a project folder has been created', async function (): Promise<void> {
testRepoProjectName = StringUtil.getProjectNameFromGitUrl(FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL);
Logger.debug(`new SideBarView().getContent().getSection: get ${testRepoProjectName}`);
projectSection = await new SideBarView().getContent().getSection(testRepoProjectName);
projectSection = await projectAndFileTests.getProjectViewSession();
expect(await projectAndFileTests.getProjectTreeItem(projectSection, testRepoProjectName), 'Project folder was not imported')
.not.undefined;
});

test('Accept the project as a trusted one', async function (): Promise<void> {
await projectAndFileTests.performTrustAuthorDialog();
});

test('Check if the project files were imported', async function (): Promise<void> {
Logger.debug(`projectSection.findItem: find ${label}`);
const isFileImported: ViewItem | undefined = await projectSection.findItem(label);
// projectSection.findItem(label) can return undefined but test will goes on
expect(isFileImported).not.eqls(undefined);
expect(await projectAndFileTests.getProjectTreeItem(projectSection, label), 'Project files were not imported').not
.undefined;
});

test('Make changes to the file', async function (): Promise<void> {
Expand Down Expand Up @@ -243,7 +240,7 @@ suite(
webCheCodeLocators.ScmView.actionConstructor(commitChangesButtonLabel),
'aria-disabled'
);
expect(isCommitButtonDisabled).eql('true');
expect(isCommitButtonDisabled).to.be.true;
});

test('Stop the workspace', async function (): Promise<void> {
Expand Down
18 changes: 7 additions & 11 deletions tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ import {
Locators,
ModalDialog,
NewScmView,
SideBarView,
SingleScmProvider,
TextEditor,
ViewControl,
ViewItem,
ViewSection
} from 'monaco-page-objects';
import { expect } from 'chai';
Expand Down Expand Up @@ -99,8 +97,9 @@ suite(

test('Check if a project folder has been created', async function (): Promise<void> {
testRepoProjectName = StringUtil.getProjectNameFromGitUrl(FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL);
Logger.debug(`new SideBarView().getContent().getSection: get ${testRepoProjectName}`);
projectSection = await new SideBarView().getContent().getSection(testRepoProjectName);
projectSection = await projectAndFileTests.getProjectViewSession();
expect(await projectAndFileTests.getProjectTreeItem(projectSection, testRepoProjectName), 'Project folder was not imported').not
.undefined;
});

test('Accept the project as a trusted one', async function (): Promise<void> {
Expand All @@ -116,15 +115,12 @@ suite(
});

test('Check that project files were not imported', async function (): Promise<void> {
const isFileImported: ViewItem | undefined = await projectSection.findItem(label);
expect(isFileImported).eqls(undefined);
expect(await projectAndFileTests.getProjectTreeItem(projectSection, label), 'Project files were found').to.be.undefined;
});
} else {
test('Check if the project files were imported', async function (): Promise<void> {
Logger.debug(`projectSection.findItem: find ${label}`);
const isFileImported: ViewItem | undefined = await projectSection.findItem(label);
// projectSection.findItem(label) can return undefined but test will goes on
expect(isFileImported).not.eqls(undefined);
expect(await projectAndFileTests.getProjectTreeItem(projectSection, label), 'Project files were not imported').not
.undefined;
});

test('Make changes to the file', async function (): Promise<void> {
Expand Down Expand Up @@ -231,7 +227,7 @@ suite(
webCheCodeLocators.ScmView.actionConstructor(commitChangesButtonLabel),
'aria-disabled'
);
expect(isCommitButtonDisabled).eql('true');
expect(isCommitButtonDisabled).to.be.true;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import { e2eContainer } from '../../configs/inversify.config';
import { ViewSection, SideBarView, ViewItem } from 'monaco-page-objects';
import { ViewSection } from 'monaco-page-objects';
import { CLASSES } from '../../configs/inversify.types';
import { expect } from 'chai';
import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests';
Expand Down Expand Up @@ -42,9 +42,12 @@ suite('"Start workspace with existed workspace name" test', function (): void {

test('Wait workspace readiness and project folder has been created', async function (): Promise<void> {
await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor();
projectSection = await new SideBarView().getContent().getSection(projectName);
const isFileImported: ViewItem | undefined = await projectSection.findItem(BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME);
expect(isFileImported).not.eqls(undefined);
projectSection = await projectAndFileTests.getProjectViewSession();
expect(await projectAndFileTests.getProjectTreeItem(projectSection, projectName), 'Project folder was not imported').not.undefined;
expect(
await projectAndFileTests.getProjectTreeItem(projectSection, BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME),
'Project files were not imported'
).not.undefined;
});

test('Stop created workspace', async function (): Promise<void> {
Expand All @@ -65,9 +68,12 @@ suite('"Start workspace with existed workspace name" test', function (): void {

test('Wait the second workspace readiness and project folder has been created', async function (): Promise<void> {
await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor();
projectSection = await new SideBarView().getContent().getSection(projectName);
const isFileImported: ViewItem | undefined = await projectSection.findItem(BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME);
expect(isFileImported).not.eqls(undefined);
projectSection = await projectAndFileTests.getProjectViewSession();
expect(await projectAndFileTests.getProjectTreeItem(projectSection, projectName), 'Project folder was not imported').not.undefined;
expect(
await projectAndFileTests.getProjectTreeItem(projectSection, BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME),
'Project files were not imported'
).not.undefined;
});

test(`Stop all created ${stackName} workspaces`, async function (): Promise<void> {
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/specs/miscellaneous/KubedockPodmanTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import { SideBarView, ViewSection } from 'monaco-page-objects';
import { ViewSection } from 'monaco-page-objects';
import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests';
import { CLASSES } from '../../configs/inversify.types';
import { e2eContainer } from '../../configs/inversify.config';
Expand Down Expand Up @@ -66,8 +66,8 @@ suite('Check possibility to manage containers within a workspace with kubedock a
});

test('Check the project files were imported', async function (): Promise<void> {
const [projectSection]: ViewSection[] = await new SideBarView().getContent().getSections();
expect(await projectSection.findItem('Dockerfile'), 'Files not imported').not.undefined;
const projectSection: ViewSection = await projectAndFileTests.getProjectViewSession();
expect(await projectAndFileTests.getProjectTreeItem(projectSection, 'Dockerfile'), 'Files not imported').not.undefined;
});

test('Create and check container runs using kubedock and podman', function (): void {
Expand Down
Loading

0 comments on commit a49cec7

Please sign in to comment.