@eclipse-che/che-e2e 7.64.0-dev-20514b2 → 7.64.0-dev-db63138
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -37
- package/build/dockerfiles/entrypoint.sh +1 -1
- package/configs/inversify.config.ts +11 -26
- package/configs/inversify.types.ts +3 -33
- package/configs/mocharc.ts +9 -3
- package/configs/sh-scripts/initDefaultValues.sh +0 -5
- package/constants/TestConstants.ts +34 -96
- package/dist/configs/inversify.config.js +8 -23
- package/dist/configs/inversify.config.js.map +1 -1
- package/dist/configs/inversify.types.js +3 -33
- package/dist/configs/inversify.types.js.map +1 -1
- package/dist/configs/mocharc.js +11 -4
- package/dist/configs/mocharc.js.map +1 -1
- package/dist/constants/TestConstants.js +31 -86
- package/dist/constants/TestConstants.js.map +1 -1
- package/dist/driver/ChromeDriver.js +1 -1
- package/dist/driver/ChromeDriver.js.map +1 -1
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/pageobjects/dashboard/CreateWorkspace.js +3 -11
- package/dist/pageobjects/dashboard/CreateWorkspace.js.map +1 -1
- package/dist/pageobjects/dashboard/Dashboard.js +16 -1
- package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
- package/dist/pageobjects/dashboard/Workspaces.js +1 -3
- package/dist/pageobjects/dashboard/Workspaces.js.map +1 -1
- package/dist/pageobjects/git-providers/OauthPage.js +150 -0
- package/dist/pageobjects/git-providers/OauthPage.js.map +1 -0
- package/dist/pageobjects/ide/CheCodeLocatorLoader.js +65 -0
- package/dist/pageobjects/ide/CheCodeLocatorLoader.js.map +1 -0
- package/dist/pageobjects/login/OcpRedHatLoginPage.js +67 -0
- package/dist/pageobjects/login/OcpRedHatLoginPage.js.map +1 -0
- package/dist/pageobjects/login/RedHatLoginPage.js +78 -0
- package/dist/pageobjects/login/RedHatLoginPage.js.map +1 -0
- package/dist/pageobjects/login/RegularUserOcpCheLoginPage.js +3 -21
- package/dist/pageobjects/login/RegularUserOcpCheLoginPage.js.map +1 -1
- package/dist/pageobjects/openshift/CheLoginPage.js +0 -33
- package/dist/pageobjects/openshift/CheLoginPage.js.map +1 -1
- package/dist/pageobjects/openshift/OcpLoginPage.js +0 -14
- package/dist/pageobjects/openshift/OcpLoginPage.js.map +1 -1
- package/dist/specs/MochaHooks.js +2 -2
- package/dist/specs/MochaHooks.js.map +1 -1
- package/dist/specs/devfiles/EmptyWorkspace.spec.js +1 -0
- package/dist/specs/devfiles/EmptyWorkspace.spec.js.map +1 -1
- package/dist/specs/devfiles/Quarkus.spec.js +50 -0
- package/dist/specs/devfiles/Quarkus.spec.js.map +1 -0
- package/dist/specs/factory/Factory.spec.js +160 -0
- package/dist/specs/factory/Factory.spec.js.map +1 -0
- package/dist/specs/factory/NoSetupRepoFactory.spec.js +228 -0
- package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +1 -0
- package/dist/specs/factory/RefusedOAuthFactory.spec.js +220 -0
- package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +1 -0
- package/dist/specs/miscellaneous/PredefinedNamespace.spec.js +66 -0
- package/dist/specs/miscellaneous/PredefinedNamespace.spec.js.map +1 -0
- package/dist/tests-library/LoginTests.js +10 -2
- package/dist/tests-library/LoginTests.js.map +1 -1
- package/dist/tests-library/WorkspaceHandlingTests.js +3 -6
- package/dist/tests-library/WorkspaceHandlingTests.js.map +1 -1
- package/dist/utils/BrowserTabsUtil.js +2 -21
- package/dist/utils/BrowserTabsUtil.js.map +1 -1
- package/dist/utils/DriverHelper.js +11 -73
- package/dist/utils/DriverHelper.js.map +1 -1
- package/dist/utils/Logger.js +5 -0
- package/dist/utils/Logger.js.map +1 -1
- package/dist/utils/Sanitizer.js.map +1 -1
- package/dist/utils/request-handlers/CheApiRequestHandler.js +1 -1
- package/dist/utils/request-handlers/CheApiRequestHandler.js.map +1 -1
- package/dist/utils/vsc/GitUtil.js +41 -0
- package/dist/utils/vsc/GitUtil.js.map +1 -0
- package/dist/utils/workspace/ApiUrlResolver.js +0 -3
- package/dist/utils/workspace/ApiUrlResolver.js.map +1 -1
- package/dist/utils/workspace/TestWorkspaceUtil.js +2 -192
- package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -1
- package/driver/ChromeDriver.ts +1 -1
- package/index.ts +37 -0
- package/package.json +9 -5
- package/pageobjects/dashboard/CreateWorkspace.ts +4 -15
- package/pageobjects/dashboard/Dashboard.ts +29 -4
- package/pageobjects/dashboard/Workspaces.ts +1 -3
- package/pageobjects/git-providers/OauthPage.ts +156 -0
- package/pageobjects/ide/CheCodeLocatorLoader.ts +69 -0
- package/pageobjects/login/OcpRedHatLoginPage.ts +49 -0
- package/pageobjects/login/RedHatLoginPage.ts +62 -0
- package/pageobjects/login/RegularUserOcpCheLoginPage.ts +1 -20
- package/pageobjects/openshift/CheLoginPage.ts +6 -55
- package/pageobjects/openshift/OcpLoginPage.ts +0 -21
- package/specs/MochaHooks.ts +2 -2
- package/specs/devfiles/EmptyWorkspace.spec.ts +1 -0
- package/specs/devfiles/Quarkus.spec.ts +52 -0
- package/specs/factory/Factory.spec.ts +199 -0
- package/specs/factory/NoSetupRepoFactory.spec.ts +272 -0
- package/specs/factory/RefusedOAuthFactory.spec.ts +260 -0
- package/specs/miscellaneous/PredefinedNamespace.spec.ts +74 -0
- package/tests-library/LoginTests.ts +9 -1
- package/tests-library/WorkspaceHandlingTests.ts +3 -7
- package/utils/BrowserTabsUtil.ts +2 -24
- package/utils/DriverHelper.ts +9 -84
- package/utils/Logger.ts +5 -0
- package/utils/Sanitizer.ts +0 -1
- package/utils/request-handlers/CheApiRequestHandler.ts +1 -1
- package/utils/vsc/GitUtil.ts +28 -0
- package/utils/workspace/ApiUrlResolver.ts +0 -4
- package/utils/workspace/ITestWorkspaceUtil.ts +1 -56
- package/utils/workspace/TestWorkspaceUtil.ts +2 -243
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.js +0 -97
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.js.map +0 -1
- package/dist/pageobjects/login/MultiUserLoginPage.js +0 -49
- package/dist/pageobjects/login/MultiUserLoginPage.js.map +0 -1
- package/dist/pageobjects/login/UpdateAccountInformationPage.js +0 -74
- package/dist/pageobjects/login/UpdateAccountInformationPage.js.map +0 -1
- package/dist/pageobjects/third-parties/GitLoginPage.js +0 -85
- package/dist/pageobjects/third-parties/GitLoginPage.js.map +0 -1
- package/dist/pageobjects/third-parties/GitOauthAppsSettings.js +0 -110
- package/dist/pageobjects/third-parties/GitOauthAppsSettings.js.map +0 -1
- package/dist/specs/login/LinkCheAndOcpUsers.spec.js +0 -40
- package/dist/specs/login/LinkCheAndOcpUsers.spec.js.map +0 -1
- package/dist/utils/WorkspaceNameHandler.js +0 -60
- package/dist/utils/WorkspaceNameHandler.js.map +0 -1
- package/dist/utils/request-handlers/tokens/CheMultiuserTokenHandler.js +0 -50
- package/dist/utils/request-handlers/tokens/CheMultiuserTokenHandler.js.map +0 -1
- package/dist/utils/request-handlers/tokens/ITokenHandler.js +0 -12
- package/dist/utils/request-handlers/tokens/ITokenHandler.js.map +0 -1
- package/dist/utils/vsc/CheGitApi.js +0 -42
- package/dist/utils/vsc/CheGitApi.js.map +0 -1
- package/dist/utils/vsc/github/GitHubUtil.js +0 -126
- package/dist/utils/vsc/github/GitHubUtil.js.map +0 -1
- package/files/devfiles/plugins/GitHubPullRequestPlugin.yaml +0 -11
- package/files/devfiles/plugins/InstallPluginUsingUI.yaml +0 -3
- package/files/devfiles/plugins/Java11PluginTest.yaml +0 -17
- package/files/devfiles/plugins/PhpPluginTest.yaml +0 -47
- package/files/devfiles/plugins/PythonPluginTest.yaml +0 -14
- package/files/devfiles/plugins/TypescriptNodeDebug2PluginTest.yaml +0 -49
- package/files/devfiles/plugins/VscodeKubernetesPlugin.yaml +0 -12
- package/files/devfiles/plugins/VscodeShellcheckPlugin.yaml +0 -12
- package/files/devfiles/plugins/VscodeValePlugin.yaml +0 -42
- package/files/devfiles/plugins/VscodeXmlPlugin.yaml +0 -12
- package/files/devfiles/plugins/VscodeYamlPlugin.yaml +0 -12
- package/files/happy-path/containers-happy-path.yaml +0 -127
- package/files/happy-path/happy-path-workspace.yaml +0 -95
- package/files/happy-path/petclinic-classpath.txt +0 -49
- package/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.ts +0 -95
- package/pageobjects/login/MultiUserLoginPage.ts +0 -33
- package/pageobjects/login/UpdateAccountInformationPage.ts +0 -70
- package/pageobjects/third-parties/GitLoginPage.ts +0 -81
- package/pageobjects/third-parties/GitOauthAppsSettings.ts +0 -110
- package/specs/login/LinkCheAndOcpUsers.spec.ts +0 -49
- package/utils/WorkspaceNameHandler.ts +0 -48
- package/utils/request-handlers/tokens/CheMultiuserTokenHandler.ts +0 -41
- package/utils/request-handlers/tokens/ITokenHandler.ts +0 -14
- package/utils/vsc/CheGitApi.ts +0 -22
- package/utils/vsc/github/GitHubUtil.ts +0 -110
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* Copyright (c) 2021 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
**********************************************************************/
|
|
10
|
+
|
|
11
|
+
import 'reflect-metadata';
|
|
12
|
+
import { e2eContainer } from '../../configs/inversify.config';
|
|
13
|
+
import {
|
|
14
|
+
ActivityBar,
|
|
15
|
+
ContextMenu,
|
|
16
|
+
EditorView,
|
|
17
|
+
error,
|
|
18
|
+
InputBox,
|
|
19
|
+
Locators,
|
|
20
|
+
ModalDialog,
|
|
21
|
+
NewScmView,
|
|
22
|
+
SideBarView,
|
|
23
|
+
SingleScmProvider,
|
|
24
|
+
TextEditor,
|
|
25
|
+
ViewControl,
|
|
26
|
+
ViewItem,
|
|
27
|
+
ViewSection
|
|
28
|
+
} from 'monaco-page-objects';
|
|
29
|
+
import { expect } from 'chai';
|
|
30
|
+
import WebDriverError = error.WebDriverError;
|
|
31
|
+
import { registerRunningWorkspace } from '../MochaHooks';
|
|
32
|
+
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
|
|
33
|
+
import { CLASSES } from '../../configs/inversify.types';
|
|
34
|
+
import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests';
|
|
35
|
+
import { CheCodeLocatorLoader } from '../../pageobjects/ide/CheCodeLocatorLoader';
|
|
36
|
+
import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests';
|
|
37
|
+
import { DriverHelper } from '../../utils/DriverHelper';
|
|
38
|
+
import { TestConstants } from '../../constants/TestConstants';
|
|
39
|
+
import { OauthPage } from '../../pageobjects/git-providers/OauthPage';
|
|
40
|
+
import { GitUtil } from '../../utils/vsc/GitUtil';
|
|
41
|
+
import { Logger } from '../../utils/Logger';
|
|
42
|
+
import { TimeoutConstants } from '../../constants/TimeoutConstants';
|
|
43
|
+
import { LoginTests } from '../../tests-library/LoginTests';
|
|
44
|
+
|
|
45
|
+
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
|
|
46
|
+
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
|
|
47
|
+
const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
|
|
48
|
+
const webCheCodeLocators: Locators = new CheCodeLocatorLoader().webCheCodeLocators;
|
|
49
|
+
const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper);
|
|
50
|
+
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
|
|
51
|
+
|
|
52
|
+
suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository and deny the access`, async function () {
|
|
53
|
+
const oauthPage: OauthPage = new OauthPage(driverHelper);
|
|
54
|
+
|
|
55
|
+
let projectSection: ViewSection;
|
|
56
|
+
let scmProvider: SingleScmProvider;
|
|
57
|
+
let rest: SingleScmProvider[];
|
|
58
|
+
let scmContextMenu: ContextMenu;
|
|
59
|
+
const gitUtil: GitUtil = new GitUtil();
|
|
60
|
+
|
|
61
|
+
// test specific data
|
|
62
|
+
const timeToRefresh: number = 1500;
|
|
63
|
+
const changesToCommit: string = (new Date()).getTime().toString();
|
|
64
|
+
const fileToChange: string = 'Date.txt';
|
|
65
|
+
const commitChangesButtonLabel: string = `Commit Changes on "${TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_BRANCH}"`;
|
|
66
|
+
const refreshButtonLabel: string = 'Refresh';
|
|
67
|
+
const pushItemLabel: string = 'Push';
|
|
68
|
+
const label: string = TestConstants.TS_SELENIUM_PROJECT_ROOT_FILE_NAME;
|
|
69
|
+
const testRepoProjectName: string = gitUtil.getProjectNameFromGitUrl(TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_URL);
|
|
70
|
+
const isPrivateRepo: string = TestConstants.TS_SELENIUM_IS_PRIVATE_FACTORY_GIT_REPO ? 'private' : 'public';
|
|
71
|
+
|
|
72
|
+
loginTests.loginIntoChe();
|
|
73
|
+
|
|
74
|
+
test(`Navigate to the ${isPrivateRepo} repository factory URL`, async function () {
|
|
75
|
+
await browserTabsUtil.navigateTo(TestConstants.TS_SELENIUM_FACTORY_URL());
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (TestConstants.TS_SELENIUM_GIT_PROVIDER_OAUTH) {
|
|
79
|
+
test(`Authorize with a ${TestConstants.TS_SELENIUM_FACTORY_GIT_PROVIDER} OAuth and deny access`, async function () {
|
|
80
|
+
await oauthPage.login();
|
|
81
|
+
await oauthPage.waitOauthPage();
|
|
82
|
+
await oauthPage.denyAccess();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
|
|
87
|
+
|
|
88
|
+
test('The workspace starts with access deny flag in the url', async function () {
|
|
89
|
+
expect(await driverHelper.getDriver().getCurrentUrl()).contains('&error_code=access_denied');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('Registering the running workspace', async function () {
|
|
93
|
+
registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName());
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('Wait the workspace readiness', async function () {
|
|
97
|
+
await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('Check if a project folder has been created', async function () {
|
|
101
|
+
Logger.debug(`new SideBarView().getContent().getSection: get ${testRepoProjectName}`);
|
|
102
|
+
projectSection = await new SideBarView().getContent().getSection(testRepoProjectName as unknown as string);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('Accept the project as a trusted one', async function () {
|
|
106
|
+
// click somewhere to trigger "Welcome Content" dialog
|
|
107
|
+
try {
|
|
108
|
+
await driverHelper.waitAndClick(webCheCodeLocators.Workbench.notificationItem);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
Logger.info(`Click on ${webCheCodeLocators.Workbench.notificationItem} to get "Welcome Content" dialog ${e as string}`);
|
|
111
|
+
}
|
|
112
|
+
// "Welcome Content" dialog can be shown before of after dialog with an error for private repo
|
|
113
|
+
try {
|
|
114
|
+
const buttonYesITrustTheAuthors: string = `Yes, I trust the authors`;
|
|
115
|
+
await driverHelper.waitVisibility(webCheCodeLocators.WelcomeContent.text, TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM);
|
|
116
|
+
const welcomeContentDialog: ModalDialog = new ModalDialog();
|
|
117
|
+
Logger.debug(`trustedProjectDialog.pushButton: "${buttonYesITrustTheAuthors}"`);
|
|
118
|
+
await welcomeContentDialog.pushButton(buttonYesITrustTheAuthors);
|
|
119
|
+
await driverHelper.waitDisappearance(webCheCodeLocators.WelcomeContent.text);
|
|
120
|
+
} catch (e) {
|
|
121
|
+
Logger.info(`"Accept the project as a trusted one" dialog was not shown firstly for "${isPrivateRepo}"`);
|
|
122
|
+
if (!TestConstants.TS_SELENIUM_IS_PRIVATE_FACTORY_GIT_REPO) {
|
|
123
|
+
throw new WebDriverError(e as string);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
if (TestConstants.TS_SELENIUM_IS_PRIVATE_FACTORY_GIT_REPO) {
|
|
129
|
+
test('Check that project can not be cloned', async function () {
|
|
130
|
+
await driverHelper.waitVisibility(webCheCodeLocators.Dialog.message);
|
|
131
|
+
const workspaceDoesNotExistDialog: ModalDialog = new ModalDialog();
|
|
132
|
+
const message: string = await workspaceDoesNotExistDialog.getMessage();
|
|
133
|
+
expect(message).contains('space does not exist');
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('Check that project files were not imported', async function () {
|
|
137
|
+
const isFileImported: ViewItem | undefined = await projectSection.findItem(label);
|
|
138
|
+
expect(isFileImported).eqls(undefined);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
} else {
|
|
142
|
+
test('Check if the project files were imported', async function () {
|
|
143
|
+
Logger.debug(`projectSection.findItem: find ${label}`);
|
|
144
|
+
const isFileImported: ViewItem | undefined = await projectSection.findItem(label);
|
|
145
|
+
// projectSection.findItem(label) can return undefined but test will goes on
|
|
146
|
+
expect(isFileImported).not.eqls(undefined);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('Make changes to the file', async function () {
|
|
150
|
+
Logger.debug(`projectSection.openItem: "${fileToChange}"`);
|
|
151
|
+
await projectSection.openItem(fileToChange);
|
|
152
|
+
const editor: TextEditor = await new EditorView().openEditor(fileToChange) as TextEditor;
|
|
153
|
+
await driverHelper.waitVisibility(webCheCodeLocators.Editor.inputArea);
|
|
154
|
+
Logger.debug(`editor.clearText`);
|
|
155
|
+
await editor.clearText();
|
|
156
|
+
Logger.debug(`editor.typeTextAt: "${changesToCommit}"`);
|
|
157
|
+
await editor.typeTextAt(1, 1, changesToCommit);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test('Open a source control manager', async function () {
|
|
161
|
+
const viewSourceControl: string = `Source Control`;
|
|
162
|
+
const sourceControl: ViewControl = await new ActivityBar().getViewControl(viewSourceControl) as ViewControl;
|
|
163
|
+
Logger.debug(`sourceControl.openView: "${viewSourceControl}"`);
|
|
164
|
+
await sourceControl.openView();
|
|
165
|
+
const scmView: NewScmView = new NewScmView();
|
|
166
|
+
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.actionConstructor(commitChangesButtonLabel));
|
|
167
|
+
[scmProvider, ...rest] = await scmView.getProviders();
|
|
168
|
+
Logger.debug(`scmView.getProviders: "${scmProvider}, ${scmProvider}"`);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test('Check if the changes is displayed in the source control manager', async function () {
|
|
172
|
+
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more);
|
|
173
|
+
await driverHelper.wait(timeToRefresh);
|
|
174
|
+
Logger.debug(`scmProvider.takeAction: "${refreshButtonLabel}"`);
|
|
175
|
+
await scmProvider.takeAction(refreshButtonLabel);
|
|
176
|
+
// wait while changes counter will be refreshed
|
|
177
|
+
await driverHelper.wait(timeToRefresh);
|
|
178
|
+
const changes: number = await scmProvider.getChangeCount();
|
|
179
|
+
Logger.debug(`scmProvider.getChangeCount: number of changes is "${changes}"`);
|
|
180
|
+
expect(changes).eql(1);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test('Stage the changes', async function () {
|
|
184
|
+
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more);
|
|
185
|
+
Logger.debug(`scmProvider.openMoreActions`);
|
|
186
|
+
scmContextMenu = await scmProvider.openMoreActions();
|
|
187
|
+
await driverHelper.waitVisibility(webCheCodeLocators.ContextMenu.contextView);
|
|
188
|
+
Logger.debug(`scmContextMenu.select: "Changes" -> "Stage All Changes"`);
|
|
189
|
+
await scmContextMenu.select('Changes', 'Stage All Changes');
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test('Commit the changes', async function () {
|
|
193
|
+
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.actionConstructor(commitChangesButtonLabel));
|
|
194
|
+
Logger.debug(`scmProvider.commitChanges: commit name "Commit ${changesToCommit}"`);
|
|
195
|
+
await scmProvider.commitChanges('Commit ' + changesToCommit);
|
|
196
|
+
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more);
|
|
197
|
+
await driverHelper.wait(timeToRefresh);
|
|
198
|
+
Logger.debug(`scmProvider.takeAction: "${refreshButtonLabel}"`);
|
|
199
|
+
await scmProvider.takeAction(refreshButtonLabel);
|
|
200
|
+
// wait while changes counter will be refreshed
|
|
201
|
+
await driverHelper.wait(timeToRefresh);
|
|
202
|
+
const changes: number = await scmProvider.getChangeCount();
|
|
203
|
+
Logger.debug(`scmProvider.getChangeCount: number of changes is "${changes}"`);
|
|
204
|
+
expect(changes).eql(0);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test('Push the changes', async function () {
|
|
208
|
+
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.actionConstructor(`Push 1 commits to origin/${TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_BRANCH}`));
|
|
209
|
+
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more);
|
|
210
|
+
Logger.debug(`scmProvider.openMoreActions`);
|
|
211
|
+
scmContextMenu = await scmProvider.openMoreActions();
|
|
212
|
+
await driverHelper.waitVisibility(webCheCodeLocators.ContextMenu.itemConstructor(pushItemLabel));
|
|
213
|
+
Logger.debug(`scmContextMenu.select: "${pushItemLabel}"`);
|
|
214
|
+
await scmContextMenu.select(pushItemLabel);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test('Insert git credentials which were asked after push', async function () {
|
|
218
|
+
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more);
|
|
219
|
+
|
|
220
|
+
try {
|
|
221
|
+
await driverHelper.waitVisibility(webCheCodeLocators.Input.inputBox);
|
|
222
|
+
} catch (e) {
|
|
223
|
+
Logger.info(`Workspace did not ask credentials before push - ${e};
|
|
224
|
+
Known issue for github.com - https://issues.redhat.com/browse/CRW-4066`);
|
|
225
|
+
}
|
|
226
|
+
const input: InputBox = new InputBox();
|
|
227
|
+
await input.setText(TestConstants.TS_SELENIUM_GIT_PROVIDER_USERNAME);
|
|
228
|
+
await input.confirm();
|
|
229
|
+
await driverHelper.wait(timeToRefresh);
|
|
230
|
+
await input.setText(TestConstants.TS_SELENIUM_GIT_PROVIDER_PASSWORD);
|
|
231
|
+
await input.confirm();
|
|
232
|
+
await driverHelper.wait(timeToRefresh);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
test('Check if the changes were pushed', async function () {
|
|
236
|
+
try {
|
|
237
|
+
Logger.debug(`scmProvider.takeAction: "${refreshButtonLabel}"`);
|
|
238
|
+
await scmProvider.takeAction(refreshButtonLabel);
|
|
239
|
+
} catch (e) {
|
|
240
|
+
Logger.info('Check you use correct credentials.' +
|
|
241
|
+
'For bitbucket.org ensure you use an app password: https://support.atlassian.com/bitbucket-cloud/docs/using-app-passwords/;' +
|
|
242
|
+
'For github.com - personal access token instead of password.');
|
|
243
|
+
}
|
|
244
|
+
const isCommitButtonDisabled: string = await driverHelper.waitAndGetElementAttribute(webCheCodeLocators.ScmView.actionConstructor(commitChangesButtonLabel), 'aria-disabled');
|
|
245
|
+
expect(isCommitButtonDisabled).eql('true');
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
test(`Stop and remove the workspace`, async function () {
|
|
250
|
+
await workspaceHandlingTests.stopAndRemoveWorkspace(WorkspaceHandlingTests.getWorkspaceName());
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
loginTests.logoutFromChe();
|
|
254
|
+
|
|
255
|
+
suiteTeardown('Close the browser', async function () {
|
|
256
|
+
if (!TestConstants.TS_DEBUG_MODE) {
|
|
257
|
+
await driverHelper.getDriver().close();
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { e2eContainer } from '../../configs/inversify.config';
|
|
2
|
+
import { assert } from 'chai';
|
|
3
|
+
import { registerRunningWorkspace } from '../MochaHooks';
|
|
4
|
+
import { CLASSES } from '../../configs/inversify.types';
|
|
5
|
+
import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests';
|
|
6
|
+
import { Logger } from '../../utils/Logger';
|
|
7
|
+
import { LoginTests } from '../../tests-library/LoginTests';
|
|
8
|
+
|
|
9
|
+
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
|
|
10
|
+
const util: any = require('node:util');
|
|
11
|
+
const exec: any = util.promisify(require('node:child_process').exec);
|
|
12
|
+
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
|
|
13
|
+
const predefinedNamespaceName: string = 'predefined-ns';
|
|
14
|
+
|
|
15
|
+
async function runShellScript(shellCommandToExecution: string): Promise<string> {
|
|
16
|
+
const {stdout, stderr} = await exec(shellCommandToExecution);
|
|
17
|
+
console.log(stdout);
|
|
18
|
+
console.error(stderr);
|
|
19
|
+
return stdout;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
suite(`Create predefined workspace and check it `, async function () {
|
|
23
|
+
let workspaceName: string = '';
|
|
24
|
+
|
|
25
|
+
const setEditRightsForUser: string = `oc adm policy add-role-to-user edit user -n ${predefinedNamespaceName}`;
|
|
26
|
+
const getDevWorkspaceFromPredefinedNameSpace: string = `oc get dw -n ${predefinedNamespaceName}`;
|
|
27
|
+
const deletePredefinedNamespace: string = `oc delete project ${predefinedNamespaceName}`;
|
|
28
|
+
const createPredefinedProjectCommand: string = 'cat <<EOF | oc apply -f - \n' +
|
|
29
|
+
'kind: Namespace\n' +
|
|
30
|
+
'apiVersion: v1\n' +
|
|
31
|
+
'metadata:\n' +
|
|
32
|
+
` name: ${predefinedNamespaceName}\n` +
|
|
33
|
+
' labels:\n' +
|
|
34
|
+
' app.kubernetes.io/part-of: che.eclipse.org\n' +
|
|
35
|
+
' app.kubernetes.io/component: workspaces-namespace\n' +
|
|
36
|
+
' annotations:\n' +
|
|
37
|
+
' che.eclipse.org/username: user\n' +
|
|
38
|
+
'EOF';
|
|
39
|
+
// create a predefined namespace for user using shell script and login into user dashboard
|
|
40
|
+
suiteSetup(async function () {
|
|
41
|
+
Logger.info('Test prerequisites:');
|
|
42
|
+
Logger.info(' (1) there is OCP user with username and user password that have been set in the TS_SELENIUM_USERNAME and TS_SELENIUM_PASSWORD variables');
|
|
43
|
+
Logger.info(' (2) \'oc\' client installed and logged into test OCP cluster with admin rights.');
|
|
44
|
+
|
|
45
|
+
await runShellScript(createPredefinedProjectCommand);
|
|
46
|
+
await runShellScript(setEditRightsForUser);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
suiteTeardown(async () => {
|
|
50
|
+
const workspaceName: string = WorkspaceHandlingTests.getWorkspaceName();
|
|
51
|
+
try {
|
|
52
|
+
await runShellScript(deletePredefinedNamespace);
|
|
53
|
+
} catch (e) {
|
|
54
|
+
Logger.error(`Cannot remove the predefined project: ${workspaceName}, please fix it manually: ${e}`);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
loginTests.loginIntoChe();
|
|
59
|
+
// create the Empty workspace using CHE Dashboard
|
|
60
|
+
workspaceHandlingTests.createAndOpenWorkspace('Empty Workspace');
|
|
61
|
+
workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
|
|
62
|
+
|
|
63
|
+
// verify that just created workspace with unique name is present in the predefined namespace
|
|
64
|
+
test('Validate the created workspace is present in predefined namespace', async function () {
|
|
65
|
+
workspaceName = WorkspaceHandlingTests.getWorkspaceName();
|
|
66
|
+
registerRunningWorkspace(workspaceName);
|
|
67
|
+
const ocDevWorkspaceOutput: string = await runShellScript(getDevWorkspaceFromPredefinedNameSpace);
|
|
68
|
+
await assert.isTrue(ocDevWorkspaceOutput.includes(workspaceName));
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
loginTests.logoutFromChe();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
|
|
@@ -14,12 +14,14 @@ import { TestConstants } from '../constants/TestConstants';
|
|
|
14
14
|
import { BrowserTabsUtil } from '../utils/BrowserTabsUtil';
|
|
15
15
|
import { Logger } from '../utils/Logger';
|
|
16
16
|
import { inject, injectable } from 'inversify';
|
|
17
|
+
import { Dashboard } from '../pageobjects/dashboard/Dashboard';
|
|
17
18
|
|
|
18
19
|
@injectable()
|
|
19
20
|
export class LoginTests {
|
|
20
21
|
constructor(
|
|
21
22
|
@inject(CLASSES.BrowserTabsUtil) private readonly browserTabsUtil: BrowserTabsUtil,
|
|
22
|
-
@inject(TYPES.CheLogin) private readonly loginPage: ICheLoginPage
|
|
23
|
+
@inject(TYPES.CheLogin) private readonly loginPage: ICheLoginPage,
|
|
24
|
+
@inject(CLASSES.Dashboard) private readonly dashboard: Dashboard) {
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
public loginIntoChe(): void {
|
|
@@ -32,4 +34,10 @@ export class LoginTests {
|
|
|
32
34
|
}
|
|
33
35
|
});
|
|
34
36
|
}
|
|
37
|
+
|
|
38
|
+
public logoutFromChe(): void {
|
|
39
|
+
test('Logout', async () => {
|
|
40
|
+
await this.dashboard.logout();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
35
43
|
}
|
|
@@ -29,10 +29,6 @@ export class WorkspaceHandlingTests {
|
|
|
29
29
|
return WorkspaceHandlingTests.workspaceName;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
public static setWorkspaceName(workspaceName: string): void {
|
|
33
|
-
WorkspaceHandlingTests.workspaceName = workspaceName;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
32
|
private static WORKSPACE_NAME_LOCATOR: By = By.xpath(`//h1[contains(.,'Starting workspace ')]`);
|
|
37
33
|
private static workspaceName: string = 'undefined';
|
|
38
34
|
private static parentGUID: string;
|
|
@@ -61,7 +57,7 @@ export class WorkspaceHandlingTests {
|
|
|
61
57
|
await this.dashboard.clickCreateWorkspaceButton();
|
|
62
58
|
await this.createWorkspace.waitPage();
|
|
63
59
|
WorkspaceHandlingTests.parentGUID = await this.browserTabsUtil.getCurrentWindowHandle();
|
|
64
|
-
await this.createWorkspace.
|
|
60
|
+
await this.createWorkspace.clickOnSampleNoEditorSelection(stack);
|
|
65
61
|
await this.browserTabsUtil.waitAndSwitchToAnotherWindow(WorkspaceHandlingTests.parentGUID, TimeoutConstants.TS_IDE_LOAD_TIMEOUT);
|
|
66
62
|
});
|
|
67
63
|
}
|
|
@@ -110,8 +106,8 @@ export class WorkspaceHandlingTests {
|
|
|
110
106
|
Logger.info(`Obtained workspace name from workspace loader page: ${WorkspaceHandlingTests.workspaceName}`);
|
|
111
107
|
return;
|
|
112
108
|
}
|
|
113
|
-
Logger.error(`WorkspaceHandlingTests.
|
|
114
|
-
throw new error.InvalidArgumentError(`WorkspaceHandlingTests.
|
|
109
|
+
Logger.error(`WorkspaceHandlingTests.obtainWorkspaceNameFromStartingPage failed to obtain workspace name:${WorkspaceHandlingTests.workspaceName}`);
|
|
110
|
+
throw new error.InvalidArgumentError(`WorkspaceHandlingTests.obtainWorkspaceNameFromStartingPage failed to obtain workspace name:${WorkspaceHandlingTests.workspaceName}`);
|
|
115
111
|
});
|
|
116
112
|
}
|
|
117
113
|
|
package/utils/BrowserTabsUtil.ts
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
**********************************************************************/
|
|
10
10
|
|
|
11
11
|
import { injectable, inject } from 'inversify';
|
|
12
|
-
import { By, error } from 'selenium-webdriver';
|
|
13
12
|
import { CLASSES } from '../configs/inversify.types';
|
|
14
13
|
import { DriverHelper } from './DriverHelper';
|
|
15
14
|
import { Logger } from './Logger';
|
|
@@ -60,18 +59,11 @@ export class BrowserTabsUtil {
|
|
|
60
59
|
|
|
61
60
|
const windowHandles: string[] = await this.getAllWindowHandles();
|
|
62
61
|
|
|
63
|
-
|
|
62
|
+
for (const windowHandle of windowHandles) {
|
|
64
63
|
if (windowHandle !== currentWindowHandle) {
|
|
65
64
|
await this.switchToWindow(windowHandle);
|
|
66
|
-
return;
|
|
67
65
|
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async waitContentAvailableInTheNewTab(contentLocator: By, timeout: number) {
|
|
72
|
-
Logger.debug('BrowserTabsUtil.waitContentAvailableInTheNewTab');
|
|
73
|
-
|
|
74
|
-
await this.driverHelper.waitVisibility(contentLocator, timeout);
|
|
66
|
+
}
|
|
75
67
|
}
|
|
76
68
|
|
|
77
69
|
async refreshPage() {
|
|
@@ -80,20 +72,6 @@ export class BrowserTabsUtil {
|
|
|
80
72
|
await (await this.driverHelper.getDriver()).navigate().refresh();
|
|
81
73
|
}
|
|
82
74
|
|
|
83
|
-
async refreshForDebug() {
|
|
84
|
-
Logger.debug('BrowserTabsUtil.refreshForDebug');
|
|
85
|
-
|
|
86
|
-
// if refresh triggers debug breakpoint test stucks of the refreshing
|
|
87
|
-
// and fail with a timeout error.
|
|
88
|
-
try {
|
|
89
|
-
await (await this.driverHelper.getDriver()).navigate().refresh();
|
|
90
|
-
} catch (err) {
|
|
91
|
-
if (!(err instanceof error.TimeoutError)) {
|
|
92
|
-
throw err;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
75
|
async getCurrentUrl(): Promise<string> {
|
|
98
76
|
return await this.driverHelper.getDriver().getCurrentUrl();
|
|
99
77
|
}
|
package/utils/DriverHelper.ts
CHANGED
|
@@ -10,9 +10,8 @@
|
|
|
10
10
|
import { IDriver } from '../driver/IDriver';
|
|
11
11
|
import { inject, injectable } from 'inversify';
|
|
12
12
|
import { TYPES } from '../configs/inversify.types';
|
|
13
|
-
import { error,
|
|
13
|
+
import { Actions, By, error, ThenableWebDriver, until, WebElement } from 'selenium-webdriver';
|
|
14
14
|
import 'reflect-metadata';
|
|
15
|
-
import { ThenableWebDriver, By, until, WebElement } from 'selenium-webdriver';
|
|
16
15
|
import { TestConstants } from '../constants/TestConstants';
|
|
17
16
|
import { Logger } from './Logger';
|
|
18
17
|
import { TimeoutConstants } from '../constants/TimeoutConstants';
|
|
@@ -32,23 +31,12 @@ export class DriverHelper {
|
|
|
32
31
|
return this.driver.actions();
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
/**
|
|
36
|
-
* @deprecated Method deprecated. Use the next method instead.
|
|
37
|
-
* @see BrowserTabsUtil.maximize()
|
|
38
|
-
*/
|
|
39
|
-
public async maximize() {
|
|
40
|
-
Logger.trace(`DriverHelper.maximize`);
|
|
41
|
-
|
|
42
|
-
await this.driver.manage().window().maximize();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
34
|
public async isVisible(locator: By): Promise<boolean> {
|
|
46
35
|
Logger.trace(`DriverHelper.isVisible ${locator}`);
|
|
47
36
|
|
|
48
37
|
try {
|
|
49
38
|
const element: WebElement = await this.driver.findElement(locator);
|
|
50
|
-
|
|
51
|
-
return isVisible;
|
|
39
|
+
return await element.isDisplayed();
|
|
52
40
|
} catch {
|
|
53
41
|
return false;
|
|
54
42
|
}
|
|
@@ -164,8 +152,7 @@ export class DriverHelper {
|
|
|
164
152
|
|
|
165
153
|
for (let i = 0; i < attempts; i++) {
|
|
166
154
|
try {
|
|
167
|
-
|
|
168
|
-
return webElement;
|
|
155
|
+
return await this.driver.wait(until.elementLocated(elementLocator), polling);
|
|
169
156
|
} catch (err) {
|
|
170
157
|
if (err instanceof error.TimeoutError) {
|
|
171
158
|
Logger.trace(`DriverHelper.waitPresence - Polling timed out attempt #${(i + 1)}, retrying with ${polling}ms timeout`);
|
|
@@ -182,7 +169,7 @@ export class DriverHelper {
|
|
|
182
169
|
}
|
|
183
170
|
}
|
|
184
171
|
|
|
185
|
-
throw new error.TimeoutError(`Exceeded maximum presence
|
|
172
|
+
throw new error.TimeoutError(`Exceeded maximum presence checking attempts, problems with 'StaleElementReferenceError' of '${elementLocator}' element`);
|
|
186
173
|
}
|
|
187
174
|
|
|
188
175
|
public async waitAllPresence(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<Array<WebElement>> {
|
|
@@ -193,8 +180,7 @@ export class DriverHelper {
|
|
|
193
180
|
|
|
194
181
|
for (let i = 0; i < attempts; i++) {
|
|
195
182
|
try {
|
|
196
|
-
|
|
197
|
-
return webElements;
|
|
183
|
+
return await this.driver.wait(until.elementsLocated(elementLocator), polling);
|
|
198
184
|
} catch (err) {
|
|
199
185
|
if (err instanceof error.TimeoutError) {
|
|
200
186
|
Logger.trace(`DriverHelper.waitAllPresence - Polling timed out attempt #${(i + 1)}, retrying with ${polling}ms timeout`);
|
|
@@ -299,7 +285,6 @@ export class DriverHelper {
|
|
|
299
285
|
}
|
|
300
286
|
|
|
301
287
|
throw new error.TimeoutError(`Exceeded maximum clicking attempts, the '${elementLocator}' element is not clickable`);
|
|
302
|
-
|
|
303
288
|
}
|
|
304
289
|
|
|
305
290
|
public async waitAndGetElementAttribute(elementLocator: By, attribute: string,
|
|
@@ -329,8 +314,7 @@ export class DriverHelper {
|
|
|
329
314
|
}
|
|
330
315
|
|
|
331
316
|
try {
|
|
332
|
-
|
|
333
|
-
return attributeValue;
|
|
317
|
+
return await element.getAttribute(attribute);
|
|
334
318
|
} catch (err) {
|
|
335
319
|
if (err instanceof error.StaleElementReferenceError) {
|
|
336
320
|
await this.wait(polling);
|
|
@@ -372,8 +356,7 @@ export class DriverHelper {
|
|
|
372
356
|
}
|
|
373
357
|
|
|
374
358
|
try {
|
|
375
|
-
|
|
376
|
-
return cssAttributeValue;
|
|
359
|
+
return await element.getCssValue(cssAttribute);
|
|
377
360
|
} catch (err) {
|
|
378
361
|
if (err instanceof error.StaleElementReferenceError) {
|
|
379
362
|
await this.wait(polling);
|
|
@@ -622,8 +605,7 @@ export class DriverHelper {
|
|
|
622
605
|
}
|
|
623
606
|
|
|
624
607
|
try {
|
|
625
|
-
|
|
626
|
-
return innerText;
|
|
608
|
+
return await element.getText();
|
|
627
609
|
} catch (err) {
|
|
628
610
|
if (err instanceof error.StaleElementReferenceError) {
|
|
629
611
|
await this.wait(polling);
|
|
@@ -641,8 +623,7 @@ export class DriverHelper {
|
|
|
641
623
|
public async waitAndGetValue(elementLocator: By, timeout: number): Promise<string> {
|
|
642
624
|
Logger.trace(`DriverHelper.waitAndGetValue ${elementLocator}`);
|
|
643
625
|
|
|
644
|
-
|
|
645
|
-
return elementValue;
|
|
626
|
+
return await this.waitAndGetElementAttribute(elementLocator, 'value', timeout);
|
|
646
627
|
}
|
|
647
628
|
|
|
648
629
|
public async waitUntilTrue(callback: any, timeout: number) {
|
|
@@ -651,54 +632,6 @@ export class DriverHelper {
|
|
|
651
632
|
await this.driver.wait(callback, timeout);
|
|
652
633
|
}
|
|
653
634
|
|
|
654
|
-
/**
|
|
655
|
-
* @deprecated Method deprecated. Use the next method instead.
|
|
656
|
-
* @see BrowserTabsUtil.refreshPage()
|
|
657
|
-
*/
|
|
658
|
-
public async reloadPage() {
|
|
659
|
-
Logger.debug('DriverHelper.reloadPage');
|
|
660
|
-
|
|
661
|
-
await this.driver.navigate().refresh();
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
/**
|
|
665
|
-
* @deprecated Method deprecated. Use the next method instead.
|
|
666
|
-
* @see BrowserTabsUtil.navigateAndWaitToUrl()
|
|
667
|
-
*/
|
|
668
|
-
public async navigateAndWaitToUrl(url: string, timeout: number = TimeoutConstants.TS_SELENIUM_WAIT_FOR_URL) {
|
|
669
|
-
Logger.trace(`DriverHelper.navigateAndWaitToUrl ${url}`);
|
|
670
|
-
|
|
671
|
-
await this.navigateToUrl(url);
|
|
672
|
-
await this.waitURL(url, timeout);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
/**
|
|
676
|
-
* @deprecated Method deprecated. Use the next method instead.
|
|
677
|
-
* @see BrowserTabsUtil.navigateTo()
|
|
678
|
-
*/
|
|
679
|
-
public async navigateToUrl(url: string) {
|
|
680
|
-
Logger.debug(`DriverHelper.navigateToUrl ${url}`);
|
|
681
|
-
|
|
682
|
-
await this.driver.navigate().to(url);
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
/**
|
|
686
|
-
* @deprecated Method deprecated. Use the next method instead.
|
|
687
|
-
* @see BrowserTabsUtil.waitURL()
|
|
688
|
-
*/
|
|
689
|
-
public async waitURL(expectedUrl: string, timeout: number) {
|
|
690
|
-
Logger.trace(`DriverHelper.waitURL ${expectedUrl}`);
|
|
691
|
-
|
|
692
|
-
await this.getDriver().wait(async () => {
|
|
693
|
-
const currentUrl: string = await this.getDriver().getCurrentUrl();
|
|
694
|
-
const urlEquals: boolean = currentUrl === expectedUrl;
|
|
695
|
-
|
|
696
|
-
if (urlEquals) {
|
|
697
|
-
return true;
|
|
698
|
-
}
|
|
699
|
-
}, timeout);
|
|
700
|
-
}
|
|
701
|
-
|
|
702
635
|
public async scrollTo(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM) {
|
|
703
636
|
const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING;
|
|
704
637
|
const attempts: number = Math.ceil(timeout / polling);
|
|
@@ -741,14 +674,6 @@ export class DriverHelper {
|
|
|
741
674
|
throw new error.TimeoutError(`Exceeded maximum mouse move attempts, for the '${elementLocator}' element`);
|
|
742
675
|
}
|
|
743
676
|
|
|
744
|
-
/**
|
|
745
|
-
* @deprecated Method deprecated. Use the next method instead.
|
|
746
|
-
* @see BrowserTabsUtil.getCurrentUrl()
|
|
747
|
-
*/
|
|
748
|
-
public async getCurrentUrl(): Promise<string> {
|
|
749
|
-
return await this.driver.getCurrentUrl();
|
|
750
|
-
}
|
|
751
|
-
|
|
752
677
|
getDriver(): ThenableWebDriver {
|
|
753
678
|
Logger.trace('DriverHelper.getDriver');
|
|
754
679
|
|
package/utils/Logger.ts
CHANGED
|
@@ -15,6 +15,7 @@ export abstract class Logger {
|
|
|
15
15
|
/**
|
|
16
16
|
* Uses for logging of fatal errors.
|
|
17
17
|
* @param text log text
|
|
18
|
+
* @param indentLevel log level
|
|
18
19
|
*/
|
|
19
20
|
public static error(text: string, indentLevel: number = 1) {
|
|
20
21
|
this.logText(indentLevel, `[ERROR] ${text}`);
|
|
@@ -23,6 +24,7 @@ export abstract class Logger {
|
|
|
23
24
|
/**
|
|
24
25
|
* Uses for logging of recoverable errors and general warnings.
|
|
25
26
|
* @param text log text
|
|
27
|
+
* @param indentLevel log level
|
|
26
28
|
*/
|
|
27
29
|
public static warn(text: string, indentLevel: number = 1) {
|
|
28
30
|
if (TestConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR') {
|
|
@@ -34,6 +36,7 @@ export abstract class Logger {
|
|
|
34
36
|
/**
|
|
35
37
|
* Uses for logging of the public methods of the pageobjects.
|
|
36
38
|
* @param text log text
|
|
39
|
+
* @param indentLevel log level
|
|
37
40
|
*/
|
|
38
41
|
public static info(text: string, indentLevel: number = 3) {
|
|
39
42
|
if (TestConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR' ||
|
|
@@ -46,6 +49,7 @@ export abstract class Logger {
|
|
|
46
49
|
/**
|
|
47
50
|
* Uses for logging of the public methods of the pageobjects.
|
|
48
51
|
* @param text log text
|
|
52
|
+
* @param indentLevel log level
|
|
49
53
|
*/
|
|
50
54
|
public static debug(text: string, indentLevel: number = 5) {
|
|
51
55
|
if (TestConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR' ||
|
|
@@ -60,6 +64,7 @@ export abstract class Logger {
|
|
|
60
64
|
* Uses for logging of the public methods of the {@link DriverHelper} or
|
|
61
65
|
* private methods inside of pageobjects.
|
|
62
66
|
* @param text log text
|
|
67
|
+
* @param indentLevel log level
|
|
63
68
|
*/
|
|
64
69
|
public static trace(text: string, indentLevel: number = 6) {
|
|
65
70
|
if (TestConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR' ||
|