44package software.aws.toolkits.jetbrains.uitests.profileTests
55
66import com.intellij.driver.client.Driver
7+ import com.intellij.driver.sdk.openFile
78import com.intellij.driver.sdk.ui.components.common.editor
8- import com.intellij.driver.sdk.waitForProjectOpen
99import com.intellij.driver.sdk.ui.components.common.ideFrame
10- import com.intellij.driver.sdk.openFile
1110import com.intellij.driver.sdk.ui.ui
1211import com.intellij.driver.sdk.ui.xQuery
13- import java.awt.event.KeyEvent
12+ import com.intellij.driver.sdk.waitForProjectOpen
1413import com.intellij.ide.starter.ci.CIServer
1514import com.intellij.ide.starter.config.ConfigurationStorage
1615import com.intellij.ide.starter.di.di
@@ -38,7 +37,7 @@ import software.aws.toolkits.jetbrains.uitests.setupMultipleProfilesForTest
3837import software.aws.toolkits.jetbrains.uitests.setupMultipleProfilesWithSelectionForTest
3938import software.aws.toolkits.jetbrains.uitests.setupTestEnvironment
4039import software.aws.toolkits.jetbrains.uitests.useExistingConnectionForTest
41- import software.aws.toolkits.jetbrains.uitests.writeToAwsXml
40+ import java.awt.event.KeyEvent
4241import java.io.File
4342import java.nio.file.Files
4443import java.nio.file.Path
@@ -58,8 +57,6 @@ class QProfileSelectionTest {
5857
5958}"""
6059
61-
62-
6360 init {
6461 di = DI {
6562 extend(di)
@@ -165,24 +162,23 @@ class QProfileSelectionTest {
165162 assertThat(result).contains(" Profile selector is shown" )
166163 }
167164
168- step(" Q services not triggered when no profile selected" ){
165+ step(" Q services not triggered when no profile selected" ) {
169166 triggerDevFeatures(this , false )
170167 }
171168
172- step(" Switching profile notifies and shows chat" ){
169+ step(" Switching profile notifies and shows chat" ) {
173170 changeProfileAndVerify(this , true )
174171 val result = executePuppeteerScript(testActiveToolWindowPage)
175172 assertThat(result).contains(" Chat is shown" )
176173 }
177174
178- step(" Q features work with selected profile" ){
175+ step(" Q features work with selected profile" ) {
179176 triggerDevFeatures(this , true )
180177 }
181178
182179 step(" Changing profile A -> A does nothing" ) {
183180 changeProfileAndVerify(this , false )
184181 }
185-
186182 }
187183 }
188184
@@ -243,9 +239,11 @@ class QProfileSelectionTest {
243239 private fun changeProfileAndVerify (driver : Driver , switchingProfiles : Boolean ) =
244240 driver.ideFrame {
245241 // Click Amazon Q button in status bar
246- x(xQuery {
247- byAccessibleName(" Amazon Q" ) and byJavaClass(" com.intellij.openapi.wm.impl.status.MultipleTextValues" )
248- }).click()
242+ x(
243+ xQuery {
244+ byAccessibleName(" Amazon Q" ) and byJavaClass(" com.intellij.openapi.wm.impl.status.MultipleTextValues" )
245+ }
246+ ).click()
249247 Thread .sleep(100 )
250248
251249 driver.ui.keyboard {
@@ -254,12 +252,12 @@ class QProfileSelectionTest {
254252 key(KeyEvent .VK_UP )
255253 key(KeyEvent .VK_ENTER )
256254
257- // wait for list to load
255+ // wait for list to load
258256 Thread .sleep(3000 )
259257
260258 // profile combobox selection and select connection
261259 key(KeyEvent .VK_TAB )
262- if (switchingProfiles){
260+ if (switchingProfiles) {
263261 // navigate past (current)
264262 key(KeyEvent .VK_DOWN )
265263 }
@@ -273,16 +271,15 @@ class QProfileSelectionTest {
273271 // Verify notification behavior
274272 Thread .sleep(100 )
275273 val notification = x(xQuery { byVisibleText(" You changed your profile" ) })
276- if (switchingProfiles){
274+ if (switchingProfiles) {
277275 assertTrue { notification.present() }
278276 } else {
279277 assertTrue { notification.notPresent() }
280278 }
281279 }
282280
283281 private fun triggerDevFeatures (driver : Driver , isProfileSelected : Boolean ) {
284-
285- // trigger inline completion
282+ // trigger inline completion
286283 var originalText: String? = null
287284 var afterSuggestion: String? = null
288285 driver.ideFrame {
@@ -299,10 +296,9 @@ class QProfileSelectionTest {
299296 Thread .sleep(2000 )
300297
301298 val hintExists = editor.getInlayModel().getInlineElementsInRange(0 , text.length).isNotEmpty()
302- if (isProfileSelected) {
299+ if (isProfileSelected) {
303300 assertThat(hintExists).isTrue()
304- }
305- else {
301+ } else {
306302 assertThat(hintExists).isFalse()
307303 }
308304 driver.ui.keyboard {
@@ -312,16 +308,15 @@ class QProfileSelectionTest {
312308 text = setupContent
313309 }
314310 }
315- if (isProfileSelected) {
311+ if (isProfileSelected) {
316312 assertThat(afterSuggestion?.replace(Regex (" \\ s+" ), " " )?.trim())
317313 .isNotEqualTo(originalText?.replace(Regex (" \\ s+" ), " " )?.trim())
318- }
319- else {
314+ } else {
320315 assertThat(afterSuggestion?.replace(Regex (" \\ s+" ), " " )?.trim())
321316 .isEqualTo(originalText?.replace(Regex (" \\ s+" ), " " )?.trim())
322317 }
323318
324- // check q features
319+ // check q features
325320 driver.ideFrame {
326321 val editor = x(xQuery { byClass(" EditorComponentImpl" ) })
327322 editor.click()
@@ -331,13 +326,14 @@ class QProfileSelectionTest {
331326 Thread .sleep(100 )
332327
333328 // Check if "Amazon Q" option is present
334- val amazonQInMenu = x(xQuery {
335- byVisibleText(" Amazon Q" ) and byJavaClass(" com.intellij.openapi.actionSystem.impl.ActionMenu" )
336- })
337- if (isProfileSelected) {
329+ val amazonQInMenu = x(
330+ xQuery {
331+ byVisibleText(" Amazon Q" ) and byJavaClass(" com.intellij.openapi.actionSystem.impl.ActionMenu" )
332+ }
333+ )
334+ if (isProfileSelected) {
338335 assertTrue { amazonQInMenu.present() }
339- }
340- else {
336+ } else {
341337 assertTrue { amazonQInMenu.notPresent() }
342338 }
343339 }
0 commit comments