Skip to content

Commit 7d4c8a9

Browse files
authored
[Test] Fix 'Factory' tests according to the editor changes (#23385)
* Update editor locator * Fix 'Factory' tests according to the editor changes
1 parent e4e067d commit 7d4c8a9

File tree

5 files changed

+47
-20
lines changed

5 files changed

+47
-20
lines changed

tests/e2e/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export * from './pageobjects/dashboard/workspace-details/WorkspaceDetails';
3030
export * from './pageobjects/dashboard/Workspaces';
3131
export * from './pageobjects/git-providers/OauthPage';
3232
export * from './pageobjects/ide/CheCodeLocatorLoader';
33-
export * from './pageobjects/ide/ViewsMoreActionsButton';
3433
export * from './pageobjects/ide/RestrictedModeButton';
34+
export * from './pageobjects/ide/ViewsMoreActionsButton';
3535
export * from './pageobjects/login/interfaces/ICheLoginPage';
3636
export * from './pageobjects/login/interfaces/IOcpLoginPage';
3737
export * from './pageobjects/login/kubernetes/DexLoginPage';

tests/e2e/pageobjects/ide/CheCodeLocatorLoader.ts

+6
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,15 @@ export class CheCodeLocatorLoader extends LocatorLoader {
4646
},
4747
ContextMenu: {
4848
contextView: By.className('monaco-menu-container')
49+
},
50+
Editor: {
51+
inputArea: By.className('native-edit-context-textarea')
4952
}
5053
},
5154
extras: {
55+
ScmView: {
56+
scmEditor: By.className('scm-editor')
57+
},
5258
ExtensionsViewSection: {
5359
requireReloadButton: By.xpath('//a[text()="Reload Required"]')
5460
},

tests/e2e/specs/factory/Factory.spec.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
ActivityBar,
1616
ContextMenu,
1717
EditorView,
18+
Key,
1819
Locators,
1920
NewScmView,
2021
SingleScmProvider,
@@ -136,10 +137,8 @@ suite(
136137
await projectSection.openItem(testRepoProjectName, fileToChange);
137138
const editor: TextEditor = (await new EditorView().openEditor(fileToChange)) as TextEditor;
138139
await driverHelper.waitVisibility(webCheCodeLocators.Editor.inputArea);
139-
Logger.debug('editor.clearText');
140-
await editor.clearText();
141-
Logger.debug(`editor.typeTextAt: "${changesToCommit}"`);
142-
await editor.typeTextAt(1, 1, changesToCommit);
140+
Logger.debug(`editor.setText: "${changesToCommit}"`);
141+
await editor.setText(changesToCommit);
143142
});
144143

145144
test('Open a source control manager', async function (): Promise<void> {
@@ -179,8 +178,16 @@ suite(
179178
});
180179

181180
test('Commit the changes', async function (): Promise<void> {
182-
Logger.debug(`scmProvider.commitChanges: commit name "Commit ${changesToCommit}"`);
183-
await scmProvider.commitChanges('Commit ' + changesToCommit);
181+
Logger.info(`ScmView inputField locator: "${(webCheCodeLocators.ScmView as any).scmEditor}"`);
182+
Logger.debug('Click on the Scm Editor');
183+
await driverHelper
184+
.getDriver()
185+
.findElement((webCheCodeLocators.ScmView as any).scmEditor)
186+
.click();
187+
Logger.debug(`Type commit text: "Commit ${changesToCommit}"`);
188+
await driverHelper.getDriver().actions().sendKeys(changesToCommit).perform();
189+
Logger.debug('Press Enter to commit the changes');
190+
await driverHelper.getDriver().actions().keyDown(Key.CONTROL).sendKeys(Key.ENTER).keyUp(Key.CONTROL).perform();
184191
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more);
185192
await driverHelper.wait(timeToRefresh);
186193
Logger.debug(`wait and click on: "${refreshButtonLabel}"`);

tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
ContextMenu,
1616
EditorView,
1717
InputBox,
18+
Key,
1819
Locators,
1920
ModalDialog,
2021
NewScmView,
@@ -133,10 +134,8 @@ suite(
133134
await projectSection.openItem(testRepoProjectName, fileToChange);
134135
const editor: TextEditor = (await new EditorView().openEditor(fileToChange)) as TextEditor;
135136
await driverHelper.waitVisibility(webCheCodeLocators.Editor.inputArea);
136-
Logger.debug('editor.clearText');
137-
await editor.clearText();
138-
Logger.debug(`editor.typeTextAt: "${changesToCommit}"`);
139-
await editor.typeTextAt(1, 1, changesToCommit);
137+
Logger.debug(`editor.setText: "${changesToCommit}"`);
138+
await editor.setText(changesToCommit);
140139
});
141140

142141
test('Open a source control manager', async function (): Promise<void> {
@@ -176,8 +175,16 @@ suite(
176175
});
177176

178177
test('Commit the changes', async function (): Promise<void> {
179-
Logger.debug(`scmProvider.commitChanges: commit name "Commit ${changesToCommit}"`);
180-
await scmProvider.commitChanges('Commit ' + changesToCommit);
178+
Logger.info(`ScmView inputField locator: "${(webCheCodeLocators.ScmView as any).scmEditor}"`);
179+
Logger.debug('Click on the Scm Editor');
180+
await driverHelper
181+
.getDriver()
182+
.findElement((webCheCodeLocators.ScmView as any).scmEditor)
183+
.click();
184+
Logger.debug(`Type commit text: "Commit ${changesToCommit}"`);
185+
await driverHelper.getDriver().actions().sendKeys(changesToCommit).perform();
186+
Logger.debug('Press Enter to commit the changes');
187+
await driverHelper.getDriver().actions().keyDown(Key.CONTROL).sendKeys(Key.ENTER).keyUp(Key.CONTROL).perform();
181188
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more);
182189
await driverHelper.wait(timeToRefresh);
183190
Logger.debug(`wait and click on: "${refreshButtonLabel}"`);

tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** *******************************************************************
2-
* copyright (c) 2021-2024 Red Hat, Inc.
2+
* copyright (c) 2021-2025 Red Hat, Inc.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
@@ -15,6 +15,7 @@ import {
1515
ContextMenu,
1616
EditorView,
1717
InputBox,
18+
Key,
1819
Locators,
1920
NewScmView,
2021
SingleScmProvider,
@@ -139,10 +140,8 @@ suite(
139140
await projectSection.openItem(testRepoProjectName, fileToChange);
140141
const editor: TextEditor = (await new EditorView().openEditor(fileToChange)) as TextEditor;
141142
await driverHelper.waitVisibility(webCheCodeLocators.Editor.inputArea);
142-
Logger.debug('editor.clearText');
143-
await editor.clearText();
144-
Logger.debug(`editor.typeTextAt: "${changesToCommit}"`);
145-
await editor.typeTextAt(1, 1, changesToCommit);
143+
Logger.debug(`editor.setText: "${changesToCommit}"`);
144+
await editor.setText(changesToCommit);
146145
});
147146

148147
test('Open a source control manager', async function (): Promise<void> {
@@ -182,8 +181,16 @@ suite(
182181
});
183182

184183
test('Commit the changes', async function (): Promise<void> {
185-
Logger.debug(`scmProvider.commitChanges: commit name "Commit ${changesToCommit}"`);
186-
await scmProvider.commitChanges('Commit ' + changesToCommit);
184+
Logger.info(`ScmView inputField locator: "${(webCheCodeLocators.ScmView as any).scmEditor}"`);
185+
Logger.debug('Click on the Scm Editor');
186+
await driverHelper
187+
.getDriver()
188+
.findElement((webCheCodeLocators.ScmView as any).scmEditor)
189+
.click();
190+
Logger.debug(`Type commit text: "Commit ${changesToCommit}"`);
191+
await driverHelper.getDriver().actions().sendKeys(changesToCommit).perform();
192+
Logger.debug('Press Enter to commit the changes');
193+
await driverHelper.getDriver().actions().keyDown(Key.CONTROL).sendKeys(Key.ENTER).keyUp(Key.CONTROL).perform();
187194
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more);
188195
await driverHelper.wait(timeToRefresh);
189196
Logger.debug(`wait and click on: "${refreshButtonLabel}"`);

0 commit comments

Comments
 (0)