Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ toolkitVersion=3.56-SNAPSHOT
publishToken=
publishChannel=

ideProfileName=2024.2
ideProfileName=2024.3

remoteRobotPort=8080

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package software.aws.toolkits.jetbrains.uitests

import com.intellij.driver.sdk.openFile
import com.intellij.driver.sdk.ui.ui
import com.intellij.driver.sdk.waitForProjectOpen
import com.intellij.ide.starter.ci.CIServer
import com.intellij.ide.starter.di.di
import com.intellij.ide.starter.driver.engine.runIdeWithDriver
import com.intellij.ide.starter.ide.IdeProductProvider
import com.intellij.ide.starter.junit5.hyphenateWithClass
import com.intellij.ide.starter.models.TestCase
import com.intellij.ide.starter.project.LocalProjectInfo
import com.intellij.ide.starter.runner.CurrentTestMethod
import com.intellij.ide.starter.runner.Starter
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.condition.DisabledIfSystemProperty
import org.kodein.di.DI
import org.kodein.di.bindSingleton
import java.io.File
import java.nio.file.Path
import java.nio.file.Paths
import kotlin.io.path.createParentDirectories
import kotlin.io.path.writeText

@DisabledIfSystemProperty(named = "org.gradle.project.ideProfileName", matches = "2024.2", disabledReason = "Logging API not present for 242")
class OfflineAmazonQInlineCompletionTest {
init {
di = DI {
extend(di)
bindSingleton<CIServer>(overrides = true) { TestCIServer }
}
}

@Test
fun `completion request with expired credentials does not freeze EDT`() {
val testCase = TestCase(
IdeProductProvider.IC,
LocalProjectInfo(
Paths.get("tstData", "Hello")
)
).useRelease("2024.3")
Paths.get(System.getProperty("user.home"), ".aws", "sso", "cache", "ee1d2538cb8d358377d7661466c866af747a8a3f.json")
.createParentDirectories()
.writeText(
"""
{
"clientId": "DummyId",
"clientSecret": "DummySecret",
"expiresAt": "3070-01-01T00:00:00Z",
"scopes": [
"scope1",
"scope2"
],
"issuerUrl": "1",
"region": "2",
"clientType": "public",
"grantTypes": [
"authorization_code",
"refresh_token"
],
"redirectUris": [
"http://127.0.0.1/oauth/callback"
]
}
""".trimIndent()
)
Paths.get(System.getProperty("user.home"), ".aws", "sso", "cache", "d3b447f809607422aac1470dd17fbb32e358cdb3.json")
.writeText(
"""
{
"issuerUrl": "https://example.awsapps.com/start",
"region": "us-east-1",
"accessToken": "DummyAccessToken",
"refreshToken": "RefreshToken",
"createdAt": "1970-01-01T00:00:00Z",
"expiresAt": "1970-01-01T00:00:00Z"
}
""".trimIndent()
)
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
pluginConfigurator.installPluginFromPath(
Path.of(path)
)
}

copyExistingConfig(Paths.get("tstData", "config"))
updateGeneralSettings()
}.runIdeWithDriver()
.useDriverAndCloseIde {
waitForProjectOpen()
openFile("Example.java")
ui.keyboard {
// left meta + c
repeat(5) { hotKey(18, 67) }
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package software.aws.toolkits.jetbrains.uitests

import com.intellij.driver.sdk.openFile
import com.intellij.driver.sdk.ui.ui
import com.intellij.driver.sdk.waitForProjectOpen
import com.intellij.ide.starter.ci.CIServer
import com.intellij.ide.starter.config.ConfigurationStorage
import com.intellij.ide.starter.config.logEnvironmentVariables
import com.intellij.ide.starter.di.di
import com.intellij.ide.starter.driver.engine.runIdeWithDriver
import com.intellij.ide.starter.ide.IdeProductProvider
Expand All @@ -28,6 +30,7 @@ class OfflineAmazonQInlineCompletionTest {
di = DI {
extend(di)
bindSingleton<CIServer>(overrides = true) { TestCIServer }
ConfigurationStorage.Companion.logEnvironmentVariables(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should override the defaults so reset() does not flip this back

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried doing that but the ConfigurationStorage class which has the default values cannot be directly inherited from...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try

            val defaults = ConfigurationStorage.instance().defaults.toMutableMap().apply {
                put("LOG_ENVIRONMENT_VARIABLES", "false")
            }

            bindSingleton<ConfigurationStorage>(overrides = true) {
                ConfigurationStorage(this, defaults)
            }

Copy link
Contributor Author

@manodnyab manodnyab Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, sorry, I could access the vars only in 243, I think I was trying in 242 earlier. The var is public

}
}

Expand All @@ -38,7 +41,7 @@ class OfflineAmazonQInlineCompletionTest {
LocalProjectInfo(
Paths.get("tstData", "Hello")
)
).useRelease("2024.2")
).useRelease("2024.3")
Paths.get(System.getProperty("user.home"), ".aws", "sso", "cache", "ee1d2538cb8d358377d7661466c866af747a8a3f.json")
.createParentDirectories()
.writeText(
Expand Down
Loading