Skip to content

Commit

Permalink
test: create initial e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick-Erichsen committed Dec 12, 2024
1 parent c9b2abc commit 6f0ca64
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 23 additions & 6 deletions extensions/intellij/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,28 @@ fun properties(key: String) = providers.gradleProperty(key)

fun environment(key: String) = providers.environmentVariable(key)

val remoteRobotVersion = "0.11.23"

plugins {
id("java") // Java support
alias(libs.plugins.kotlin) // Kotlin support
alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin
// alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin
alias(libs.plugins.changelog) // Gradle Changelog Plugin
alias(libs.plugins.qodana) // Gradle Qodana Plugin
alias(libs.plugins.kover) // Gradle Kover Plugin
kotlin("plugin.serialization") version "1.8.0"
id("org.jetbrains.intellij") version "1.17.4"
}

group = properties("pluginGroup").get()

version = properties("pluginVersion").get()

// Configure project's dependencies
repositories { mavenCentral() }
repositories {
mavenCentral()
maven { url = uri("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies") }
}

// Dependencies are managed with Gradle version catalog - read more:
// https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
Expand All @@ -31,6 +37,10 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.4.32")
implementation("com.posthog.java:posthog:1.+")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0")
testImplementation("com.intellij.remoterobot:remote-robot:$remoteRobotVersion")
testImplementation("com.intellij.remoterobot:remote-fixtures:$remoteRobotVersion")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
}

// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for
Expand Down Expand Up @@ -70,6 +80,10 @@ qodana {
koverReport { defaults { xml { onCheck = true } } }

tasks {
downloadRobotServerPlugin {
version.set(remoteRobotVersion)
}

prepareSandbox {
from("../../binary/bin") { into("${intellij.pluginName.get()}/core/") }
from("../vscode/node_modules/@vscode/ripgrep") { into("${intellij.pluginName.get()}/ripgrep/") }
Expand Down Expand Up @@ -108,10 +122,9 @@ tasks {
// Configure UI tests plugin
// Read more: https://github.com/JetBrains/intellij-ui-test-robot
runIdeForUiTests {
systemProperty("robot-server.port", "8082")
systemProperty("ide.mac.message.dialogs.as.sheets", "false")
systemProperty("jb.privacy.policy.text", "<!--999.999-->")
systemProperty("jb.consents.confirmation.enabled", "false")
// systemProperty("robot-server.port", "8082")
systemProperty("ide.browser.jcef.jsQueryPoolSize", "10000")

}

signPlugin {
Expand Down Expand Up @@ -141,4 +154,8 @@ tasks {
"${rootProject.projectDir.parentFile.parentFile}/manual-testing-sandbox/test.kt"
).map { file(it).absolutePath }
}

test {
useJUnitPlatform()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.github.continuedev.continueintellijextension

import com.intellij.remoterobot.RemoteRobot
import com.intellij.remoterobot.fixtures.JCefBrowserFixture
import com.intellij.remoterobot.search.locators.byXpath
import org.junit.jupiter.api.Test
import java.util.concurrent.TimeUnit
//import org.junit.jupiter.api.extension.ExtendWith
import com.intellij.remoterobot.stepsProcessing.step

//import org.intellij.examples.simple.plugin.utils.RemoteRobotExtension

//@ExtendWith(RemoteRobotExtension::class)
class BrowserTest {
// init {
// StepsLogger.init()
// }

private val remoteRobot = RemoteRobot("http://127.0.0.1:8082")

@Test
fun testAccessJCefBrowser() {
// Assume that JCefBrowser is within a frame, window, or dialog in your application.
// Locate the JCefBrowser component. You might need to update the XPath based on your UI structure.
val jCefBrowser = remoteRobot.find(
JCefBrowserFixture::class.java,
byXpath("//div[@class='JCefBrowserComponent']")
)

// Interact with the JCef Browser
remoteRobot.run {
step("Navigate to a URL in JCEF") {
// Replace with code that interacts with the JCEF Browser.
// This might involve accessing browser features or performing navigation.
jCefBrowser.runJs("component.loadURL('https://continue')")
}

step("Check if URL loaded successfully") {
TimeUnit.SECONDS.sleep(5) // Wait for the page to load
// Example JS command to check a condition in the Browser
val title = jCefBrowser.callJs<String>("return component.getTitle();")
assert(title.contains("Example Domain")) { "Title does not match" }
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package com.github.continuedev.continueintellijextension

import com.github.continuedev.continueintellijextension.editor.VerticalDiffBlock
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.editor.Editor
Expand Down Expand Up @@ -34,10 +36,6 @@ class VerticalDiffBlockTest : BasePlatformTestCase() {
val textToAdd = "This is a new line"
val startLine = 0

// Ensure the editor's colorsScheme is initialized
// val globalScheme = EditorColorsManager.getInstance().globalScheme
// editor.setScheme(globalScheme) // Use setScheme() instead of setColorsScheme()

// Create an instance of VerticalDiffBlock
val verticalDiffBlock = VerticalDiffBlock(
editor = editor,
Expand All @@ -53,6 +51,7 @@ class VerticalDiffBlockTest : BasePlatformTestCase() {

// Assert
val documentText = editor.document.text

// We expect a newline to be inserted in addition to our line
val expectedText = "$textToAdd\n\n"
assertEquals(expectedText, documentText)
Expand Down

0 comments on commit 6f0ca64

Please sign in to comment.