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

Clean up Che Theia specific tests and page objects #22052

Merged
merged 2 commits into from
Mar 20, 2023
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
2 changes: 1 addition & 1 deletion .devfile.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2022 Red Hat, Inc.
# Copyright (c) 2022-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/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/contributing-repositories-check.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2020 Red Hat, Inc.
# Copyright (c) 2020-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/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/typescript-publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021 Red Hat, Inc.
# Copyright (c) 2021-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/
Expand Down
2 changes: 1 addition & 1 deletion .repositories-update-contributing.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# Copyright (c) 2020 Red Hat, Inc.
# Copyright (c) 2020-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/
Expand Down
2 changes: 1 addition & 1 deletion make-release.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2021 Red Hat, Inc.
# Copyright (c) 2021-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/
Expand Down
2 changes: 1 addition & 1 deletion tests/devworkspace-happy-path/common.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright (c) 2012-2021 Red Hat, Inc.
# Copyright (c) 2012-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/
Expand Down
2 changes: 1 addition & 1 deletion tests/devworkspace-happy-path/launch.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright (c) 2012-2021 Red Hat, Inc.
# Copyright (c) 2012-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/
Expand Down
2 changes: 1 addition & 1 deletion tests/devworkspace-happy-path/remote-launch.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright (c) 2012-2021 Red Hat, Inc.
# Copyright (c) 2012-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/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ spec:
env:
- name: TEST_SUITE
value: HAPPY_PATH_SUITE
- name: USERSTORY
value: HAPPY_PATH_USERSTORY
- name: NODE_TLS_REJECT_UNAUTHORIZED
value: '0'
- name: TS_SELENIUM_BASE_URL
Expand Down
88 changes: 88 additions & 0 deletions tests/e2e/configs/inversify.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*********************************************************************
* Copyright (c) 2019-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 'reflect-metadata';
import { Container } from 'inversify';
import { IDriver } from '../driver/IDriver';
import { ChromeDriver } from '../driver/ChromeDriver';
import { TYPES, CLASSES } from './inversify.types';
import { TestWorkspaceUtil } from '../utils/workspace/TestWorkspaceUtil';
import { IOcpLoginPage } from '../pageobjects/login/IOcpLoginPage';
import { OcpUserLoginPage } from '../pageobjects/login/OcpUserLoginPage';
import { TestConstants } from '../constants/TestConstants';
import { ICheLoginPage } from '../pageobjects/login/ICheLoginPage';
import { RegularUserOcpCheLoginPage } from '../pageobjects/login/RegularUserOcpCheLoginPage';
import { MultiUserLoginPage } from '../pageobjects/login/MultiUserLoginPage';
import { DriverHelper } from '../utils/DriverHelper';
import { Dashboard } from '../pageobjects/dashboard/Dashboard';
import { Workspaces } from '../pageobjects/dashboard/Workspaces';
import { WorkspaceDetails } from '../pageobjects/dashboard/workspace-details/WorkspaceDetails';
import { WorkspaceDetailsPlugins } from '../pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins';
import { ScreenCatcher } from '../utils/ScreenCatcher';
import { OcpLoginPage } from '../pageobjects/openshift/OcpLoginPage';
import { CheLoginPage } from '../pageobjects/openshift/CheLoginPage';
import { IAuthorizationHeaderHandler } from '../utils/request-handlers/headers/IAuthorizationHeaderHandler';
import { CheMultiuserAuthorizationHeaderHandler } from '../utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler';
import { CheMultiuserTokenHandler } from '../utils/request-handlers/tokens/CheMultiuserTokenHandler';
import { ITokenHandler } from '../utils/request-handlers/tokens/ITokenHandler';
import { CheApiRequestHandler } from '../utils/request-handlers/CheApiRequestHandler';
import { CheGitApi } from '../utils/vsc/CheGitApi';
import { GitHubUtil } from '../utils/vsc/github/GitHubUtil';
import { CreateWorkspace } from '../pageobjects/dashboard/CreateWorkspace';
import { UpdateAccountInformationPage } from '../pageobjects/login/UpdateAccountInformationPage';
import { BrowserTabsUtil } from '../utils/BrowserTabsUtil';
import { WorkspaceHandlingTests } from '../tests-library/WorkspaceHandlingTests';
import { GitLoginPage } from '../pageobjects/third-parties/GitLoginPage';
import { GitOauthAppsSettings } from '../pageobjects/third-parties/GitOauthAppsSettings';
import { WorkspaceNameHandler } from '../utils/WorkspaceNameHandler';
import { Sanitizer } from '../utils/Sanitizer';
import { ApiUrlResolver } from '../utils/workspace/ApiUrlResolver';
import { ITestWorkspaceUtil } from '../utils/workspace/ITestWorkspaceUtil';
import { ProjectAndFileTests } from '../tests-library/ProjectAndFileTests';
import { LoginTests } from '../tests-library/LoginTests';

const e2eContainer: Container = new Container({ defaultScope: 'Transient' });

e2eContainer.bind<IDriver>(TYPES.Driver).to(ChromeDriver).inSingletonScope();
e2eContainer.bind<ITestWorkspaceUtil>(TYPES.WorkspaceUtil).to(TestWorkspaceUtil);
e2eContainer.bind<IOcpLoginPage>(TYPES.OcpLogin).to(OcpUserLoginPage);
e2eContainer.bind<IAuthorizationHeaderHandler>(TYPES.IAuthorizationHeaderHandler).to(CheMultiuserAuthorizationHeaderHandler);
e2eContainer.bind<ITokenHandler>(TYPES.ITokenHandler).to(CheMultiuserTokenHandler);

if (JSON.parse(TestConstants.TS_SELENIUM_VALUE_OPENSHIFT_OAUTH)) {
e2eContainer.bind<ICheLoginPage>(TYPES.CheLogin).to(RegularUserOcpCheLoginPage);
} else {
e2eContainer.bind<ICheLoginPage>(TYPES.CheLogin).to(MultiUserLoginPage);
}

e2eContainer.bind<BrowserTabsUtil>(CLASSES.BrowserTabsUtil).to(BrowserTabsUtil);
e2eContainer.bind<DriverHelper>(CLASSES.DriverHelper).to(DriverHelper);
e2eContainer.bind<Dashboard>(CLASSES.Dashboard).to(Dashboard);
e2eContainer.bind<Workspaces>(CLASSES.Workspaces).to(Workspaces);
e2eContainer.bind<WorkspaceDetails>(CLASSES.WorkspaceDetails).to(WorkspaceDetails);
e2eContainer.bind<WorkspaceDetailsPlugins>(CLASSES.WorkspaceDetailsPlugins).to(WorkspaceDetailsPlugins);
e2eContainer.bind<ScreenCatcher>(CLASSES.ScreenCatcher).to(ScreenCatcher);
e2eContainer.bind<OcpLoginPage>(CLASSES.OcpLoginPage).to(OcpLoginPage);
e2eContainer.bind<CheLoginPage>(CLASSES.CheLoginPage).to(CheLoginPage);
e2eContainer.bind<CheApiRequestHandler>(CLASSES.CheApiRequestHandler).to(CheApiRequestHandler);
e2eContainer.bind<CheGitApi>(CLASSES.CheGitApi).to(CheGitApi);
e2eContainer.bind<GitHubUtil>(CLASSES.GitHubUtil).to(GitHubUtil);
e2eContainer.bind<CreateWorkspace>(CLASSES.CreateWorkspace).to(CreateWorkspace);
e2eContainer.bind<UpdateAccountInformationPage>(CLASSES.UpdateAccountInformationPage).to(UpdateAccountInformationPage);
e2eContainer.bind<ProjectAndFileTests>(CLASSES.ProjectAndFileTests).to(ProjectAndFileTests);
e2eContainer.bind<LoginTests>(CLASSES.LoginTests).to(LoginTests);
e2eContainer.bind<WorkspaceNameHandler>(CLASSES.WorkspaceNameHandler).to(WorkspaceNameHandler);
e2eContainer.bind<GitLoginPage>(CLASSES.GitLoginPage).to(GitLoginPage);
e2eContainer.bind<GitOauthAppsSettings>(CLASSES.GitOauthAppsSettings).to(GitOauthAppsSettings);
e2eContainer.bind<Sanitizer>(CLASSES.Sanitizer).to(Sanitizer);
e2eContainer.bind<ApiUrlResolver>(CLASSES.ApiUrlResolver).to(ApiUrlResolver);
e2eContainer.bind<WorkspaceHandlingTests>(CLASSES.WorkspaceHandlingTests).to(WorkspaceHandlingTests);

export { e2eContainer };
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

/*********************************************************************
* Copyright (c) 2019 Red Hat, Inc.
* Copyright (c) 2019-2023 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -9,6 +8,7 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/


const TYPES = {
Driver: Symbol.for('Driver'),
CheLogin: Symbol.for('CheLogin'),
Expand Down Expand Up @@ -48,27 +48,24 @@ const CLASSES = {
CheGitApi: 'CheGitApi',
GitPlugin: 'GitPlugin',
NotificationCenter: 'NotificationCenter',
PreferencesHandlerTheia: 'PreferencesHandlerTheia',
CheApiRequestHandler: 'CheApiRequestHandler',
CreateWorkspace: 'CreateWorkspace',
OpenDialogWidget: 'OpenDialogWidget',
UpdateAccountInformationPage: 'UpdateAccountInformationPage',
KubernetesPlugin: 'KubernetesPlugin',
BrowserTabsUtil: 'BrowserTabsUtil',
PluginsView: 'PluginsView',
LanguageServerTestsTheia: 'LanguageServerTestsTheia',
CodeExecutionTestsTheia: 'CodeExecutionTestsTheia',
ProjectAndFileTestsTheia: 'ProjectAndFileTestsTheia',
ProjectAndFileTestsCheCode: 'ProjectAndFileTestsCheCode',
WorkspaceHandlingTests: 'WorkspaceHandlingTests',
ProjectAndFileTests: 'ProjectAndFileTests',
ScrewTSW marked this conversation as resolved.
Show resolved Hide resolved
WorkspaceNameHandler: 'WorkspaceNameHandler',
GitHubPullRequestPlugin: 'GitHubPullRequestPlugin',
GitLoginPage: 'GitLoginPage',
GitOauthAppsSettings: 'GitOauthAppsSettings',
AnimationChecker: 'AnimationChecker',
Sanitizer: 'Sanitizer',
NavigationBar: 'NavigationBar',
ApiUrlResolver: 'ApiUrlResolver'
ApiUrlResolver: 'ApiUrlResolver',
LoginTests: 'LoginTests',
WorkspaceHandlingTests: 'WorkspaceHandlingTests'
};

export { TYPES, CLASSES };
21 changes: 21 additions & 0 deletions tests/e2e/configs/mocharc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

module.exports = {
timeout: 1200000,
reporter: './dist/utils/CheReporter.js',
ui: 'tdd',
require: [
'./dist/specs/MochaHooks.js',
'ts-node/register',
],
bail: true,
'full-trace': true,
spec:
process.env.MOCHA_DIRECTORY ?
process.env.USERSTORY ?
`dist/specs/${process.env.MOCHA_DIRECTORY}/${process.env.USERSTORY}.spec.js`
: `dist/specs/${process.env.MOCHA_DIRECTORY}/**.spec.js`
: `dist/specs/**/**.spec.js`,
grep: process.env.MOCHA_SUITE ? process.env.MOCHA_SUITE : '',
retries: process.env.MOCHA_RETRIES ? process.env.MOCHA_RETRIES : 3,
};
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#!/usr/bin/env bash

echo "Generating index.ts file..."
echo "import * as inversifyConfig from './inversify.config';
echo "import * as inversifyConfig from './configs/inversify.config';
export { inversifyConfig };
export * from './inversify.types';
export * from './TestConstants';
export * from './TimeoutConstants';
" > index.ts
export * from './configs/inversify.types';
export * from './constants/TestConstants';
export * from './constants/TimeoutConstants';" > ./index.ts

listOfDirs="driver utils pageobjects testsLibrary"
listOfExcludes="./driver/CheReporter.ts"
listOfDirs="driver utils pageobjects tests-library"
listOfExcludes="./utils/CheReporter.ts"
for dir in $listOfDirs
do
files=$(find ./$dir -type f | sort)
Expand All @@ -21,9 +20,8 @@ do
if [ $excludedFile == $file ]; then
continue
else
end=$((${#file}-3))
file_without_ending=${file:0:end}
echo "export * from '$file_without_ending';" >> index.ts
file_without_ending=${file::-3}
echo "export * from '$file_without_ending';" >> ./index.ts
fi
done
;;
Expand Down
54 changes: 54 additions & 0 deletions tests/e2e/configs/sh-scripts/initDevfileTests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

########################################
############# Methods ##################
########################################

launchUserstories(){
export MOCHA_DIRECTORY=${MOCHA_DIRECTORY:-"devfiles"}
echo "MOCHA_DIRECTORY = ${MOCHA_DIRECTORY}"
npm run lint && npm run tsc && mocha --config dist/configs/mocharc.js
}

checkUserstoryName(){
local checkedName="$(ls specs/devfiles | grep ${USERSTORY}.spec.ts)";

if [ -z "$TS_SELENIUM_EDITOR" ]; then
echo ""
echo "Variable TS_SELENIUM_EDITOR is unset. It will be assign to default value."
echo ""
export TS_SELENIUM_EDITOR=${TS_SELENIUM_EDITOR:-"che-code"}
echo "TS_SELENIUM_EDITOR = ${TS_SELENIUM_EDITOR}"
echo ""
exit 1
fi

if [ -z "$checkedName" ]; then
echo ""
echo "Current value USERSTORY=\"${USERSTORY}\" doesn't match to any of existing tests:"
echo ""
echo "$(ls specs/devfiles | sed -e 's/.spec.ts//g')"
echo ""
echo "Please choose one of the tests above, or unset the \"USERSTORY\" variable for launching all of them."
echo ""

exit 1;
fi
}

########################################
############# Launching ################
########################################

if [ -z "$USERSTORY" ]; then
echo ""
echo "Launching all userstories";
echo ""
launchUserstories ;
else
checkUserstoryName ;
echo ""
echo "Launching the \"${USERSTORY}\" userstory";
echo ""
launchUserstories ;
fi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*********************************************************************
* Copyright (c) 2019 Red Hat, Inc.
* Copyright (c) 2019-2023 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*********************************************************************
* Copyright (c) 2020 Red Hat, Inc.
* Copyright (c) 2020-2023 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/driver/ChromeDriver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*********************************************************************
* Copyright (c) 2019 Red Hat, Inc.
* Copyright (c) 2019-2023 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -13,7 +13,7 @@ import { injectable } from 'inversify';
import { ThenableWebDriver, Builder } from 'selenium-webdriver';
import { IDriver } from './IDriver';
import { Options } from 'selenium-webdriver/chrome';
import { TestConstants } from '../TestConstants';
import { TestConstants } from '../constants/TestConstants';

@injectable()
export class ChromeDriver implements IDriver {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/driver/IDriver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*********************************************************************
* Copyright (c) 2019 Red Hat, Inc.
* Copyright (c) 2019-2023 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down
Loading