Skip to content

Commit

Permalink
feat: change Login, Logout, Stop and delete workspace tests to be hoo…
Browse files Browse the repository at this point in the history
…ks (suileSetup, suiteTeardown)

Signed-off-by: mdolhalo <[email protected]>
  • Loading branch information
mdolhalo committed Oct 27, 2023
1 parent 26a6708 commit 34f6656
Show file tree
Hide file tree
Showing 17 changed files with 199 additions and 95 deletions.
8 changes: 6 additions & 2 deletions tests/e2e/specs/SmokeTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ suite(`The SmokeTest userstory ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, functio
FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL || 'https://github.com/che-incubator/quarkus-api-example.git';
let projectSection: ViewSection;
suite(`Create workspace from factory:${factoryUrl}`, function (): void {
loginTests.loginIntoChe();
suiteSetup('Login', async function (): Promise<void> {
await loginTests.loginIntoChe();
});
test(`Create and open new workspace from factory:${factoryUrl}`, async function (): Promise<void> {
await workspaceHandlingTests.createAndOpenWorkspaceFromGitRepository(factoryUrl);
});
Expand Down Expand Up @@ -61,6 +63,8 @@ suite(`The SmokeTest userstory ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, functio
test('Delete the workspace', async function (): Promise<void> {
await workspaceHandlingTests.removeWorkspace(WorkspaceHandlingTests.getWorkspaceName());
});
loginTests.logoutFromChe();
suiteTeardown('Unregister running workspace', function (): void {
registerRunningWorkspace('');
});
});
});
11 changes: 8 additions & 3 deletions tests/e2e/specs/dashboard-samples/Documentation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ suite(`Check links to documentation page in Dashboard ${BASE_TEST_CONSTANTS.TEST
({ webSocketTroubleshooting, workspace, devfile, general, storageTypes } = docs);
});

suiteSetup('Login', async function (): Promise<void> {
await loginTests.loginIntoChe();
});

test('Check if product.json config contains correct application version', function (): void {
[productVersion, links[1].href, devfile, workspace, general, storageTypes, webSocketTroubleshooting].forEach((e): void => {
expect(e, 'Fetched links not matches with tested product version').contains(testingVersion);
});
});

loginTests.loginIntoChe();

test('Check if documentation section "About" present on Dashboard', async function (): Promise<void> {
await dashboard.openAboutMenu();
});
Expand Down Expand Up @@ -135,7 +137,10 @@ suite(`Check links to documentation page in Dashboard ${BASE_TEST_CONSTANTS.TEST
});
}

loginTests.logoutFromChe();
suiteTeardown('Open dashboard and close all other tabs', async function (): Promise<void> {
await dashboard.openDashboard();
await browserTabsUtil.closeAllTabsExceptCurrent();
});

suiteTeardown('Delete default DevWorkspace', function (): void {
kubernetesCommandLineToolsExecutor.deleteDevWorkspace();
Expand Down
23 changes: 15 additions & 8 deletions tests/e2e/specs/dashboard-samples/EmptyWorkspace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
**********************************************************************/
import { e2eContainer } from '../../configs/inversify.config';
import { ActivityBar, ViewControl, Workbench } from 'monaco-page-objects';
import { CLASSES } from '../../configs/inversify.types';
import { CLASSES, TYPES } from '../../configs/inversify.types';
import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests';
import { Logger } from '../../utils/Logger';
import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests';
import { LoginTests } from '../../tests-library/LoginTests';
import { registerRunningWorkspace } from '../MochaHooks';
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
import { Dashboard } from '../../pageobjects/dashboard/Dashboard';

const stackName: string = 'Empty Workspace';

Expand All @@ -25,9 +27,12 @@ suite(`${stackName} test ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function ():
const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil);
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);

loginTests.loginIntoChe();

suiteSetup('Login', async function (): Promise<void> {
await loginTests.loginIntoChe();
});
test(`Create and open new workspace, stack:${stackName}`, async function (): Promise<void> {
await workspaceHandlingTests.createAndOpenWorkspace(stackName);
});
Expand All @@ -53,14 +58,16 @@ suite(`${stackName} test ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function ():
}
});

test('Stop the workspace', async function (): Promise<void> {
await workspaceHandlingTests.stopWorkspace(WorkspaceHandlingTests.getWorkspaceName());
suiteTeardown('Open dashboard and close all other tabs', async function (): Promise<void> {
await dashboard.openDashboard();
await browserTabsUtil.closeAllTabsExceptCurrent();
});

test('Delete the workspace', async function (): Promise<void> {
await workspaceHandlingTests.removeWorkspace(WorkspaceHandlingTests.getWorkspaceName());
suiteTeardown('Stop and delete the workspace by API', function (): void {
testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName());
});

loginTests.logoutFromChe();
suiteTeardown('Unregister running workspace', function (): void {
registerRunningWorkspace('');
});
});
22 changes: 15 additions & 7 deletions tests/e2e/specs/dashboard-samples/Quarkus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ 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 { CLASSES, TYPES } from '../../configs/inversify.types';
import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests';
import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests';
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
import { expect } from 'chai';
import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
import { Dashboard } from '../../pageobjects/dashboard/Dashboard';

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

Expand All @@ -26,11 +28,15 @@ suite(`The ${stackName} userstory ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, func
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil);
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);

let projectSection: ViewSection;
const projectName: string = 'quarkus-quickstarts';

loginTests.loginIntoChe();
suiteSetup('Login', async function (): Promise<void> {
await loginTests.loginIntoChe();
});

test(`Create and open new workspace, stack:${stackName}`, async function (): Promise<void> {
await workspaceHandlingTests.createAndOpenWorkspace(stackName);
Expand Down Expand Up @@ -64,14 +70,16 @@ suite(`The ${stackName} userstory ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, func
).not.undefined;
});

test('Stop the workspace', async function (): Promise<void> {
await workspaceHandlingTests.stopWorkspace(WorkspaceHandlingTests.getWorkspaceName());
suiteTeardown('Open dashboard and close all other tabs', async function (): Promise<void> {
await dashboard.openDashboard();
await browserTabsUtil.closeAllTabsExceptCurrent();
});

test('Delete the workspace', async function (): Promise<void> {
await workspaceHandlingTests.removeWorkspace(WorkspaceHandlingTests.getWorkspaceName());
suiteTeardown('Stop and delete the workspace by API', function (): void {
testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName());
});

loginTests.logoutFromChe();
suiteTeardown('Unregister running workspace', function (): void {
registerRunningWorkspace('');
});
});
22 changes: 15 additions & 7 deletions tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
import { registerRunningWorkspace } from '../MochaHooks';
import { LoginTests } from '../../tests-library/LoginTests';
import { e2eContainer } from '../../configs/inversify.config';
import { CLASSES } from '../../configs/inversify.types';
import { CLASSES, TYPES } from '../../configs/inversify.types';
import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests';
import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests';
import { Logger } from '../../utils/Logger';
Expand All @@ -34,6 +34,8 @@ import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS';
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
import { PLUGIN_TEST_CONSTANTS } from '../../constants/PLUGIN_TEST_CONSTANTS';
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
import { Dashboard } from '../../pageobjects/dashboard/Dashboard';

const samples: string[] = PLUGIN_TEST_CONSTANTS.TS_SAMPLE_LIST.split(',');

Expand All @@ -46,6 +48,8 @@ for (const sample of samples) {
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
const cheCodeLocatorLoader: CheCodeLocatorLoader = e2eContainer.get(CLASSES.CheCodeLocatorLoader);
const webCheCodeLocators: Locators = cheCodeLocatorLoader.webCheCodeLocators;
const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil);
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);

let projectSection: ViewSection;
let extensionSection: ExtensionsViewSection;
Expand All @@ -56,7 +60,9 @@ for (const sample of samples) {
recommendations: []
};

loginTests.loginIntoChe();
suiteSetup('Login', async function (): Promise<void> {
await loginTests.loginIntoChe();
});

test(`Create and open new workspace, stack:${sample}`, async function (): Promise<void> {
await workspaceHandlingTests.createAndOpenWorkspace(sample);
Expand Down Expand Up @@ -202,15 +208,17 @@ for (const sample of samples) {
}
});

test('Stop the workspace', async function (): Promise<void> {
await workspaceHandlingTests.stopWorkspace(WorkspaceHandlingTests.getWorkspaceName());
suiteTeardown('Open dashboard and close all other tabs', async function (): Promise<void> {
await dashboard.openDashboard();
await browserTabsUtil.closeAllTabsExceptCurrent();
});

test('Delete the workspace', async function (): Promise<void> {
await workspaceHandlingTests.removeWorkspace(WorkspaceHandlingTests.getWorkspaceName());
suiteTeardown('Stop and delete the workspace by API', function (): void {
testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName());
});

loginTests.logoutFromChe();
suiteTeardown('Unregister running workspace', function (): void {
registerRunningWorkspace('');
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ import { OcpApplicationPage } from '../../pageobjects/openshift/OcpApplicationPa
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
import { Dashboard } from '../../pageobjects/dashboard/Dashboard';

suite(`DevConsole Integration ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
let ocpImportPage: OcpImportFromGitPage;
let ocpApplicationPage: OcpApplicationPage;

const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
Expand Down Expand Up @@ -72,7 +74,9 @@ suite(`DevConsole Integration ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function
await ocpApplicationPage.waitAndOpenEditSourceCodeIcon();
});

loginTests.loginIntoChe();
test('Login', async function (): Promise<void> {
await loginTests.loginIntoChe();
});

test('Obtain workspace name from workspace loader page', async function (): Promise<void> {
await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
Expand All @@ -99,12 +103,18 @@ suite(`DevConsole Integration ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function
).not.undefined;
});

test('Stop and delete the workspace by API', async function (): Promise<void> {
suiteTeardown('Open dashboard and close all other tabs', async function (): Promise<void> {
await dashboard.openDashboard();
await browserTabsUtil.closeAllTabsExceptCurrent();
});

suiteTeardown('Stop and delete the workspace by API', function (): void {
testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName());
});

loginTests.logoutFromChe();
suiteTeardown('Unregister running workspace', function (): void {
registerRunningWorkspace('');
});

suiteTeardown('Delete project using ocp', function (): void {
kubernetesCommandLineToolsExecutor.deleteProject(projectName);
Expand Down
22 changes: 15 additions & 7 deletions tests/e2e/specs/factory/Factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ import { CheCodeLocatorLoader } from '../../pageobjects/ide/CheCodeLocatorLoader
import { registerRunningWorkspace } from '../MochaHooks';
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests';
import { CLASSES } from '../../configs/inversify.types';
import { CLASSES, TYPES } from '../../configs/inversify.types';
import { DriverHelper } from '../../utils/DriverHelper';
import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests';
import { Logger } from '../../utils/Logger';
import { LoginTests } from '../../tests-library/LoginTests';
import { OAUTH_CONSTANTS } from '../../constants/OAUTH_CONSTANTS';
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
import { FACTORY_TEST_CONSTANTS } from '../../constants/FACTORY_TEST_CONSTANTS';
import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
import { Dashboard } from '../../pageobjects/dashboard/Dashboard';

suite(
`Create a workspace via launching a factory from the ${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`,
Expand All @@ -49,6 +51,8 @@ suite(
const cheCodeLocatorLoader: CheCodeLocatorLoader = e2eContainer.get(CLASSES.CheCodeLocatorLoader);
const webCheCodeLocators: Locators = cheCodeLocatorLoader.webCheCodeLocators;
const oauthPage: OauthPage = e2eContainer.get(CLASSES.OauthPage);
const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil);
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);

let projectSection: ViewSection;
let scmProvider: SingleScmProvider;
Expand All @@ -64,7 +68,9 @@ suite(
const pushItemLabel: string = 'Push';
let testRepoProjectName: string;

loginTests.loginIntoChe();
suiteSetup('Login', async function (): Promise<void> {
await loginTests.loginIntoChe();
});
test('Navigate to the factory URL', async function (): Promise<void> {
await browserTabsUtil.navigateTo(FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_URL());
});
Expand Down Expand Up @@ -189,15 +195,17 @@ suite(
expect(isCommitButtonDisabled).to.equal('true');
});

test('Stop the workspace', async function (): Promise<void> {
await workspaceHandlingTests.stopWorkspace(WorkspaceHandlingTests.getWorkspaceName());
suiteTeardown('Open dashboard and close all other tabs', async function (): Promise<void> {
await dashboard.openDashboard();
await browserTabsUtil.closeAllTabsExceptCurrent();
});

test('Delete the workspace', async function (): Promise<void> {
await workspaceHandlingTests.removeWorkspace(WorkspaceHandlingTests.getWorkspaceName());
suiteTeardown('Stop and delete the workspace by API', function (): void {
testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName());
});

loginTests.logoutFromChe();
suiteTeardown('Unregister running workspace', function (): void {
registerRunningWorkspace('');
});
}
);
Loading

0 comments on commit 34f6656

Please sign in to comment.