mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
[IFT] Fix UI tests in Git lessons
GitOrigin-RevId: ca88dc30a2d8b552c4ba5485335f505b7161c700
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b927380be2
commit
fea0d09484
@@ -302,4 +302,19 @@ object GitLessonsUtil {
|
||||
robot.click(tree, Point(pathRect.x + offset, pathRect.y + offset))
|
||||
}
|
||||
}
|
||||
|
||||
fun TaskTestContext.clickTreeRow(doubleClick: Boolean = false, rightClick: Boolean = false, rowItemPredicate: (Any) -> Boolean) {
|
||||
ideFrame {
|
||||
val tree = jTree { path -> rowItemPredicate(path.lastPathComponent) }
|
||||
val rowToClick = invokeAndWaitIfNeeded {
|
||||
val path = TreeUtil.treePathTraverser(tree.target()).find { path -> rowItemPredicate(path.lastPathComponent) }
|
||||
tree.target().getRowForPath(path)
|
||||
}
|
||||
when {
|
||||
doubleClick -> tree.doubleClickRow(rowToClick)
|
||||
rightClick -> tree.rightClickRow(rowToClick)
|
||||
else -> tree.clickRow(rowToClick)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import training.dsl.*
|
||||
import training.dsl.LessonUtil.adjustPopupPosition
|
||||
import training.dsl.LessonUtil.restorePopupPosition
|
||||
import training.git.GitLessonsBundle
|
||||
import training.git.GitLessonsUtil.clickTreeRow
|
||||
import training.git.GitLessonsUtil.openCommitWindow
|
||||
import training.git.GitLessonsUtil.restoreByUiAndBackgroundTask
|
||||
import training.git.GitLessonsUtil.restoreCommitWindowStateInformer
|
||||
@@ -154,7 +155,10 @@ class GitChangelistsAndShelveLesson : GitLesson("Git.ChangelistsAndShelf", GitLe
|
||||
|
||||
task("CheckinProject") {
|
||||
openCommitWindow(GitLessonsBundle.message("git.changelists.shelf.open.commit.window"))
|
||||
test { actions(it) }
|
||||
test {
|
||||
val stripe = previous.ui ?: error("Not found Commit stripe button")
|
||||
ideFrame { jComponent(stripe).click() }
|
||||
}
|
||||
}
|
||||
|
||||
task {
|
||||
@@ -189,8 +193,7 @@ class GitChangelistsAndShelveLesson : GitLesson("Git.ChangelistsAndShelf", GitLe
|
||||
showWarningIfCommitWindowClosed(restoreTaskWhenResolved = true)
|
||||
test {
|
||||
ideFrame {
|
||||
val tree = jTree { path -> path.getPathComponent(path.pathCount - 1).toString() == newChangeListName }
|
||||
tree.rightClickPath(newChangeListName)
|
||||
clickTreeRow(rightClick = true) { item -> item.toString() == newChangeListName }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -262,8 +265,7 @@ class GitChangelistsAndShelveLesson : GitLesson("Git.ChangelistsAndShelf", GitLe
|
||||
showWarningIfCommitWindowClosed()
|
||||
test {
|
||||
ideFrame {
|
||||
val tree = jTree { path -> path.getPathComponent(path.pathCount - 1).toString() == newChangeListName }
|
||||
tree.rightClickPath(newChangeListName)
|
||||
clickTreeRow(rightClick = true) { item -> item.toString() == newChangeListName }
|
||||
jMenuItem { item: ActionMenuItem -> item.anAction is UnshelveWithDialogAction }.click()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,10 @@ class GitCommitLesson : GitLesson("Git.Commit", GitLessonsBundle.message("git.co
|
||||
|
||||
task {
|
||||
openCommitWindow(GitLessonsBundle.message("git.commit.open.commit.window"))
|
||||
test { actions("CheckinProject") }
|
||||
test {
|
||||
val stripe = previous.ui ?: error("Not found Commit stripe button")
|
||||
ideFrame { jComponent(stripe).click() }
|
||||
}
|
||||
}
|
||||
|
||||
prepareRuntimeTask {
|
||||
|
||||
@@ -31,6 +31,7 @@ import git4idea.ui.branch.GitBranchPopupActions
|
||||
import training.dsl.*
|
||||
import training.git.GitFeaturesTrainerIcons
|
||||
import training.git.GitLessonsBundle
|
||||
import training.git.GitLessonsUtil.clickTreeRow
|
||||
import training.git.GitLessonsUtil.highlightLatestCommitsFromBranch
|
||||
import training.git.GitLessonsUtil.highlightSubsequentCommitsInGitLog
|
||||
import training.git.GitLessonsUtil.resetGitLogWindow
|
||||
@@ -107,7 +108,10 @@ class GitFeatureBranchWorkflowLesson : GitLesson("Git.BasicWorkflow", GitLessons
|
||||
triggerAndBorderHighlight().treeItem { _, path ->
|
||||
(path.lastPathComponent as? GitLocalBranch)?.name == main
|
||||
}
|
||||
test { actions(it) }
|
||||
test {
|
||||
val widget = previous.ui ?: error("Not found VCS widget")
|
||||
ideFrame { jComponent(widget).click() }
|
||||
}
|
||||
}
|
||||
|
||||
task {
|
||||
@@ -121,7 +125,7 @@ class GitFeatureBranchWorkflowLesson : GitLesson("Git.BasicWorkflow", GitLessons
|
||||
delayMillis = 2 * defaultRestoreDelay, restoreId = firstShowBranchesTaskId)
|
||||
test {
|
||||
ideFrame {
|
||||
jList(main).clickItem(main)
|
||||
clickTreeRow { item -> (item as? GitLocalBranch)?.name == main }
|
||||
jList(checkoutItemText).clickItem(checkoutItemText)
|
||||
}
|
||||
}
|
||||
@@ -181,7 +185,10 @@ class GitFeatureBranchWorkflowLesson : GitLesson("Git.BasicWorkflow", GitLessons
|
||||
triggerAndBorderHighlight().treeItem { _, path ->
|
||||
(path.lastPathComponent as? GitLocalBranch)?.name == branchName
|
||||
}
|
||||
test { actions(it) }
|
||||
test {
|
||||
val widget = previous.ui ?: error("Not found VCS widget")
|
||||
ideFrame { jComponent(widget).click() }
|
||||
}
|
||||
}
|
||||
|
||||
task {
|
||||
@@ -197,7 +204,7 @@ class GitFeatureBranchWorkflowLesson : GitLesson("Git.BasicWorkflow", GitLessons
|
||||
delayMillis = defaultRestoreDelay, secondShowBranchesTaskId)
|
||||
test {
|
||||
ideFrame {
|
||||
jList(branchName).clickItem(branchName)
|
||||
clickTreeRow { item -> (item as? GitLocalBranch)?.name == branchName }
|
||||
jList(checkoutAndRebaseText).clickItem(checkoutAndRebaseText)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
package training.git.lesson
|
||||
|
||||
import com.intellij.diff.tools.util.SimpleDiffPanel
|
||||
import com.intellij.openapi.application.invokeAndWaitIfNeeded
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.popup.Balloon
|
||||
import com.intellij.openapi.vcs.changes.VcsEditorTabFilesManager
|
||||
@@ -25,6 +24,7 @@ import org.assertj.swing.fixture.JPanelFixture
|
||||
import org.assertj.swing.fixture.JTableFixture
|
||||
import training.dsl.*
|
||||
import training.git.GitLessonsBundle
|
||||
import training.git.GitLessonsUtil.clickTreeRow
|
||||
import training.git.GitLessonsUtil.highlightLatestCommitsFromBranch
|
||||
import training.git.GitLessonsUtil.highlightSubsequentCommitsInGitLog
|
||||
import training.git.GitLessonsUtil.resetGitLogWindow
|
||||
@@ -93,8 +93,7 @@ class GitProjectHistoryLesson : GitLesson("Git.ProjectHistory", GitLessonsBundle
|
||||
showWarningIfGitWindowClosed(restoreTaskWhenResolved = true)
|
||||
test {
|
||||
ideFrame {
|
||||
val fixture = jTree { path -> path.getPathComponent(path.pathCount - 1).toString() == "HEAD_NODE" }
|
||||
fixture.doubleClickPath("HEAD_NODE")
|
||||
clickTreeRow(doubleClick = true) { item -> item.toString() == "HEAD_NODE" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,15 +188,7 @@ class GitProjectHistoryLesson : GitLesson("Git.ProjectHistory", GitLessonsBundle
|
||||
triggerUI().component { _: SimpleDiffPanel -> true }
|
||||
showWarningIfGitWindowClosed()
|
||||
test {
|
||||
ideFrame {
|
||||
val treeNodeText = sampleFilePath
|
||||
val fixture = jTree { path -> path.getPathComponent(path.pathCount - 1).toString().contains(treeNodeText) }
|
||||
val row = invokeAndWaitIfNeeded {
|
||||
val tree = fixture.target()
|
||||
(0 until tree.rowCount).find { fixture.valueAt(it).toString().contains(treeNodeText) }
|
||||
} ?: error("Failed to find row with text '$treeNodeText'")
|
||||
fixture.doubleClickRow(row)
|
||||
}
|
||||
clickTreeRow(doubleClick = true) { item -> item.toString().contains(sampleFilePath) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import training.dsl.LessonUtil.adjustPopupPosition
|
||||
import training.dsl.LessonUtil.sampleRestoreNotification
|
||||
import training.git.GitLessonsBundle
|
||||
import training.git.GitLessonsUtil.clickChangeElement
|
||||
import training.git.GitLessonsUtil.clickTreeRow
|
||||
import training.git.GitLessonsUtil.openCommitWindow
|
||||
import training.git.GitLessonsUtil.restoreByUiAndBackgroundTask
|
||||
import training.git.GitLessonsUtil.restoreCommitWindowStateInformer
|
||||
@@ -174,7 +175,10 @@ class GitQuickStartLesson : GitLesson("Git.QuickStart", GitLessonsBundle.message
|
||||
val action = (path.lastPathComponent as? PopupFactoryImpl.ActionItem)?.action
|
||||
action is GitNewBranchAction
|
||||
}
|
||||
test { actions(it) }
|
||||
test {
|
||||
val widget = previous.ui ?: error("Not found VCS widget")
|
||||
ideFrame { jComponent(widget).click() }
|
||||
}
|
||||
}
|
||||
|
||||
val createButtonText = GitBundle.message("new.branch.dialog.operation.create.name")
|
||||
@@ -186,7 +190,7 @@ class GitQuickStartLesson : GitLesson("Git.QuickStart", GitLessonsBundle.message
|
||||
}
|
||||
restoreByUi(showBranchesTaskId, delayMillis = defaultRestoreDelay)
|
||||
test {
|
||||
ideFrame { jList(newBranchActionText).clickItem(newBranchActionText) }
|
||||
clickTreeRow { item -> (item as? PopupFactoryImpl.ActionItem)?.action is GitNewBranchAction }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +261,10 @@ class GitQuickStartLesson : GitLesson("Git.QuickStart", GitLessonsBundle.message
|
||||
}
|
||||
else null
|
||||
}
|
||||
test { actions(it) }
|
||||
test {
|
||||
val stripe = previous.ui ?: error("Not found Commit stripe button")
|
||||
ideFrame { jComponent(stripe).click() }
|
||||
}
|
||||
}
|
||||
|
||||
task {
|
||||
@@ -295,7 +302,7 @@ class GitQuickStartLesson : GitLesson("Git.QuickStart", GitLessonsBundle.message
|
||||
}
|
||||
}
|
||||
|
||||
val pushButtonText = DvcsBundle.message("action.push").dropMnemonic()
|
||||
val pushButtonText = DvcsBundle.message("action.complex.push").dropMnemonic()
|
||||
task {
|
||||
before {
|
||||
LearningUiHighlightingManager.clearHighlights()
|
||||
@@ -318,7 +325,8 @@ class GitQuickStartLesson : GitLesson("Git.QuickStart", GitLessonsBundle.message
|
||||
restoreByUiAndBackgroundTask(DvcsBundle.message("push.process.pushing"), delayMillis = defaultRestoreDelay)
|
||||
test(waitEditorToBeReady = false) {
|
||||
ideFrame {
|
||||
button { b: JBOptionButton -> b.text == pushButtonText }.click()
|
||||
val pushAnywayText = DvcsBundle.message("action.push.anyway").dropMnemonic()
|
||||
button { b: JBOptionButton -> b.text == pushButtonText || b.text == pushAnywayText }.click()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user