-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
AutocompleteJSFilesTest.java
148 lines (129 loc) · 6.13 KB
/
AutocompleteJSFilesTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
* Copyright (c) 2012-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.selenium.editor.autocomplete;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.MarkersType.INFO_MARKER;
import com.google.inject.Inject;
import java.net.URL;
import java.nio.file.Paths;
import org.eclipse.che.commons.lang.NameGenerator;
import org.eclipse.che.selenium.core.client.TestProjectServiceClient;
import org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants;
import org.eclipse.che.selenium.core.project.ProjectTemplates;
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
import org.eclipse.che.selenium.pageobject.AskForValueDialog;
import org.eclipse.che.selenium.pageobject.CodenvyEditor;
import org.eclipse.che.selenium.pageobject.Ide;
import org.eclipse.che.selenium.pageobject.Loader;
import org.eclipse.che.selenium.pageobject.Menu;
import org.eclipse.che.selenium.pageobject.NotificationsPopupPanel;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.openqa.selenium.Keys;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/** @author Andrey Chizhikov */
public class AutocompleteJSFilesTest {
private static final String PROJECT_NAME =
NameGenerator.generate(AutocompleteJSFilesTest.class.getSimpleName(), 4);
private static final String EXPECTED_TEXT =
"function a (){\n"
+ " var b = 5;\n"
+ " var c = b;\n"
+ " return c;\n"
+ "}\n"
+ "a();\n"
+ "/**\n"
+ " * \n"
+ " */";
@Inject private TestWorkspace workspace;
@Inject private Ide ide;
@Inject private ProjectExplorer projectExplorer;
@Inject private Loader loader;
@Inject private CodenvyEditor editor;
@Inject private NotificationsPopupPanel notificationsPopupPanel;
@Inject private Menu menu;
@Inject private AskForValueDialog askForValueDialog;
@Inject private TestProjectServiceClient testProjectServiceClient;
@BeforeClass
public void setUp() throws Exception {
URL resource = getClass().getResource("/projects/default-spring-project");
testProjectServiceClient.importProject(
workspace.getId(),
Paths.get(resource.toURI()),
PROJECT_NAME,
ProjectTemplates.MAVEN_SPRING);
ide.open(workspace);
}
@Test
public void checkAutocompleteJSFilesTest() {
projectExplorer.waitItem(PROJECT_NAME);
projectExplorer.openItemByPath(PROJECT_NAME);
notificationsPopupPanel.waitProgressPopupPanelClose();
projectExplorer.waitProjectExplorer();
projectExplorer.quickExpandWithJavaScript();
menu.runCommand(
TestMenuCommandsConstants.Project.PROJECT,
TestMenuCommandsConstants.Project.New.NEW,
TestMenuCommandsConstants.Project.New.JAVASCRIPT_FILE);
askForValueDialog.waitFormToOpen();
askForValueDialog.typeAndWaitText("newJsFile");
askForValueDialog.clickOkBtn();
loader.waitOnClosed();
projectExplorer.waitItemInVisibleArea("newJsFile.js");
editor.waitActiveEditor();
loader.waitOnClosed();
editor.setCursorToLine(1);
editor.typeTextIntoEditorWithoutDelayForSaving("function a (");
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.END.toString());
editor.typeTextIntoEditorWithoutDelayForSaving("{");
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.ENTER.toString());
editor.typeTextIntoEditorWithoutDelayForSaving("var b = 5;");
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.ENTER.toString());
editor.typeTextIntoEditorWithoutDelayForSaving("var c = ");
editor.launchPropositionAssistPanelForJSFiles();
editor.enterTextIntoFixErrorPropByEnterForJsFiles("b", " : number");
editor.typeTextIntoEditorWithoutDelayForSaving(";");
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.ENTER.toString());
editor.typeTextIntoEditorWithoutDelayForSaving("return c;");
editor.setCursorToLine(5);
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.END.toString());
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.ENTER.toString());
editor.launchPropositionAssistPanelForJSFiles();
editor.enterTextIntoFixErrorPropByEnterForJsFiles("a()", " : number");
editor.typeTextIntoEditorWithoutDelayForSaving(";");
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.ENTER.toString());
editor.typeTextIntoEditorWithoutDelayForSaving("/**");
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.ENTER.toString());
Assert.assertEquals(editor.getVisibleTextFromEditor(), EXPECTED_TEXT);
editor.setCursorToLine(9);
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.END.toString());
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.ENTER.toString());
editor.typeTextIntoEditorWithoutDelayForSaving("function f (");
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.END.toString());
editor.typeTextIntoEditorWithoutDelayForSaving("{");
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.ENTER.toString());
editor.typeTextIntoEditorWithoutDelayForSaving("return 'test text';");
editor.setCursorToLine(12);
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.END.toString());
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.ENTER.toString());
editor.launchPropositionAssistPanelForJSFiles();
editor.enterTextIntoFixErrorPropByEnterForJsFiles("f()", " : string");
editor.typeTextIntoEditorWithoutDelayForSaving(";");
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.ENTER.toString());
editor.setCursorToLine(11);
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.END.toString());
editor.typeTextIntoEditorWithoutDelayForSaving(Keys.BACK_SPACE.toString());
editor.waitMarkerInPositionAndClick(INFO_MARKER, 11);
editor.clickOnElementByXpath("//button[text()='Add missing semicolon']");
editor.waitAllMarkersDisappear(INFO_MARKER);
loader.waitOnClosed();
}
}