test: use intellij-ide-starter for e2e tests (#7690)
* test: use intellij-ide-starter for e2e tests Solves CON-3723 Extra / details: * Update the CI and docs accordingly * Remove robot dependencies and remove the custom runIdeForUiTests task. The IDE startup is now automatic/per test (+ instance can be reused if we want). * A new DSL for E2E tests means we no longer need to add "wait" everywhere, because each closure opening ensures that the window is ready to use. As a result, the tests are slightly faster. The only exception is waiting for inline completion. * The testing task now depends on prepareSandbox, because an E2E test requires specifying where the plugin can be copied from (hence this dependency, since we need to make sure these files exist, see: CONTINUE_PLUGIN_DIR). * The test framework is specified in a different version than the platform version, because older versions don't have the required drivers (241 vs 243). * fix: add testIntegration * fix: fix warning in build script * fix: remove invalid run config
This commit is contained in:
parent
58c2b7373f
commit
507cdfc61a
18 changed files with 99 additions and 872 deletions
18
.github/actions/run-jetbrains-tests/action.yml
vendored
18
.github/actions/run-jetbrains-tests/action.yml
vendored
|
|
@ -107,7 +107,7 @@ runs:
|
|||
cd binary
|
||||
npm run build
|
||||
|
||||
- name: Start test IDE
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
cd extensions/intellij
|
||||
|
|
@ -115,21 +115,7 @@ runs:
|
|||
Xvfb -ac :99 -screen 0 1920x1080x24 &
|
||||
sleep 10
|
||||
mkdir -p build/reports
|
||||
./gradlew runIdeForUiTests &
|
||||
|
||||
- name: Wait for JB connection
|
||||
uses: jtalk/url-health-check-action@v3
|
||||
with:
|
||||
url: http://127.0.0.1:8082
|
||||
max-attempts: 15
|
||||
retry-delay: 30s
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
cd extensions/intellij
|
||||
export DISPLAY=:99.0
|
||||
./gradlew test
|
||||
./gradlew test testIntegration
|
||||
|
||||
- name: Move video
|
||||
if: ${{ failure() }}
|
||||
|
|
|
|||
4
extensions/intellij/.gitignore
vendored
4
extensions/intellij/.gitignore
vendored
|
|
@ -5,5 +5,5 @@ src/main/resources/config_schema.json
|
|||
src/main/resources/continue_rc_schema.json
|
||||
video
|
||||
.intellijPlatform
|
||||
src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/test-continue/*
|
||||
!src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/test-continue/config.json
|
||||
src/testIntegration/kotlin/com/github/continuedev/continueintellijextension/test-continue/*
|
||||
!src/testIntegration/kotlin/com/github/continuedev/continueintellijextension/test-continue/config.json
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Run Test IDE" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName"/>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$/extensions/intellij"/>
|
||||
<option name="externalSystemIdString" value="GRADLE"/>
|
||||
<option name="scriptParameters" value=""/>
|
||||
<option name="taskDescriptions">
|
||||
<list/>
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="runIdeForUiTests"/>
|
||||
</list>
|
||||
</option>
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2">
|
||||
<option name="Gradle.BeforeRunTask" enabled="true" tasks="clean"
|
||||
externalProjectPath="$PROJECT_DIR$/extensions/intellij" vmOptions="" scriptParameters=""/>
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Run e2e tests" type="CompoundRunConfigurationType">
|
||||
<toRun name="Run Test IDE" type="GradleRunConfiguration" />
|
||||
<toRun name="Run Tests" type="GradleRunConfiguration" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
|
|
@ -179,55 +179,29 @@ This will generate a .zip file in `./build/distributions` with the version defin
|
|||
|
||||
## Testing
|
||||
|
||||
### e2e testing
|
||||
Test commands:
|
||||
|
||||
#### Overview
|
||||
- `./gradlew test` - to run **unit tests**
|
||||
- `./gradlew testIntegration` - to run **e2e tests**
|
||||
|
||||
The e2e tests are written using [intellij-ui-test-robot](`https://github.com/JetBrains/intellij-ui-test-robot`). The
|
||||
README for this project has a lot of helpful info on how to use the library.
|
||||
### About e2e tests
|
||||
|
||||
Note that these tests fully take control of your mouse while executing.
|
||||
The e2e tests are written using [intellij-ide-starter](https://github.com/JetBrains/intellij-ide-starter).
|
||||
The first run of the e2e tests may take a while because the required IDE needs
|
||||
to be downloaded. Note that these tests
|
||||
fully take control of your mouse while executing.
|
||||
|
||||
#### Setup
|
||||
|
||||
If you are on macOS, you'll need to give IntelliJ permission to control your computer in order to run the e2e tests.
|
||||
Open _System Settings_ and select `Privacy & Security` -> `Accessibility` and toggle the switch for IntelliJ.
|
||||
Open `System Settings > Privacy & Security > Accessibility` and toggle the switch for IntelliJ.
|
||||
|
||||
#### Running the tests
|
||||
#### Working with Intellij IDE Starter
|
||||
|
||||
Instantiate the test IDE as a background task:
|
||||
The testing platform provides a rich DSL for most UI components in IntelliJ. However, if you want to interact with a
|
||||
custom element, you can define your own XPath selector.
|
||||
|
||||
```sh
|
||||
./gradlew clean runIdeForUiTests &
|
||||
```
|
||||
|
||||
Once the IDE has loaded, you can run the tests. Note that you need to have the test IDE focused in order for the tests
|
||||
to run.
|
||||
|
||||
```sh
|
||||
./gradlew test
|
||||
```
|
||||
|
||||
Run a single test
|
||||
|
||||
```sh
|
||||
./gradlew test --tests "com.github.continuedev.continueintellijextension.e2e.TESTNAME"
|
||||
```
|
||||
|
||||
#### Identifying selectors
|
||||
|
||||
While the `runIdeForUiTests` task is running, you can visit the following URL
|
||||
to view the UI hierarchy of the running IDE:
|
||||
|
||||
<http://127.0.0.1:8082/>
|
||||
|
||||
#### Rebuilding the extension
|
||||
|
||||
To rebuild the extension with the latest source code, run the following:
|
||||
|
||||
```sh
|
||||
./gradlew buildPlugin
|
||||
```
|
||||
|
||||
This will update the contents of the extension that is loaded into the test IDE from
|
||||
`build/idea-sandbox/plugins-uiTest/continue-intellij-extension`
|
||||
To do this, run an e2e test and visit [localhost:63343/api/remote-driver/](http://localhost:63343/api/remote-driver/) to
|
||||
view an HTML representation of the IDE's Swing component tree.
|
||||
See [Integration Tests](https://plugins.jetbrains.com/docs/intellij/integration-tests-ui.html#searching-components) for
|
||||
more details about this workflow.
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
import org.jetbrains.changelog.markdownToHTML
|
||||
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
|
||||
import org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask
|
||||
import org.gradle.kotlin.dsl.intellijPlatform
|
||||
|
||||
fun environment(key: String) = providers.environmentVariable(key)
|
||||
|
||||
val remoteRobotVersion = "0.11.23"
|
||||
val platformVersion: String by project
|
||||
val pluginGroup: String by project
|
||||
val pluginVersion: String by project
|
||||
val isEap get() = environment("RELEASE_CHANNEL").orNull == "eap"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.9.22"
|
||||
kotlin("jvm") version "2.1.0"
|
||||
id("org.jetbrains.intellij.platform") version "2.7.2"
|
||||
id("org.jetbrains.changelog") version "2.1.2"
|
||||
id("org.jetbrains.qodana") version "0.1.13"
|
||||
|
|
@ -28,17 +28,28 @@ repositories {
|
|||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val testIntegration = create("testIntegration")
|
||||
testIntegration.apply {
|
||||
compileClasspath += sourceSets.main.get().output
|
||||
runtimeClasspath += sourceSets.main.get().output
|
||||
}
|
||||
}
|
||||
|
||||
val testIntegrationImplementation: Configuration by configurations.getting {
|
||||
extendsFrom(configurations.testImplementation.get())
|
||||
}
|
||||
|
||||
dependencies {
|
||||
intellijPlatform {
|
||||
create("IC", platformVersion)
|
||||
intellijIdeaCommunity(platformVersion)
|
||||
plugins(listOf("org.jetbrains.plugins.terminal:241.14494.150"))
|
||||
testFramework(TestFrameworkType.Platform)
|
||||
testFramework(TestFrameworkType.Starter, "243.21565.193", configurationName = "testIntegrationImplementation")
|
||||
}
|
||||
implementation("com.posthog.java:posthog:1.2.0")
|
||||
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
testImplementation("com.intellij.remoterobot:remote-robot:$remoteRobotVersion")
|
||||
testImplementation("com.intellij.remoterobot:remote-fixtures:$remoteRobotVersion")
|
||||
testImplementation("io.mockk:mockk:1.14.2") {
|
||||
// this transitive dependency (1.6.4) conflicts with built-in version (1.7.3)
|
||||
// otherwise e2e tests (runIdeForUiTests) will have linkage errors
|
||||
|
|
@ -47,6 +58,10 @@ dependencies {
|
|||
testImplementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
|
||||
testImplementation("com.automation-remarks:video-recorder-junit5:2.0")
|
||||
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.10.0") // required to run both JUnit 5 and JUnit 3
|
||||
|
||||
testIntegrationImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
|
||||
testIntegrationImplementation("org.kodein.di:kodein-di-jvm:7.20.2")
|
||||
testIntegrationImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.1")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
|
@ -88,40 +103,6 @@ qodana {
|
|||
showReport = environment("QODANA_SHOW_REPORT").map { it.toBoolean() }.getOrElse(false)
|
||||
}
|
||||
|
||||
intellijPlatformTesting {
|
||||
runIde {
|
||||
// This task might not work locally because the binary tends to ignore CONTINUE_GLOBAL_DIR when a
|
||||
// local Continue config is present. If you want to run the e2e tests locally, the most effective
|
||||
// way is to temporarily disconnect from the network and run the tests again.
|
||||
// todo: fix it properly
|
||||
register("runIdeForUiTests") {
|
||||
task {
|
||||
environment(
|
||||
"CONTINUE_GLOBAL_DIR",
|
||||
"${rootProject.projectDir}/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/test-continue"
|
||||
)
|
||||
jvmArgumentProviders += CommandLineArgumentProvider {
|
||||
listOf(
|
||||
"-Drobot-server.port=8082",
|
||||
"-Dide.mac.message.dialogs.as.sheets=false",
|
||||
"-Djb.privacy.policy.text=<!--999.999-->",
|
||||
"-Djb.consents.confirmation.enabled=false",
|
||||
"-Dide.mac.file.chooser.native=false",
|
||||
"-DjbScreenMenuBar.enabled=false",
|
||||
"-Dapple.laf.useScreenMenuBar=false",
|
||||
"-Didea.trust.all.projects=true",
|
||||
"-Dide.show.tips.on.startup.default.value=false",
|
||||
"-Dide.browser.jcef.sandbox.enable=false"
|
||||
)
|
||||
}
|
||||
}
|
||||
plugins {
|
||||
robotServerPlugin()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<PrepareSandboxTask> {
|
||||
from("../../binary/bin") {
|
||||
|
|
@ -146,6 +127,17 @@ tasks {
|
|||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
environment("CONTINUE_GLOBAL_DIR", "${rootProject.projectDir}/src/test/kotlin/com/github/continuedev/continueintellijextension/test-continue")
|
||||
jvmArgumentProviders += CommandLineArgumentProvider { listOf("-Dide.browser.jcef.sandbox.enable=false") }
|
||||
}
|
||||
}
|
||||
|
||||
val testIntegration = task<Test>("testIntegration") {
|
||||
val integrationTestSourceSet = sourceSets.getByName("testIntegration")
|
||||
testClassesDirs = integrationTestSourceSet.output.classesDirs
|
||||
classpath = integrationTestSourceSet.runtimeClasspath
|
||||
systemProperty("CONTINUE_PLUGIN_DIR", tasks.prepareSandbox.get().pluginDirectory.get().asFile)
|
||||
environment("CONTINUE_GLOBAL_DIR", "${rootProject.projectDir}/src/testIntegration/kotlin/com/github/continuedev/continueintellijextension/test-continue")
|
||||
useJUnitPlatform()
|
||||
dependsOn(tasks.prepareSandbox)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,75 +0,0 @@
|
|||
package com.github.continuedev.continueintellijextension.e2e
|
||||
|
||||
import com.automation.remarks.junit5.Video
|
||||
import com.github.continuedev.continueintellijextension.fixtures.dialog
|
||||
import com.github.continuedev.continueintellijextension.fixtures.idea
|
||||
import com.github.continuedev.continueintellijextension.fixtures.welcomeFrame
|
||||
import com.github.continuedev.continueintellijextension.utils.RemoteRobotExtension
|
||||
import com.github.continuedev.continueintellijextension.utils.StepsLogger
|
||||
import com.intellij.remoterobot.RemoteRobot
|
||||
import com.intellij.remoterobot.fixtures.ComponentFixture
|
||||
import com.intellij.remoterobot.search.locators.byXpath
|
||||
import com.intellij.remoterobot.steps.CommonSteps
|
||||
import com.intellij.remoterobot.utils.keyboard
|
||||
import com.intellij.remoterobot.utils.waitFor
|
||||
import com.intellij.remoterobot.utils.waitForIgnoringError
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import java.time.Duration.ofMinutes
|
||||
import java.time.Duration.ofSeconds
|
||||
|
||||
@ExtendWith(RemoteRobotExtension::class)
|
||||
class Autocomplete {
|
||||
init {
|
||||
StepsLogger.init()
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
fun waitForIde(remoteRobot: RemoteRobot) {
|
||||
waitForIgnoringError(ofMinutes(3)) { remoteRobot.callJs("true") }
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
fun closeProject(remoteRobot: RemoteRobot) {
|
||||
CommonSteps(remoteRobot).closeProject()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Video
|
||||
fun displayCompletion(remoteRobot: RemoteRobot): Unit = with(remoteRobot) {
|
||||
welcomeFrame {
|
||||
createNewProjectLink.click()
|
||||
dialog("New Project") {
|
||||
findText("Java").click()
|
||||
checkBox("Add sample code").select()
|
||||
button("Create").click()
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for the default "Main.java" tab to load
|
||||
// Our "continue_tutorial.java.ft" tab loads first, but then "Main.java" takes focus.
|
||||
waitFor(ofSeconds(20)) {
|
||||
findAll<ComponentFixture>(
|
||||
byXpath("//div[@visible_text='Main.java']")
|
||||
).isNotEmpty()
|
||||
}
|
||||
|
||||
idea {
|
||||
with(textEditor()) {
|
||||
val userMsg = "TEST_USER_MESSAGE_0"
|
||||
editor.insertTextAtLine(0, 0, userMsg)
|
||||
editor.clickOnOffset(userMsg.length)
|
||||
|
||||
keyboard {
|
||||
enterText(" ")
|
||||
}
|
||||
|
||||
waitFor(ofSeconds(20)) {
|
||||
editor.hasText("TEST_LLM_RESPONSE_0")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/**
|
||||
* Currently we can't test any actions in the GUI that involve clicks.
|
||||
* See this open issue for details: https://github.com/JetBrains/intellij-ui-test-robot/issues/491
|
||||
*/
|
||||
package com.github.continuedev.continueintellijextension.e2e
|
||||
|
||||
import com.automation.remarks.junit5.Video
|
||||
import com.github.continuedev.continueintellijextension.fixtures.*
|
||||
import com.github.continuedev.continueintellijextension.utils.RemoteRobotExtension
|
||||
import com.github.continuedev.continueintellijextension.utils.StepsLogger
|
||||
import com.github.continuedev.continueintellijextension.utils.getMetaKey
|
||||
import com.intellij.remoterobot.RemoteRobot
|
||||
import com.intellij.remoterobot.fixtures.ComponentFixture
|
||||
import com.intellij.remoterobot.search.locators.byXpath
|
||||
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 com.intellij.remoterobot.utils.waitForIgnoringError
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import java.awt.event.KeyEvent.*
|
||||
import java.time.Duration.ofMinutes
|
||||
import java.time.Duration.ofSeconds
|
||||
|
||||
@ExtendWith(RemoteRobotExtension::class)
|
||||
class GUI {
|
||||
init {
|
||||
StepsLogger.init()
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
fun waitForIde(remoteRobot: RemoteRobot) {
|
||||
waitForIgnoringError(ofMinutes(3)) { remoteRobot.callJs("true") }
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject()
|
||||
|
||||
// @Test
|
||||
@Video
|
||||
fun highlightCode(remoteRobot: RemoteRobot): Unit = with(remoteRobot) {
|
||||
welcomeFrame {
|
||||
createNewProjectLink.click()
|
||||
dialog("New Project") {
|
||||
findText("Java").click()
|
||||
checkBox("Add sample code").select()
|
||||
button("Create").click()
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for the default "Main.java" tab to load
|
||||
// Our "continue_tutorial.java.ft" tab loads first, but then "Main.java" takes focus.
|
||||
// If we don't wait for this, clicking on the GUI may fail because a popup displays
|
||||
// while the `continue_tutorial.java` is loading.
|
||||
waitFor(ofSeconds(20)) {
|
||||
findAll<ComponentFixture>(
|
||||
byXpath("//div[@accessiblename='Main.java' and @class='SingleHeightLabel']")
|
||||
).isNotEmpty()
|
||||
}
|
||||
|
||||
idea {
|
||||
step("Manually open the webview") {
|
||||
// Manually open the webview
|
||||
find<ComponentFixture>(byXpath("//div[@text='Continue']"), ofSeconds((10))).click()
|
||||
|
||||
waitFor(ofSeconds(10)) {
|
||||
browser().isShowing
|
||||
}
|
||||
|
||||
// Arbitrary timeout due to a bug where the webview will refresh
|
||||
// and clear the editor state on first load
|
||||
Thread.sleep(5000)
|
||||
}
|
||||
|
||||
step("Verify we can highlight code and add to webview") {
|
||||
val textToInsert = "Hello world!"
|
||||
|
||||
with(textEditor()) {
|
||||
editor.insertTextAtLine(0, 0, textToInsert)
|
||||
editor.selectText(textToInsert)
|
||||
|
||||
keyboard {
|
||||
hotKey(getMetaKey(), VK_J)
|
||||
}
|
||||
}
|
||||
|
||||
waitFor(ofSeconds(10)) {
|
||||
browser().findElementByContainsText(textToInsert).html.isNotEmpty()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
package com.github.continuedev.continueintellijextension.e2e
|
||||
|
||||
import com.automation.remarks.junit5.Video
|
||||
import com.github.continuedev.continueintellijextension.fixtures.dialog
|
||||
import com.github.continuedev.continueintellijextension.fixtures.idea
|
||||
import com.github.continuedev.continueintellijextension.fixtures.welcomeFrame
|
||||
import com.github.continuedev.continueintellijextension.utils.RemoteRobotExtension
|
||||
import com.github.continuedev.continueintellijextension.utils.StepsLogger
|
||||
import com.github.continuedev.continueintellijextension.utils.*
|
||||
import com.intellij.remoterobot.RemoteRobot
|
||||
import com.intellij.remoterobot.fixtures.ComponentFixture
|
||||
import com.intellij.remoterobot.search.locators.byXpath
|
||||
import com.intellij.remoterobot.steps.CommonSteps
|
||||
import com.intellij.remoterobot.utils.keyboard
|
||||
import com.intellij.remoterobot.utils.waitFor
|
||||
import com.intellij.remoterobot.utils.waitForIgnoringError
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import java.awt.event.KeyEvent.VK_I
|
||||
import java.time.Duration.ofMinutes
|
||||
import java.time.Duration.ofSeconds
|
||||
|
||||
@ExtendWith(RemoteRobotExtension::class)
|
||||
class InlineEdit {
|
||||
init {
|
||||
StepsLogger.init()
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
fun waitForIde(remoteRobot: RemoteRobot) {
|
||||
waitForIgnoringError(ofMinutes(3)) { remoteRobot.callJs("true") }
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject()
|
||||
|
||||
@Test
|
||||
@Disabled("Failing in CI, seems like the timeout just needs to be increased")
|
||||
@Video
|
||||
fun submitInlineEdit(remoteRobot: RemoteRobot): Unit = with(remoteRobot) {
|
||||
welcomeFrame {
|
||||
createNewProjectLink.click()
|
||||
dialog("New Project") {
|
||||
findText("Java").click()
|
||||
checkBox("Add sample code").select()
|
||||
button("Create").click()
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for the default "Main.java" tab to load
|
||||
// Our "continue_tutorial.java.ft" tab loads first, but then "Main.java" takes focus.
|
||||
waitFor(ofSeconds(20)) {
|
||||
findAll<ComponentFixture>(
|
||||
byXpath("//div[@accessiblename='Main.java' and @class='SingleHeightLabel']")
|
||||
).isNotEmpty()
|
||||
}
|
||||
|
||||
idea {
|
||||
with(textEditor()) {
|
||||
val userMsg = "TEST_USER_MESSAGE_0"
|
||||
editor.insertTextAtLine(0, 0, userMsg)
|
||||
editor.selectText(userMsg)
|
||||
|
||||
keyboard {
|
||||
hotKey(getMetaKey(), VK_I)
|
||||
}
|
||||
|
||||
val textArea = find<ComponentFixture>(byXpath("//div[@class='CustomTextArea']"))
|
||||
textArea.hasText("Enter instructions...")
|
||||
|
||||
val modelSelect = find<ComponentFixture>(byXpath("//div[@class='JComboBox']"))
|
||||
modelSelect.hasText("TEST LLM")
|
||||
|
||||
keyboard {
|
||||
enterText("Hello world!")
|
||||
}
|
||||
|
||||
val enterBtn = find<ComponentFixture>(byXpath("//div[@class='CustomButton']"))
|
||||
enterBtn.click()
|
||||
|
||||
val rejectText = "${getAltKeyLabel()}${getShiftKeyLabel()}N"
|
||||
val acceptText = "${getAltKeyLabel()}${getShiftKeyLabel()}Y"
|
||||
val acceptAllText = "Accept All (${getMetaKeyLabel()}${getShiftKeyLabel()}⏎)"
|
||||
val rejectAllText = "Reject All (${getMetaKeyLabel()}${getShiftKeyLabel()}⌫)"
|
||||
|
||||
find<ComponentFixture>(byXpath("//div[@text='$rejectText']")).isShowing
|
||||
find<ComponentFixture>(byXpath("//div[@text='$acceptText']")).isShowing
|
||||
find<ComponentFixture>(byXpath("//div[@text='$acceptAllText']")).isShowing
|
||||
find<ComponentFixture>(byXpath("//div[@text='$rejectAllText']")).isShowing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
package com.github.continuedev.continueintellijextension.e2e
|
||||
|
||||
import com.automation.remarks.junit5.Video
|
||||
import com.github.continuedev.continueintellijextension.fixtures.dialog
|
||||
import com.github.continuedev.continueintellijextension.fixtures.idea
|
||||
import com.github.continuedev.continueintellijextension.fixtures.welcomeFrame
|
||||
import com.github.continuedev.continueintellijextension.utils.RemoteRobotExtension
|
||||
import com.github.continuedev.continueintellijextension.utils.StepsLogger
|
||||
import com.intellij.remoterobot.RemoteRobot
|
||||
import com.intellij.remoterobot.fixtures.ComponentFixture
|
||||
import com.intellij.remoterobot.search.locators.byXpath
|
||||
import com.intellij.remoterobot.steps.CommonSteps
|
||||
import com.intellij.remoterobot.stepsProcessing.step
|
||||
import com.intellij.remoterobot.utils.waitFor
|
||||
import com.intellij.remoterobot.utils.waitForIgnoringError
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import java.time.Duration.ofMinutes
|
||||
import java.time.Duration.ofSeconds
|
||||
|
||||
@ExtendWith(RemoteRobotExtension::class)
|
||||
class Onboarding {
|
||||
init {
|
||||
StepsLogger.init()
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
fun waitForIde(remoteRobot: RemoteRobot) {
|
||||
waitForIgnoringError(ofMinutes(3)) { remoteRobot.callJs("true") }
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject()
|
||||
|
||||
|
||||
// @Test
|
||||
@Video
|
||||
fun onboarding(remoteRobot: RemoteRobot): Unit = with(remoteRobot) {
|
||||
welcomeFrame {
|
||||
createNewProjectLink.click()
|
||||
dialog("New Project") {
|
||||
findText("Java").click()
|
||||
checkBox("Add sample code").select()
|
||||
button("Create").click()
|
||||
}
|
||||
}
|
||||
|
||||
idea {
|
||||
// Wait for the default "Main.java" tab to load
|
||||
// Our "continue_tutorial.java.ft" tab loads first, but then "Main.java" takes focus.
|
||||
// So we need to wait for that to occur, and then focus on "continue_tutorial.java.ft"
|
||||
waitFor(ofSeconds(20)) {
|
||||
findAll<ComponentFixture>(
|
||||
byXpath("//div[@accessiblename='Main.java' and @class='SingleHeightLabel']")
|
||||
).isNotEmpty()
|
||||
}
|
||||
|
||||
// TODO: Need a good way to ensure this is the first test ran in the entire suite
|
||||
// step("Verify Continue tutorial file is loaded") {
|
||||
// find<ComponentFixture>(byXpath("//div[@visible_text='continue_tutorial.java']"))
|
||||
// }
|
||||
|
||||
step("Manually open the webview") {
|
||||
// Manually open the webview
|
||||
find<ComponentFixture>(byXpath("//div[@text='Continue']"), ofSeconds((10))).click()
|
||||
|
||||
waitFor(ofSeconds(10)) {
|
||||
browser().isShowing
|
||||
}
|
||||
}
|
||||
|
||||
step("Verify the onboarding card is present") {
|
||||
waitFor(ofSeconds(30)) {
|
||||
try {
|
||||
browser().findElement("//*[@data-testid='onboarding-card']").html.isNotEmpty()
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
package com.github.continuedev.continueintellijextension.fixtures
|
||||
|
||||
/*
|
||||
* Source: https://github.com/JetBrains/intellij-ui-test-robot/blob/139a05eb99e9a49f13605626b81ad9864be23c96/ui-test-example/src/test/kotlin/org/intellij/examples/simple/plugin/pages/DialogFixture.kt
|
||||
*/
|
||||
import com.intellij.remoterobot.RemoteRobot
|
||||
import com.intellij.remoterobot.data.RemoteComponent
|
||||
import com.intellij.remoterobot.fixtures.CommonContainerFixture
|
||||
import com.intellij.remoterobot.fixtures.ContainerFixture
|
||||
import com.intellij.remoterobot.fixtures.FixtureName
|
||||
import com.intellij.remoterobot.search.locators.byXpath
|
||||
import com.intellij.remoterobot.stepsProcessing.step
|
||||
import java.time.Duration
|
||||
|
||||
fun ContainerFixture.dialog(
|
||||
title: String,
|
||||
timeout: Duration = Duration.ofSeconds(30),
|
||||
function: DialogFixture.() -> Unit = {}
|
||||
): DialogFixture = step("Search for dialog with title $title") {
|
||||
find<DialogFixture>(DialogFixture.byTitle(title), timeout).apply(function)
|
||||
}
|
||||
|
||||
@FixtureName("Dialog")
|
||||
class DialogFixture(
|
||||
remoteRobot: RemoteRobot,
|
||||
remoteComponent: RemoteComponent
|
||||
) : CommonContainerFixture(remoteRobot, remoteComponent) {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun byTitle(title: String) = byXpath("title $title", "//div[@title='$title' and @class='MyDialog']")
|
||||
}
|
||||
|
||||
val title: String
|
||||
get() = callJs("component.getTitle();")
|
||||
}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
package com.github.continuedev.continueintellijextension.fixtures
|
||||
|
||||
/*
|
||||
* Source: https://github.com/JetBrains/intellij-ui-test-robot/blob/139a05eb99e9a49f13605626b81ad9864be23c96/ui-test-example/src/test/kotlin/org/intellij/examples/simple/plugin/pages/IdeaFrame.kt
|
||||
*/
|
||||
import com.intellij.remoterobot.RemoteRobot
|
||||
import com.intellij.remoterobot.data.RemoteComponent
|
||||
import com.intellij.remoterobot.fixtures.*
|
||||
import com.intellij.remoterobot.search.locators.byXpath
|
||||
import com.intellij.remoterobot.stepsProcessing.step
|
||||
import com.intellij.remoterobot.utils.waitFor
|
||||
import java.time.Duration
|
||||
|
||||
fun RemoteRobot.idea(function: IdeaFrame.() -> Unit) {
|
||||
find<IdeaFrame>(timeout = Duration.ofSeconds(10)).apply(function)
|
||||
}
|
||||
|
||||
@FixtureName("Idea frame")
|
||||
@DefaultXpath("IdeFrameImpl type", "//div[@class='IdeFrameImpl']")
|
||||
class IdeaFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) :
|
||||
CommonContainerFixture(remoteRobot, remoteComponent) {
|
||||
|
||||
val projectViewTree
|
||||
get() = find<ContainerFixture>(byXpath("ProjectViewTree", "//div[@class='ProjectViewTree']"))
|
||||
|
||||
val projectName
|
||||
get() = step("Get project name") { return@step callJs<String>("component.getProject().getName()") }
|
||||
|
||||
val menuBar: JMenuBarFixture
|
||||
get() = step("Menu...") {
|
||||
return@step remoteRobot.find(JMenuBarFixture::class.java, JMenuBarFixture.byType())
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun dumbAware(timeout: Duration = Duration.ofMinutes(5), function: () -> Unit) {
|
||||
step("Wait for smart mode") {
|
||||
waitFor(duration = timeout, interval = Duration.ofSeconds(5)) {
|
||||
runCatching { isDumbMode().not() }.getOrDefault(false)
|
||||
}
|
||||
function()
|
||||
step("..wait for smart mode again") {
|
||||
waitFor(duration = timeout, interval = Duration.ofSeconds(5)) {
|
||||
isDumbMode().not()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun isDumbMode(): Boolean {
|
||||
return callJs(
|
||||
"""
|
||||
const frameHelper = com.intellij.openapi.wm.impl.ProjectFrameHelper.getFrameHelper(component)
|
||||
if (frameHelper) {
|
||||
const project = frameHelper.getProject()
|
||||
project ? com.intellij.openapi.project.DumbService.isDumb(project) : true
|
||||
} else {
|
||||
true
|
||||
}
|
||||
""", true
|
||||
)
|
||||
}
|
||||
|
||||
fun openFile(path: String) {
|
||||
runJs(
|
||||
"""
|
||||
importPackage(com.intellij.openapi.fileEditor)
|
||||
importPackage(com.intellij.openapi.vfs)
|
||||
importPackage(com.intellij.openapi.wm.impl)
|
||||
importClass(com.intellij.openapi.application.ApplicationManager)
|
||||
|
||||
const path = '$path'
|
||||
const frameHelper = ProjectFrameHelper.getFrameHelper(component)
|
||||
if (frameHelper) {
|
||||
const project = frameHelper.getProject()
|
||||
const projectPath = project.getBasePath()
|
||||
const file = LocalFileSystem.getInstance().findFileByPath(projectPath + '/' + path)
|
||||
const openFileFunction = new Runnable({
|
||||
run: function() {
|
||||
FileEditorManager.getInstance(project).openTextEditor(
|
||||
new OpenFileDescriptor(
|
||||
project,
|
||||
file
|
||||
), true
|
||||
)
|
||||
}
|
||||
})
|
||||
ApplicationManager.getApplication().invokeLater(openFileFunction)
|
||||
}
|
||||
""", true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
package com.github.continuedev.continueintellijextension.fixtures
|
||||
|
||||
/*
|
||||
* Source: https://github.com/JetBrains/intellij-ui-test-robot/blob/139a05eb99e9a49f13605626b81ad9864be23c96/ui-test-example/src/test/kotlin/org/intellij/examples/simple/plugin/pages/WelcomeFrame.kt
|
||||
*/
|
||||
import com.intellij.remoterobot.RemoteRobot
|
||||
import com.intellij.remoterobot.data.RemoteComponent
|
||||
import com.intellij.remoterobot.fixtures.*
|
||||
import com.intellij.remoterobot.search.locators.byXpath
|
||||
import java.time.Duration
|
||||
|
||||
fun RemoteRobot.welcomeFrame(function: WelcomeFrame.() -> Unit) {
|
||||
find(WelcomeFrame::class.java, Duration.ofSeconds(20)).apply(function)
|
||||
}
|
||||
|
||||
@FixtureName("Welcome Frame")
|
||||
@DefaultXpath("type", "//div[@class='FlatWelcomeFrame']")
|
||||
class WelcomeFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) :
|
||||
CommonContainerFixture(remoteRobot, remoteComponent) {
|
||||
val createNewProjectLink
|
||||
get() = actionLink(
|
||||
byXpath(
|
||||
"New Project",
|
||||
"//div[(@class='MainButton' and @text='New Project') or (@accessiblename='New Project' and @class='JButton')]"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
/**
|
||||
* Notes:
|
||||
* - `sendIntellijMessage` isn't working, but keeping this around as an example of how we might be able to implement
|
||||
* - Below is an AI generated summary of what the problem might be based on troubleshooting attempts
|
||||
* - For details, see https://intellij-support.jetbrains.com/hc/en-us/community/posts/26714246086162--intellij-ui-test-robot-Error-when-attempting-to-click-on-DomElement-491
|
||||
*
|
||||
*
|
||||
* The issue is with how the JCefBrowserFixture.executeJsInBrowser method handles JavaScript code execution.
|
||||
* When trying to call window.postIntellijMessage, we're encountering these challenges:
|
||||
*
|
||||
* 1. **Double Injection Problem**: The postIntellijMessage function already uses JBCefJSQuery.inject internally.
|
||||
* When we try to call it through executeJsInBrowser, we're essentially trying to pass it through another injection
|
||||
* mechanism, creating nested injections that break.
|
||||
*
|
||||
* 2. **String Escaping Issues**: The way quotes are being escaped between the layers of execution is causing syntax
|
||||
* errors in the final JavaScript that gets executed.
|
||||
*
|
||||
* 3. **Context Isolation**: The executeJsInBrowser method likely runs in a different execution context than where the
|
||||
* function was defined, causing scope/reference issues.
|
||||
*
|
||||
* The key insight is that we cannot directly call a function that itself uses the JBCefJSQuery bridge through the test
|
||||
* framework's executeJsInBrowser method. These bridge functions are designed to be called directly in the browser
|
||||
* context, not through another layer of script injection.
|
||||
*/
|
||||
package com.github.continuedev.continueintellijextension.utils
|
||||
|
||||
import com.intellij.remoterobot.fixtures.JCefBrowserFixture
|
||||
|
||||
/**
|
||||
* Utility functions for interacting with browser components in tests
|
||||
*/
|
||||
object BrowserUtils {
|
||||
|
||||
/**
|
||||
* Sends a message to the webview using JCefBrowserFixture's executeJsInBrowser
|
||||
*
|
||||
* @param browser The JCefBrowserFixture to execute JavaScript in
|
||||
* @param messageType The type of message to send
|
||||
* @param messageData The data object to send as message payload
|
||||
* @param messageId A unique ID for the message
|
||||
*/
|
||||
fun sendIntellijMessage(
|
||||
browser: JCefBrowserFixture,
|
||||
messageType: String,
|
||||
messageData: Any,
|
||||
messageId: String = "test-message-id"
|
||||
) {
|
||||
// Convert the messageData to a JSON string
|
||||
val dataJson = when (messageData) {
|
||||
is String -> "\"$messageData\""
|
||||
else -> messageData.toString()
|
||||
}
|
||||
|
||||
val jsCode = """
|
||||
(function() {
|
||||
window.postIntellijMessage(
|
||||
"$messageType",
|
||||
$dataJson,
|
||||
"$messageId"
|
||||
);
|
||||
return true;
|
||||
})();
|
||||
""".trimIndent()
|
||||
|
||||
browser.executeJsInBrowser(jsCode)
|
||||
}
|
||||
}
|
||||
|
||||
// Extension function for JCefBrowserFixture for easier usage
|
||||
fun JCefBrowserFixture.sendIntellijMessage(
|
||||
messageType: String,
|
||||
messageData: Any,
|
||||
messageId: String = "test-message-id"
|
||||
) {
|
||||
BrowserUtils.sendIntellijMessage(this, messageType, messageData, messageId)
|
||||
}
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
package com.github.continuedev.continueintellijextension.utils
|
||||
|
||||
/**
|
||||
* Source: https://github.com/JetBrains/intellij-ui-test-robot/blob/139a05eb99e9a49f13605626b81ad9864be23c96/ui-test-example/src/test/kotlin/org/intellij/examples/simple/plugin/utils/RemoteRobotExtension.kt
|
||||
*/
|
||||
import com.intellij.remoterobot.RemoteRobot
|
||||
import com.intellij.remoterobot.fixtures.ContainerFixture
|
||||
import com.intellij.remoterobot.search.locators.byXpath
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
import org.junit.jupiter.api.extension.AfterTestExecutionCallback
|
||||
import org.junit.jupiter.api.extension.ExtensionContext
|
||||
import org.junit.jupiter.api.extension.ParameterContext
|
||||
import org.junit.jupiter.api.extension.ParameterResolver
|
||||
import java.awt.image.BufferedImage
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
import java.lang.IllegalStateException
|
||||
import java.lang.reflect.Method
|
||||
import javax.imageio.ImageIO
|
||||
|
||||
class RemoteRobotExtension : AfterTestExecutionCallback, ParameterResolver {
|
||||
private val url: String = System.getProperty("remote-robot-url") ?: "http://127.0.0.1:8082"
|
||||
private val remoteRobot: RemoteRobot = if (System.getProperty("debug-retrofit")?.equals("enable") == true) {
|
||||
val interceptor: HttpLoggingInterceptor = HttpLoggingInterceptor().apply {
|
||||
this.level = HttpLoggingInterceptor.Level.BODY
|
||||
}
|
||||
val client = OkHttpClient.Builder().apply {
|
||||
this.addInterceptor(interceptor)
|
||||
}.build()
|
||||
RemoteRobot(url, client)
|
||||
} else {
|
||||
RemoteRobot(url)
|
||||
}
|
||||
private val client = OkHttpClient()
|
||||
|
||||
override fun supportsParameter(parameterContext: ParameterContext?, extensionContext: ExtensionContext?): Boolean {
|
||||
return parameterContext?.parameter?.type?.equals(RemoteRobot::class.java) ?: false
|
||||
}
|
||||
|
||||
override fun resolveParameter(parameterContext: ParameterContext?, extensionContext: ExtensionContext?): Any {
|
||||
return remoteRobot
|
||||
}
|
||||
|
||||
override fun afterTestExecution(context: ExtensionContext?) {
|
||||
val testMethod: Method = context?.requiredTestMethod ?: throw IllegalStateException("test method is null")
|
||||
val testMethodName = testMethod.name
|
||||
val testFailed: Boolean = context.executionException?.isPresent ?: false
|
||||
if (testFailed) {
|
||||
// saveScreenshot(testMethodName)
|
||||
saveIdeaFrames(testMethodName)
|
||||
saveHierarchy(testMethodName)
|
||||
}
|
||||
}
|
||||
|
||||
private fun saveScreenshot(testName: String) {
|
||||
fetchScreenShot().save(testName)
|
||||
}
|
||||
|
||||
private fun saveHierarchy(testName: String) {
|
||||
val hierarchySnapshot =
|
||||
saveFile(url, "build/reports", "hierarchy-$testName.html")
|
||||
if (File("build/reports/styles.css").exists().not()) {
|
||||
saveFile("$url/styles.css", "build/reports", "styles.css")
|
||||
}
|
||||
println("Hierarchy snapshot: ${hierarchySnapshot.absolutePath}")
|
||||
}
|
||||
|
||||
private fun saveFile(url: String, folder: String, name: String): File {
|
||||
val response = client.newCall(Request.Builder().url(url).build()).execute()
|
||||
return File(folder).apply {
|
||||
mkdirs()
|
||||
}.resolve(name).apply {
|
||||
writeText(response.body?.string() ?: "")
|
||||
}
|
||||
}
|
||||
|
||||
private fun BufferedImage.save(name: String) {
|
||||
val bytes = ByteArrayOutputStream().use { b ->
|
||||
ImageIO.write(this, "png", b)
|
||||
b.toByteArray()
|
||||
}
|
||||
File("build/reports").apply { mkdirs() }.resolve("$name.png").writeBytes(bytes)
|
||||
}
|
||||
|
||||
private fun saveIdeaFrames(testName: String) {
|
||||
remoteRobot.findAll<ContainerFixture>(byXpath("//div[@class='IdeFrameImpl']")).forEachIndexed { n, frame ->
|
||||
val pic = try {
|
||||
frame.callJs<ByteArray>(
|
||||
"""
|
||||
importPackage(java.io)
|
||||
importPackage(javax.imageio)
|
||||
importPackage(java.awt.image)
|
||||
const screenShot = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||
component.paint(screenShot.getGraphics())
|
||||
let pictureBytes;
|
||||
const baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
ImageIO.write(screenShot, "png", baos);
|
||||
pictureBytes = baos.toByteArray();
|
||||
} finally {
|
||||
baos.close();
|
||||
}
|
||||
pictureBytes;
|
||||
""", true
|
||||
)
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
throw e
|
||||
}
|
||||
pic.inputStream().use {
|
||||
ImageIO.read(it)
|
||||
}.save(testName + "_" + n)
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchScreenShot(): BufferedImage {
|
||||
return remoteRobot.callJs<ByteArray>(
|
||||
"""
|
||||
importPackage(java.io)
|
||||
importPackage(javax.imageio)
|
||||
const screenShot = new java.awt.Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
|
||||
let pictureBytes;
|
||||
const baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
ImageIO.write(screenShot, "png", baos);
|
||||
pictureBytes = baos.toByteArray();
|
||||
} finally {
|
||||
baos.close();
|
||||
}
|
||||
pictureBytes;
|
||||
"""
|
||||
).inputStream().use {
|
||||
ImageIO.read(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
package com.github.continuedev.continueintellijextension.utils
|
||||
|
||||
/**
|
||||
* Source: https://github.com/JetBrains/intellij-ui-test-robot/blob/139a05eb99e9a49f13605626b81ad9864be23c96/ui-test-example/src/test/kotlin/org/intellij/examples/simple/plugin/utils/StepsLogger.kt
|
||||
*/
|
||||
import com.intellij.remoterobot.stepsProcessing.StepLogger
|
||||
import com.intellij.remoterobot.stepsProcessing.StepWorker
|
||||
|
||||
object StepsLogger {
|
||||
private var initialized = false
|
||||
|
||||
@JvmStatic
|
||||
fun init() {
|
||||
if (initialized.not()) {
|
||||
StepWorker.registerProcessor(StepLogger())
|
||||
initialized = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.github.continuedev.continueintellijextension
|
||||
|
||||
import com.automation.remarks.junit5.Video
|
||||
import com.intellij.driver.sdk.ui.components.*
|
||||
import com.intellij.driver.sdk.wait
|
||||
import com.intellij.ide.starter.driver.engine.runIdeWithDriver
|
||||
import com.intellij.ide.starter.ide.IdeProductProvider
|
||||
import com.intellij.ide.starter.models.TestCase
|
||||
import com.intellij.ide.starter.plugins.PluginConfigurator
|
||||
import com.intellij.ide.starter.project.NoProject
|
||||
import com.intellij.ide.starter.runner.Starter
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import java.io.File
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
class Autocomplete {
|
||||
|
||||
@Video
|
||||
@Test
|
||||
fun testAutocomplete() {
|
||||
val starter = Starter.newContext("testExample", TestCase(IdeProductProvider.IC, NoProject).withVersion("2024.3"))
|
||||
PluginConfigurator(starter).installPluginFromFolder(File(System.getProperty("CONTINUE_PLUGIN_DIR")))
|
||||
starter.runIdeWithDriver().useDriverAndCloseIde {
|
||||
welcomeScreen {
|
||||
createNewProjectButton.click()
|
||||
button("Create").click()
|
||||
}
|
||||
ideFrame {
|
||||
editorTabs {
|
||||
clickTab("Main.java")
|
||||
}
|
||||
codeEditor {
|
||||
keyboard {
|
||||
enterText("TEST_USER_MESSAGE_0")
|
||||
space()
|
||||
}
|
||||
wait(2.seconds)
|
||||
keyboard {
|
||||
tab()
|
||||
}
|
||||
assertTrue(text.contains("TEST_LLM_RESPONSE_0"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue