[jupyter-ui-tests] Add test for drag and drop

GitOrigin-RevId: df97d25d71ed52aea1b4fff42242e2791216e3f9
This commit is contained in:
Ilya Misiukevich
2025-10-02 15:12:41 +00:00
committed by intellij-monorepo-bot
parent e1e58bdd81
commit 097b9cef61
4 changed files with 30 additions and 0 deletions
@@ -492,6 +492,16 @@ open class UiComponent(private val data: ComponentData) : Finder, WithKeyboard {
}
}
fun press(point: Point? = null) {
LOG.info("Press at $this${point?.let { ": $it" } ?: ""}")
withComponent { robot.moveMouseAndPress(it, point) }
}
fun mouseRelease() {
LOG.info("Release at $this")
withComponent { robot.releaseMouse(RemoteMouseButton.LEFT) }
}
fun getBackgroundColor(): Color {
return withComponent { Color(it.getBackground().getRGB()) }
}
@@ -98,6 +98,8 @@ class NotebookEditorUiComponent(private val data: ComponentData) : JEditorUiComp
get() = xx("//div[@class='MyScrollPane']//div[@class='JBViewport']").list().first()
val selectedCellActions: UiComponent
get() = xx("//div[@class='JupyterCellActionsToolbar']").list().first()
val firstFoldingBar: UiComponent
get() = xx("//div[@class='EditorCellFoldingBarComponent']").list().first()
override val editorComponent: EditorComponentImpl
get() = when {
@@ -221,6 +223,12 @@ class NotebookEditorUiComponent(private val data: ComponentData) : JEditorUiComp
cell.strictClick()
}
fun moveMouseOnCell(cellSelector: CellSelector) {
val cellEditors = notebookCellEditors
val cell = cellSelector(cellEditors)
cell.moveMouse()
}
fun typeInCell(
cellSelector: CellSelector,
text: String,
@@ -39,6 +39,7 @@ interface Robot {
*/
fun strictClick(component: Component, point: Point?)
fun moveMouseAndPress(component: Component, where: Point?)
fun pressMouse(mouseButton: RemoteMouseButton)
fun pressMouse(component: Component, point: Point)
@@ -375,6 +375,17 @@ internal class SmoothRobot @JvmOverloads constructor(
}
}
fun moveMouseAndPress(component: Component, where: Point?) {
if (where != null) {
moveMouse(component, where)
}
else {
moveMouse(component)
}
ApplicationManager.getApplication().invokeAndWait({}, ModalityState.any())
basicRobot.pressMouse(MouseButton.LEFT_BUTTON)
}
private fun moveMouseWithAttempts(c: Component, x: Int, y: Int, attempts: Int = 3) {
waitFor(Duration.ofSeconds(5), Duration.ofSeconds(1)) { performOnEdt { c.isShowing }!! }