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

fix(UITest): fix for unstable tests & minor improvements #301

Merged
merged 3 commits into from
Sep 5, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private void removeTopProjectFromRecentProjects() {
"robot.click(component, new Point(horizontal_offset, 22), MouseButton.LEFT_BUTTON, 1);");

if (ideaVersion >= 20231) {
ComponentFixture removeDialog = remoteRobot.find(ComponentFixture.class, byXpath(XPathDefinitions.MY_DIALOG), Duration.ofSeconds(2));
ComponentFixture removeDialog = remoteRobot.find(ComponentFixture.class, byXpath(XPathDefinitions.MY_DIALOG), Duration.ofSeconds(10));
removeDialog.findText(ButtonLabels.REMOVE_FROM_LIST_LABEL)
.click();
} else if (ideaVersion >= 20203) { // Code for IntelliJ Idea 2020.3 or newer
Expand Down
2 changes: 2 additions & 0 deletions src/test-project/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ test {

tasks.register('integrationUITestUltimate', Test) {
dependsOn copyKey
group = 'verification'
systemProperties['task.name'] = 'integrationUITestUltimate'
systemProperties['intellij_debug'] = 'true'
useJUnitPlatform()
}

tasks.register('integrationUITest', Test) {
systemProperties['intellij_debug'] = 'true'
group = 'verification'
useJUnitPlatform()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,26 @@ public void hideAllPopups() {

@Test
public void isItemPresentTest() {
boolean isItemPresent = projectExplorer.isItemPresent(PROJECT_NAME, PROJECT_NAME + ".iml");
assertTrue(isItemPresent, "The file '" + PROJECT_NAME + ".iml' should be present in the project on location '" + PROJECT_NAME + "/" + PROJECT_NAME + ".iml' but is not.");
boolean isItemPresent = projectExplorer.isItemPresent(PROJECT_NAME, "src", "Main");
assertTrue(isItemPresent, "The file 'Main' should be present in the project on location 'src/Main' but is not.");
}

@Test
public void openFileTest() {
projectExplorer.openFile(PROJECT_NAME, PROJECT_NAME + ".iml");
projectExplorer.openFile(PROJECT_NAME, ".gitignore");
if (ideaVersionInt >= 20231) { // Code for IJ 2023.1+
String projectLabelXpath = "//div[@accessiblename='" + PROJECT_NAME + ".iml' and @class='EditorTabLabel']//div[@class='ActionPanel']";
String projectLabelXpath = "//div[@accessiblename='.gitignore' and @class='EditorTabLabel']//div[@class='ActionPanel']";
try { // Verify file is opened by finding its tab in the editor
remoteRobot.find(ComponentFixture.class, byXpath(projectLabelXpath));
} catch (Exception e) {
fail("The '" + PROJECT_NAME + ".iml' file should be opened but is not.");
fail("The '.gitignore' file should be opened but is not.");
}
} else {
List<ContainerFixture> cfs = remoteRobot.findAll(ContainerFixture.class, byXpath(XPathDefinitions.SINGLE_HEIGHT_LABEL));
ContainerFixture cf = cfs.get(cfs.size() - 1);
String allText = TextUtils.listOfRemoteTextToString(cf.findAllText());
boolean isFileOpened = allText.contains(PROJECT_NAME + ".iml");
assertTrue(isFileOpened, "The '" + PROJECT_NAME + ".iml' file should be opened but is not.");
boolean isFileOpened = allText.contains(".gitignore");
assertTrue(isFileOpened, "The '.gitignore' file should be opened but is not.");
}
}

Expand All @@ -117,12 +117,16 @@ public void openViewsPopupTest() {

@Test
public void selectOpenedFileTest() {
projectExplorer.openFile(PROJECT_NAME, PROJECT_NAME + ".iml");
projectExplorer.expandAll();
projectExplorer.openFile(PROJECT_NAME, "src", "Main");
projectExplorer.projectViewTree().clickRow(0);
SharedSteps.waitForComponentByXpath(remoteRobot,3,1, byXpath(XPathDefinitions.MY_ICON_LOCATE_SVG));
SharedSteps.waitForComponentByXpath(remoteRobot, 3, 1, byXpath(XPathDefinitions.MY_ICON_LOCATE_SVG));
projectExplorer.selectOpenedFile();
SharedSteps.waitForComponentByXpath(remoteRobot,3,1, byXpath(XPathDefinitions.MY_ICON_LOCATE_SVG));
assertTrue(projectExplorer.projectViewTree().isPathSelected(projectExplorer.projectViewTree().getValueAtRow(0), PROJECT_NAME + ".iml"), "The file '" + PROJECT_NAME + ".xml' should be selected but is not.");
SharedSteps.waitForComponentByXpath(remoteRobot, 3, 1, byXpath(XPathDefinitions.MY_ICON_LOCATE_SVG));
assertTrue(projectExplorer.projectViewTree().isPathSelected(
projectExplorer.projectViewTree().getValueAtRow(0), "src", "Main"),
"The file 'Main' should be selected but is not."
);
}

@Test
Expand Down
Loading