Skip to content

Commit a7fc8d7

Browse files
committed
Refactor test framework interactions and adjust CI workflow.
Updated AWT robot script with improved error handling and logging in test cases. Modified GitHub Actions workflow to run tests differently based on OS, ensuring better compatibility with Ubuntu.
1 parent 51af5a8 commit a7fc8d7

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

.github/workflows/gradle.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ jobs:
5757

5858
# Run tests
5959
- name: Tests
60+
if: matrix.os != 'ubuntu-latest'
61+
run: ./gradlew test
62+
63+
- name: Tests Ubuntu
64+
if: matrix.os == 'ubuntu-latest'
6065
run: |
6166
export DISPLAY=:99.0
6267
./gradlew test

src/test/kotlin/com/magento/idea/magento2plugin/actions/content/MarkDirectoryAsMagentoRootTest.kt

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,31 @@ class MarkDirectoryAsMagentoRootTest {
7373
val startTrialFree = find<ContainerFixture>(byXpath("//div[@class='s']"))
7474
startTrialFree.click()
7575
val dialog = find<DialogFixture>(byXpath("//div[@class='MyDialog']"))
76-
dialog.button("Close").click();
76+
dialog.button("Close").click()
7777

7878
step("Switch back to PhpStorm IDE window if Firefox overlay detected") {
7979
waitFor(ofMinutes(2)) {
8080
remoteRobot.callJs(
8181
"""
82-
const robot = java.awt.Robot();
83-
const activeWindowName = java.awt.Frame.getFrames().find(frame => frame.isActive()).getName();
84-
if (activeWindowName.contains("Firefox")) {
85-
robot.keyPress(java.awt.event.KeyEvent.VK_ALT);
86-
robot.keyPress(java.awt.event.KeyEvent.VK_TAB);
87-
robot.keyRelease(java.awt.event.KeyEvent.VK_TAB);
88-
robot.keyRelease(java.awt.event.KeyEvent.VK_ALT);
82+
try {
83+
const Robot = Java.type("java.awt.Robot");
84+
const KeyEvent = Java.type("java.awt.event.KeyEvent");
85+
const Frames = Java.type("java.awt.Frame");
86+
const robot = new Robot();
87+
const activeWindow = Array.from(Frames.getFrames()).find(frame => frame.isActive());
88+
if (activeWindow && activeWindow.getName().includes("Firefox")) {
89+
print("Firefox overlay detected, switching to PhpStorm...");
90+
robot.keyPress(KeyEvent.VK_ALT);
91+
robot.keyPress(KeyEvent.VK_TAB);
92+
Thread.sleep(100);
93+
robot.keyRelease(KeyEvent.VK_TAB);
94+
robot.keyRelease(KeyEvent.VK_ALT);
95+
}
96+
true;
97+
} catch (error) {
98+
print("Error during script execution: " + error);
99+
false;
89100
}
90-
true
91101
""".trimIndent()
92102
)
93103
}

0 commit comments

Comments
 (0)