From 2b1b4fc71ed417e839ad517a7afec6d96f2e48ff Mon Sep 17 00:00:00 2001 From: Alex Plate <aleksei.plate@jetbrains.com> Date: Fri, 14 Mar 2025 16:01:03 +0200 Subject: [PATCH] Create UI test for Rider --- .../kotlin/ui/pages/WelcomeFrame.kt | 8 ++++ .../src/test/kotlin/ManageLicensesFrame.kt | 37 +++++++++++++++++++ .../src/test/kotlin/RiderUiTest.kt | 29 +++++---------- 3 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 tests/ui-rd-tests/src/test/kotlin/ManageLicensesFrame.kt diff --git a/tests/ui-fixtures/src/testFixtures/kotlin/ui/pages/WelcomeFrame.kt b/tests/ui-fixtures/src/testFixtures/kotlin/ui/pages/WelcomeFrame.kt index 9dc1b33bb..7774cbc2d 100644 --- a/tests/ui-fixtures/src/testFixtures/kotlin/ui/pages/WelcomeFrame.kt +++ b/tests/ui-fixtures/src/testFixtures/kotlin/ui/pages/WelcomeFrame.kt @@ -33,6 +33,14 @@ class WelcomeFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) : ), ) + val createNewSolutionLink + get() = actionLink( + byXpath( + "New Solution", + "//div[(@class='MainButton' and @text='New Solution') or (@accessiblename='New Solution' and @class='JButton')]", + ), + ) + @Suppress("unused") val moreActions get() = button(byXpath("More Action", "//div[@accessiblename='More Actions' and @class='ActionButton']")) diff --git a/tests/ui-rd-tests/src/test/kotlin/ManageLicensesFrame.kt b/tests/ui-rd-tests/src/test/kotlin/ManageLicensesFrame.kt new file mode 100644 index 000000000..a59dea0e5 --- /dev/null +++ b/tests/ui-rd-tests/src/test/kotlin/ManageLicensesFrame.kt @@ -0,0 +1,37 @@ +/* + * Copyright 2003-2024 The IdeaVim authors + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE.txt file or at + * https://opensource.org/licenses/MIT. + */ + +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.data.RemoteComponent +import com.intellij.remoterobot.fixtures.CommonContainerFixture +import com.intellij.remoterobot.fixtures.ComponentFixture +import com.intellij.remoterobot.fixtures.DefaultXpath +import com.intellij.remoterobot.fixtures.FixtureName +import com.intellij.remoterobot.search.locators.byXpath +import java.time.Duration + +fun RemoteRobot.manageLicensesFrame(function: ManageLicensesFrame.() -> Unit) { + find(ManageLicensesFrame::class.java, Duration.ofSeconds(10)).apply(function) +} + +@FixtureName("Manage Licenses Frame") +@DefaultXpath("type", "//div[@class='MyDialog' and @title='Manage Licenses']") +class ManageLicensesFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) : + CommonContainerFixture(remoteRobot, remoteComponent) { + + fun enableFreeTier() { + find<ComponentFixture>( + byXpath( + "//div[@class='SegmentedButton' and @action='Non-commercial use (null)']", + ) + ).click() + checkBox("I agree with", contains = true).select() + button("Start Non-Commercial Use").click() + button("Close").click() + } +} diff --git a/tests/ui-rd-tests/src/test/kotlin/RiderUiTest.kt b/tests/ui-rd-tests/src/test/kotlin/RiderUiTest.kt index 204f08bf6..98b84a425 100644 --- a/tests/ui-rd-tests/src/test/kotlin/RiderUiTest.kt +++ b/tests/ui-rd-tests/src/test/kotlin/RiderUiTest.kt @@ -11,7 +11,6 @@ import com.intellij.remoterobot.RemoteRobot import com.intellij.remoterobot.steps.CommonSteps import com.intellij.remoterobot.stepsProcessing.step import com.intellij.remoterobot.utils.keyboard -import com.intellij.remoterobot.utils.waitFor import org.assertj.swing.core.MouseButton import org.junit.jupiter.api.Test import ui.pages.Editor @@ -23,7 +22,6 @@ import ui.pages.idea import ui.pages.welcomeFrame import ui.utils.StepsLogger import ui.utils.uiTest -import java.time.Duration import kotlin.test.assertEquals class RiderUiTest { @@ -44,42 +42,35 @@ class RiderUiTest { idea { waitSmartMode() - createFile("1.txt", this@uiTest) - val editor = editor("1.txt") { - step("Write a text") { - injectText( - """ - |One Two - |Three Four - """.trimMargin() - ) - } - } - waitFor(Duration.ofMinutes(1)) { editor.findAllText("One").isNotEmpty() } + val editor = editor("Program.cs") testEnterWorksInNormalMode(editor) } } private fun IdeaFrame.testEnterWorksInNormalMode(editor: Editor) { - editor.findText("Two").click() + editor.findText(" for more information").click() keyboard { enter() } assertEquals( """ - |One Two - |Three Four + |// See https://aka.ms/new-console-template for more information + | + |Console.WriteLine("Hello, World!"); """.trimMargin(), editor.text ) - assertEquals(8, editor.caretOffset) + assertEquals(64, editor.caretOffset) } private fun RemoteRobot.startNewProject() { + manageLicensesFrame { + enableFreeTier() + } welcomeFrame { - createNewProjectLink.click() + createNewSolutionLink.click() button("Create").click() } }