6
6
package com.magento.idea.magento2plugin.actions.content
7
7
8
8
import com.automation.remarks.junit5.Video
9
+ import com.intellij.openapi.util.io.NioFiles.createDirectories
9
10
import org.assertj.swing.core.MouseButton
10
11
import com.intellij.remoterobot.RemoteRobot
11
- import com.intellij.remoterobot.fixtures.ComponentFixture
12
12
import com.intellij.remoterobot.fixtures.ContainerFixture
13
- import com.intellij.remoterobot.fixtures.Fixture
14
- import com.intellij.remoterobot.fixtures.JButtonFixture
15
13
import com.intellij.remoterobot.search.locators.byXpath
16
14
import com.intellij.remoterobot.steps.CommonSteps
17
15
import com.intellij.remoterobot.stepsProcessing.step
18
- import com.intellij.remoterobot.utils.Keyboard
19
16
import com.intellij.remoterobot.utils.keyboard
20
17
import com.intellij.remoterobot.utils.waitFor
21
18
import com.intellij.remoterobot.utils.waitForIgnoringError
22
- import com.intellij.ui.components.dialog
23
19
import com.magento.idea.magento2plugin.pages.*
24
20
import com.magento.idea.magento2plugin.utils.RemoteRobotExtension
25
21
import com.magento.idea.magento2plugin.utils.StepsLogger
@@ -30,8 +26,8 @@ import org.junit.jupiter.api.extension.ExtendWith
30
26
import java.awt.event.KeyEvent.*
31
27
import java.io.File
32
28
import java.io.IOException
29
+ import java.nio.file.Paths
33
30
import java.time.Duration.ofMinutes
34
- import kotlin.io.path.createTempDirectory
35
31
36
32
@ExtendWith(RemoteRobotExtension ::class )
37
33
class MarkDirectoryAsMagentoRootTest {
@@ -43,9 +39,21 @@ class MarkDirectoryAsMagentoRootTest {
43
39
44
40
@BeforeEach
45
41
fun setup () {
46
- // Create a temporary directory
42
+ // Get the user's home directory in a platform-independent way
43
+ val userHomeDir = System .getProperty(" user.home" )
44
+
45
+ // Create a temporary directory inside the user's home directory
46
+ val tempDirPath = Paths .get(userHomeDir, " intellij-test-project" )
47
+ tempProjectDir = createDirectories(tempDirPath).toFile().apply {
48
+ // Ensure the temporary directory is deleted and recreated
49
+ if (exists()) {
50
+ deleteRecursively()
51
+ }
52
+ mkdirs()
53
+ }
54
+
55
+ // Define the source directory for the test data
47
56
val sourceDir = File (" testData/project/magento2" )
48
- tempProjectDir = createTempDirectory(" intellij-test-project" ).toFile()
49
57
50
58
// Copy the test data to the temporary directory
51
59
sourceDir.copyRecursively(
@@ -86,8 +94,12 @@ class MarkDirectoryAsMagentoRootTest {
86
94
// end temporary workaround
87
95
88
96
welcomeFrame {
89
- val launchedFromScript = find<ContainerFixture >(byXpath(" //div[@class='LinkLabel']" ))
90
- launchedFromScript.click()
97
+ try {
98
+ val launchedFromScript = find<ContainerFixture >(byXpath(" //div[@class='LinkLabel']" ))
99
+ launchedFromScript.click()
100
+ } catch (e: Exception ) {
101
+ // Element does not exist, continue without failing the test
102
+ }
91
103
92
104
createNewProjectFromExistingFilesLink.click()
93
105
dialog(" Open File or Project" ) {
@@ -111,8 +123,10 @@ class MarkDirectoryAsMagentoRootTest {
111
123
enableSupportLink.click(java.awt.Point (1 , 1 ))
112
124
waitFor(ofMinutes(1 )) { isDumbMode().not () }
113
125
114
- keyboard {
115
- hotKey(VK_ALT , VK_1 )
126
+ if (! isProjectViewVisible()) {
127
+ keyboard {
128
+ hotKey(VK_ALT , VK_1 )
129
+ }
116
130
}
117
131
118
132
with (projectViewTree) {
0 commit comments