diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 2133c2da7..8f93654ad 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -32,7 +32,7 @@ jobs: ./gradlew uiTests reportName: ui-test-fails-report-linux - - os: macOS-latest + - os: macos-latest prepareEnv: echo "No preparations needed for MacOS" runTests: ./gradlew uiTests reportName: ui-test-fails-report-mac @@ -52,11 +52,6 @@ jobs: distribution: zulu java-version: 21 - - name: Setup FFmpeg - uses: FedericoCarboni/setup-ffmpeg@v3.1 - with: - github-token: ${{ github.server_url == 'https://github.com' && github.token || '' }} - - name: Prepare test env run: ${{ matrix.prepareEnv }} diff --git a/.idea/copyright/ijmp.xml b/.idea/copyright/ijmp.xml index 8fb50f00f..fedd89723 100644 --- a/.idea/copyright/ijmp.xml +++ b/.idea/copyright/ijmp.xml @@ -1,6 +1,6 @@ - - + \ No newline at end of file diff --git a/.run/Run UI regression tests.run.xml b/.run/Run UI regression tests.run.xml new file mode 100644 index 000000000..a996a2edd --- /dev/null +++ b/.run/Run UI regression tests.run.xml @@ -0,0 +1,24 @@ + + + + + + + false + true + false + true + + + \ No newline at end of file diff --git a/README.md b/README.md index 466fd3920..39913f5ea 100644 --- a/README.md +++ b/README.md @@ -137,9 +137,7 @@ the [contribution guide](CONTRIBUTING.md). If you have any questions, related to the project development, further plans or something else, you can reach as out by some of the communication chanels: -* [For Mainframe Slack channel in IBA workspace](https://iba-mainframe-tools.slack.com/archives/C01V4MZL9DH) * [Zowe Explorer IntelliJ team Slack channel in Open Mainframe Project workspace](https://openmainframeproject.slack.com/archives/C020BGPSU0M) -* [For Mainframe GitHub (create or review issues)](https://github.com/for-mainframe/For-Mainframe/issues) * [Zowe Explorer plug-in for IntelliJ IDEA GitHub (create or review issues)](https://github.com/zowe/zowe-explorer-intellij/issues) * Email to: Uladzislau Kalesnikau (Team Lead of the Zowe Explorer IntelliJ squad) * Email to: Alex Burak (Product Owner) diff --git a/build.gradle.kts b/build.gradle.kts index 1009cf6b1..93f0bb116 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,6 +10,7 @@ * Contributors: * IBA Group * Zowe Community + * Uladzislau Kalesnikau */ import org.jetbrains.changelog.Changelog @@ -347,18 +348,11 @@ val uiTests by intellijPlatformTesting.testIdeUi.registering { "-Xms512m", "-Dide.test.version=${descriptor.sdkVersion}", "-Dplugin.path=${tasks.buildPlugin.flatMap { it.archiveFile }.get().asFile.absolutePath}", - "-Dui.tests.mock.project.path=src/uiTest/resources/mock_project", + "-Dui.test.mock.project.path=src/uiTest/resources/mock_project", "-Didea.trust.all.projects=true", "-Dide.show.tips.on.startup.default.value=false", "-Didea.log.config.properties.file=src/uiTest/resources/log.properties", "-Didea.log.path=src/uiTest/resources/mock_project", - // TODO: delete - "-DideLaunchFolder=ide_for_launch", - "-DremoteRobotUrl=http://127.0.0.1", - "-DideaBuildVersionForTest=ideaIC-242.20224.91", - "-DrobotServerForTest=robot-server-plugin-0.11.23", - "-Didea.trust.all.projects=true", - "-Dide.show.tips.on.startup.default.value=false", "-Dkotest.framework.classpath.scanning.autoscan.disable=true", ) } @@ -373,12 +367,9 @@ val uiTests by intellijPlatformTesting.testIdeUi.registering { } dependencies { -// testImplementation(libs.junit.platform.launcher) -// testImplementation(libs.junit.platform.suite) -// testImplementation(libs.junit.jupiter) -// testImplementation(libs.junit.jupiter.engine) testImplementation(libs.junit.jupiter.api) testImplementation(libs.junit.jupiter.params) + testImplementation(libs.okhttp3.logging.interceptor) testImplementation(libs.okhttp3.mockwebserver) testImplementation(libs.okhttp3.okhttp.tls) // TODO: revise and delete old unnecessary deps @@ -387,36 +378,3 @@ val uiTests by intellijPlatformTesting.testIdeUi.registering { testImplementation("com.intellij.remoterobot:remote-fixtures:0.11.23") } } - -// TODO: fix -///** -// * Runs the first UI test, which agrees to the license agreement -// */ -//val firstTimeUiTest = task("firstTimeUiTest") { -// description = "Gets rid of license agreement, etc." -// group = "verification" -// testClassesDirs = sourceSets["uiTest"].output.classesDirs -// classpath = sourceSets["uiTest"].runtimeClasspath -// useJUnitPlatform { -// includeTags("FirstTime") -// } -// testLogging { -// events("passed", "skipped", "failed") -// } -//} -// -///** -// * Runs the smoke ui test -// */ -//val smokeUiTest = task("smokeUiTest") { -// description = "Gets rid of license agreement, etc." -// group = "verification" -// testClassesDirs = sourceSets["uiTest"].output.classesDirs -// classpath = sourceSets["uiTest"].runtimeClasspath -// useJUnitPlatform { -// includeTags("SmokeTest") -// } -// testLogging { -// events("passed", "skipped", "failed") -// } -//} diff --git a/src/main/kotlin/org/zowe/explorer/explorer/actions/TsoConsoleCreateAction.kt b/src/main/kotlin/org/zowe/explorer/explorer/actions/TsoConsoleCreateAction.kt index 9817f2324..aabf3148a 100644 --- a/src/main/kotlin/org/zowe/explorer/explorer/actions/TsoConsoleCreateAction.kt +++ b/src/main/kotlin/org/zowe/explorer/explorer/actions/TsoConsoleCreateAction.kt @@ -43,7 +43,7 @@ import javax.swing.JComponent * Class which represents TSO console creation action */ class TsoConsoleCreateAction : AnAction() { - private val presentationText = "Zowe TSO Console" + private val presentationText = "TSO Console" override fun getActionUpdateThread(): ActionUpdateThread { return ActionUpdateThread.EDT diff --git a/src/uiTest/kotlin/tests/AddConnectionDialogTest.kt b/src/uiTest/kotlin/tests/AddConnectionDialogTest.kt index 62e88e94e..7d2f04724 100644 --- a/src/uiTest/kotlin/tests/AddConnectionDialogTest.kt +++ b/src/uiTest/kotlin/tests/AddConnectionDialogTest.kt @@ -10,52 +10,51 @@ * Contributors: * IBA Group * Zowe Community + * Uladzislau Kalesnikau */ package tests -import auxiliary.mockServer -import auxiliary.startMockServer import io.kotest.core.annotation.Description - import com.intellij.driver.client.Driver +import org.junit.Ignore import org.junit.jupiter.api.* -import tests.utils.ActionMenuPoints -import tests.utils.FilesExplorerPanel -import tests.utils.dialogs.AddConnectionDialog -import tests.utils.notification.UnsecureConnectionDialog -import testutils.* - -import workingset.testutils.injectTestInfo -import workingset.testutils.injectTestInfoRestTopology - +import tests.utils.* +import tests.utils.uidefinitions.dialogs.AddConnectionDialog +import tests.utils.uidefinitions.dialogs.UnsecureConnectionDialog +import tests.utils.uidefinitions.ActionMenuPoints +import tests.utils.uidefinitions.FilesExplorerPanel +import tests.utils.uidefinitions.dialogs.ErrorCreatingConnectionDialog + +@Ignore @Description("Tests for interaction and filling the connection creation dialog") class AddConnectionDialogTest { - private lateinit var ideDriver: Driver private lateinit var filesExplorerPanel: FilesExplorerPanel - lateinit var addConnectionDialog: AddConnectionDialog + private lateinit var addConnectionDialog: AddConnectionDialog private lateinit var unsecureConnectionDialog: UnsecureConnectionDialog + private lateinit var errorCreatingConnectionDialog: ErrorCreatingConnectionDialog companion object { + private lateinit var ideDriver: Driver + @JvmStatic @BeforeAll fun prepareBeforeAll() { - startMockServer() IdeRunManager.prepareRunManager() .runningIde .resetTestEnv() val ideDriver = IdeRunManager.getIdeDriver() - callRightSidePanel(ideDriver) + openZoweExplorerPanel(ideDriver) } @JvmStatic @AfterAll fun afterAll() { - mockServer.shutdown() + deleteConfigEntities(ideDriver, "Connections") + MockWebServerManager.removeAllEndpoints() } } - @BeforeEach fun prepareTestEnv() { IdeRunManager.prepareRunManager() @@ -65,6 +64,7 @@ class AddConnectionDialogTest { filesExplorerPanel = FilesExplorerPanel(ideDriver) addConnectionDialog = AddConnectionDialog(ideDriver) unsecureConnectionDialog = UnsecureConnectionDialog(ideDriver) + errorCreatingConnectionDialog = ErrorCreatingConnectionDialog(ideDriver) } @AfterEach @@ -72,42 +72,51 @@ class AddConnectionDialogTest { IdeRunManager.prepareRunManager() .runningIde .resetTestEnv() + MockWebServerManager.removeAllEndpoints() } - @Test - @Tag("New") - fun fieldsPresenceTest() { - filesExplorerPanel.openExplorerToolWindow(ActionMenuPoints.CONNECTION) - - - - addConnectionDialog.passwordInput.click() - assert(addConnectionDialog.connectionDialogPanel.isVisible()) - assert(addConnectionDialog.connectionNameLabel.isVisible()) - assert(addConnectionDialog.connectionUrlLabel.isVisible()) - assert(addConnectionDialog.connectionUsernameLabel.isVisible()) - assert(addConnectionDialog.passwordLabel.isVisible()) - assert(addConnectionDialog.passwordInput.isVisible()) - assert(addConnectionDialog.questionMark.isVisible()) - assert(addConnectionDialog.connectionDialogCancelButton.isVisible()) - } - + /** + * @see + * + * Regression: Add invalid connection + * + */ @Test @Tag("New") fun createInvalidConnectionTest(testInfo: TestInfo) { - injectTestInfo(testInfo) - injectTestInfoRestTopology(testInfo) - - filesExplorerPanel.openExplorerToolWindow(ActionMenuPoints.CONNECTION) - - addConnectionDialog.passwordInput.text = "passwordInput" - addConnectionDialog.connectionNameInput.text = "nameInput" - addConnectionDialog.urlInput.text = "https://${mockServer.hostName}:${mockServer.port}" - addConnectionDialog.userNameInput.text = "userNameInput" - addConnectionDialog.acceptSelfSignedCheckbox.click() - unsecureConnectionDialog.preceedButton.click() - - addConnectionDialog.connectionDialogOkButton.click() - unsecureConnectionDialog.preceedButton.click() + 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.openDialogByPlusButtonInExplorer(ActionMenuPoints.CONNECTION) + + addConnectionDialog.checkFieldsArePresent() + + 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() + + // TODO: finalize the check (the error dialog should appear) +// assert(errorCreatingConnectionDialog.dialogComponent.isVisible()) +// +// errorCreatingConnectionDialog.noButton.click() } } diff --git a/src/uiTest/kotlin/tests/AllocateDatasetTest.kt b/src/uiTest/kotlin/tests/AllocateDatasetTest.kt index d0d8c57d5..0576f9790 100644 --- a/src/uiTest/kotlin/tests/AllocateDatasetTest.kt +++ b/src/uiTest/kotlin/tests/AllocateDatasetTest.kt @@ -10,112 +10,169 @@ * Contributors: * IBA Group * Zowe Community + * Uladzislau Kalesnikau */ package tests -import auxiliary.ZOS_USERID -import auxiliary.mockServer -import auxiliary.responseDispatcher -import auxiliary.startMockServer import io.kotest.core.annotation.Description -import testutils.* - import com.intellij.driver.client.Driver +import okhttp3.mockwebserver.MockResponse import org.junit.jupiter.api.* import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource -import tests.utils.FilesExplorerPanel -import tests.utils.dialogs.AddConnectionDialog -import tests.utils.dialogs.AllocateDatasetDialog +import tests.utils.* +import tests.utils.uidefinitions.dialogs.AddConnectionDialog +import tests.utils.uidefinitions.dialogs.AllocateDatasetDialog import tests.utils.notification.AddWorkingSetSuccessNotification -import tests.utils.notification.UnsecureConnectionDialog - -import workingset.* - +import tests.utils.uidefinitions.dialogs.UnsecureConnectionDialog +import tests.utils.uidefinitions.ActionMenuPoints +import tests.utils.uidefinitions.FilesExplorerPanel +import tests.utils.uidefinitions.dialogs.AddWorkingSetDialog import java.util.stream.Stream +private val dsTemplate = + "{" + + "\"dsname\": \"###dsname###\"," + + "\"blksz\": \"###blksz###\"," + + "\"catnm\": \"CATALOG.Z23D.MASTER\"," + + "\"cdate\": \"2023/08/28\"," + + "\"dev\": \"3390\"," + + "\"dsorg\": \"###dsorg###\"," + + "\"edate\": \"***None***\"," + + "\"extx\": \"1\"," + + "\"lrecl\": \"###lrecl###\"," + + "\"migr\": \"NO\"," + + "\"mvol\": \"N\"," + + "\"ovf\": \"NO\"," + + "\"rdate\": \"2024/10/09\"," + + "\"recfm\": \"###recfm###\"," + + "\"sizex\": \"6\"," + + "\"spacu\": \"###spacu###\"," + + "\"used\": \"16\"," + + "\"vol\": \"D3SYS1\"," + + "\"vols\": \"D3SYS1\"" + + "}" + @Description("Tests to check the functionality associated with dataset allocation") class AllocateDatasetTest { - private lateinit var ideDriver: Driver - private lateinit var filesExplorerPanel: FilesExplorerPanel lateinit var addConnectionDialog: AddConnectionDialog private lateinit var unsecureConnectionDialog: UnsecureConnectionDialog private lateinit var allocateDatasetDialog: AllocateDatasetDialog private lateinit var addWsNotification: AddWorkingSetSuccessNotification companion object { - const val connectionName = "valid connection" - const val wsName = "WS1" - private val allocMask = Pair("$ZOS_USERID.ALLOC.*", "z/OS") + const val connectionName = "CON00001" + const val wsName = "WS000001" + private val tstHlq = "$UI_TEST_USERNAME.UI.REGRESS.TEST" + private val allocMask = Pair("$tstHlq.*", "z/OS") + private val createdDatasets = mutableListOf() + + private lateinit var ideDriver: Driver + private lateinit var filesExplorerPanel: FilesExplorerPanel @JvmStatic fun provideOrgTypes(): Stream { - val datasetOrg = listOf( - DatasetOrganization.SEQUENTIAL_ORG_FULL_ITEM, - DatasetOrganization.PO_ORG_FULL_ITEM, - DatasetOrganization.POE_ORG_FULL_ITEM - ) + val dsNameToDsOrg = listOf(DsOrg.PS, DsOrg.PO, DsOrg.POE) - return RecordFormatsShort.entries.flatMap { recordFormat -> - datasetOrg.map { organisationType -> - val datasetOrgShort = organisationType.value.substringAfter('(').substringBefore(')') - val allocateDatasetPram = AllocateDatasetParams( - name = datasetOrgShort, - preset = "Custom Dataset", - primaryAlloc = "10", - blockSize = "3200", - secondaryAlloc = "1", - avgBlockLen = "0", - unit = TRACKS_ALLOCATION_UNIT_SHORT, - dsOrganisationShort = datasetOrgShort - ) - allocateDatasetPram.organisation = organisationType - allocateDatasetPram.format = recordFormat.name - if (organisationType != DatasetOrganization.SEQUENTIAL_ORG_FULL_ITEM) { - allocateDatasetPram.dirBlock = "1" + return RecFM + .entries + .filter { recordFormat -> recordFormat != RecFM.U } + .flatMap { recordFormat -> + dsNameToDsOrg.map { dsOrg -> + val dirBlock = if (dsOrg != DsOrg.PS) "1" else null + val lrecl = if (recordFormat == RecFM.F) "3200" else "80" + val allocateDatasetParams = AllocateDatasetParams( + name = "${tstHlq}.${calcDsHlqLastElem(dsOrg.value.short)}", + preset = "Custom Dataset", + dsOrg = dsOrg, + primAlloc = "10", + secAlloc = "1", + blksz = "3200", + avgBlkLen = "0", + unit = AllocUnit.TRK, + recfm = recordFormat, + dirBlock = dirBlock, + lrecl = lrecl + ) + Arguments.of(allocateDatasetParams) } - allocateDatasetPram.recordLength = if (recordFormat.name == F_RECORD_FORMAT_SHORT) "3200" else "80" - - Arguments.of(allocateDatasetPram) } - }.stream() + .stream() } @JvmStatic @BeforeAll fun prepareBeforeAll(testInfo: TestInfo) { - startMockServer() - IdeRunManager.prepareRunManager() .runningIde .resetTestEnv() - val ideDriver = IdeRunManager.getIdeDriver() + ideDriver = IdeRunManager.getIdeDriver() - callRightSidePanel(ideDriver) + openZoweExplorerPanel(ideDriver) - createValidConnectionWithMock( - testInfo, - connectionName, - ideDriver + 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 } + ) + MockWebServerManager.injectEndpoint( + "${testInfo.displayName}_dslevel", + endpointResolver = { it?.requestLine?.contains("/zosmf/restfiles/ds?dslevel=${allocMask.first}") ?: false }, + customHandler = { + MockResponse() + .setBody( + "{\n" + + "\"items\": [${createdDatasets.joinToString(",")}],\n" + + "\"returnedRows\": ${createdDatasets.size},\n" + + "\"JSONversion\": 1\n" + + "}" + ) + } ) - // Avoid check connection - Thread.sleep(3000) - createWsAndMask(ideDriver, wsName, connectionName, listOf(allocMask)) + MockWebServerManager.injectEndpoint( + "${testInfo.displayName}_DELETE_ds", + endpointResolver = { it?.requestLine?.contains("DELETE /zosmf/restfiles/ds/") ?: false }, + customHandler = { + if (it == null) { + fail("It is expected that the request is not empty") + } + val dsn = it.requestLine + .substringAfter("/zosmf/restfiles/ds/") + .substringBefore(" HTTP") + val dsToDelete = createdDatasets.find { datasetDefinition -> datasetDefinition.contains("\"$dsn\"") } + createdDatasets.remove(dsToDelete) + MockResponse().setResponseCode(204) + } + ) + filesExplorerPanel = FilesExplorerPanel(ideDriver) + filesExplorerPanel.createValidConnection(ideDriver, connectionName) + + filesExplorerPanel.openDialogByPlusButtonInExplorer(ActionMenuPoints.WORKING_SET) + val addWsDialog = AddWorkingSetDialog(ideDriver) + addWsDialog.fillDialog(connectionName, wsName, listOf(allocMask)) + addWsDialog.okButton.click() } @JvmStatic @AfterAll fun afterAll() { - mockServer.shutdown() + filesExplorerPanel.deleteAllMaskElements(1) + deleteConfigEntities(ideDriver, "Working Sets") + deleteConfigEntities(ideDriver, "Connections") + MockWebServerManager.removeAllEndpoints() } } - @BeforeEach fun prepareTestEnv() { IdeRunManager.prepareRunManager() @@ -136,26 +193,72 @@ class AllocateDatasetTest { .resetTestEnv() } + /** + * @see + * + * Regression: Allocate data sets + * + */ @Tag("New") @ParameterizedTest @MethodSource("provideOrgTypes") fun allocateDatasetsTest(allocationParams: AllocateDatasetParams) { - filesExplorerPanel.callSubMenuForRow(0, NEW_POINT_TEXT, DATASET_POINT_TEXT) + // Right-click on a working set, New -> Dataset + filesExplorerPanel.selectRightClickMenuItem(0, "New", "Dataset") allocateDatasetDialog.fillDialog(allocationParams) - responseDispatcher.injectAllocationResultPo( - allocationParams.organisation.toString(), - allocationParams.format.toString(), - allocationParams.name, - allocationParams.dsOrganisationShort.toString(), - allocationParams.recordLength.toString().toInt() + + val dsName = allocationParams.name + val dsOrg = allocationParams.dsOrg + + MockWebServerManager.injectEndpoint( + "testAllocateValid_${dsOrg.value.full}_Datasets_${allocationParams.recfm}_restfiles", + endpointResolver = { + it?.requestLine?.contains("POST /zosmf/restfiles/ds/${dsName}") ?: false + }, + customHandler = { + if (it == null) { + fail("It is expected that the request is not empty") + } else { + val dsn = it.requestLine + .substringAfter("/zosmf/restfiles/ds/") + .substringBefore(" HTTP") + val allocRequestParams = it.body.clone().readUtf8() + val blksz = allocRequestParams.substringAfter("blksize\":") + .substringBefore(",") + .substringBefore("}") + val dsorg = allocRequestParams.substringAfter("dsorg\":\"").substringBefore("\"") + val lrecl = allocRequestParams.substringAfter("lrecl\":") + .substringBefore(",") + .substringBefore("}") + val recfm = allocRequestParams.substringAfter("recfm\":\"").substringBefore("\"") + val alcunit = allocRequestParams.substringAfter("alcunit\":\"").substringBefore("\"") + val spacu = if (alcunit == AllocUnit.TRK.toString()) "TRACKS" else "CYLINDERS" + val newDs = dsTemplate + .replace("###dsname###", dsn) + .replace("###blksz###", blksz) + .replace("###dsorg###", dsorg) + .replace("###lrecl###", lrecl) + .replace("###recfm###", recfm) + .replace("###spacu###", spacu) + createdDatasets.add(newDs) + } + MockResponse() + } ) + allocateDatasetDialog.okButton.click() + // Right-click on a dataset mask, Refresh + filesExplorerPanel.selectRightClickMenuItem(1, "Refresh") - val isNotificationShown = addWsNotification.isAllocNotificationVisible(allocationParams.name) - addWsNotification.skipButton.click() + filesExplorerPanel + .waitForTreeToLoadRow(filesExplorerPanel.fileExplorerTree.collectExpandedPaths().size - 1) + val fileExplorerTreePaths = filesExplorerPanel.fileExplorerTree.collectExpandedPaths() + assert(fileExplorerTreePaths.last().path.any { it.contains(dsName) }) - assert(isNotificationShown) + // TODO: the other test??? +// val isNotificationShown = addWsNotification.isAllocNotificationVisible(dsName) +// addWsNotification.skipButton.click() +// assert(isNotificationShown) } - } diff --git a/src/uiTest/kotlin/tests/SmokeTest.kt b/src/uiTest/kotlin/tests/SmokeTest.kt index 2e07cabff..4ccf1da22 100644 --- a/src/uiTest/kotlin/tests/SmokeTest.kt +++ b/src/uiTest/kotlin/tests/SmokeTest.kt @@ -20,8 +20,9 @@ import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test -import testutils.IdeRunManager -import testutils.resetTestEnv +import tests.utils.IdeRunManager +import tests.utils.openZoweExplorerPanel +import tests.utils.resetTestEnv import java.awt.Point @Description("Smoke test case to check basic functionalities of the plug-in") @@ -62,7 +63,7 @@ class SmokeTest { // Check input fields val inputFields = connectionDialogPanel.xx { byClass("JBTextField") } assert(inputFields.list().size == 3) - val passwordInput = connectionDialogPanel.x { byClass("JPasswordField") } + val passwordInput = connectionDialogPanel.x { byClass("JBPasswordField") } assert(passwordInput.isVisible()) // Check question mark @@ -90,11 +91,11 @@ class SmokeTest { /** * Check the selected settings tab basic elements if it is a table view tab - * @param forMainframeSettingsTabs the settings tab to check + * @param zoweExplorerSettingsTabs the settings tab to check * @param tabText the tab text to distinguish between different types of tabs * @return a plus button on the tab for further checking */ - private fun checkSettingsTabElements(forMainframeSettingsTabs: UiComponent, tabText: String): ActionButtonUi { + private fun checkSettingsTabElements(zoweExplorerSettingsTabs: UiComponent, tabText: String): ActionButtonUi { val (titledSeparatorText, tabContentsHeaderText) = when (tabText) { "Connections" -> "z/OSMF Connections" to "Name || z/OSMF URL || Username || Owner" "JES Working Sets" -> "JES Working Sets" to "Name || Connection || Username || z/OSMF URL" @@ -104,7 +105,7 @@ class SmokeTest { } // Check the tab content - val tabContents = forMainframeSettingsTabs.x( + val tabContents = zoweExplorerSettingsTabs.x( "//div[@class='DialogPanel' and div[@class='TitledSeparator' and @originaltext='$titledSeparatorText']]" ) assert(tabContents.isVisible()) @@ -329,40 +330,32 @@ class SmokeTest { private fun checkOtherSettingsTab(settingsDialog: UiComponent) { // Check all elements are in place val tabContents = settingsDialog.xx("//div[@class='DialogPanel']/div").list() - assert(tabContents[0].allTextAsString() == "Analytics") - val showPrivacyPolicyButton = tabContents[1].button("Show the Privacy Policy") - assert(showPrivacyPolicyButton.isVisible()) - val privacyPolicyResult = tabContents[2].x(JLabelUiComponent::class.java) { byClass("JLabel") } - assert(privacyPolicyResult.getText() == "you haven't agreed to the collection and processing of data") - assert(tabContents[3].allTextAsString() == "Other Settings") - val batchAmountLabel = tabContents[4].x(JLabelUiComponent::class.java) { byClass("JLabel") } + assert(tabContents.size == 14) + assert(tabContents[0].allTextAsString() == "JES Explorer") + val maxRCSuccessLabel = tabContents[1].x(JLabelUiComponent::class.java) { byClass("JLabel") } + assert(maxRCSuccessLabel.getText() == "Max RC to consider as success") + val maxRCSuccessInput = tabContents[2].textField { byClass("JBTextField") } + assert(maxRCSuccessInput.text == "0") + val maxRCWarningLabel = tabContents[3].x(JLabelUiComponent::class.java) { byClass("JLabel") } + assert(maxRCWarningLabel.getText() == "Max RC to consider as warning") + val maxRCWarningInput = tabContents[4].textField { byClass("JBTextField") } + assert(maxRCWarningInput.text == "7") + val otherRCLabel = tabContents[5].x(JLabelUiComponent::class.java) { byClass("JLabel") } + assert(otherRCLabel.getText() == "Other RC value will be considered as an error") + assert(tabContents[6].allTextAsString() == "Other Settings") + val batchAmountLabel = tabContents[7].x(JLabelUiComponent::class.java) { byClass("JLabel") } assert(batchAmountLabel.getText() == "Batch amount to show per fetch") - val batchAmountInput = tabContents[5].textField { byClass("JBTextField") } + val batchAmountInput = tabContents[8].textField { byClass("JBTextField") } assert(batchAmountInput.text == "100") - val autoSyncCheckBox = tabContents[6].checkBox { byClass("JBCheckBox") } + val autoSyncCheckBox = tabContents[9].checkBox { byClass("JBCheckBox") } assert(!autoSyncCheckBox.isSelected()) assert(autoSyncCheckBox.text == "Enable auto-sync with mainframe") - assert(tabContents[7].allTextAsString() == "Rate Us") - val reviewLabel = tabContents[8].x(JLabelUiComponent::class.java) { byClass("JLabel") } + val clearFilesCacheButton = tabContents[10].button { byClass("JButton") } + assert(clearFilesCacheButton.text == "Clear File Cache") + assert(tabContents[11].allTextAsString() == "Rate Us") + val reviewLabel = tabContents[12].x(JLabelUiComponent::class.java) { byClass("JLabel") } assert(reviewLabel.getText() == "If you want to leave a review:") - assert(tabContents[9].allTextAsString() == "click here") - - // Check Privacy Policy dialog - showPrivacyPolicyButton.setFocus() - showPrivacyPolicyButton.click() - - val privacyPolicyTitle = settingsDialog.x( - "//div[@class='DialogHeader']/div[@class='JLabel' and @visible_text='For Mainframe Plugin Privacy Policy and Terms and Conditions']" - ) - assert(privacyPolicyTitle.isVisible()) - val policyText = settingsDialog.x("//div[@class='JBTextArea' and contains(@visible_text,'Privacy Policy')]") - assert(policyText.isVisible() && policyText.allTextAsString().contains("Information IBA Group Collects")) - val bottomText = settingsDialog.x { byClass("DslLabel") } - assert(bottomText.isVisible() && bottomText.allTextAsString().contains("By clicking “I agree” the User agrees")) - - val dismissButton = settingsDialog.actionButton { byText("Dismiss") } - dismissButton.setFocus() - dismissButton.click() + assert(tabContents[13].allTextAsString() == "click here") } /** @@ -372,40 +365,40 @@ class SmokeTest { */ private fun checkSettings(ideFrameComponent: IdeaFrameUI, settingsDialog: UiComponent) { // Check that we are actually in the plug-in's settings - val forMainframeBreadcrumb = settingsDialog.x { - and(byClass("Breadcrumbs"), byVisibleText("For Mainframe")) + val zoweExplorerBreadcrumb = settingsDialog.x { + and(byClass("Breadcrumbs"), byVisibleText("Zowe Explorer")) } - assert(forMainframeBreadcrumb.isVisible()) + assert(zoweExplorerBreadcrumb.isVisible()) - val forMainframeSettingsTabs = settingsDialog.x { + val zoweExplorerSettingsTabs = settingsDialog.x { and(byClass("JBEditorTabs"), byAttribute("nextaction", "Select Next Tab (Activate next tab)")) } - assert(forMainframeSettingsTabs.isVisible()) + assert(zoweExplorerSettingsTabs.isVisible()) // Check tabs - val connectionsTab = forMainframeSettingsTabs.x { + val connectionsTab = zoweExplorerSettingsTabs.x { and(byClass("SimpleColoredComponent"), byVisibleText("Connections")) } assert(connectionsTab.isVisible()) - val jesWorkingSetsTab = forMainframeSettingsTabs.x { + val jesWorkingSetsTab = zoweExplorerSettingsTabs.x { and(byClass("SimpleColoredComponent"), byVisibleText("JES Working Sets")) } assert(jesWorkingSetsTab.isVisible()) - val filesWorkingSetsTab = forMainframeSettingsTabs.x { + val filesWorkingSetsTab = zoweExplorerSettingsTabs.x { and(byClass("SimpleColoredComponent"), byVisibleText("Working Sets")) } assert(filesWorkingSetsTab.isVisible()) - val tsoSessionsTab = forMainframeSettingsTabs.x { + val tsoSessionsTab = zoweExplorerSettingsTabs.x { and(byClass("SimpleColoredComponent"), byVisibleText("TSO Sessions")) } assert(tsoSessionsTab.isVisible()) - val otherSettingsTab = forMainframeSettingsTabs.x { + val otherSettingsTab = zoweExplorerSettingsTabs.x { and(byClass("SimpleColoredComponent"), byVisibleText("Settings")) } assert(otherSettingsTab.isVisible()) // Check Connections tab - val connectionsTabPlusButton = checkSettingsTabElements(forMainframeSettingsTabs, "Connections") + val connectionsTabPlusButton = checkSettingsTabElements(zoweExplorerSettingsTabs, "Connections") // Check "plus" action for Connections tab connectionsTabPlusButton.setFocus() @@ -424,7 +417,7 @@ class SmokeTest { jesWorkingSetsTab.setFocus() jesWorkingSetsTab.click() - val jesWorkingSetsTabPlusButton = checkSettingsTabElements(forMainframeSettingsTabs, "JES Working Sets") + val jesWorkingSetsTabPlusButton = checkSettingsTabElements(zoweExplorerSettingsTabs, "JES Working Sets") // Check "plus" action for JES Working Sets tab jesWorkingSetsTabPlusButton.setFocus() @@ -437,7 +430,7 @@ class SmokeTest { filesWorkingSetsTab.setFocus() filesWorkingSetsTab.click() - val filesWorkingSetsTabPlusButton = checkSettingsTabElements(forMainframeSettingsTabs, "Working Sets") + val filesWorkingSetsTabPlusButton = checkSettingsTabElements(zoweExplorerSettingsTabs, "Working Sets") // Check "plus" action for JES Working Sets tab filesWorkingSetsTabPlusButton.setFocus() @@ -450,7 +443,7 @@ class SmokeTest { tsoSessionsTab.setFocus() tsoSessionsTab.click() - val tsoSessionsTabPlusButton = checkSettingsTabElements(forMainframeSettingsTabs, "TSO Sessions") + val tsoSessionsTabPlusButton = checkSettingsTabElements(zoweExplorerSettingsTabs, "TSO Sessions") // Check "plus" action for TSO Sessions tab tsoSessionsTabPlusButton.setFocus() @@ -490,27 +483,32 @@ class SmokeTest { explorerViewAddButton.setFocus() explorerViewAddButton.click() - val plusDropdownTooltipForConnection = ideFrameComponent.x { byClass("HeavyWeightWindow") } - val plusDropdownList = plusDropdownTooltipForConnection.list { byClass("MyList") } + var plusDropdownList = ideFrameComponent.popup().list() + assert(plusDropdownList.isVisible()) - assert(plusDropdownList.rawItems.size == 3) + assert(plusDropdownList.rawItems.size == 4) assert(plusDropdownList.rawItems[0] == "Connection") + assert(plusDropdownList.rawItems[1] == "Add Zowe Team Configuration") val wsItem = if (explorerViewType == "FileExplorerView") "Working Set" else "JES Working Set" - assert(plusDropdownList.rawItems[1] == wsItem) - assert(plusDropdownList.rawItems[2] == "TSO Console") + assert(plusDropdownList.rawItems[2] == wsItem) + assert(plusDropdownList.rawItems[3] == "TSO Console") // Check disabled items are functioning correctly - plusDropdownList.clickItemAtIndex(1) // Working Set - assert(plusDropdownList.isVisible()) - plusDropdownList.clickItemAtIndex(2) // TSO Console - assert(plusDropdownList.isVisible()) - plusDropdownList.hoverItemAtIndex(2) // TSO Console tooltip + plusDropdownList.hoverItemAtIndex(2) // Working Set tooltip + assert( + ideFrameComponent.x { and(byClass("Header"), byVisibleText("Create connection first")) }.isVisible() + ) + plusDropdownList.hoverItemAtIndex(3) // TSO Console tooltip assert( ideFrameComponent.x { and(byClass("Header"), byVisibleText("Create connection first")) }.isVisible() ) + // To reset hover + ideFrameComponent.moveMouse() + plusDropdownList = ideFrameComponent.popup().list() + // Check 'Connection' dialog is opened and correct for File Explorer - plusDropdownList.clickItem("Connection") + plusDropdownList.clickItemAtIndex(0) val explorerViewConnectionDialog = ideFrameComponent.dialog(title = "Add Connection") assert(explorerViewConnectionDialog.isVisible()) @@ -521,21 +519,14 @@ class SmokeTest { @Tag("New") fun smokeTestCase() { val ideDriver = IdeRunManager.getIdeDriver() + openZoweExplorerPanel(ideDriver) ideDriver.ideFrame { - // Open the plug-in's tool window view - val forMainframeTool = rightToolWindowToolbar.actionButton { - byAttribute("myaction", "For Mainframe (null)") - } - assert(forMainframeTool.isVisible()) - forMainframeTool.setFocus() - forMainframeTool.click() - // Check tool window elements are in place - val forMainframeTabs = x("//div[@class='TabPanel' and div[@class='BaseLabel' and @visible_text='For Mainframe']]") + val zoweExplorerTabs = x("//div[@class='TabPanel' and div[@class='BaseLabel' and @visible_text='Zowe Explorer']]") - val fileExplorerTab = forMainframeTabs.x { byText("File Explorer") } + val fileExplorerTab = zoweExplorerTabs.x { byText("File Explorer") } assert(fileExplorerTab.isVisible()) - val jesExplorerTab = forMainframeTabs.x { byText("JES Explorer") } + val jesExplorerTab = zoweExplorerTabs.x { byText("JES Explorer") } assert(jesExplorerTab.isVisible()) // Check button elements are in place for File Explorer diff --git a/src/uiTest/kotlin/tests/utils/FilesExplorerPanel.kt b/src/uiTest/kotlin/tests/utils/FilesExplorerPanel.kt deleted file mode 100644 index deb89e33e..000000000 --- a/src/uiTest/kotlin/tests/utils/FilesExplorerPanel.kt +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2024 IBA Group. - * - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBA Group - * Zowe Community - */ -package tests.utils - -import com.intellij.driver.sdk.ui.components.* -import com.intellij.driver.client.Driver - -enum class ActionMenuPoints(val point: String) { - CONNECTION("Connection"), - WORKING_SET("Working Set"), -} - -class FilesExplorerPanel(val driver: Driver) { - - lateinit var explorerView: UiComponent - lateinit var fileExplorerTree: JTreeUiComponent - lateinit var plusDropdownTooltipForConnection: UiComponent - lateinit var wsMenu: JListUiComponent - - val explorerViewAddButton by lazy { explorerView.actionButton { byAttribute("myicon", "add.svg") } } - val plusDropdownList by lazy { plusDropdownTooltipForConnection.list { byClass("MyList") } } - - - init { - driver.ideFrame { - explorerView = x("//div[@class='SimpleToolWindowPanel' and div[@class='FileExplorerView']]") - plusDropdownTooltipForConnection = x { byClass("HeavyWeightWindow") } - fileExplorerTree = tree("//div[@class='DnDAwareTree']") - wsMenu = list("//div[@class='MyMenu']") - } - } - - fun openExplorerToolWindow(point: ActionMenuPoints): UiComponent? { - explorerViewAddButton.click() - var dialog: UiComponent? = null - if (point == ActionMenuPoints.CONNECTION || point == ActionMenuPoints.WORKING_SET) { - plusDropdownList.clickItem(point.point) - driver.ideFrame { - dialog = dialog(title = "Add Connection") - } - } else { - throw IllegalArgumentException("Unsupported point: $point") - } - return dialog - } - - fun callSubMenuForRow(row: Int, menuPoint: String, submenuPoint: String? = null) { - fileExplorerTree.rightClickRow(row) -// Thread.sleep(1000) - driver.ideFrame { - x("//div[@class='MyMenu']").x { byText(menuPoint) }.click() - } - if (submenuPoint != null) { - driver.ideFrame { - x("//div[@class='ActionMenu']").x { byText(submenuPoint) }.click() - } - } - } -} diff --git a/src/uiTest/kotlin/testutils/IdeRunManager.kt b/src/uiTest/kotlin/tests/utils/IdeRunManager.kt similarity index 77% rename from src/uiTest/kotlin/testutils/IdeRunManager.kt rename to src/uiTest/kotlin/tests/utils/IdeRunManager.kt index 4858c4f9d..a0f605590 100644 --- a/src/uiTest/kotlin/testutils/IdeRunManager.kt +++ b/src/uiTest/kotlin/tests/utils/IdeRunManager.kt @@ -1,22 +1,21 @@ /* - * Copyright (c) 2024 IBA Group. - * * This program and the accompanying materials are made available under the terms of the * Eclipse Public License v2.0 which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-v20.html * * SPDX-License-Identifier: EPL-2.0 * + * Copyright Contributors to the Zowe Project. + * * Contributors: - * IBA Group * Zowe Community + * IBA Group + * Uladzislau Kalesnikau */ -package testutils +package tests.utils import com.intellij.driver.client.Driver -import com.intellij.driver.sdk.ui.components.actionButton -import com.intellij.driver.sdk.ui.components.dialog import com.intellij.driver.sdk.ui.components.ideFrame import com.intellij.driver.sdk.waitForIndicators import com.intellij.ide.starter.driver.engine.BackgroundRun @@ -36,7 +35,7 @@ import kotlin.time.Duration.Companion.minutes class IdeRunManager private constructor() { private val ideVersion by lazy { System.getProperty("ide.test.version") } private val pluginPathStr by lazy { System.getProperty("plugin.path") } - private val mockProjectRelativePathStr by lazy { System.getProperty("ui.tests.mock.project.path") } + private val mockProjectRelativePathStr by lazy { System.getProperty("ui.test.mock.project.path") } private val testCaseDesc by lazy { TestCase(IdeProductProvider.IC, LocalProjectInfo(Paths.get(mockProjectRelativePathStr))) } @@ -44,7 +43,6 @@ class IdeRunManager private constructor() { .newContext("test_plugin_action", testCase = testCaseDesc.useRelease(ideVersion)) .prepareProjectCleanImport() .disableAutoImport(disabled = true) - private var isPolicyDialogAlreadyClosed = false val runningIde: BackgroundRun @@ -57,21 +55,7 @@ class IdeRunManager private constructor() { * If the initialization is already done, will just return the IDE run manager instance */ fun prepareRunManager(): IdeRunManager { - createdRunManager.runningIde - val driver = createdRunManager.runningIde.driver - if (!createdRunManager.isPolicyDialogAlreadyClosed) { - driver.ideFrame { - // Dismiss policy dialog - val policyDialog = dialog(title = "For Mainframe Plugin Privacy Policy and Terms and Conditions") - assert(policyDialog.isVisible()) - val dismissButton = policyDialog.actionButton { byText("Dismiss") } - dismissButton.setFocus() - dismissButton.click() - - createdRunManager.runningIde.driver.waitForIndicators(5.minutes) - } - createdRunManager.isPolicyDialogAlreadyClosed = true - } + createdRunManager.runningIde.driver.waitForIndicators(5.minutes) return createdRunManager } @@ -108,4 +92,4 @@ class IdeRunManager private constructor() { runningIde.closeIdeAndWait() } -} \ No newline at end of file +} diff --git a/src/uiTest/kotlin/tests/utils/MockEndpointDefinition.kt b/src/uiTest/kotlin/tests/utils/MockEndpointDefinition.kt new file mode 100644 index 000000000..4d706e275 --- /dev/null +++ b/src/uiTest/kotlin/tests/utils/MockEndpointDefinition.kt @@ -0,0 +1,24 @@ +/* + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + * Contributors: + * Zowe Community + * Uladzislau Kalesnikau + */ + +package tests.utils + +import okhttp3.mockwebserver.MockResponse +import okhttp3.mockwebserver.RecordedRequest + +data class MockEndpointDefinition( + val name: String, + val endpointResolver: (RecordedRequest?) -> Boolean, + val customHandler: (RecordedRequest?) -> MockResponse +) diff --git a/src/uiTest/kotlin/tests/utils/MockWebServerManager.kt b/src/uiTest/kotlin/tests/utils/MockWebServerManager.kt new file mode 100644 index 000000000..a33bb93cd --- /dev/null +++ b/src/uiTest/kotlin/tests/utils/MockWebServerManager.kt @@ -0,0 +1,156 @@ +/* + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + * Contributors: + * Zowe Community + * Uladzislau Kalesnikau + */ + +package tests.utils + +import okhttp3.mockwebserver.Dispatcher +import okhttp3.mockwebserver.MockResponse +import okhttp3.mockwebserver.MockWebServer +import okhttp3.mockwebserver.RecordedRequest +import okhttp3.tls.HandshakeCertificates +import okhttp3.tls.HeldCertificate +import java.util.concurrent.TimeUnit + +/** Mock web server manager. Provides functionality to work with the plugin without the need to have the real server */ +class MockWebServerManager private constructor() { + + /** Mock response dispatcher functionality for the mock web server */ + private class MockResponseDispatcher : Dispatcher() { + private var endpoints = mutableListOf() + + private fun getResourceText(resourcePath: String): String { + return javaClass.classLoader.getResource(resourcePath)?.readText() ?: "" + } + + /** + * Read mock JSON file by the provided [mockFilePath] + * @param mockFilePath the mock file path to read + * @return the contents of the file + */ + fun readMockJson(mockFilePath: String): String { + return getResourceText("mock/${mockFilePath}.json") + } + + /** + * Inject the mock server endpoint. The name of the endpoint must be unique. + * If the response should be a JSON from a mock file, the [jsonMock] file name must be provided. + * If the [customHandler] is not provided, the default response is used with the 503 HTTP error + * @param name the name of the endpoint + * @param jsonMock the JSON file mock + * @param endpointResolver the function to recognize the request to provide a corresponding endpoint + * @param customHandler the function to provide a custom behavior of the endpoint response + */ + fun injectEndpoint( + name: String, + jsonMock: String, + endpointResolver: (RecordedRequest?) -> Boolean, + customHandler: (RecordedRequest?) -> MockResponse + ) { + if (endpoints.find { it.name == name } != null) { + throw Exception("Injected endpoint must have a unique name. Provided endpoint name \"$name\" already injected") + } + + val customHandlerOrJson = if (jsonMock.isNotEmpty()) { + { + val jsonResponse = readMockJson(jsonMock) + if (jsonResponse.isNotEmpty()) + MockResponse().setBody(jsonResponse) + else + MockResponse() + .setBody("The endpoint request is recognized, but the JSON response mock is empty") + .setResponseCode(503) + } + } else { + customHandler + } + + endpoints.add(MockEndpointDefinition(name, endpointResolver, customHandlerOrJson)) + } + + /** Remove an injected endpoint by the [name] */ + fun removeEndpoint(name: String) { + endpoints.removeAll { it.name == name } + } + + /** Clean the response dispatcher's endpoints */ + fun removeAllEndpoints() { + endpoints.clear() + } + + // TODO: logs + /** + * Dispatch a request with a response if it could be handled with the previously injected endpoint + * @param request the request to dispatch + * @return a mock response or a response with 404 HTTP code + */ + override fun dispatch(request: RecordedRequest): MockResponse { + return endpoints + .firstOrNull { it.endpointResolver(request) } + ?.customHandler + ?.let { it(request) } + ?: MockResponse().setBody("Response is not implemented").setResponseCode(404) + } + } + + companion object { + private val mockServer by lazy { MockWebServer() } + private val responseDispatcher by lazy { MockResponseDispatcher() } + private var isMockServerStarted = false + + /** Prepare a mock web server instance if it is not ready yet. Will return the prepared mock web server */ + fun prepareMockServer(): MockWebServer { + if (isMockServerStarted) return mockServer + + val localhostCertificate = HeldCertificate.Builder() + .addSubjectAlternativeName("localhost") + .addSubjectAlternativeName("127.0.0.1") + .duration(30, TimeUnit.MINUTES) + .build() + val serverCertificates = HandshakeCertificates.Builder() + .heldCertificate(localhostCertificate) + .build() + mockServer.dispatcher = responseDispatcher + mockServer.useHttps(serverCertificates.sslSocketFactory(), false) + mockServer.start() + isMockServerStarted = true + + return mockServer + } + + val url by lazy { + val mockServer = prepareMockServer() + "https://127.0.0.1:${mockServer.port}" + } + + /** @see MockResponseDispatcher.injectEndpoint */ + fun injectEndpoint( + name: String, + jsonMock: String = "", + endpointResolver: (RecordedRequest?) -> Boolean = { false }, + customHandler: (RecordedRequest?) -> MockResponse = { + MockResponse() + .setBody("The endpoint request is recognized, but the response is not implemented") + .setResponseCode(503) + } + ) { + prepareMockServer() + responseDispatcher.injectEndpoint(name, jsonMock, endpointResolver, customHandler) + } + + fun removeAllEndpoints() { + prepareMockServer() + responseDispatcher.removeAllEndpoints() + } + } +} diff --git a/src/uiTest/kotlin/testutils/UiTestsExecutionListener.kt b/src/uiTest/kotlin/tests/utils/UiTestsExecutionListener.kt similarity index 93% rename from src/uiTest/kotlin/testutils/UiTestsExecutionListener.kt rename to src/uiTest/kotlin/tests/utils/UiTestsExecutionListener.kt index 58b81fc5a..198fc6054 100644 --- a/src/uiTest/kotlin/testutils/UiTestsExecutionListener.kt +++ b/src/uiTest/kotlin/tests/utils/UiTestsExecutionListener.kt @@ -1,18 +1,18 @@ /* - * Copyright (c) 2024 IBA Group. - * * This program and the accompanying materials are made available under the terms of the * Eclipse Public License v2.0 which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-v20.html * * SPDX-License-Identifier: EPL-2.0 * + * Copyright Contributors to the Zowe Project. + * * Contributors: - * IBA Group * Zowe Community + * IBA Group */ -package testutils +package tests.utils import org.junit.platform.launcher.TestExecutionListener import org.junit.platform.launcher.TestPlan diff --git a/src/uiTest/kotlin/tests/utils/datasetUtils.kt b/src/uiTest/kotlin/tests/utils/datasetUtils.kt new file mode 100644 index 000000000..679e992c7 --- /dev/null +++ b/src/uiTest/kotlin/tests/utils/datasetUtils.kt @@ -0,0 +1,66 @@ +/* + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + * Contributors: + * Zowe Community + * Uladzislau Kalesnikau + */ + +package tests.utils + +/** To represent used indexes for datasets */ +private var dsIdx = 0 + +/** Dataset record format */ +enum class RecFM { + F, FB, V, VA, VB, U +} + +/** Class to represent both full and short versions of dataset organizations */ +data class DsOrgItem(val full: String, val short: String) + +/** Dataset organization */ +enum class DsOrg(val value: DsOrgItem) { + PS(DsOrgItem(full="Physical Sequential (PS)", short="PS")), + PO(DsOrgItem(full="Partitioned Organization (PO)", short="PO")), + POE(DsOrgItem(full="Partitioned Data Set Extended (PO-E)", short="PO-E")) +} + +/** Dataset allocation unit */ +enum class AllocUnit { + TRK, CYL +} + +/** Allocate dataset parameters class for the dataset parameters transmission through UI tests */ +data class AllocateDatasetParams( + val name: String, + val preset: String, + val dsOrg: DsOrg, + val unit: AllocUnit, + val recfm: RecFM, + val memberName: String? = null, + val primAlloc: String? = null, + val secAlloc: String? = null, + val blksz: String? = null, + val avgBlkLen: String? = null, + val dirBlock: String? = null, + val lrecl: String? = null +) + +/** + * Calculate the next dataset HLQ last element basing on the provided [prefix] and already used indexes ([dsIdx]). + * @return an 8 character string as a result + */ +fun calcDsHlqLastElem(prefix: String): String { + require(prefix.length < 8) { "Prefix must be less than 8 characters" } + val remainingLength = 8 - prefix.length + val formattedIndex = dsIdx.toString().padStart(remainingLength, '0') + dsIdx++ + return prefix + formattedIndex.takeLast(remainingLength) +} diff --git a/src/uiTest/kotlin/tests/utils/dialogs/AddConnectionDialog.kt b/src/uiTest/kotlin/tests/utils/dialogs/AddConnectionDialog.kt deleted file mode 100644 index 8897ac882..000000000 --- a/src/uiTest/kotlin/tests/utils/dialogs/AddConnectionDialog.kt +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2024 IBA Group. - * - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBA Group - * Zowe Community - */ - -package tests.utils.dialogs - -import com.intellij.driver.client.Driver -import com.intellij.driver.sdk.ui.components.* -import com.intellij.driver.sdk.ui.components.textField - - -class AddConnectionDialog(val driver: Driver) { - - private lateinit var connectionDialog: DialogUiComponent - - val connectionDialogPanel by lazy { connectionDialog.x { byClass("DialogPanel") } } - val connectionNameLabel by lazy { connectionDialogPanel.x { and(byClass("JLabel"), byText("Connection name: ")) } } - private val inputFields by lazy { connectionDialogPanel.xx { byClass("JBTextField") }.list() } - val connectionNameInput by lazy { inputFields[0].textField() } - val urlInput by lazy { inputFields[1].textField() } - val userNameInput by lazy { inputFields[2].textField() } - val connectionUrlLabel by lazy { connectionDialogPanel.x { and(byClass("JLabel"), byText("Connection URL: ")) } } - val connectionUsernameLabel by lazy { connectionDialogPanel.x { and(byClass("JLabel"), byText("Username: ")) } } - val passwordLabel by lazy { connectionDialogPanel.x { and(byClass("JLabel"), byText("Password: ")) } } - val passwordInput by lazy { connectionDialog.textField { byClass("JPasswordField") } } - val questionMark by lazy { connectionDialogPanel.x { byAttribute("defaulticon", "questionMark.svg") } } - val questionMarkTip by lazy { connectionDialog.x { byClass("HeavyWeightWindow") } } - val questionMarkTipParagraph by lazy { questionMarkTip.x { byClass("Paragraph") } } - val acceptSelfSignedCheckbox by lazy { - connectionDialogPanel.x { - and(byClass("JBCheckBox"), byText("Accept self-signed SSL certificates")) - } - } - val connectionDialogCancelButton by lazy { connectionDialog.actionButton { byVisibleText("Cancel") } } - val connectionDialogOkButton by lazy { connectionDialog.actionButton { byVisibleText("OK") } } - - - init { - driver.ideFrame { - connectionDialog = dialog(title = "Add Connection") - } - } - - /** - * Fills in the required information for adding a new connection. - */ - fun fillDialog( - connectionName: String, - connectionUrl: String, - username: String, - password: String, - isAcceptSelfSigned: Boolean - ) { - connectionNameInput.text = connectionName - urlInput.text = connectionUrl - userNameInput.text = username - passwordInput.text = password - if (isAcceptSelfSigned) { - acceptSelfSignedCheckbox.click() - } - } - - -} diff --git a/src/uiTest/kotlin/tests/utils/navigation.kt b/src/uiTest/kotlin/tests/utils/navigation.kt new file mode 100644 index 000000000..55e2c1f96 --- /dev/null +++ b/src/uiTest/kotlin/tests/utils/navigation.kt @@ -0,0 +1,144 @@ +/* + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + * Contributors: + * Zowe Community + * Uladzislau Kalesnikau + */ + +package tests.utils + +import com.intellij.driver.client.Driver +import com.intellij.driver.sdk.WaitForException +import com.intellij.driver.sdk.ui.components.* +import com.intellij.driver.sdk.ui.components.UIComponentsList.Companion.waitAny +import com.intellij.driver.sdk.ui.components.UiComponent.Companion.waitFound +import com.intellij.driver.sdk.waitForOne +import com.jediterm.core.input.KeyEvent +import kotlinx.coroutines.* +import kotlinx.coroutines.selects.select +import kotlinx.coroutines.Dispatchers +import kotlin.time.Duration.Companion.seconds + +/** + * Get any explorer view that is showing on a screen right now by the [driver] + * @return the visible explorer view as a [UiComponent] or throw otherwise + */ +fun getAnyExplorerView(driver: Driver): UiComponent { + var explorerView: UiComponent? = null + driver.ideFrame { + explorerView = x("//div[@class='SimpleToolWindowPanel' and (div[@class='FileExplorerView'] or div[@class='JesExplorerView'])]") + .waitFound() + } + return explorerView ?: throw Exception("No explorer view is opened") +} + +/** + * Open Zowe Explorer right side panel if it is not opened yet + * @param driver the IDE driver to use to open the panel + */ +fun openZoweExplorerPanel(driver: Driver) { + driver.ideFrame { + while (isDialogOpened()) { + keyboard { escape() } + } + val zoweExplorerToolWindowTab = rightToolWindowToolbar.actionButton { + byAttribute("myaction", "Zowe Explorer (null)") + } + if (!zoweExplorerToolWindowTab.isSelected) { + zoweExplorerToolWindowTab.setFocus() + zoweExplorerToolWindowTab.click() + } + } +} + +/** + * Go to settings from any explorer view available by the [driver]. + * Will open the provided [tabName] or "Connections" as a default if is not provided + * @return settings tab as a [DialogUiComponent] + */ +fun goToSettings(driver: Driver, tabName: String = ""): DialogUiComponent { + openZoweExplorerPanel(driver) + val explorerView = getAnyExplorerView(driver) + var settingsDialog: DialogUiComponent? = null + driver.ideFrame { + val explorerViewSettingsButton = explorerView.actionButton { + byAttribute("myicon", "settings.svg") + } + explorerViewSettingsButton.setFocus() + explorerViewSettingsButton.click() + + settingsDialog = dialog(title = "Settings") + settingsDialog?.isVisible() + + if (tabName != "") { + val zoweExplorerSettingsTabs = settingsDialog?.x { + and(byClass("JBEditorTabs"), byAttribute("nextaction", "Select Next Tab (Activate next tab)")) + } ?: throw Exception("Settings dialog is not initialized") + zoweExplorerSettingsTabs.isVisible() + + val theTab = zoweExplorerSettingsTabs.x { + and(byClass("SimpleColoredComponent"), byVisibleText(tabName)) + } + theTab.isVisible() + theTab.setFocus() + theTab.click() + } + } + return settingsDialog ?: throw Exception("Settings dialog is not initialized") +} + +/** + * Delete config entities by the specified [driver]. + * Will enter the settings, select the specified [entityNameInSettings], and delete the specified [entityRowInSettings]. + * If the [entityRowInSettings] is -1, will remove all the entities on the tab + */ +fun deleteConfigEntities(driver: Driver, entityNameInSettings: String, entityRowInSettings: Int = -1) { + val settingsDialog = goToSettings(driver, entityNameInSettings) + driver.ideFrame { + val zoweExplorerSettingsTabs = settingsDialog.x { + and(byClass("JBEditorTabs"), byAttribute("nextaction", "Select Next Tab (Activate next tab)")) + } + + val tabElements = zoweExplorerSettingsTabs.table { byClass("ValidatingTableView") } + tabElements.isVisible() + val didTabHasElements = tabElements.rowCount() != 0 + + if (entityRowInSettings == -1) { + while (tabElements.rowCount() != 0) { + tabElements.clickCell(0, 0) + keyboard { key(KeyEvent.VK_DELETE) } + } + } else { + tabElements.clickCell(entityRowInSettings, 0) + keyboard { key(KeyEvent.VK_DELETE) } + } + + if (didTabHasElements) { + // For the Apply button to change the state + Thread.sleep(1000) + + // TODO: warning dialog handling for a connection removal + + val applySettingsDialogButton = settingsDialog.actionButton { + and(byClass("JButton"), byVisibleText("Apply")) + } + applySettingsDialogButton.isVisible() + applySettingsDialogButton.setFocus() + applySettingsDialogButton.click() + } + + val okSettingsDialogButton = settingsDialog.actionButton { + and(byClass("JButton"), byVisibleText("OK")) + } + okSettingsDialogButton.isVisible() + okSettingsDialogButton.setFocus() + okSettingsDialogButton.click() + } +} diff --git a/src/uiTest/kotlin/tests/utils/notification/CreateConnectionErrorNotification.kt b/src/uiTest/kotlin/tests/utils/notification/CreateConnectionErrorNotification.kt deleted file mode 100644 index 988aae717..000000000 --- a/src/uiTest/kotlin/tests/utils/notification/CreateConnectionErrorNotification.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2024 IBA Group. - * - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBA Group - * Zowe Community - */ - -package tests.utils.notification - -import com.intellij.driver.client.Driver -import com.intellij.driver.sdk.ui.components.* - - -class CreateConnectionErrorNotification(val driver: Driver) { - - lateinit var dialog: DialogUiComponent - val yesButton by lazy { dialog.actionButton { byVisibleText("Yes") } } - val noButton by lazy { dialog.actionButton { byVisibleText("No") } } - - init { - driver.ideFrame { - dialog = dialog(title = "Error Creating Connection") - - } - } - - -} diff --git a/src/uiTest/kotlin/tests/utils/uidefinitions/FilesExplorerPanel.kt b/src/uiTest/kotlin/tests/utils/uidefinitions/FilesExplorerPanel.kt new file mode 100644 index 000000000..5b882a662 --- /dev/null +++ b/src/uiTest/kotlin/tests/utils/uidefinitions/FilesExplorerPanel.kt @@ -0,0 +1,221 @@ +/* + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + * Contributors: + * Zowe Community + * IBA Group + * Uladzislau Kalesnikau + */ + +package tests.utils.uidefinitions + +import com.intellij.driver.sdk.ui.components.* +import com.intellij.driver.client.Driver +import tests.utils.* +import tests.utils.uidefinitions.dialogs.UnsecureConnectionDialog +import tests.utils.uidefinitions.dialogs.AddConnectionDialog +import tests.utils.uidefinitions.dialogs.ErrorCreatingConnectionDialog +import java.awt.event.KeyEvent + +enum class ActionMenuPoints(val point: String) { + CONNECTION("Connection"), + WORKING_SET("Working Set"), +} + +/** File explorer panel wrapper. Provides functionalities to work with File Explorer view elements */ +class FilesExplorerPanel(val driver: Driver) { + + lateinit var explorerView: UiComponent + lateinit var fileExplorerTree: JTreeUiComponent + lateinit var deleteWsDialog: DialogUiComponent + lateinit var deleteFilesDialog: DialogUiComponent + lateinit var plusDropdownList: JListUiComponent + lateinit var rightClickMenu: PopupMenuUiComponent + + val plusButton by lazy { explorerView.actionButton { byAttribute("myicon", "add.svg") } } + + init { + driver.ideFrame { + explorerView = x("//div[@class='SimpleToolWindowPanel' and div[@class='FileExplorerView']]") + plusDropdownList = popup().list { byClass("MyList") } + fileExplorerTree = tree("//div[@class='DnDAwareTree']") + rightClickMenu = popupMenu() + deleteWsDialog = dialog(locator = { and(byClass("MyDialog"), contains(".='Confirm File Working Set(s) Deletion'")) }) + deleteFilesDialog = dialog(title = "Confirm Files Deletion") + } + } + + /** + * Open a respective dialog by the "+" button in explorer view + * @param point the menu point to select + */ + fun openDialogByPlusButtonInExplorer(point: ActionMenuPoints) { + plusButton.click() + if (point == ActionMenuPoints.CONNECTION || point == ActionMenuPoints.WORKING_SET) { + plusDropdownList.clickItem(point.point) + } else { + throw IllegalArgumentException("Unsupported point: $point") + } + } + + /** + * Imitate the right mouse click on the element on the [row]. + * Will select the [menuPoint], and, if provided, the [submenuPoint] if the menu is a drop-down list + */ + fun selectRightClickMenuItem(row: Int, menuPoint: String, submenuPoint: String? = null) { + fileExplorerTree.rightClickRow(row) + rightClickMenu.select(menuPoint) + if (submenuPoint != null) { + rightClickMenu.select(submenuPoint) + } + } + + /** Delete a working set from the explorer tree by the [rowNumber] */ + fun deleteWorkingSet(rowNumber: Int) { + selectRightClickMenuItem(rowNumber, "Delete...") + val yesButton = deleteWsDialog.actionButton { byVisibleText("Yes") } + yesButton.click() + } + + /** + * Wait 15 seconds for the row by the provided [rowToBeLoaded] number to change from "loaded..." to something else. + * Will throw if the row is not loaded after the timeout + */ + fun waitForTreeToLoadRow(rowToBeLoaded: Int) { + var loadingRow = fileExplorerTree.collectExpandedPaths()[rowToBeLoaded] + if (loadingRow.path.last().contains("loading…")) { + var isLoadingFinished = false + var isTimeoutExceeded = false + var currentCounter = 15 + while (!isLoadingFinished && !isTimeoutExceeded) { + loadingRow = fileExplorerTree.collectExpandedPaths()[rowToBeLoaded] + if (loadingRow.path.last().contains("loading…")) { + Thread.sleep(1000) + currentCounter-- + if (currentCounter == 0) { + isTimeoutExceeded = true + } + } else { + isLoadingFinished = true + } + } + // Incorrect IntelliJ behavior + if (!isLoadingFinished && isTimeoutExceeded) { + throw Exception("Tree is not loaded in 15 seconds") + } + } + } + + // TODO: load more and expanded paths handling + /** Delete all mask elements, where the mask is in the [maskRowInTree] line */ + fun deleteAllMaskElements(maskRowInTree: Int) { + val mask = fileExplorerTree.collectExpandedPaths()[maskRowInTree] + if (mask.path.size != 2) { + throw Exception("The provided mask row ($maskRowInTree) is not a mask") + } + val startElemIdx = maskRowInTree + 1 + waitForTreeToLoadRow(startElemIdx) + val currentTreePath = fileExplorerTree.collectExpandedPaths() + val elemToDeleteStart = currentTreePath[startElemIdx] + if (!elemToDeleteStart.path.last().contains("No items found")) { + var nextElemIdx = startElemIdx + 1 + while (nextElemIdx <= currentTreePath.size - 1) { + val nextTreeElem = currentTreePath[nextElemIdx] + if (nextTreeElem.path.size != 3) { + break + } + nextElemIdx++ + } + val elementsToDeleteCount = nextElemIdx - startElemIdx + + if (elementsToDeleteCount > 1) { + fileExplorerTree.clickRow(startElemIdx) + driver.ideFrame { + keyboard { pressing(KeyEvent.VK_SHIFT) { fileExplorerTree.clickRow(startElemIdx + elementsToDeleteCount - 1) } } + } + } + selectRightClickMenuItem(startElemIdx, "Delete…") + deleteFilesDialog.isVisible() + assert(deleteFilesDialog.allTextAsString().contains("Are you sure want to delete $elementsToDeleteCount file(s)?")) + val deleteFilesYesButton = deleteFilesDialog.actionButton { byVisibleText("Yes") } + deleteFilesYesButton.click() + + // To wait for the delete dialog to finish + Thread.sleep(3000) + waitForTreeToLoadRow(startElemIdx) + val noItemsFoundElem = fileExplorerTree.collectExpandedPaths()[startElemIdx] + assert(noItemsFoundElem.path.last().contains("No items found")) + } + } + + // TODO: move to some abstraction when ready + /** + * Create a valid connection in a Files Explorer view + * @param ideDriver the IDE driver to work with other components + * @param connectionName the connection name to use + * @param scheme the HTTP scheme to use in the connection + * @param host the host to connect to + * @param port the port to connect to + * @param username the username to connect to the server with + * @param password the password to connect to the server with + * @param isAllowSelfSignedStr if "true", the "Allow self-signed certificates" option will be marked + */ + fun createValidConnection( + ideDriver: Driver, + connectionName: String, + scheme: String = UI_TEST_HTTP_SCHEME, + host: String = UI_TEST_HOST, + port: String = UI_TEST_PORT, + username: String = UI_TEST_USERNAME, + password: String = UI_TEST_PASSWORD, + isAllowSelfSignedStr: String = UI_TEST_ALLOW_SELF_SIGNED + ) { + val filesExplorerPanel = FilesExplorerPanel(ideDriver) + filesExplorerPanel.openDialogByPlusButtonInExplorer(ActionMenuPoints.CONNECTION) + val addConnectionDialog = AddConnectionDialog(ideDriver) + val unsecureConnectionDialog = UnsecureConnectionDialog(ideDriver) + val (url, isAllowSelfSigned) = prepareConnectionInfo(scheme, host, port, isAllowSelfSignedStr) + addConnectionDialog.fillDialog(connectionName, url, username, password, isAllowSelfSigned) + if (isAllowSelfSigned) { + unsecureConnectionDialog.proceedButton.click() + } + addConnectionDialog.okButton.click() + if (!url.contains("https") || isAllowSelfSigned) { + unsecureConnectionDialog.proceedButton.click() + } + // TODO: find a more suitable way to track the connection is checked + Thread.sleep(3000) + } + + // TODO: move to some abstraction when ready + /** + * Create an invalid connection in a Files Explorer view + * @param ideDriver the IDE driver to work with other components + * @param connectionName the connection name to use + * @param scheme the HTTP scheme to use in the connection + * @param host the host to connect to + * @param port the port to connect to + * @param username the username to connect to the server with + * @param password the password to connect to the server with + * @param isAllowSelfSignedStr if "true", the "Allow self-signed certificates" option will be marked + */ + fun createInvalidConnection( + connectionName: String, + ideDriver: Driver, + scheme: String = UI_TEST_HTTP_SCHEME, + host: String = UI_TEST_HOST, + port: String = UI_TEST_PORT, + username: String = UI_TEST_USERNAME, + password: String = UI_TEST_PASSWORD, + isAllowSelfSignedStr: String = UI_TEST_ALLOW_SELF_SIGNED + ) { + createValidConnection(ideDriver, connectionName, scheme, host, port, username, password, isAllowSelfSignedStr) + ErrorCreatingConnectionDialog(ideDriver).yesButton.click() + } +} diff --git a/src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/AddConnectionDialog.kt b/src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/AddConnectionDialog.kt new file mode 100644 index 000000000..bf2d52a43 --- /dev/null +++ b/src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/AddConnectionDialog.kt @@ -0,0 +1,82 @@ +/* + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + * Contributors: + * Zowe Community + * Uladzislau Kalesnikau + */ + +package tests.utils.uidefinitions.dialogs + +import com.intellij.driver.client.Driver +import com.intellij.driver.sdk.ui.components.* +import com.intellij.driver.sdk.ui.components.textField + +class AddConnectionDialog(val driver: Driver) { + + lateinit var dialogComponent: DialogUiComponent + + private val connectionDialogPanel by lazy { dialogComponent.x { byClass("DialogPanel") } } + private val connectionNameLabel by lazy { connectionDialogPanel.x { and(byClass("JLabel"), byText("Connection name: ")) } } + private val inputFields by lazy { connectionDialogPanel.xx { byClass("JBTextField") }.list() } + private val connectionNameInput by lazy { inputFields[0].textField() } + private val urlInput by lazy { inputFields[1].textField() } + private val userNameInput by lazy { inputFields[2].textField() } + private val connectionUrlLabel by lazy { connectionDialogPanel.x { and(byClass("JLabel"), byText("Connection URL: ")) } } + private val connectionUsernameLabel by lazy { connectionDialogPanel.x { and(byClass("JLabel"), byText("Username: ")) } } + private val passwordLabel by lazy { connectionDialogPanel.x { and(byClass("JLabel"), byText("Password: ")) } } + private val passwordInput by lazy { dialogComponent.textField { byClass("JBPasswordField") } } + private val questionMark by lazy { connectionDialogPanel.x { byAttribute("defaulticon", "questionMark.svg") } } + private val questionMarkTip by lazy { dialogComponent.x { byClass("HeavyWeightWindow") } } + private val questionMarkTipParagraph by lazy { questionMarkTip.x { byClass("Paragraph") } } + private val acceptSelfSignedCheckbox by lazy { + connectionDialogPanel.x { + and(byClass("JBCheckBox"), byText("Accept self-signed SSL certificates")) + } + } + + val cancelButton by lazy { dialogComponent.actionButton { byVisibleText("Cancel") } } + val okButton by lazy { dialogComponent.actionButton { byVisibleText("OK") } } + + init { + driver.ideFrame { + dialogComponent = dialog(title = "Add Connection") + } + } + + /** Fills in the required information for adding a new connection */ + fun fillDialog( + connectionName: String, + connectionUrl: String, + username: String, + password: String, + isAcceptSelfSigned: Boolean + ) { + connectionNameInput.text = connectionName + urlInput.text = connectionUrl + userNameInput.text = username + passwordInput.text = password + if (isAcceptSelfSigned) { + acceptSelfSignedCheckbox.click() + } + } + + /** Check that all the dialog fields are present and visible on a screen */ + fun checkFieldsArePresent() { + assert(connectionDialogPanel.isVisible()) + assert(connectionNameLabel.isVisible()) + assert(connectionUrlLabel.isVisible()) + assert(connectionUsernameLabel.isVisible()) + assert(passwordLabel.isVisible()) + assert(passwordInput.isVisible()) + assert(questionMark.isVisible()) + assert(cancelButton.isVisible()) + } + +} diff --git a/src/uiTest/kotlin/tests/utils/dialogs/AddWorkingSetDialog.kt b/src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/AddWorkingSetDialog.kt similarity index 95% rename from src/uiTest/kotlin/tests/utils/dialogs/AddWorkingSetDialog.kt rename to src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/AddWorkingSetDialog.kt index 82c1235c6..42ef92875 100644 --- a/src/uiTest/kotlin/tests/utils/dialogs/AddWorkingSetDialog.kt +++ b/src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/AddWorkingSetDialog.kt @@ -1,18 +1,18 @@ /* - * Copyright (c) 2024 IBA Group. - * * This program and the accompanying materials are made available under the terms of the * Eclipse Public License v2.0 which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-v20.html * * SPDX-License-Identifier: EPL-2.0 * + * Copyright Contributors to the Zowe Project. + * * Contributors: - * IBA Group * Zowe Community + * Uladzislau Kalesnikau */ -package tests.utils.dialogs +package tests.utils.uidefinitions.dialogs import com.intellij.driver.client.Driver import com.intellij.driver.sdk.ui.components.* diff --git a/src/uiTest/kotlin/tests/utils/dialogs/AllocateDatasetDialog.kt b/src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/AllocateDatasetDialog.kt similarity index 52% rename from src/uiTest/kotlin/tests/utils/dialogs/AllocateDatasetDialog.kt rename to src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/AllocateDatasetDialog.kt index 0aa5d5451..433561a2b 100644 --- a/src/uiTest/kotlin/tests/utils/dialogs/AllocateDatasetDialog.kt +++ b/src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/AllocateDatasetDialog.kt @@ -1,23 +1,25 @@ /* - * Copyright (c) 2024 IBA Group. - * * This program and the accompanying materials are made available under the terms of the * Eclipse Public License v2.0 which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-v20.html * * SPDX-License-Identifier: EPL-2.0 * + * Copyright Contributors to the Zowe Project. + * * Contributors: - * IBA Group * Zowe Community + * IBA Group + * Uladzislau Kalesnikau */ -package tests.utils.dialogs +package tests.utils.uidefinitions.dialogs import com.intellij.driver.client.Driver import com.intellij.driver.sdk.ui.components.* import com.intellij.driver.sdk.ui.components.textField -import workingset.* +import tests.utils.AllocateDatasetParams +import tests.utils.DsOrg val inputToIdx = mapOf( "Member name" to 2, @@ -48,28 +50,26 @@ val inputToIdx = mapOf( "Record len (PO-MEMBER)" to 6, "Block size (PO-MEMBER)" to 7, "Avg block (PO-MEMBER)" to 8, - - ) - +) class AllocateDatasetDialog(val driver: Driver) { - private lateinit var dialogHeader: DialogUiComponent - val okButton: ActionButtonUi by lazy { dialogHeader.actionButton { byVisibleText("OK") } } - val cancelButton: ActionButtonUi by lazy { dialogHeader.actionButton { byVisibleText("Cancel") } } - val datasetNameInput: JTextFieldUI by lazy { dialogHeader.textField("//div[@class='JBTextField']") } + lateinit var dialogComponent: DialogUiComponent - val choosePresetButton: JComboBoxUiComponent by lazy { dialogHeader.comboBox("(//div[@class='ComboBox'])[1]") } - val chooseOrgButton: JComboBoxUiComponent by lazy { dialogHeader.comboBox("(//div[@class='ComboBox'])[2]") } - val chooseUnitButton: JComboBoxUiComponent by lazy { dialogHeader.comboBox("(//div[@class='ComboBox'])[3]") } - val chooseFormatButton: JComboBoxUiComponent by lazy { dialogHeader.comboBox("(//div[@class='ComboBox'])[4]") } - val datasetParametrExpand: UiComponent by lazy { dialogHeader.x { byText("Dataset Parameters") } } - val advancedParametrExpand: UiComponent by lazy { dialogHeader.x { byText("Advanced Parameters") } } + private val datasetNameInput: JTextFieldUI by lazy { dialogComponent.textField("//div[@class='JBTextField']") } + private val choosePresetButton: JComboBoxUiComponent by lazy { dialogComponent.comboBox("(//div[@class='ComboBox'])[1]") } + private val chooseOrgButton: JComboBoxUiComponent by lazy { dialogComponent.comboBox("(//div[@class='ComboBox'])[2]") } + private val chooseUnitButton: JComboBoxUiComponent by lazy { dialogComponent.comboBox("(//div[@class='ComboBox'])[3]") } + private val chooseFormatButton: JComboBoxUiComponent by lazy { dialogComponent.comboBox("(//div[@class='ComboBox'])[4]") } + private val datasetParameterExpand: UiComponent by lazy { dialogComponent.x { byText("Dataset Parameters") } } + private val advancedParameterExpand: UiComponent by lazy { dialogComponent.x { byText("Advanced Parameters") } } + val okButton: ActionButtonUi by lazy { dialogComponent.actionButton { byVisibleText("OK") } } + val cancelButton: ActionButtonUi by lazy { dialogComponent.actionButton { byVisibleText("Cancel") } } init { driver.ideFrame { - dialogHeader = dialog(title = "Allocate Dataset") + dialogComponent = dialog(title = "Allocate Dataset") } } @@ -77,54 +77,46 @@ class AllocateDatasetDialog(val driver: Driver) { return "(//div[@class='JBTextField'])[${inputLabel}]" } - fun fillDialog(allocationParams: AllocateDatasetParams) { datasetNameInput.text = allocationParams.name choosePresetButton.click() choosePresetButton.selectItem(allocationParams.preset) val memberName = allocationParams.memberName - val dsOrganisationShort = allocationParams.dsOrganisationShort - if (memberName != null) { driver.ideFrame { textField(getJBTextFieldXPathFor(inputToIdx["Member name"])).text = memberName } } + val memberFlag = if (allocationParams.memberName != null) "MEMBER" else "NO_MEMBER" + // To remove "-E" from "PO-E" + val dsOrgShortGen = allocationParams.dsOrg.value.short.substringBefore("-") + val allocationTypeKey = "$dsOrgShortGen-$memberFlag" - if (dsOrganisationShort == null) { - return - } - - - val allocationType = if (dsOrganisationShort.contains("PS")) "PS" else "PO" - val member = if (allocationParams.memberName != null) "MEMBER" else "NO_MEMBER" - val allocationTypeKey = "$allocationType-$member" - - datasetParametrExpand.click() + datasetParameterExpand.click() chooseOrgButton.click() - chooseOrgButton.selectItem(allocationParams.organisation.toString()) + chooseOrgButton.selectItem(allocationParams.dsOrg.value.full) chooseUnitButton.click() chooseUnitButton.selectItem(allocationParams.unit.toString()) chooseFormatButton.click() - chooseFormatButton.selectItem(allocationParams.format.toString()) + chooseFormatButton.selectItem(allocationParams.recfm.toString()) driver.ideFrame { - textField(getJBTextFieldXPathFor(inputToIdx["Primary allocation (${allocationTypeKey})"])).text = - allocationParams.primaryAlloc.toString() - textField(getJBTextFieldXPathFor(inputToIdx["Secondary allocation (${allocationTypeKey})"])).text = - allocationParams.secondaryAlloc.toString() - if (allocationParams.dsOrganisationShort != DatasetOrganization.SEQUENTIAL_ORG_SHORT_ITEM.value) { - textField(getJBTextFieldXPathFor(inputToIdx["dirBlock (${allocationTypeKey})"])).text = - allocationParams.dirBlock.toString() + textField(getJBTextFieldXPathFor(inputToIdx["Primary allocation (${allocationTypeKey})"])) + .text = allocationParams.primAlloc ?: "" + textField(getJBTextFieldXPathFor(inputToIdx["Secondary allocation (${allocationTypeKey})"])) + .text = allocationParams.secAlloc ?: "" + if (allocationParams.dsOrg != DsOrg.PS) { + textField(getJBTextFieldXPathFor(inputToIdx["dirBlock (${allocationTypeKey})"])) + .text = allocationParams.dirBlock ?: "" } - textField(getJBTextFieldXPathFor(inputToIdx["Record len (${allocationTypeKey})"])).text = - allocationParams.recordLength.toString() - textField(getJBTextFieldXPathFor(inputToIdx["Block size (${allocationTypeKey})"])).text = - allocationParams.blockSize.toString() - textField(getJBTextFieldXPathFor(inputToIdx["Avg block (${allocationTypeKey})"])).text = - allocationParams.avgBlockLen.toString() + textField(getJBTextFieldXPathFor(inputToIdx["Record len (${allocationTypeKey})"])) + .text = allocationParams.lrecl ?: "" + textField(getJBTextFieldXPathFor(inputToIdx["Block size (${allocationTypeKey})"])) + .text = allocationParams.blksz ?: "" + textField(getJBTextFieldXPathFor(inputToIdx["Avg block (${allocationTypeKey})"])) + .text = allocationParams.avgBlkLen ?: "" } } diff --git a/src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/ErrorCreatingConnectionDialog.kt b/src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/ErrorCreatingConnectionDialog.kt new file mode 100644 index 000000000..c94bfc7ab --- /dev/null +++ b/src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/ErrorCreatingConnectionDialog.kt @@ -0,0 +1,31 @@ +/* + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + * Contributors: + * Zowe Community + * Uladzislau Kalesnikau + */ + +package tests.utils.uidefinitions.dialogs + +import com.intellij.driver.client.Driver +import com.intellij.driver.sdk.ui.components.* +import com.intellij.driver.sdk.ui.components.textField + +class ErrorCreatingConnectionDialog(val driver: Driver) { + lateinit var dialogComponent: DialogUiComponent + val yesButton by lazy { dialogComponent.actionButton { byVisibleText("Yes") } } + val noButton by lazy { dialogComponent.actionButton { byVisibleText("No") } } + + init { + driver.ideFrame { + dialogComponent = dialog(title = "Error Creating Connection") + } + } +} diff --git a/src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/TestingConnectionDialog.kt b/src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/TestingConnectionDialog.kt new file mode 100644 index 000000000..a78fc3d93 --- /dev/null +++ b/src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/TestingConnectionDialog.kt @@ -0,0 +1,40 @@ +/* + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + * Contributors: + * Zowe Community + * Uladzislau Kalesnikau + */ + +package tests.utils.uidefinitions.dialogs + +import com.intellij.driver.client.Driver +import com.intellij.driver.sdk.ui.components.* +import com.intellij.driver.sdk.waitFor +import kotlin.time.Duration.Companion.seconds + +/** Testing connection dialog wrapper. The dialog appears when a connection dialog is fulfilled */ +class TestingConnectionDialog(val driver: Driver) { + private lateinit var testingDialog: DialogUiComponent + + val cancelButton by lazy { testingDialog.actionButton { byVisibleText("Cancel") } } + + init { + driver.ideFrame { + testingDialog = dialog(locator = { and(byClass("MyDialog"), contains(".='Testing Connection to '")) }) + } + } + + // TODO: does not work as expected... + fun waitDialogClosed() { + waitFor(message = "Dialog is closed", timeout = 10.seconds) { + !testingDialog.isDialogOpened(testingDialog.searchContext.context) + } + } +} diff --git a/src/uiTest/kotlin/tests/utils/notification/UnsecureConnectionDialog.kt b/src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/UnsecureConnectionDialog.kt similarity index 86% rename from src/uiTest/kotlin/tests/utils/notification/UnsecureConnectionDialog.kt rename to src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/UnsecureConnectionDialog.kt index d9a5eeec5..4cf85259c 100644 --- a/src/uiTest/kotlin/tests/utils/notification/UnsecureConnectionDialog.kt +++ b/src/uiTest/kotlin/tests/utils/uidefinitions/dialogs/UnsecureConnectionDialog.kt @@ -12,23 +12,18 @@ * Zowe Community */ -package tests.utils.notification +package tests.utils.uidefinitions.dialogs import com.intellij.driver.client.Driver import com.intellij.driver.sdk.ui.components.* - class UnsecureConnectionDialog(val driver: Driver) { - lateinit var dialog: DialogUiComponent - val preceedButton by lazy { dialog.actionButton { byVisibleText("Proceed") } } + val proceedButton by lazy { dialog.actionButton { byVisibleText("Proceed") } } init { driver.ideFrame { dialog = dialog(xpath = "//div[@accessiblename='Attempt to create an unsecured connection']") - } } - - } diff --git a/src/uiTest/kotlin/tests/utils/utils.kt b/src/uiTest/kotlin/tests/utils/utils.kt new file mode 100644 index 000000000..e5d5402e4 --- /dev/null +++ b/src/uiTest/kotlin/tests/utils/utils.kt @@ -0,0 +1,55 @@ +/* + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + * Contributors: + * Zowe Community + * IBA Group + * Uladzislau Kalesnikau + */ + +package tests.utils + +import com.intellij.driver.sdk.ui.components.ideFrame +import com.intellij.driver.sdk.ui.components.isDialogOpened +import com.intellij.driver.sdk.ui.components.waitForNoOpenedDialogs +import com.intellij.ide.starter.driver.engine.BackgroundRun +import com.jediterm.core.input.KeyEvent + +/** + * Reset the running IDE test environment. + * Is useful to reset the IDE state before the other tests run + */ +fun BackgroundRun.resetTestEnv(): BackgroundRun { + driver.ideFrame { + while (isDialogOpened()) { + robot.pressAndReleaseKey(KeyEvent.VK_ESCAPE) + } + waitForNoOpenedDialogs() + } + return this +} + +/** + * Prepare connection URL and "Allow self-signed certificates" options basing on the provided data. + * If scheme, host, and port are provided as "undef", the URL will be provided as the mock server URL + * @param scheme the HTTP scheme to form the URL + * @param host the host to form the URL + * @param port the port to form the URL + * @param isAllowSelfSignedStr if "true", the "Allow self-signed certificates" option will be true, false otherwise + * @return a pair of URL and "Allow self-signed certificates" + */ +fun prepareConnectionInfo(scheme: String, host: String, port: String, isAllowSelfSignedStr: String): Pair { + val url = if (scheme == "undef" && host == "undef" && port == "undef") { + MockWebServerManager.url + } else "$scheme://$host:$port" + + val isAllowSelfSigned = if (isAllowSelfSignedStr == "undef") false else isAllowSelfSignedStr == "true" + + return url to isAllowSelfSigned +} diff --git a/src/uiTest/kotlin/tests/utils/variables.kt b/src/uiTest/kotlin/tests/utils/variables.kt new file mode 100644 index 000000000..1b64c505f --- /dev/null +++ b/src/uiTest/kotlin/tests/utils/variables.kt @@ -0,0 +1,23 @@ +/* + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + * Contributors: + * Zowe Community + * Uladzislau Kalesnikau + */ + +package tests.utils + +val UI_TEST_HTTP_SCHEME: String by lazy { System.getProperty("ui.test.http.scheme", "undef") } +val UI_TEST_HOST: String by lazy { System.getProperty("ui.test.host", "undef") } +val UI_TEST_PORT: String by lazy { System.getProperty("ui.test.port", "undef") } +val UI_TEST_USERNAME: String by lazy { System.getProperty("ui.test.username", "UNDEF") } +val UI_TEST_PASSWORD: String by lazy { System.getProperty("ui.test.password", "undef") } +val UI_TEST_ALLOW_SELF_SIGNED: String by lazy { System.getProperty("ui.test.allow.self.signed", "undef") } + diff --git a/src/uiTest/kotlin/testutils/MockResponseDispatcher.kt b/src/uiTest/kotlin/testutils/MockResponseDispatcher.kt index e4e009766..ed601b0fe 100644 --- a/src/uiTest/kotlin/testutils/MockResponseDispatcher.kt +++ b/src/uiTest/kotlin/testutils/MockResponseDispatcher.kt @@ -13,7 +13,6 @@ */ package testutils -//import auxiliary.buildFinalListDatasetJson import auxiliary.buildListMembersJson import auxiliary.responseDispatcher import okhttp3.mockwebserver.Dispatcher diff --git a/src/uiTest/kotlin/testutils/newTestsUtils.kt b/src/uiTest/kotlin/testutils/newTestsUtils.kt deleted file mode 100644 index b7408007f..000000000 --- a/src/uiTest/kotlin/testutils/newTestsUtils.kt +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2024 IBA Group. - * - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBA Group - * Zowe Community - */ - -package testutils - -import auxiliary.* -import com.intellij.driver.sdk.ui.components.ideFrame -import com.intellij.driver.sdk.ui.components.isDialogOpened -import com.intellij.driver.sdk.ui.components.waitForNoOpenedDialogs -import com.intellij.ide.starter.driver.engine.BackgroundRun -import com.jediterm.core.input.KeyEvent -import com.intellij.driver.client.Driver -import com.intellij.driver.sdk.ui.components.actionButton -import org.junit.jupiter.api.TestInfo -import tests.utils.ActionMenuPoints -import tests.utils.FilesExplorerPanel -import tests.utils.dialogs.AddConnectionDialog -import tests.utils.dialogs.AddWorkingSetDialog -import tests.utils.notification.CreateConnectionErrorNotification -import tests.utils.notification.UnsecureConnectionDialog -import workingset.testutils.injectTestInfo -import workingset.testutils.injectTestInfoRestTopology - -/** - * Reset the running IDE test environment. - * Is useful to reset the IDE state before the other tests run - */ -fun BackgroundRun.resetTestEnv(): BackgroundRun { - driver.ideFrame { - while (isDialogOpened()) { - robot.pressAndReleaseKey(KeyEvent.VK_ESCAPE) - } - waitForNoOpenedDialogs() - } - return this -} - -fun callRightSidePanel(driver: Driver) { - driver.ideFrame { - val forMainframeTool = rightToolWindowToolbar.actionButton { - byAttribute("myaction", "For Mainframe (null)") - } - forMainframeTool.setFocus() - forMainframeTool.click() - } -} - -/** - * Creates valid connection to mock server. - */ -fun createValidConnectionWithMock(testInfo: TestInfo, connectionName: String, ideDriver: Driver) { - injectTestInfo(testInfo) - injectTestInfoRestTopology(testInfo) - - createConnection( - connectionName, - true, - ideDriver, - "https://${mockServer.hostName}:${mockServer.port}", - ) -} - -/** - * Steps to create a connection(valid or invalid) from settings . - */ - -fun createConnection( - connectionName: String, - isValidConnection: Boolean, - ideDriver: Driver, - url: String = CONNECTION_URL, - user: String = ZOS_USERID, - password: String = ZOS_PWD, - useSsl: Boolean = true -) { - val filesExplorerPanel = FilesExplorerPanel(ideDriver) - filesExplorerPanel.openExplorerToolWindow(ActionMenuPoints.CONNECTION) - val addConnectionDialog = AddConnectionDialog(ideDriver) - val unsecureConnectionDialog = UnsecureConnectionDialog(ideDriver) - if (isValidConnection) { - addConnectionDialog.fillDialog(connectionName, url, user, password, useSsl) - } else { - addConnectionDialog.fillDialog(connectionName, "${url}1", user, password, useSsl) - } - unsecureConnectionDialog.preceedButton.click() - addConnectionDialog.connectionDialogOkButton.click() - unsecureConnectionDialog.preceedButton.click() - if (isValidConnection.not()) { - CreateConnectionErrorNotification(ideDriver).yesButton.click() - } -} - - -/** - * Creates working set without masks. - */ -fun createWsWithoutMask( - ideDriver: Driver, - wsName: String, - connectionName: String, -) { - FilesExplorerPanel(ideDriver).openExplorerToolWindow(ActionMenuPoints.WORKING_SET) - val AddWorkingSetDialog = AddWorkingSetDialog(ideDriver) - AddWorkingSetDialog.fillDialog(connectionName, wsName) - AddWorkingSetDialog.okButton.click() - AddWorkingSetDialog.okButton.click() -} - -/** - * Creates working set and a mask. - */ -fun createWsAndMask(ideDriver: Driver, wsName: String, connectionName: String, masks: List>) { - FilesExplorerPanel(ideDriver).openExplorerToolWindow(ActionMenuPoints.WORKING_SET) - val AddWorkingSetDialog = AddWorkingSetDialog(ideDriver) - AddWorkingSetDialog.fillDialog(connectionName, wsName, masks) - AddWorkingSetDialog.okButton.click() - -} diff --git a/src/uiTest/kotlin/workingset/AllocateDatasetTest.kt b/src/uiTest/kotlin/workingset/AllocateDatasetTest.kt index dd90795a5..1defcdb61 100644 --- a/src/uiTest/kotlin/workingset/AllocateDatasetTest.kt +++ b/src/uiTest/kotlin/workingset/AllocateDatasetTest.kt @@ -155,7 +155,7 @@ class AllocateDatasetTest : IdeaInteractionClass() { datasetOrganization.value, s, dsName, dsOrganisationShort, recordLength ) allocateDataSet( - wsName, dsName, datasetOrganization, TRACKS_ALLOCATION_UNIT_SHORT, 10, 1, 1, + wsName, dsName, datasetOrganization, "TRK", 10, 1, 1, s, recordLength, 3200, 0, remoteRobot ) diff --git a/src/uiTest/kotlin/workingset/Data.kt b/src/uiTest/kotlin/workingset/Data.kt index b2ff7ea21..79cb39431 100644 --- a/src/uiTest/kotlin/workingset/Data.kt +++ b/src/uiTest/kotlin/workingset/Data.kt @@ -10,44 +10,23 @@ * Contributors: * IBA Group * Zowe Community + * Uladzislau Kalesnikau */ + package workingset import auxiliary.* - //Global constants enum class JobAction { SUBMIT, CANCEL, HOLD, RELEASE, PURGED, ERROR_PURGED} -enum class RecordFormatsShort { F, FB, V, VA, VB, U} -enum class DatasetOrganization(val value: String){ +enum class DatasetOrganization(val value: String) { PO_ORG_FULL_ITEM("Partitioned Organization (PO)"), PO_ORG_PROPERTY("Partitioned (PO)"), - PO_ORG_SHORT_ITEM("PO"), SEQUENTIAL_ORG_FULL_ITEM("Physical Sequential (PS)"), SEQUENTIAL_ORG_PROPERTY("Sequential (PS)"), - SEQUENTIAL_ORG_SHORT_ITEM("PS"), POE_ORG_FULL_ITEM("Partitioned Data Set Extended (PO-E)"), - POE_ORG_PROPERTY("Partitioned Extended (PO-E)"), - PDS_TYPE_ITEM("PDS") } -data class AllocateDatasetParams( - val name: String, - val preset: String, - val memberName: String?=null, - var primaryAlloc: String? = null, - var blockSize: String? = null, - var secondaryAlloc: String, - var avgBlockLen: String? = null, - var unit: String? = null, - var dsOrganisationShort: String? = null, - var dirBlock: String? = null, - var organisation: DatasetOrganization? = null, - var format: String? = null, - var recordLength: String? = null, -) - - const val PROJECT_NAME = "untitled" object Constants { @@ -59,9 +38,6 @@ object Constants { val robotServerForTest: String = System.getProperty("robotServerForTest") } -//Allocation unit shorts -const val TRACKS_ALLOCATION_UNIT_SHORT = "TRK" - //Button text const val NO_TEXT = "No" const val OK_TEXT = "OK" @@ -76,7 +52,6 @@ const val CONNECTIONS = "Connections" const val PREFIX_WORD = "Prefix" - //rename dataset const val DATASET_FOR_RENAME_PROPERTY = "{\"dsorg\":\"PO\",\"alcunit\":\"TRK\",\"primary\":10,\"secondary\":1,\"dirblk\":2,\"recfm\":\"VB\",\"blksize\":6120,\"lrecl\":255, \"migr\":false}" diff --git a/src/uiTest/kotlin/workingset/DeleteDatasetTest.kt b/src/uiTest/kotlin/workingset/DeleteDatasetTest.kt index 12a5d7b1d..290278b54 100644 --- a/src/uiTest/kotlin/workingset/DeleteDatasetTest.kt +++ b/src/uiTest/kotlin/workingset/DeleteDatasetTest.kt @@ -120,7 +120,7 @@ class DeleteDatasetTest : IdeaInteractionClass() { recordLength ) allocateDataSet( - wsName, dsName, datasetOrganization, TRACKS_ALLOCATION_UNIT_SHORT, 10, 1, 1, + wsName, dsName, datasetOrganization, "TRK", 10, 1, 1, s, recordLength, 3200, 0, remoteRobot ) diff --git a/src/uiTest/kotlin/workingset/ViewWsPropertyTest.kt b/src/uiTest/kotlin/workingset/ViewWsPropertyTest.kt index af72d0f37..3d7451bb1 100644 --- a/src/uiTest/kotlin/workingset/ViewWsPropertyTest.kt +++ b/src/uiTest/kotlin/workingset/ViewWsPropertyTest.kt @@ -104,7 +104,7 @@ class ViewWsPropertyTest : IdeaInteractionClass() { responseDispatcher.injectAllocationResultPds(pdsName) responseDispatcher.injectAllocationResultPo( "PS", - TRACKS_ALLOCATION_UNIT_SHORT, + "TRK", dsName, VB_RECORD_FORMAT_SHORT, 255 diff --git a/src/uiTest/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener b/src/uiTest/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener index a2d4b7643..640c88774 100644 --- a/src/uiTest/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener +++ b/src/uiTest/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener @@ -1 +1 @@ -testutils.UiTestsExecutionListener \ No newline at end of file +tests.utils.UiTestsExecutionListener \ No newline at end of file