diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9e22d579..72364efe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,9 @@ jobs: - 1.20.4-fabric - 1.20.6-neoforge - 1.20.6-fabric + side: + - Host + - Joiner runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -40,7 +43,5 @@ jobs: uses: actions/setup-java@v1 with: java-version: 21 - - name: Compile World Host - run: ./gradlew :${{ matrix.subproject }}:classes - name: Run tests - run: xvfb-run -a -s "-screen 0 1920x1080x24" bash runTests.sh ${{ matrix.subproject }} + run: xvfb-run -a -s "-screen 0 1920x1080x24" ./gradlew :${{ matrix.subproject }}:runTest${{ matrix.side }} diff --git a/runTests.sh b/runTests.sh deleted file mode 100755 index ce4a8a2a..00000000 --- a/runTests.sh +++ /dev/null @@ -1,10 +0,0 @@ -./gradlew :$1:runTestHost --stacktrace & -host_pid="$!" -./gradlew :$1:runTestJoiner --stacktrace & -joiner_pid="$!" -wait $host_pid -code="$?" -if [ "$code" -ne 0 ]; then - exit $code -fi -exit $(wait $joiner_pid) diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/AddFriendScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/AddFriendScreen.java index 8cad8c49..5dc7891b 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/AddFriendScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/AddFriendScreen.java @@ -13,6 +13,7 @@ import net.minecraft.server.players.GameProfileCache; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.VisibleForTesting; import java.util.ArrayList; import java.util.List; @@ -28,10 +29,12 @@ public class AddFriendScreen extends WorldHostScreen { private static final Component FRIEND_USERNAME_TEXT = Components.translatable("world-host.add_friend.enter_username"); private static final Component ADD_FRIEND_TEXT = Components.literal("+"); //#if MC >= 1.20.0 - private static final Component ADD_FRIEND_SILENT_TEXT = Components.literal("+\ud83d\udd08"); + @VisibleForTesting + public static final Component ADD_FRIEND_SILENT_TEXT = Components.literal("+\ud83d\udd08"); private static final Component ADD_FRIEND_NOTIFY_TEXT = Components.literal("+\ud83d\udd0a"); //#else - //$$ private static final Component ADD_FRIEND_SILENT_TEXT = Components.literal("+Q"); + //$$ @VisibleForTesting + //$$ public static final Component ADD_FRIEND_SILENT_TEXT = Components.literal("+Q"); //$$ private static final Component ADD_FRIEND_NOTIFY_TEXT = Components.literal("+N"); //#endif private static final Component ADD_FRIEND_SILENT_TOOLTIP = Components.translatable("world-host.friends.add_silently.tooltip"); diff --git a/src/main/java/io/github/gaming32/worldhost/testing/MinecraftApi.java b/src/main/java/io/github/gaming32/worldhost/testing/MinecraftApi.java index a8664070..ac0d35e7 100644 --- a/src/main/java/io/github/gaming32/worldhost/testing/MinecraftApi.java +++ b/src/main/java/io/github/gaming32/worldhost/testing/MinecraftApi.java @@ -15,6 +15,7 @@ //#if MC >= 1.19.2 import net.minecraft.network.chat.contents.TranslatableContents; +import org.intellij.lang.annotations.RegExp; //#else //$$ import net.minecraft.network.chat.TranslatableComponent; //#endif @@ -65,7 +66,7 @@ public static void enterText(AbstractWidget widget, String text) { type(text); } - public static AbstractWidget findWidgetByRegex(String regex) { + public static AbstractWidget findWidgetByRegex(@RegExp String regex) { return findWidgetByRegex(Pattern.compile(regex)); } diff --git a/src/main/java/io/github/gaming32/worldhost/testing/WorldHostTesting.java b/src/main/java/io/github/gaming32/worldhost/testing/WorldHostTesting.java index d19100c0..e242fa14 100644 --- a/src/main/java/io/github/gaming32/worldhost/testing/WorldHostTesting.java +++ b/src/main/java/io/github/gaming32/worldhost/testing/WorldHostTesting.java @@ -130,7 +130,7 @@ private static ScreenChain addFriend(TestingUser user) { .then(FriendsScreen.class, () -> click(findWidgetByTranslation("world-host.add_friend"))) .then(AddFriendScreen.class, () -> { enterText(findWidgetByTranslation("world-host.add_friend.enter_username"), "o:" + user + getUsernameSuffix()); - click(findWidgetByTranslation("world-host.add_friend")); + click(findWidgetByComponent(AddFriendScreen.ADD_FRIEND_SILENT_TEXT)); }) .then(FriendsScreen.class, () -> click(findWidgetByTranslation("gui.done"))) .then(WorldHostConfigScreen.class, () -> click(findWidgetByTranslation("gui.done")));