Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 25eae35

Browse files
Merge pull request #2509 from vitaliyboykocontributor/1263-Possibility-to-add-second-code-source-directory-for-modules-local-composer-development-using-content-root-feature-tests
1263: Added UI tests for MarkDirectoryAsMagentoContentRoot
2 parents 56f7c29 + 9d5d4fa commit 25eae35

File tree

25 files changed

+29769
-51
lines changed

25 files changed

+29769
-51
lines changed

‎.github/workflows/uitests.yml‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# This workflow will build a Java project with Gradle
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3+
4+
name: Run automated tests
5+
6+
on:
7+
pull_request:
8+
branches: [ master, '*-develop', 'mainline*' ]
9+
10+
jobs:
11+
12+
testUI:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
include:
18+
- os: ubuntu-latest
19+
runIde: |
20+
export DISPLAY=:99.0
21+
Xvfb -ac :99 -screen 0 1920x1080x24 &
22+
sleep 10
23+
./gradlew runIdeForUiTests &
24+
# TODO: fix for windows is needed, currently Gradle can't process .form files for windows
25+
26+
# - os: windows-latest
27+
# runIde: start gradlew.bat runIdeForUiTests
28+
# - os: macos-latest
29+
# runIde: ./gradlew runIdeForUiTests &
30+
31+
steps:
32+
33+
# Check out the current repository
34+
- name: Fetch Sources
35+
uses: actions/checkout@v4
36+
37+
# Set up Java environment for the next steps
38+
- name: Setup Java
39+
uses: actions/setup-java@v4
40+
with:
41+
distribution: zulu
42+
java-version: 17
43+
44+
# Setup Gradle
45+
- name: Setup Gradle
46+
uses: gradle/actions/setup-gradle@v4
47+
48+
# Run IDEA prepared for UI testing
49+
- name: Run IDE
50+
run: ${{ matrix.runIde }}
51+
52+
# Wait for IDEA to be started
53+
- name: Health Check
54+
uses: jtalk/url-health-check-action@v4
55+
with:
56+
url: http://127.0.0.1:8082
57+
max-attempts: 15
58+
retry-delay: 30s
59+
60+
# Run tests
61+
- name: Tests
62+
if: matrix.os != 'ubuntu-latest'
63+
run: ./gradlew uiTests
64+
65+
- name: Tests Ubuntu
66+
if: matrix.os == 'ubuntu-latest'
67+
run: |
68+
export DISPLAY=:99.0
69+
./gradlew uiTests
70+
71+
# Uncomment if investigation is needed:
72+
73+
# - name: Capture Test Artifacts on Failure
74+
# if: failure() && matrix.os == 'windows-latest'
75+
# run: tar -cvzf video.tgz ./video
76+
# shell: bash
77+
#
78+
# - name: Upload Test Video Artifact
79+
# if: failure() && matrix.os == 'windows-latest'
80+
# uses: actions/upload-artifact@v4
81+
# with:
82+
# name: latest-test-video
83+
# path: video.tgz
84+
# overwrite: true
85+

‎.gitignore‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ out
3636
.gradle
3737
.idea-sandbox
3838
build
39-
.intellijPlatform/*
39+
.intellijPlatform/*
40+
video/*
41+
intellij-test-project

‎build.gradle.kts‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,24 @@ dependencies {
3939
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.0")
4040

4141
testImplementation("org.junit.vintage:junit-vintage-engine:5.10.0")
42-
43-
implementation("com.googlecode.json-simple:json-simple:1.1.1")
42+
implementation("org.json:json:20171018")
4443
implementation("org.codehaus.plexus:plexus-utils:3.4.0")
44+
testImplementation("com.automation-remarks:video-recorder-junit5:2.0")
45+
testImplementation("com.intellij.remoterobot:remote-robot:0.11.23")
46+
testImplementation("com.intellij.remoterobot:remote-fixtures:0.11.23")
47+
testImplementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
4548

4649
intellijPlatform {
4750
create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion"))
4851

4952
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })
5053
plugins(providers.gradleProperty("platformPlugins").map { it.split(',') })
5154
plugin("com.intellij.lang.jsgraphql", "243.21565.122")
52-
instrumentationTools()
5355
pluginVerifier()
5456
zipSigner()
5557
testFramework(TestFrameworkType.Platform)
5658

5759
phpstorm("2024.3")
58-
bundledPlugin("com.jetbrains.php")
59-
bundledPlugin("com.intellij.copyright")
6060
}
6161
}
6262

@@ -137,6 +137,7 @@ tasks {
137137
}
138138

139139
test {
140+
exclude("**/userInterface/**")
140141
useJUnitPlatform()
141142
}
142143

@@ -246,3 +247,11 @@ kover {
246247
}
247248
}
248249
}
250+
251+
tasks.register<Test>("uiTests") {
252+
exclude("**/reference/**")
253+
exclude("**/linemarker/**")
254+
exclude("**/inspections/**")
255+
exclude("**/completion/**")
256+
exclude("**/actions/**") // Deprecated, all actions should be reimplemented in the UI tests and this exclude should be removed
257+
}

‎gradle.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pluginUntilBuild = 258.*
77
platformType = PS
88
platformVersion = 2024.3
99
platformPlugins =
10-
platformBundledPlugins = com.intellij.modules.json
10+
platformBundledPlugins = com.intellij.modules.json,com.jetbrains.php,JavaScript,com.intellij.copyright
1111
gradleVersion = 8.10.2
1212
kotlin.stdlib.default.dependency = false
1313
org.gradle.configuration-cache = true

‎gradle/libs.versions.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ junit = "4.13.2"
44

55
# plugins
66
changelog = "2.2.1"
7-
intelliJPlatform = "2.1.0"
7+
intelliJPlatform = "2.4.0"
88
kotlin = "1.9.25"
99
kover = "0.8.3"
1010
qodana = "2024年2月3日"

‎runTests.sh‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
./gradlew clean
4+
./gradlew runIdeForUiTests --scan &
5+
RUN_IDE_PID=$!
6+
7+
sleep 10
8+
9+
./gradlew test --no-daemon --scan
10+
11+
# run certain test
12+
#./gradlew test --tests "com.magento.idea.magento2plugin.actions.content.MarkDirectoryAsMagentoRootTest.testMarkDirectoryAsMagentoRoot" --scan
13+
14+
kill $RUN_IDE_PID
15+
16+
wait $RUN_IDE_PID 2>/dev/null

‎src/main/java/com/magento/idea/magento2plugin/actions/content/root/MarkDirectoryAsMagentoContentRot.java‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77

88
import com.intellij.ide.projectView.ProjectView;
99
import com.intellij.ide.projectView.actions.MarkRootActionBase;
10-
import com.intellij.openapi.actionSystem.*;
10+
import com.intellij.openapi.actionSystem.AnActionEvent;
11+
import com.intellij.openapi.actionSystem.DataContext;
12+
import com.intellij.openapi.actionSystem.LangDataKeys;
13+
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys;
14+
import com.intellij.openapi.actionSystem.Presentation;
1115
import com.intellij.openapi.module.Module;
1216
import com.intellij.openapi.project.Project;
1317
import com.intellij.openapi.roots.ContentEntry;
@@ -18,21 +22,28 @@
1822
import com.magento.idea.magento2plugin.MagentoIcons;
1923
import com.magento.idea.magento2plugin.project.Settings;
2024
import com.magento.idea.magento2plugin.util.magento.MagentoPathUrlUtil;
21-
import org.jetbrains.annotations.NotNull;
2225
import java.net.MalformedURLException;
2326
import java.net.URL;
27+
import org.jetbrains.annotations.NotNull;
2428

2529
public class MarkDirectoryAsMagentoContentRot extends MarkRootActionBase {
2630
private Project project;
2731

32+
/**
33+
* This action is used to mark a selected directory as
34+
* a Magento content root within the project structure.
35+
*/
2836
public MarkDirectoryAsMagentoContentRot() {
2937
super();
3038
final Presentation presentation = this.getTemplatePresentation();
3139
presentation.setIcon(MagentoIcons.MARK_AS);
3240
}
3341

3442
@Override
35-
protected void modifyRoots(final VirtualFile virtualFile, ContentEntry contentEntry) {
43+
protected void modifyRoots(
44+
final VirtualFile virtualFile,
45+
final ContentEntry contentEntry
46+
) {
3647
if (project != null) {
3748
final Settings settings = Settings.getInstance(project);
3849
Settings.getInstance(project).addMagentoFolder(virtualFile.getUrl());
@@ -61,14 +72,14 @@ public void update(@NotNull final AnActionEvent event) {
6172
project = module.getProject();
6273
}
6374

64-
if (targetElement instanceof PsiDirectory) {
65-
final Settings settings = Settings.getInstance(project);
75+
if (targetElement instanceof PsiDirectory && project != null) {
6676
final String magentoPathUrl = MagentoPathUrlUtil.execute(project);
6777
final String directoryUrl = ((PsiDirectory) targetElement).getVirtualFile().getUrl();
6878
if (magentoPathUrl != null && magentoPathUrl.equals(directoryUrl)) {
6979
event.getPresentation().setEnabledAndVisible(false);
7080
return;
7181
}
82+
final Settings settings = Settings.getInstance(project);
7283
if (!settings.containsMagentoFolder(directoryUrl)) {
7384
event.getPresentation().setEnabledAndVisible(true);
7485
return;
@@ -79,7 +90,10 @@ public void update(@NotNull final AnActionEvent event) {
7990
}
8091

8192
@Override
82-
protected boolean isEnabled(@NotNull RootsSelection rootsSelection, @NotNull Module module) {
93+
protected boolean isEnabled(
94+
@NotNull final RootsSelection rootsSelection,
95+
@NotNull final Module module
96+
) {
8397
return false;
8498
}
8599
}

‎src/main/java/com/magento/idea/magento2plugin/actions/content/root/UnmarkDirectoryAsMagentoContentRot.java‎

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
import com.intellij.ide.projectView.ProjectView;
99
import com.intellij.ide.projectView.actions.MarkRootActionBase;
10-
import com.intellij.openapi.actionSystem.*;
10+
import com.intellij.openapi.actionSystem.AnActionEvent;
11+
import com.intellij.openapi.actionSystem.DataContext;
12+
import com.intellij.openapi.actionSystem.LangDataKeys;
13+
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys;
1114
import com.intellij.openapi.module.Module;
1215
import com.intellij.openapi.project.Project;
1316
import com.intellij.openapi.roots.ContentEntry;
@@ -17,25 +20,24 @@
1720
import com.intellij.psi.PsiElement;
1821
import com.magento.idea.magento2plugin.project.Settings;
1922
import com.magento.idea.magento2plugin.util.magento.MagentoPathUrlUtil;
20-
import org.jetbrains.annotations.NotNull;
2123
import java.net.MalformedURLException;
2224
import java.net.URL;
25+
import org.jetbrains.annotations.NotNull;
2326

2427
public class UnmarkDirectoryAsMagentoContentRot extends MarkRootActionBase {
2528
private Project project;
2629

27-
public UnmarkDirectoryAsMagentoContentRot() {
28-
super();
29-
}
30-
3130
@Override
32-
protected void modifyRoots(VirtualFile virtualFile, ContentEntry contentEntry) {
31+
protected void modifyRoots(
32+
final VirtualFile virtualFile,
33+
final ContentEntry contentEntry
34+
) {
3335
if (project != null) {
34-
Settings settings = Settings.getInstance(project);
36+
finalSettings settings = Settings.getInstance(project);
3537
Settings.getInstance(project).removeMagentoFolder(virtualFile.getUrl());
3638
if (settings.getMagentoFolders() != null) {
3739
settings.getMagentoFolders().removeIf(folder -> {
38-
VirtualFile file = null;
40+
finalVirtualFile file;
3941
try {
4042
file = VfsUtil.findFileByURL(new URL(folder));
4143
} catch (MalformedURLException e) {
@@ -50,23 +52,23 @@ protected void modifyRoots(VirtualFile virtualFile, ContentEntry contentEntry) {
5052
}
5153

5254
@Override
53-
public void update(@NotNull AnActionEvent event) {
55+
public void update(@NotNull finalAnActionEvent event) {
5456
final DataContext context = event.getDataContext();
5557
final PsiElement targetElement = LangDataKeys.PSI_ELEMENT.getData(context);
56-
Module module = event.getData(PlatformCoreDataKeys.MODULE);
58+
finalModule module = event.getData(PlatformCoreDataKeys.MODULE);
5759
if (module != null) {
5860
project = module.getProject();
5961
}
6062

61-
if (targetElement instanceof PsiDirectory) {
62-
Settings settings = Settings.getInstance(project);
63-
String magentoPathUrl = MagentoPathUrlUtil.execute(project);
64-
String directoryUrl = ((PsiDirectory) targetElement).getVirtualFile().getUrl();
63+
if (targetElement instanceof PsiDirectory && project != null) {
64+
final String magentoPathUrl = MagentoPathUrlUtil.execute(project);
65+
final String directoryUrl = ((PsiDirectory) targetElement).getVirtualFile().getUrl();
6566
if (magentoPathUrl != null && magentoPathUrl.equals(directoryUrl)) {
6667
event.getPresentation().setEnabledAndVisible(false);
6768
return;
6869
}
6970

71+
final Settings settings = Settings.getInstance(project);
7072
if (settings.containsMagentoFolder(directoryUrl)) {
7173
event.getPresentation().setEnabledAndVisible(true);
7274
return;
@@ -77,7 +79,10 @@ public void update(@NotNull AnActionEvent event) {
7779
}
7880

7981
@Override
80-
protected boolean isEnabled(@NotNull RootsSelection rootsSelection, @NotNull Module module) {
82+
protected boolean isEnabled(
83+
@NotNull final RootsSelection rootsSelection,
84+
@NotNull final Module module
85+
) {
8186
return false;
8287
}
8388
}

‎src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/CreateAPluginDialog.form‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@
6565
<preferred-size width="150" height="-1"/>
6666
</grid>
6767
</constraints>
68-
<properties/>
68+
<properties>
69+
<name value="Class Name"/>
70+
</properties>
6971
<clientProperties>
7072
<html.disable class="java.lang.Boolean" value="true"/>
7173
</clientProperties>

‎src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewModuleDialog.java‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@
5151
import org.apache.commons.lang3.ArrayUtils;
5252
import org.jetbrains.annotations.NotNull;
5353

54-
@SuppressWarnings({"PMD.TooManyFields", "PMD.DataClass", "PMD.UnusedPrivateMethod"})
54+
@SuppressWarnings({
55+
"PMD.TooManyFields",
56+
"PMD.DataClass",
57+
"PMD.UnusedPrivateMethod",
58+
"PMD.ConstructorCallsOverridableMethod",
59+
"PMD.SingularField"
60+
})
5561
public class NewModuleDialog extends AbstractDialog implements ListSelectionListener { //NOPMD
5662
private static final String MODULE_DESCRIPTION = "module description";
5763
private static final String MODULE_VERSION = "module version";
@@ -111,8 +117,8 @@ public class NewModuleDialog extends AbstractDialog implements ListSelectionList
111117
@NotNull
112118
private final PsiDirectory initialBaseDir;
113119
private String detectedPackageName;
114-
private final ModuleIndex moduleIndex;
115-
private final CamelCaseToHyphen camelCaseToHyphen;
120+
private final transientModuleIndex moduleIndex;
121+
private final transientCamelCaseToHyphen camelCaseToHyphen;
116122

117123
/**
118124
* Constructor.
@@ -178,8 +184,10 @@ private void detectPackageName(final @NotNull PsiDirectory initialBaseDir) {
178184
}
179185
}
180186

187+
@Override
181188
protected void onWriteActionOK() {
182189
generateFiles();
190+
exit();
183191
}
184192

185193
private void generateFiles() {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /