66package com.magento.idea.magento2plugin.actions.content
77
88import com.automation.remarks.junit5.Video
9+ import com.intellij.openapi.util.io.NioFiles.createDirectories
910import org.assertj.swing.core.MouseButton
1011import com.intellij.remoterobot.RemoteRobot
11- import com.intellij.remoterobot.fixtures.ComponentFixture
1212import com.intellij.remoterobot.fixtures.ContainerFixture
13- import com.intellij.remoterobot.fixtures.Fixture
14- import com.intellij.remoterobot.fixtures.JButtonFixture
1513import com.intellij.remoterobot.search.locators.byXpath
1614import com.intellij.remoterobot.steps.CommonSteps
1715import com.intellij.remoterobot.stepsProcessing.step
18- import com.intellij.remoterobot.utils.Keyboard
1916import com.intellij.remoterobot.utils.keyboard
2017import com.intellij.remoterobot.utils.waitFor
2118import com.intellij.remoterobot.utils.waitForIgnoringError
22- import com.intellij.ui.components.dialog
2319import com.magento.idea.magento2plugin.pages.*
2420import com.magento.idea.magento2plugin.utils.RemoteRobotExtension
2521import com.magento.idea.magento2plugin.utils.StepsLogger
@@ -30,8 +26,8 @@ import org.junit.jupiter.api.extension.ExtendWith
3026import java.awt.event.KeyEvent.*
3127import java.io.File
3228import java.io.IOException
29+ import java.nio.file.Paths
3330import java.time.Duration.ofMinutes
34- import kotlin.io.path.createTempDirectory
3531
3632@ExtendWith(RemoteRobotExtension ::class )
3733class MarkDirectoryAsMagentoRootTest {
@@ -43,9 +39,21 @@ class MarkDirectoryAsMagentoRootTest {
4339
4440 @BeforeEach
4541 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
4756 val sourceDir = File (" testData/project/magento2" )
48- tempProjectDir = createTempDirectory(" intellij-test-project" ).toFile()
4957
5058 // Copy the test data to the temporary directory
5159 sourceDir.copyRecursively(
@@ -86,8 +94,12 @@ class MarkDirectoryAsMagentoRootTest {
8694 // end temporary workaround
8795
8896 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+ }
91103
92104 createNewProjectFromExistingFilesLink.click()
93105 dialog(" Open File or Project" ) {
@@ -111,8 +123,10 @@ class MarkDirectoryAsMagentoRootTest {
111123 enableSupportLink.click(java.awt.Point (1 , 1 ))
112124 waitFor(ofMinutes(1 )) { isDumbMode().not () }
113125
114- keyboard {
115- hotKey(VK_ALT , VK_1 )
126+ if (! isProjectViewVisible()) {
127+ keyboard {
128+ hotKey(VK_ALT , VK_1 )
129+ }
116130 }
117131
118132 with (projectViewTree) {
0 commit comments