-
Notifications
You must be signed in to change notification settings - Fork 251
ci: UI test for feature availability in chat panel #5393
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
Changes from all commits
4c09587
a9b2f15
f1583b1
d21fc4d
bcb83de
3b5fd0e
f3fbd5f
02b1388
1985edf
b9ae167
62c6526
0316bcf
7746823
2a87205
2f4899b
c5b0124
1241bca
c9e6533
2f87eaa
32813db
dc7f4e0
08ab782
a00e5eb
7e9d97f
39ff41b
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
|
||
// project that does nothing | ||
tasks.register("test") | ||
tasks.register("uiTest") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// 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 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. waitForIndicators constantly fails even with higher time limits, keeping the thread.sleep till we find a better alternative |
||
|
||
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")) | ||
} | ||
} | ||
|
||
companion object { | ||
@JvmStatic | ||
@AfterAll | ||
fun clearAwsXml() { | ||
clearAwsXmlFile() | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.jetbrains.uitests.chatTests | ||
|
||
// language=JS | ||
val testFeatureAvailabilityOnSlash = """ | ||
manodnyab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const puppeteer = require('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,51 @@ | ||
// 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 failureCode scanning / QDJVMC Unstable API Usage Error
'com.intellij.testFramework.ApplicationExtension' is scheduled for removal in a future version
|
||
@SsoLogin("amazonq-test-account") | ||
class PreAmazonQUiTest { | ||
|
||
@TestDisposable | ||
lateinit var disposable: Disposable | ||
Check warningCode 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