Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ val availableDescriptors = listOf(
)
)

val productName = System.getenv("PRODUCT_NAME") ?: "IC-231"
val productName = System.getenv("PRODUCT_NAME") ?: "IC-243"
val descriptor = availableDescriptors.first { it.sourceFolder == productName }

group = properties("pluginGroup").get()
Expand Down Expand Up @@ -139,7 +139,8 @@ configurations["uiTestImplementation"].extendsFrom(configurations.testImplementa
dependencies {
intellijPlatform {
// useInstaller - TO TEST EAP:
intellijIdea(descriptor.sdkVersion) { useInstaller = false }
intellijIdeaCommunity(descriptor.sdkVersion) { useInstaller = false}
// intellijIdea(descriptor.sdkVersion) { useInstaller = false }
jetbrainsRuntime()
pluginVerifier()
testFramework(TestFrameworkType.Platform)
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rootProject.name = "zowe-explorer"

pluginManagement {
// https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library
val kotlinVersion = when (System.getenv("PRODUCT_NAME") ?: "IC-231") {
val kotlinVersion = when (System.getenv("PRODUCT_NAME") ?: "IC-243") {
"IC-231" -> "1.9.21" // Works fine, 1.8.0 does not have enough functionality
"IC-233" -> "1.9.21"
"IC-242" -> "1.9.24"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class ConnectionDialog(
private lateinit var sslCheckbox: JCheckBox

init {
isResizable = false
isResizable = true
}

/** Create dialog with the fields */
Expand Down
280 changes: 231 additions & 49 deletions src/uiTest/kotlin/tests/AddConnectionDialogTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,31 @@

package tests

import io.kotest.core.annotation.Description
import com.intellij.driver.client.Driver
import com.intellij.driver.sdk.ui.components.*
import io.kotest.core.annotation.Description
import okhttp3.mockwebserver.MockResponse
import org.junit.jupiter.api.*
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import tests.utils.*
import tests.utils.uidefinitions.ActionMenuPoints
import tests.utils.uidefinitions.dialogs.AddConnectionDialog
import tests.utils.uidefinitions.dialogs.UnsecureConnectionDialog
import tests.utils.uidefinitions.FilesExplorerPanel
import tests.utils.uidefinitions.dialogs.ErrorCreatingConnectionDialog
import tests.utils.uidefinitions.JesExplorerPanel

@Disabled("This testsuite needs to be reworked")
@Description("Tests for interaction and filling the connection creation dialog")
class AddConnectionDialogTest {
private lateinit var filesExplorerPanel: FilesExplorerPanel
private lateinit var addConnectionDialog: AddConnectionDialog
private lateinit var unsecureConnectionDialog: UnsecureConnectionDialog
private lateinit var errorCreatingConnectionDialog: ErrorCreatingConnectionDialog

companion object {
private const val CONNECTIONS_TAB = "Connections"
private const val TEST_USERNAME = "test"
private const val TEST_USERNAME_2 = "test2"
private const val TEST_PASSWORD = "test"

private const val CASE_1_CONNECTION = "test_valid_connection_1"
private const val CASE_2_CONNECTION = "test_valid_connection_2"
private const val CASE_4_CONNECTION = "test_valid_connection_3"

private lateinit var ideDriver: Driver

@JvmStatic
Expand All @@ -41,8 +48,9 @@ class AddConnectionDialogTest {
IdeRunManager.prepareRunManager()
.runningIde
.resetTestEnv()
val ideDriver = IdeRunManager.getIdeDriver()
ideDriver = IdeRunManager.getIdeDriver()
openZoweExplorerPanel(ideDriver)
deleteConfigEntities(ideDriver, CONNECTIONS_TAB)
}

@JvmStatic
Expand All @@ -51,7 +59,7 @@ class AddConnectionDialogTest {
IdeRunManager.prepareRunManager()
.runningIde
.resetTestEnv()
deleteConfigEntities(ideDriver, "Connections")
deleteConfigEntities(ideDriver, CONNECTIONS_TAB)
MockWebServerManager.removeAllEndpoints()
}
}
Expand All @@ -61,58 +69,232 @@ class AddConnectionDialogTest {
IdeRunManager.prepareRunManager()
.runningIde
.resetTestEnv()
ideDriver = IdeRunManager.getIdeDriver()
filesExplorerPanel = FilesExplorerPanel(ideDriver)
addConnectionDialog = AddConnectionDialog(ideDriver)
unsecureConnectionDialog = UnsecureConnectionDialog(ideDriver)
errorCreatingConnectionDialog = ErrorCreatingConnectionDialog(ideDriver)
}

@AfterEach
fun finalizeTestEnv() {
IdeRunManager.prepareRunManager()
.runningIde
.resetTestEnv()
deleteConfigEntities(ideDriver, CONNECTIONS_TAB)
MockWebServerManager.removeAllEndpoints()
}

private fun injectSuccessfulConnectionEndpoints(testInfo: TestInfo) {
MockWebServerManager.injectEndpoint(
"${testInfo.displayName}_info",
jsonMock = "infoResponse",
endpointResolver = { it?.requestLine?.contains("zosmf/info") ?: false }
)
MockWebServerManager.injectEndpoint(
"${testInfo.displayName}_resttopology",
jsonMock = "infoResponse",
endpointResolver = { it?.requestLine?.contains("zosmf/resttopology/systems") ?: false }
)
}

private fun assertConnectionsInSettings(
expectedRowsCount: Int,
expectedConnectionNames: List<String>,
expectedUsernames: List<String>
) {
val settingsDialog = goToSettings(ideDriver, CONNECTIONS_TAB)
ideDriver.ideFrame {
val connectionsTable = settingsDialog.table { byClass("ValidatingTableView") }
assertEquals(expectedRowsCount, connectionsTable.rowCount())
val tableText = settingsDialog.x { byClass("ValidatingTableView") }.allTextAsString()
val normalizedTableText = tableText.uppercase()
expectedConnectionNames.forEach { expectedName ->
assertTrue(tableText.contains(expectedName), "Expected connection '$expectedName' to be present in Settings")
}
expectedUsernames.forEach { expectedUsername ->
assertTrue(
normalizedTableText.contains(expectedUsername.uppercase()),
"Expected username '$expectedUsername' to be present in Settings"
)
}
settingsDialog.actionButton { byVisibleText("OK") }.click()
}
}

private fun assertSingleConnectionValuesInEditDialog(
expectedConnectionName: String,
expectedUrl: String,
expectedUsername: String
) {
val settingsDialog = goToSettings(ideDriver, CONNECTIONS_TAB)
ideDriver.ideFrame {
val connectionsTable = settingsDialog.table { byClass("ValidatingTableView") }
assertEquals(1, connectionsTable.rowCount())
connectionsTable.doubleClickCell(0, 0)

val editConnectionDialog = AddConnectionDialog(ideDriver)
assertEquals(expectedConnectionName, editConnectionDialog.getConnectionNameValue())
assertEquals(expectedUrl, editConnectionDialog.getConnectionUrlValue())
assertEquals(expectedUsername.uppercase(), editConnectionDialog.getUsernameValue().uppercase())
editConnectionDialog.cancelButton.click()
settingsDialog.actionButton { byVisibleText("Cancel") }.click()
}
}

private fun deleteAllConnectionsInSettings() {
IdeRunManager.prepareRunManager()
.runningIde
.resetTestEnv()
deleteConfigEntities(ideDriver, CONNECTIONS_TAB)
}

/**
* For Abdelrahman El Banna
* @see
* <a href="https://github.com/zowe/zowe-explorer-intellij/wiki/Manual-and-automated-test-cases-consistency#add-invalid-connection">
* <a href="https://github.com/zowe/zowe-explorer-intellij/wiki/Manual-and-automated-test-cases-consistency#-add-valid-connection">
* Regression: Add valid connection
* </a>
*/
@Test
@Tag("New")
fun createValidConnectionTest(testInfo: TestInfo) {
injectSuccessfulConnectionEndpoints(testInfo)

// Case 1: valid connection via Files Explorer.
FilesExplorerPanel(ideDriver).createValidConnection(
ideDriver = ideDriver,
connectionName = CASE_1_CONNECTION,
username = TEST_USERNAME,
password = TEST_PASSWORD
)
assertConnectionsInSettings(
expectedRowsCount = 1,
expectedConnectionNames = listOf(CASE_1_CONNECTION),
expectedUsernames = listOf(TEST_USERNAME)
)
deleteAllConnectionsInSettings()

// Case 2: valid connection via JES Explorer with trailing spaces in some fields.
val connectionUrlWithTrailingSpaces = "${MockWebServerManager.url} "
val jesExplorerPanel = JesExplorerPanel(ideDriver)
jesExplorerPanel.openDialogByPlusButtonInExplorer(ActionMenuPoints.CONNECTION)
val addConnectionDialog = AddConnectionDialog(ideDriver)
addConnectionDialog.fillDialog(
connectionName = "$CASE_2_CONNECTION ",
connectionUrl = connectionUrlWithTrailingSpaces,
username = "$TEST_USERNAME ",
password = TEST_PASSWORD,
isAcceptSelfSigned = false
)
addConnectionDialog.okButton.click()
assertConnectionsInSettings(
expectedRowsCount = 1,
expectedConnectionNames = listOf(CASE_2_CONNECTION),
expectedUsernames = listOf(TEST_USERNAME)
)
assertSingleConnectionValuesInEditDialog(
expectedConnectionName = CASE_2_CONNECTION,
expectedUrl = MockWebServerManager.url,
expectedUsername = TEST_USERNAME
)
deleteAllConnectionsInSettings()

// Case 3: valid connection with 200-character name.
val longConnectionName = "B".repeat(200)
FilesExplorerPanel(ideDriver).createValidConnection(
ideDriver = ideDriver,
connectionName = longConnectionName,
username = TEST_USERNAME,
password = TEST_PASSWORD
)
assertConnectionsInSettings(
expectedRowsCount = 1,
expectedConnectionNames = emptyList(),
expectedUsernames = listOf(TEST_USERNAME)
)
assertSingleConnectionValuesInEditDialog(
expectedConnectionName = longConnectionName,
expectedUrl = MockWebServerManager.url,
expectedUsername = TEST_USERNAME
)
deleteAllConnectionsInSettings()

// Case 4: adding another connection with different username is allowed.
val filesExplorerPanel = FilesExplorerPanel(ideDriver)
filesExplorerPanel.createValidConnection(
ideDriver = ideDriver,
connectionName = CASE_1_CONNECTION,
username = TEST_USERNAME,
password = TEST_PASSWORD
)
filesExplorerPanel.createValidConnection(
ideDriver = ideDriver,
connectionName = CASE_4_CONNECTION,
username = TEST_USERNAME_2,
password = TEST_PASSWORD
)
assertConnectionsInSettings(
expectedRowsCount = 2,
expectedConnectionNames = listOf(CASE_1_CONNECTION, CASE_4_CONNECTION),
expectedUsernames = listOf(TEST_USERNAME, TEST_USERNAME_2)
)
}

/**
* For Andres Pedreros Castro
* @see
* <a href="https://github.com/zowe/zowe-explorer-intellij/wiki/Manual-and-automated-test-cases-consistency#-add-invalid-connection">
* Regression: Add invalid connection
* </a>
*/
@Disabled("This testcase needs to be reworked")
@Test
@Tag("New")
@Disabled("Assigned to another scenario owner")
fun createInvalidConnectionTest(testInfo: TestInfo) {
// TODO: finalize the check (the error dialog should appear)
// val mockServer = MockWebServerManager.prepareMockServer()
//
// MockWebServerManager.injectEndpoint(
// "${testInfo.displayName}_info",
// jsonMock = "infoResponse",
// endpointResolver = { it?.requestLine?.contains("zosmf/info") ?: false }
// )
// MockWebServerManager.injectEndpoint(
// "${testInfo.displayName}_resttopology",
// jsonMock = "infoResponse",
// endpointResolver = { it?.requestLine?.contains("zosmf/resttopology/systems") ?: false }
// )
//
// filesExplorerPanel.createInvalidConnection(ideDriver, connectionName)
// addConnectionDialog
// .fillDialog(
// connectionName = "nameInput",
// connectionUrl = "https://${mockServer.hostName}:${mockServer.port}",
// username = "userNameInput",
// password = "passwordInput",
// isAcceptSelfSigned = true
// )
//
// unsecureConnectionDialog.proceedButton.click()
// addConnectionDialog.okButton.click()
// unsecureConnectionDialog.proceedButton.click()

// assert(errorCreatingConnectionDialog.dialogComponent.isVisible())
//
// errorCreatingConnectionDialog.noButton.click()
// 401 Unauthorized (for wrong credentials):
MockWebServerManager.injectEndpoint(
"${testInfo.displayName}_info",
endpointResolver = { it?.requestLine?.contains("zosmf/info") ?: false },
customHandler = {
MockResponse().setResponseCode(401)
}
)
// SSL certificate error (for self-signed SSL certificates when unchecked):
MockWebServerManager.injectEndpoint(
"${testInfo.displayName}_info",
endpointResolver = { it?.requestLine?.contains("zosmf/info") ?: false },
customHandler = {
MockResponse().setBody("Unable to find valid certification path to requested target")
}
)
}

/**
* For Kalundi Serumaga
* @see
* <a href="https://github.com/zowe/zowe-explorer-intellij/wiki/Manual-and-automated-test-cases-consistency#-edit-existing-connection">
* Regression: Edit existing connection
* </a>
*/
@Test
@Tag("New")
@Disabled("Assigned to another scenario owner")
fun editExistingConnectionTest(testInfo: TestInfo) {
// Success scenario:
MockWebServerManager.injectEndpoint(
"${testInfo.displayName}_info",
jsonMock = "infoResponse",
endpointResolver = { it?.requestLine?.contains("zosmf/info") ?: false }
)
MockWebServerManager.injectEndpoint(
"${testInfo.displayName}_resttopology",
jsonMock = "infoResponse",
endpointResolver = { it?.requestLine?.contains("zosmf/resttopology/systems") ?: false }
)

// SSL certificate error (for self-signed SSL certificates when unchecked):
MockWebServerManager.injectEndpoint(
"${testInfo.displayName}_info",
endpointResolver = { it?.requestLine?.contains("zosmf/info") ?: false },
customHandler = {
MockResponse().setBody("Unable to find valid certification path to requested target")
}
)
}
}
6 changes: 0 additions & 6 deletions src/uiTest/kotlin/tests/AllocateDatasetTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import tests.utils.*
import tests.utils.uidefinitions.dialogs.AddConnectionDialog
import tests.utils.uidefinitions.dialogs.AllocateDatasetDialog
import tests.utils.notification.AddWorkingSetSuccessNotification
import tests.utils.uidefinitions.dialogs.UnsecureConnectionDialog
import tests.utils.uidefinitions.ActionMenuPoints
import tests.utils.uidefinitions.FilesExplorerPanel
import tests.utils.uidefinitions.dialogs.AddWorkingSetDialog
Expand Down Expand Up @@ -191,11 +190,6 @@ class AllocateDatasetTest {

@BeforeEach
fun prepareTestEnv() {
IdeRunManager.prepareRunManager()
.runningIde
.resetTestEnv()
ideDriver = IdeRunManager.getIdeDriver()
filesExplorerPanel = FilesExplorerPanel(ideDriver)
addConnectionDialog = AddConnectionDialog(ideDriver)
allocateDatasetDialog = AllocateDatasetDialog(ideDriver)
addWsNotification = AddWorkingSetSuccessNotification(ideDriver)
Expand Down
Loading
Loading