-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: UI test for feature availability in chat panel #5393
base: main
Are you sure you want to change the base?
Changes from 5 commits
4c09587
a9b2f15
f1583b1
d21fc4d
bcb83de
3b5fd0e
f3fbd5f
02b1388
1985edf
b9ae167
62c6526
0316bcf
7746823
2a87205
2f4899b
c5b0124
1241bca
c9e6533
2f87eaa
32813db
dc7f4e0
08ab782
a00e5eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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.chatTests | ||
|
||
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.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.AfterAll | ||
import org.junit.jupiter.api.Assertions.assertTrue | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.kodein.di.DI | ||
import org.kodein.di.bindSingleton | ||
import software.aws.toolkits.jetbrains.uitests.TestCIServer | ||
import software.aws.toolkits.jetbrains.uitests.clearAwsXmlFile | ||
import software.aws.toolkits.jetbrains.uitests.executePuppeteerScript | ||
import software.aws.toolkits.jetbrains.uitests.setupTestEnvironment | ||
import software.aws.toolkits.jetbrains.uitests.useExistingConnectionForTest | ||
import java.io.File | ||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
|
||
class AmazonQChatTest { | ||
|
||
init { | ||
di = DI { | ||
extend(di) | ||
bindSingleton<CIServer>(overrides = true) { TestCIServer } | ||
val defaults = ConfigurationStorage.instance().defaults.toMutableMap().apply { | ||
put("LOG_ENVIRONMENT_VARIABLES", (!System.getenv("CI").toBoolean()).toString()) | ||
} | ||
|
||
bindSingleton<ConfigurationStorage>(overrides = true) { | ||
ConfigurationStorage(this, defaults) | ||
} | ||
} | ||
} | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
// Setup test environment | ||
setupTestEnvironment() | ||
} | ||
|
||
@Test | ||
fun `Ensure feature availability on slash`() { | ||
val testCase = TestCase( | ||
IdeProductProvider.IC, | ||
LocalProjectInfo( | ||
Paths.get("tstData", "Hello") | ||
) | ||
).useRelease(System.getProperty("org.gradle.project.ideProfileName")) | ||
|
||
// inject connection | ||
useExistingConnectionForTest() | ||
|
||
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", "configAmazonQTests")) | ||
updateGeneralSettings() | ||
}.runIdeWithDriver() | ||
.useDriverAndCloseIde { | ||
waitForProjectOpen() | ||
// required wait time for the system to be fully ready | ||
Thread.sleep(30000) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isnt there a wait for index done or something? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a waitForIndicator() but that doesn't still doesn't add enough time There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can do this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will address this in the next PR |
||
|
||
val result = executePuppeteerScript(testFeatureAvailabilityOnSlash) | ||
assertTrue(result.contains("/doc")) | ||
assertTrue(result.contains("/dev")) | ||
assertTrue(result.contains("/transform")) | ||
assertTrue(result.contains("/help")) | ||
assertTrue(result.contains("/clear")) | ||
assertTrue(result.contains("/review")) | ||
assertTrue(result.contains("/test")) | ||
|
||
Thread.sleep(20000) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get the first sleep but why the one here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one was mainly so that we could capture the exact output on the textbox cause otherwise it ends instantaneously. It doesnt need to be 20000 though, I'll try to make it shorter. |
||
} | ||
} | ||
|
||
companion object { | ||
@JvmStatic | ||
@AfterAll | ||
fun clearAwsXml() { | ||
clearAwsXmlFile() | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.jetbrains.uitests.chatTests | ||
|
||
val testFeatureAvailabilityOnSlash = """ | ||
manodnyab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import puppeteer from "puppeteer"; | ||
|
||
async function testNavigation() { | ||
const browser = await puppeteer.connect({ | ||
browserURL: "http://localhost:9222" | ||
}) | ||
try { | ||
const pages = await browser.pages() | ||
for(const page of pages) { | ||
const contents = await page.evaluate(el => el.innerHTML, await page.${'$'}(':root')); | ||
const element = await page.$('.mynah-chat-prompt-input') | ||
if(element) { | ||
await page.type('.mynah-chat-prompt-input', '/') | ||
const elements = await page.$$(".mynah-chat-command-selector-command"); | ||
const attr = await Promise.all( | ||
elements.map(async element => { | ||
return element.evaluate(el => el.getAttribute("command")); | ||
}) | ||
); | ||
console.log(JSON.stringify(attr, null, 2)) | ||
} | ||
} | ||
} finally { | ||
await browser.close(); | ||
} | ||
} | ||
testNavigation().catch(console.error); | ||
|
||
""".trimIndent() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import com.intellij.openapi.Disposable | ||
import com.intellij.testFramework.ApplicationExtension | ||
import com.intellij.testFramework.junit5.TestDisposable | ||
import org.junit.Rule | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import software.aws.toolkits.core.rules.SystemPropertyHelper | ||
import software.aws.toolkits.jetbrains.core.credentials.LegacyManagedBearerSsoConnection | ||
import software.aws.toolkits.jetbrains.core.credentials.ManagedBearerSsoConnection | ||
import software.aws.toolkits.jetbrains.core.credentials.pinning.ConnectionPinningManager | ||
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection | ||
import software.aws.toolkits.jetbrains.core.credentials.sono.Q_SCOPES | ||
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenProvider | ||
import software.aws.toolkits.jetbrains.utils.extensions.SsoLogin | ||
import software.aws.toolkits.jetbrains.utils.extensions.SsoLoginExtension | ||
|
||
@ExtendWith(ApplicationExtension::class, SsoLoginExtension::class) | ||
Check failure Code scanning / QDJVMC Unstable API Usage Error
'com.intellij.testFramework.ApplicationExtension' is scheduled for removal in a future version
|
||
@SsoLogin("amazonq-test-account") | ||
// @DisabledIfEnvironmentVariable(named = "IS_PROD", matches = "false") | ||
manodnyab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
class PreAmazonQUiTest { | ||
|
||
@TestDisposable | ||
lateinit var disposable: Disposable | ||
Check warning Code scanning / QDJVMC Unused symbol Warning
Property "disposable" is never used
|
||
|
||
@Rule | ||
@JvmField | ||
val systemPropertyHelper = SystemPropertyHelper() | ||
|
||
private lateinit var connection: ManagedBearerSsoConnection | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
System.setProperty("aws.dev.useDAG", "true") | ||
} | ||
|
||
@Test | ||
fun `can set up Connection`() { | ||
try { | ||
val startUrl = System.getenv("TEST_START_URL") | ||
val region = System.getenv("TEST_REGION") | ||
connection = LegacyManagedBearerSsoConnection(startUrl, region, Q_SCOPES) | ||
ConnectionPinningManager.getInstance().setPinnedConnection(QConnection.getInstance(), connection) | ||
(connection.getConnectionSettings().tokenProvider.delegate as BearerTokenProvider).reauthenticate() | ||
} catch (e: Exception) { | ||
error("Could not connect to Idc.") | ||
} | ||
} | ||
} |
Check notice
Code scanning / QDJVMC
Function or property has platform type Note