Skip to content

Commit cdf4f18

Browse files
committed
Merge remote-tracking branch 'contributor/1263-Possibility-to-add-second-code-source-directory-for-modules-local-composer-development-using-content-root-feature-tests' into 1263-Possibility-to-add-second-code-source-directory-for-modules-local-composer-development-using-content-root-feature-tests
2 parents d74e650 + d0dd5f4 commit cdf4f18

File tree

156 files changed

+10311
-71
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+10311
-71
lines changed

.github/workflows/gradle.yml

Lines changed: 67 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -8,76 +8,83 @@ on:
88
branches: [ master, '*-develop', 'mainline*' ]
99

1010
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-
- os: windows-latest
25-
runIde: start gradlew.bat runIdeForUiTests
26-
- os: macos-latest
27-
runIde: ./gradlew runIdeForUiTests &
11+
build-linux:
12+
runs-on: ubuntu-latest
2813

2914
steps:
30-
31-
# Check out the current repository
32-
- name: Fetch Sources
33-
uses: actions/checkout@v4
34-
35-
# Set up Java environment for the next steps
36-
- name: Setup Java
37-
uses: actions/setup-java@v4
15+
- uses: actions/checkout@v3
16+
- name: Set up JDK 17
17+
uses: actions/setup-java@v3
3818
with:
39-
distribution: zulu
4019
java-version: 17
41-
42-
# Setup Gradle
43-
- name: Setup Gradle
44-
uses: gradle/actions/setup-gradle@v4
45-
46-
# Run IDEA prepared for UI testing
47-
- name: Run IDE
48-
run: ${{ matrix.runIde }}
49-
50-
# Wait for IDEA to be started
51-
- name: Health Check
52-
uses: jtalk/url-health-check-action@v4
20+
distribution: 'temurin'
21+
cache: gradle
22+
- uses: actions/cache@v3
5323
with:
54-
url: http://127.0.0.1:8082
55-
max-attempts: 15
56-
retry-delay: 30s
24+
path: |
25+
~/.gradle/caches
26+
~/.gradle/wrapper
27+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
28+
restore-keys: |
29+
${{ runner.os }}-gradle-
30+
- name: Gradle wrapper
31+
run: gradle wrapper
32+
- name: Grant execute permission for gradlew
33+
run: chmod +x gradlew
34+
- name: Run automated tests
35+
run: ./gradlew test --no-daemon
5736

58-
# Run tests
59-
- name: Tests
60-
if: matrix.os != 'ubuntu-latest'
61-
run: ./gradlew test
37+
build-windows:
38+
runs-on: windows-latest
6239

63-
- name: Tests Ubuntu
64-
if: matrix.os == 'ubuntu-latest'
65-
run: |
66-
export DISPLAY=:99.0
67-
./gradlew test
40+
steps:
41+
- uses: actions/checkout@v3
42+
- name: Set up JDK 17
43+
uses: actions/setup-java@v3
44+
with:
45+
java-version: 17
46+
distribution: 'temurin'
47+
cache: gradle
48+
- uses: actions/cache@v3
49+
with:
50+
path: |
51+
~/.gradle/caches
52+
~/.gradle/wrapper
53+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
54+
restore-keys: |
55+
${{ runner.os }}-gradle-
56+
- name: Gradle wrapper
57+
run: gradle wrapper
58+
- name: Grant execute permission for gradlew
59+
run: chmod +x gradlew
60+
- name: Run automated tests
61+
run: ./gradlew test --no-daemon
6862

69-
- name: Capture Test Artifacts on Failure
70-
if: failure() && matrix.os == 'windows-latest'
71-
run: tar -cvzf video.tgz ./video
72-
shell: bash
63+
build-macos:
64+
runs-on: macos-latest
7365

74-
- name: Upload Test Video Artifact
75-
if: failure() && matrix.os == 'windows-latest'
76-
uses: actions/upload-artifact@v4
66+
steps:
67+
- uses: actions/checkout@v3
68+
- name: Set up JDK 17
69+
uses: actions/setup-java@v3
7770
with:
78-
name: latest-test-video
79-
path: video.tgz
80-
overwrite: true
71+
java-version: 17
72+
distribution: 'temurin'
73+
cache: gradle
74+
- uses: actions/cache@v3
75+
with:
76+
path: |
77+
~/.gradle/caches
78+
~/.gradle/wrapper
79+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
80+
restore-keys: |
81+
${{ runner.os }}-gradle-
82+
- name: Gradle wrapper
83+
run: gradle wrapper
84+
- name: Grant execute permission for gradlew
85+
run: chmod +x gradlew
86+
- name: Run automated tests
87+
run: ./gradlew test --no-daemon
8188

8289
static-tests:
8390
runs-on: ubuntu-latest

.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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ out
3737
.idea-sandbox
3838
build
3939
.intellijPlatform/*
40-
video/*
40+
video/*
41+
intellij-test-project

build.gradle.kts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ 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 ("org.json:json:20171018")
42+
implementation("org.json:json:20171018")
4443
implementation("org.codehaus.plexus:plexus-utils:3.4.0")
4544
testImplementation("com.automation-remarks:video-recorder-junit5:2.0")
4645
testImplementation("com.intellij.remoterobot:remote-robot:0.11.23")
@@ -138,6 +137,7 @@ tasks {
138137
}
139138

140139
test {
140+
exclude("**/userInterface/**")
141141
useJUnitPlatform()
142142
}
143143

@@ -247,3 +247,11 @@ kover {
247247
}
248248
}
249249
}
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+
}

src/main/java/com/magento/idea/magento2plugin/project/SettingsForm.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ protected void reindex() {
120120

121121
@Override
122122
public boolean isModified() {
123+
if (moduleDefaultLicenseName == null) {
124+
return true;
125+
}
126+
123127
final boolean licenseChanged = !moduleDefaultLicenseName.getText().equals(
124128
getSettings().defaultLicense
125129
);
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin;
7+
8+
import com.intellij.openapi.util.text.StringUtil;
9+
import com.intellij.testFramework.IndexingTestUtil;
10+
import com.intellij.testFramework.PlatformTestUtil;
11+
import com.intellij.testFramework.fixtures.BasePlatformTestCase;
12+
import com.magento.idea.magento2plugin.indexes.IndexManager;
13+
import com.magento.idea.magento2plugin.magento.packages.File;
14+
import com.magento.idea.magento2plugin.project.Settings;
15+
16+
/**
17+
* Configure test environment with Magento 2 project.
18+
*/
19+
public abstract class BaseProjectTestCase extends BasePlatformTestCase {
20+
private static final String testDataProjectPath = "testData" //NOPMD
21+
+ File.separator
22+
+ "project";
23+
24+
private static final String testDataProjectDirectory = "magento2"; //NOPMD
25+
26+
@Override
27+
public void setUp() throws Exception {
28+
super.setUp();
29+
copyMagento2ToTestProject();
30+
enablePluginAndReindex();
31+
}
32+
33+
private void copyMagento2ToTestProject() {
34+
myFixture.setTestDataPath(testDataProjectPath);
35+
myFixture.copyDirectoryToProject(
36+
testDataProjectDirectory,
37+
""
38+
);
39+
}
40+
41+
@Override
42+
protected String getTestDataPath() {
43+
//configure specific test data in your test.
44+
return "testData";
45+
}
46+
47+
protected void enablePluginAndReindex() {
48+
final Settings settings = Settings.getInstance(myFixture.getProject());
49+
settings.magentoPath = "/src";
50+
settings.pluginEnabled = true;
51+
settings.mftfSupportEnabled = true;
52+
IndexManager.manualReindex();
53+
PlatformTestUtil.dispatchAllEventsInIdeEventQueue();
54+
IndexingTestUtil.waitUntilIndexesAreReady(myFixture.getProject());
55+
}
56+
57+
protected void disablePluginAndReindex() {
58+
final Settings settings = Settings.getInstance(myFixture.getProject());
59+
settings.pluginEnabled = false;
60+
IndexManager.manualReindex();
61+
PlatformTestUtil.dispatchAllEventsInIdeEventQueue();
62+
IndexingTestUtil.waitUntilIndexesAreReady(myFixture.getProject());
63+
}
64+
65+
protected void disableMftfSupportAndReindex() {
66+
final Settings settings = Settings.getInstance(myFixture.getProject());
67+
settings.mftfSupportEnabled = false;
68+
IndexManager.manualReindex();
69+
PlatformTestUtil.dispatchAllEventsInIdeEventQueue();
70+
IndexingTestUtil.waitUntilIndexesAreReady(myFixture.getProject());
71+
}
72+
73+
protected String prepareFixturePath(
74+
final String fileName,
75+
final String fixturesFolderPath
76+
) {
77+
return fixturesFolderPath + getClass().getSimpleName().replace("Test", "")
78+
+ File.separator
79+
+ name()
80+
+ File.separator
81+
+ fileName;
82+
}
83+
84+
private String name() {
85+
return StringUtil.trimEnd(getTestName(true), "Test");
86+
}
87+
88+
}

0 commit comments

Comments
 (0)