Skip to content

Commit f1583b1

Browse files
committed
UI tests with Auth
1 parent a9b2f15 commit f1583b1

File tree

9 files changed

+302
-241
lines changed

9 files changed

+302
-241
lines changed

ui-tests-starter/build.gradle.kts

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,26 @@ plugins {
99
id("toolkit-kotlin-conventions")
1010
id("toolkit-intellij-plugin")
1111

12-
id("org.jetbrains.intellij.platform")
12+
id("org.jetbrains.intellij.platform.module")
1313
}
1414

1515
val ideProfile = IdeVersions.ideProfile(project)
1616
val testPlugins by configurations.registering
17-
val testPrep by sourceSets.creating {
18-
java.srcDirs(findFolders(project, "tst-prep", ideProfile))
19-
}
20-
2117

22-
// Add our source sets per IDE profile version (i.e. src-211)
2318
sourceSets {
2419
test {
25-
java.srcDirs(findFolders(project, "tst", ideProfile))
26-
resources.srcDirs(findFolders(project, "tst-resources", ideProfile))
20+
java.setSrcDirs(findFolders(project, "tst-prep", ideProfile))
21+
resources.setSrcDirs(findFolders(project, "tst-resources", ideProfile))
22+
}
23+
}
24+
25+
val uiTestSource = sourceSets.create("uiTest") {
26+
java.setSrcDirs(findFolders(project, "tst", ideProfile))
27+
}
28+
29+
idea {
30+
module {
31+
testSources.from(uiTestSource.allSource.srcDirs)
2732
}
2833
}
2934

@@ -32,56 +37,57 @@ intellijPlatform {
3237
instrumentCode = false
3338
}
3439

40+
val uiTestImplementation by configurations.getting
3541

42+
configurations.getByName(uiTestSource.compileClasspathConfigurationName) {
43+
extendsFrom(uiTestImplementation)
44+
}
45+
46+
configurations.getByName(uiTestSource.runtimeClasspathConfigurationName) {
47+
extendsFrom(uiTestImplementation)
48+
}
3649

3750
dependencies {
38-
//testImplementation(platform("com.jetbrains.intellij.tools:ide-starter"))
3951
// should really be set by the BOM, but too much work to figure out right now
40-
testImplementation("org.kodein.di:kodein-di-jvm:7.20.2")
41-
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
42-
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.0")
43-
44-
testImplementation(project(":plugin-core:jetbrains-community"))
45-
testImplementation(project(":plugin-core:core"))
46-
testImplementation(testFixtures(project(":plugin-core:jetbrains-community")))
47-
val testPrepImplementation by configurations.getting
48-
49-
testPrepImplementation(testFixtures(project(":plugin-core:jetbrains-community")))
50-
51-
52-
52+
uiTestImplementation("org.kodein.di:kodein-di-jvm:7.20.2")
53+
uiTestImplementation(platform(libs.junit5.bom))
54+
uiTestImplementation(libs.junit5.jupiter)
5355

5456
intellijPlatform {
55-
//intellijIdeaCommunity(IdeVersions.ideProfile(providers).map { it.name })
56-
//intellijIdeaCommunity(ideProfile.community.sdkVersion)
5757
val version = ideProfile.community.sdkVersion
5858
intellijIdeaCommunity(version, !version.contains("SNAPSHOT"))
59-
testFramework(TestFrameworkType.JUnit5)
60-
testFramework(TestFrameworkType.Starter)
59+
60+
localPlugin(project(":plugin-core"))
61+
testImplementation(project(":plugin-core:core"))
62+
testImplementation(project(":plugin-core:jetbrains-community"))
63+
testImplementation(testFixtures(project(":plugin-core:jetbrains-community")))
64+
6165
testFramework(TestFrameworkType.Bundled)
66+
testFramework(TestFrameworkType.JUnit5)
67+
68+
testFramework(TestFrameworkType.Starter, configurationName = uiTestImplementation.name)
6269
}
6370

6471
testPlugins(project(":plugin-amazonq", "pluginZip"))
6572
testPlugins(project(":plugin-core", "pluginZip"))
6673
}
6774

68-
val prepareAmazonQTest = tasks.register<Test>("prepareAmazonQTest") {
69-
// dependsOn(":plugin-core:jetbrains-community:test:abc")
70-
// filter {
71-
// setIncludePatterns("abc.*")
72-
// //includeTestsMatching("abc.AbcTest")
73-
// //excludeTestsMatching("software.aws.toolkits.jetbrains.*")
74-
// }
75-
testClassesDirs = testPrep.output.classesDirs
76-
classpath = testPrep.runtimeClasspath
77-
78-
useJUnitPlatform()// Assuming your test task is named amazonQTest
75+
tasks.test {
76+
enabled = false
77+
}
78+
79+
val prepareAmazonQTest by intellijPlatformTesting.testIde.registering {
80+
task {
81+
useJUnitPlatform()
82+
}
7983
}
8084

81-
tasks.test {
82-
dependsOn(testPlugins)
85+
tasks.register<Test>("uiTest") {
86+
testClassesDirs = uiTestSource.output.classesDirs
87+
classpath = uiTestSource.runtimeClasspath
88+
8389
dependsOn(prepareAmazonQTest)
84-
useJUnitPlatform()
90+
dependsOn(testPlugins)
8591

8692
systemProperty("ui.test.plugins", testPlugins.get().asPath)
8793
}
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,52 @@
11
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
package abc
5-
64
import com.intellij.openapi.Disposable
7-
import com.intellij.openapi.util.Disposer
85
import com.intellij.testFramework.ApplicationExtension
96
import com.intellij.testFramework.junit5.TestDisposable
107
import org.junit.Rule
11-
import org.junit.jupiter.api.AfterEach
128
import org.junit.jupiter.api.BeforeEach
139
import org.junit.jupiter.api.Test
1410
import org.junit.jupiter.api.extension.ExtendWith
1511
import software.aws.toolkits.core.rules.SystemPropertyHelper
1612
import software.aws.toolkits.jetbrains.core.credentials.LegacyManagedBearerSsoConnection
1713
import software.aws.toolkits.jetbrains.core.credentials.ManagedBearerSsoConnection
14+
import software.aws.toolkits.jetbrains.core.credentials.pinning.ConnectionPinningManager
15+
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection
1816
import software.aws.toolkits.jetbrains.core.credentials.sono.Q_SCOPES
1917
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenProvider
2018
import software.aws.toolkits.jetbrains.utils.extensions.SsoLogin
2119
import software.aws.toolkits.jetbrains.utils.extensions.SsoLoginExtension
2220

23-
2421
@ExtendWith(ApplicationExtension::class, SsoLoginExtension::class)
2522
@SsoLogin("amazonq-test-account")
26-
//@DisabledIfEnvironmentVariable(named = "IS_PROD", matches = "false")
27-
class AbcTest {
28-
23+
// @DisabledIfEnvironmentVariable(named = "IS_PROD", matches = "false")
24+
class PreAmazonQUiTest {
2925

3026
@TestDisposable
31-
private lateinit var disposable: Disposable
32-
27+
lateinit var disposable: Disposable
3328

3429
@Rule
3530
@JvmField
3631
val systemPropertyHelper = SystemPropertyHelper()
3732

3833
private lateinit var connection: ManagedBearerSsoConnection
3934

40-
41-
4235
@BeforeEach
4336
fun setUp() {
44-
// Setup test environment
45-
System.setProperty("AWS_PROFILE","act_cred")
46-
37+
System.setProperty("aws.dev.useDAG", "true")
4738
}
4839

49-
5040
@Test
5141
fun `can set up Connection`() {
52-
println("This ran")
53-
connection = LegacyManagedBearerSsoConnection("start_url", "us-east-1", Q_SCOPES)
54-
//ConnectionPinningManager.getInstance().setPinnedConnection(QConnection.getInstance(), connection)
55-
(connection.getConnectionSettings().tokenProvider.delegate as BearerTokenProvider).reauthenticate()
56-
57-
//Disposer.register(disposable, connection)
58-
// MockClientManager.useRealImplementations(disposableExtension.disposable)
59-
42+
try {
43+
val startUrl = System.getenv("TEST_START_URL")
44+
val region = System.getenv("TEST_REGION")
45+
connection = LegacyManagedBearerSsoConnection(startUrl, region, Q_SCOPES)
46+
ConnectionPinningManager.getInstance().setPinnedConnection(QConnection.getInstance(), connection)
47+
(connection.getConnectionSettings().tokenProvider.delegate as BearerTokenProvider).reauthenticate()
48+
} catch (e: Exception) {
49+
error("Could not connect to Idc.")
50+
}
6051
}
61-
62-
63-
6452
}

ui-tests-starter/tst/software/aws/toolkits/jetbrains/uitests/AmazonQChatTest.kt

Lines changed: 0 additions & 173 deletions
This file was deleted.

0 commit comments

Comments
 (0)