Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SmokeTest utilizing Quarkus REST API #22085

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/e2e/configs/mocharc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
`dist/specs/${process.env.MOCHA_DIRECTORY}/${process.env.USERSTORY}.spec.js`
: `dist/specs/${process.env.MOCHA_DIRECTORY}/**.spec.js`
: process.env.USERSTORY ?
`dist/specs/**/${process.env.USERSTORY}.spec.js`
: `dist/specs/**/**.spec.js`,
[`dist/specs/**/${process.env.USERSTORY}.spec.js`, `dist/specs/${process.env.USERSTORY}.spec.js`]
: [`dist/specs/**/**.spec.js`, `dist/specs/**.spec.js`],
retries: TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
};
1,937 changes: 4 additions & 1,933 deletions tests/e2e/package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions tests/e2e/pageobjects/dashboard/CreateWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ export class CreateWorkspace {
await this.driverHelper.waitAndClick(sampleLocator, timeout);
}

async startWorkspaceUsingFactory(factoryUrl: string, timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise<void> {
Logger.debug(`CreateWorkspace.startWorkspaceUsingFactory factoryUrl: "${factoryUrl}"`);
await this.driverHelper.waitVisibility(CreateWorkspace.FACTORY_URL_LOCATOR, timeout);
await this.driverHelper.type(CreateWorkspace.FACTORY_URL_LOCATOR, Key.chord(factoryUrl, Key.ENTER), timeout);
}

async clickOnSampleForSpecificEditor(sampleName: string, timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise<void> {
await this.clickOnEditorsDropdownListButton(sampleName, timeout);

Expand All @@ -59,6 +53,12 @@ export class CreateWorkspace {
await this.driverHelper.waitAndClick(sampleLocator, timeout);
}

async importFromGitUsingUI(factoryUrl: string, timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise<void> {
Logger.debug(`CreateWorkspace.importFromGitUsingUI factoryUrl: "${factoryUrl}"`);
await this.driverHelper.waitVisibility(CreateWorkspace.FACTORY_URL_LOCATOR, timeout);
await this.driverHelper.type(CreateWorkspace.FACTORY_URL_LOCATOR, Key.chord(factoryUrl, Key.ENTER), timeout);
}

private async clickOnEditorsDropdownListButton(sampleName: string, timeout: number): Promise<void> {
Logger.debug(`CreateWorkspace.clickOnSample sampleName: "${sampleName}, editor ${TestConstants.TS_SELENIUM_EDITOR}"`);

Expand Down
6 changes: 1 addition & 5 deletions tests/e2e/pageobjects/dashboard/Dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@
**********************************************************************/
import { inject, injectable } from 'inversify';
import 'reflect-metadata';
import { CLASSES, TYPES } from '../../configs/inversify.types';
import { CLASSES } from '../../configs/inversify.types';
import { By } from 'selenium-webdriver';
import { DriverHelper } from '../../utils/DriverHelper';
import { TestConstants } from '../../constants/TestConstants';
import { TimeoutConstants } from '../../constants/TimeoutConstants';
import { Workspaces } from './Workspaces';
import { Logger } from '../../utils/Logger';
import { ICheLoginPage } from '../login/ICheLoginPage';
import { RegularUserOcpCheLoginPage } from '../login/RegularUserOcpCheLoginPage';
import { OcpRedHatLoginPage } from '../login/OcpRedHatLoginPage';
import { e2eContainer } from '../../configs/inversify.config';

@injectable()
export class Dashboard {
Expand Down
50 changes: 50 additions & 0 deletions tests/e2e/specs/SmokeTest.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*********************************************************************
* Copyright (c) 2023 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import { SideBarView, 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';

const factoryUrl: string = 'https://github.com/che-incubator/quarkus-api-example.git';
const projectName: string = 'quarkus-api-example';
const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);

suite(`The SmokeTest userstory`, async function () {
let projectSection: ViewSection;
suite(`Create workspace from factory:${factoryUrl}`, async function () {
loginTests.loginIntoChe();
workspaceHandlingTests.createAndOpenWorkspaceFromGitRepository(factoryUrl);
workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
test('Register running workspace', async () => {
registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName());
});
test('Wait workspace readiness', async function () {
await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor();
});
test('Check a project folder has been created', async function () {
projectSection = await new SideBarView().getContent().getSection(projectName);
Logger.debug(`new SideBarView().getContent().getSection: get ${projectName}`);
});
test('Check the project files was imported', async function () {
const label: string = 'devfile.yaml';
await projectSection.findItem(label);
Logger.debug(`projectSection.findItem: find ${label}`);
});
test('Stopping and deleting the workspace', async function () {
await workspaceHandlingTests.stopAndRemoveWorkspace(WorkspaceHandlingTests.getWorkspaceName());
});
});
});
13 changes: 13 additions & 0 deletions tests/e2e/tests-library/WorkspaceHandlingTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ export class WorkspaceHandlingTests {
});
}

public createAndOpenWorkspaceFromGitRepository(factoryUrl: string): void {
test(`Create and open new workspace from factory:${factoryUrl}`, async () => {
await this.dashboard.waitPage();
Logger.debug(`Fetching user kubernetes namespace, storing auth token by getting workspaces API URL.`);
await this.apiUrlResolver.getWorkspacesApiUrl();
await this.dashboard.clickCreateWorkspaceButton();
await this.createWorkspace.waitPage();
WorkspaceHandlingTests.parentGUID = await this.browserTabsUtil.getCurrentWindowHandle();
await this.createWorkspace.importFromGitUsingUI(factoryUrl);
await this.browserTabsUtil.waitAndSwitchToAnotherWindow(WorkspaceHandlingTests.parentGUID, TimeoutConstants.TS_IDE_LOAD_TIMEOUT);
});
}

public openExistingWorkspace(workspaceName: string): void {
test('Open and start existing workspace', async () => {
await this.dashboard.waitPage();
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/utils/CheReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class CheReporter extends mocha.reporters.Spec {
DELETE_WORKSPACE_ON_FAILED_TEST: ${TestConstants.DELETE_WORKSPACE_ON_FAILED_TEST}
TS_SELENIUM_LOG_LEVEL: ${TestConstants.TS_SELENIUM_LOG_LEVEL}
TS_SELENIUM_LAUNCH_FULLSCREEN: ${TestConstants.TS_SELENIUM_LAUNCH_FULLSCREEN}

${process.env.MOCHA_DIRECTORY ? 'MOCHA_DIRECTORY: ' + process.env.MOCHA_DIRECTORY : 'MOCHA_DRIRECTORY is not set'}
${process.env.USERSTORY ? 'USERSTORY: ' + process.env.USERSTORY : 'USERSTORY is not set'}
`;

if (TestConstants.TS_SELENIUM_PRINT_TIMEOUT_VARIABLES) {
Expand Down
3 changes: 0 additions & 3 deletions tests/e2e/utils/vsc/GitUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import { injectable } from 'inversify';

@injectable()
export class GitUtil {

constructor() { }

/**
* Method extracts a test repo name from git clone https url;
* it splits the url into string[] by "/" or ".", deletes empty elements and elements that contains just "git" word, than returns the last one;
Expand Down