Skip to content

Commit c8d9d19

Browse files
authored
Fix up 'Factory' E2E tests (#23497)
* Update locators in 'CheCodeLocatorLoader' * Update 'factory' E2E tests related to changes in editor * Do formatting 'CODE_STYLE' file
1 parent 791d4e0 commit c8d9d19

File tree

5 files changed

+38
-27
lines changed

5 files changed

+38
-27
lines changed

tests/e2e/CODE_STYLE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Automated lint checking and code format performs with ESLint and Prettier tools
2828
### Preferable code style
2929

3030
1. Page-object and util classes
31+
3132
1. ✔ Class declaration using dependency injection (inversify library)
3233

3334
```
@@ -37,6 +38,7 @@ Automated lint checking and code format performs with ESLint and Prettier tools
3738
```
3839
3940
2. Public methods
41+
4042
- ✔ Declare public methods without "public "keyword
4143
- ✔ Add Logger.debug() inside method to log its name (with optional message)
4244
@@ -49,6 +51,7 @@ Automated lint checking and code format performs with ESLint and Prettier tools
4951
```
5052
5153
3. Locators
54+
5255
- ✔ For static locators - private static readonly fields type of By
5356
5457
```
@@ -102,6 +105,7 @@ Automated lint checking and code format performs with ESLint and Prettier tools
102105
```
103106
104107
2. Mocha framework
108+
105109
- ✔ TDD framework (`suite()`, `test()`)
106110
- ✔ Inject class instances, declare all test data inside test `suit()` function to avoid unnecessary code execution if test suit will not be run
107111
@@ -118,6 +122,7 @@ Automated lint checking and code format performs with ESLint and Prettier tools
118122
- ✔ Use test [./constants](constants) to make test flexible
119123
120124
3. Packages
125+
121126
1. Add packages as dev dependencies
122127
2. If any changes re-create package-lock.json before push
123128

tests/e2e/pageobjects/ide/CheCodeLocatorLoader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ export class CheCodeLocatorLoader extends LocatorLoader {
4848
contextView: By.className('monaco-menu-container')
4949
},
5050
Editor: {
51-
inputArea: By.className('native-edit-context-textarea')
51+
inputArea: By.className('editor-container')
5252
},
5353
ExtensionsViewSection: {
54-
searchBox: By.className('native-edit-context-textarea')
54+
searchBox: By.className('ime-text-area')
5555
},
5656
ExtensionsViewItem: {
5757
author: By.className('publisher')

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

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,7 @@
1111
import 'reflect-metadata';
1212

1313
import { e2eContainer } from '../../configs/inversify.config';
14-
import {
15-
ActivityBar,
16-
ContextMenu,
17-
EditorView,
18-
Key,
19-
Locators,
20-
NewScmView,
21-
SingleScmProvider,
22-
TextEditor,
23-
ViewControl,
24-
ViewSection
25-
} from 'monaco-page-objects';
14+
import { ActivityBar, ContextMenu, Key, Locators, NewScmView, SingleScmProvider, ViewControl, ViewSection } from 'monaco-page-objects';
2615
import { expect } from 'chai';
2716
import { OauthPage } from '../../pageobjects/git-providers/OauthPage';
2817
import { StringUtil } from '../../utils/StringUtil';
@@ -135,10 +124,17 @@ suite(
135124
test('Make changes to the file', async function (): Promise<void> {
136125
Logger.debug(`projectSection.openItem: "${fileToChange}"`);
137126
await projectSection.openItem(testRepoProjectName, fileToChange);
138-
const editor: TextEditor = (await new EditorView().openEditor(fileToChange)) as TextEditor;
139127
await driverHelper.waitVisibility(webCheCodeLocators.Editor.inputArea);
140-
Logger.debug(`editor.setText: "${changesToCommit}"`);
141-
await editor.setText(changesToCommit);
128+
await driverHelper.getDriver().findElement(webCheCodeLocators.Editor.inputArea).click();
129+
130+
Logger.debug('Clearing the editor with Ctrl+A');
131+
await driverHelper.getDriver().actions().keyDown(Key.CONTROL).sendKeys('a').keyUp(Key.CONTROL).perform();
132+
await driverHelper.wait(500);
133+
Logger.debug('Deleting selected text');
134+
await driverHelper.getDriver().actions().sendKeys(Key.DELETE).perform();
135+
await driverHelper.wait(500);
136+
Logger.debug(`Entering text: "${changesToCommit}"`);
137+
await driverHelper.getDriver().actions().sendKeys(changesToCommit).perform();
142138
});
143139

144140
test('Open a source control manager', async function (): Promise<void> {

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ import { e2eContainer } from '../../configs/inversify.config';
1313
import {
1414
ActivityBar,
1515
ContextMenu,
16-
EditorView,
1716
InputBox,
1817
Key,
1918
Locators,
2019
ModalDialog,
2120
NewScmView,
2221
SingleScmProvider,
23-
TextEditor,
2422
ViewControl,
2523
ViewSection
2624
} from 'monaco-page-objects';
@@ -132,10 +130,17 @@ suite(
132130
test('Make changes to the file', async function (): Promise<void> {
133131
Logger.debug(`projectSection.openItem: "${fileToChange}"`);
134132
await projectSection.openItem(testRepoProjectName, fileToChange);
135-
const editor: TextEditor = (await new EditorView().openEditor(fileToChange)) as TextEditor;
136133
await driverHelper.waitVisibility(webCheCodeLocators.Editor.inputArea);
137-
Logger.debug(`editor.setText: "${changesToCommit}"`);
138-
await editor.setText(changesToCommit);
134+
await driverHelper.getDriver().findElement(webCheCodeLocators.Editor.inputArea).click();
135+
136+
Logger.debug('Clearing the editor with Ctrl+A');
137+
await driverHelper.getDriver().actions().keyDown(Key.CONTROL).sendKeys('a').keyUp(Key.CONTROL).perform();
138+
await driverHelper.wait(500);
139+
Logger.debug('Deleting selected text');
140+
await driverHelper.getDriver().actions().sendKeys(Key.DELETE).perform();
141+
await driverHelper.wait(500);
142+
Logger.debug(`Entering text: "${changesToCommit}"`);
143+
await driverHelper.getDriver().actions().sendKeys(changesToCommit).perform();
139144
});
140145

141146
test('Open a source control manager', async function (): Promise<void> {

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ import { e2eContainer } from '../../configs/inversify.config';
1313
import {
1414
ActivityBar,
1515
ContextMenu,
16-
EditorView,
1716
InputBox,
1817
Key,
1918
Locators,
2019
NewScmView,
2120
SingleScmProvider,
22-
TextEditor,
2321
ViewControl,
2422
ViewSection
2523
} from 'monaco-page-objects';
@@ -138,10 +136,17 @@ suite(
138136
test('Make changes to the file', async function (): Promise<void> {
139137
Logger.debug(`projectSection.openItem: "${fileToChange}"`);
140138
await projectSection.openItem(testRepoProjectName, fileToChange);
141-
const editor: TextEditor = (await new EditorView().openEditor(fileToChange)) as TextEditor;
142139
await driverHelper.waitVisibility(webCheCodeLocators.Editor.inputArea);
143-
Logger.debug(`editor.setText: "${changesToCommit}"`);
144-
await editor.setText(changesToCommit);
140+
await driverHelper.getDriver().findElement(webCheCodeLocators.Editor.inputArea).click();
141+
142+
Logger.debug('Clearing the editor with Ctrl+A');
143+
await driverHelper.getDriver().actions().keyDown(Key.CONTROL).sendKeys('a').keyUp(Key.CONTROL).perform();
144+
await driverHelper.wait(500);
145+
Logger.debug('Deleting selected text');
146+
await driverHelper.getDriver().actions().sendKeys(Key.DELETE).perform();
147+
await driverHelper.wait(500);
148+
Logger.debug(`Entering text: "${changesToCommit}"`);
149+
await driverHelper.getDriver().actions().sendKeys(changesToCommit).perform();
145150
});
146151

147152
test('Open a source control manager', async function (): Promise<void> {

0 commit comments

Comments
 (0)