diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d16f46..6cda48a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,12 @@ ## [Unreleased] -## [1.7.0] +## [1.8.0] +### Changed +- New supported IDE version range: 2023.1.6-2024.2-EAP. +- Plugin configuration and dependency updates. +## [1.7.0] ### Changed - Temporarily disable quick documentations for Terra Wdio functions in Terra spec files. diff --git a/build.gradle.kts b/build.gradle.kts index 063d895..32c6c0e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -29,12 +29,11 @@ kotlin { dependencies { //https://kotlinlang.org/docs/reflection.html#jvm-dependency implementation("org.jetbrains.kotlin:kotlin-reflect:1.9.0") - //testImplementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22") //Testing testImplementation("junit:junit:4.13.2") - testImplementation("org.assertj:assertj-core:3.25.2") - testImplementation("org.mockito:mockito-core:5.10.0") + testImplementation("org.assertj:assertj-core:3.26.0") + testImplementation("org.mockito:mockito-core:5.12.0") testImplementation("org.mockito:mockito-inline:5.2.0") //for using static method mocking } diff --git a/gradle.properties b/gradle.properties index 2909872..0a48397 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,22 +4,22 @@ pluginGroup = com.picimako.terra pluginName = Terra Support pluginRepositoryUrl = https://github.com/picimako/terra-support # SemVer format -> https://semver.org -pluginVersion = 1.7.0 +pluginVersion = 1.8.0 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html -pluginSinceBuild = 223.8836.41 -pluginUntilBuild = 241.* +pluginSinceBuild = 231.9414.13 +pluginUntilBuild = 242.* # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension platformType = IU -platformVersion = 2022.3.3 +platformVersion = 2023.1.6 # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 platformPlugins = java,JavaScript # Gradle Releases -> https://github.com/gradle/gradle/releases -gradleVersion = 8.5 +gradleVersion = 8.7 # Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib kotlin.stdlib.default.dependency = false @@ -29,6 +29,3 @@ org.gradle.configuration-cache = true # Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html org.gradle.caching = true - -# Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment -systemProp.org.gradle.unsafe.kotlin.assignment = true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 843d236..b250ffc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,8 +2,8 @@ # plugins kotlin = "1.9.0" changelog = "2.2.0" -gradleIntelliJPlugin = "1.17.2" -lombok = "8.3" +gradleIntelliJPlugin = "1.17.3" +lombok = "8.6" [plugins] changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7f93135..d64cd49 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e6aba25..b82aa23 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/com/picimako/terra/documentation/TerraDescribeViewportsDocumentationProvider.java b/src/main/java/com/picimako/terra/documentation/TerraDescribeViewportsDocumentationProvider.java index f050476..d8a0da3 100644 --- a/src/main/java/com/picimako/terra/documentation/TerraDescribeViewportsDocumentationProvider.java +++ b/src/main/java/com/picimako/terra/documentation/TerraDescribeViewportsDocumentationProvider.java @@ -93,15 +93,6 @@ private String buildDocumentation(String viewport) { + CONTENT_END; } - private static final class Breakpoint { - private final String minimumValue; - private final String mediaQuery; - private final String description; - - Breakpoint(String minimumValue, String mediaQuery, String description) { - this.minimumValue = minimumValue; - this.mediaQuery = mediaQuery; - this.description = description; - } + private record Breakpoint(String minimumValue, String mediaQuery, String description) { } } diff --git a/src/main/java/com/picimako/terra/settings/TerraSettingsConfigurable.java b/src/main/java/com/picimako/terra/settings/TerraSettingsConfigurable.java index c57d1a8..6330107 100644 --- a/src/main/java/com/picimako/terra/settings/TerraSettingsConfigurable.java +++ b/src/main/java/com/picimako/terra/settings/TerraSettingsConfigurable.java @@ -40,7 +40,7 @@ public boolean isModified() { } @Override - public void apply() throws ConfigurationException { + public void apply() { var settings = TerraApplicationState.getInstance(); settings.wdioRootPaths = component.getWdioRootPaths(); settings.showConfirmationBeforeScreenshotDeletion = component.isScreenshotDeletionConfirmationCheckboxSelected(); diff --git a/src/main/java/com/picimako/terra/wdio/TerraWdioFolders.java b/src/main/java/com/picimako/terra/wdio/TerraWdioFolders.java index 4033dcd..aba7971 100644 --- a/src/main/java/com/picimako/terra/wdio/TerraWdioFolders.java +++ b/src/main/java/com/picimako/terra/wdio/TerraWdioFolders.java @@ -18,6 +18,7 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.search.FilenameIndex; import com.intellij.psi.search.GlobalSearchScope; +import lombok.Setter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -46,6 +47,7 @@ public final class TerraWdioFolders { private static final String LATEST_RELATIVE_PATH = "/" + SNAPSHOTS + "/" + LATEST; //TODO: this might be problematic with multiple projects having different wdio paths + @Setter private static String wdioTestRootPath; /** @@ -358,10 +360,6 @@ public static String diffPath() { return wdioTestRootPath + DIFF_RELATIVE_PATH; } - public static void setWdioTestRootPath(String path) { - wdioTestRootPath = path; - } - @TestOnly public static String getWdioTestRootPath() { return wdioTestRootPath; diff --git a/src/main/java/com/picimako/terra/wdio/helpers/inspection/NestedTerraDescribeHelpersNotAllowedInspection.java b/src/main/java/com/picimako/terra/wdio/helpers/inspection/NestedTerraDescribeHelpersNotAllowedInspection.java index 08f750a..52c9220 100644 --- a/src/main/java/com/picimako/terra/wdio/helpers/inspection/NestedTerraDescribeHelpersNotAllowedInspection.java +++ b/src/main/java/com/picimako/terra/wdio/helpers/inspection/NestedTerraDescribeHelpersNotAllowedInspection.java @@ -32,7 +32,7 @@ public class NestedTerraDescribeHelpersNotAllowedInspection extends TerraWdioIns return new JSElementVisitor() { @SuppressWarnings("ConstantConditions") @Override - public void visitJSExpressionStatement(JSExpressionStatement node) { + public void visitJSExpressionStatement(@NotNull JSExpressionStatement node) { super.visitJSExpressionStatement(node); if (isNestedTerraDescribeHelper(node)) { diff --git a/src/main/java/com/picimako/terra/wdio/imagepreview/AbstractScreenshotsPreview.java b/src/main/java/com/picimako/terra/wdio/imagepreview/AbstractScreenshotsPreview.java index 6a7303d..b4b57a9 100644 --- a/src/main/java/com/picimako/terra/wdio/imagepreview/AbstractScreenshotsPreview.java +++ b/src/main/java/com/picimako/terra/wdio/imagepreview/AbstractScreenshotsPreview.java @@ -115,11 +115,6 @@ public void addPropertyChangeListener(@NotNull PropertyChangeListener listener) public void removePropertyChangeListener(@NotNull PropertyChangeListener listener) { } - @Override - public @Nullable FileEditorLocation getCurrentLocation() { - return null; - } - @Override public void dispose() { var imageEditorCache = ImageEditorCache.getInstance(project); diff --git a/src/main/java/com/picimako/terra/wdio/inspection/ReplaceTerraItWithTerraValidatesInspection.java b/src/main/java/com/picimako/terra/wdio/inspection/ReplaceTerraItWithTerraValidatesInspection.java index 4950dd2..33bc40b 100644 --- a/src/main/java/com/picimako/terra/wdio/inspection/ReplaceTerraItWithTerraValidatesInspection.java +++ b/src/main/java/com/picimako/terra/wdio/inspection/ReplaceTerraItWithTerraValidatesInspection.java @@ -60,7 +60,7 @@ public class ReplaceTerraItWithTerraValidatesInspection extends TerraWdioInspect return new JSElementVisitor() { @Override - public void visitJSExpressionStatement(JSExpressionStatement node) { + public void visitJSExpressionStatement(@NotNull JSExpressionStatement node) { super.visitJSExpressionStatement(node); if (isInWdioSpecFile(node) && isTerraIt(node) && node.getExpression() instanceof JSCallExpression) { diff --git a/src/main/java/com/picimako/terra/wdio/projectview/action/NavigateToScreenshotUsageProjectViewAction.java b/src/main/java/com/picimako/terra/wdio/projectview/action/NavigateToScreenshotUsageProjectViewAction.java index bef4835..0e8e8bc 100644 --- a/src/main/java/com/picimako/terra/wdio/projectview/action/NavigateToScreenshotUsageProjectViewAction.java +++ b/src/main/java/com/picimako/terra/wdio/projectview/action/NavigateToScreenshotUsageProjectViewAction.java @@ -10,16 +10,15 @@ import java.util.Arrays; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.psi.PsiBinaryFile; import com.intellij.psi.PsiDirectory; import com.intellij.psi.util.PsiTreeUtil; -import org.intellij.images.fileTypes.impl.ImageFileType; import org.jetbrains.annotations.NotNull; -import com.picimako.terra.resources.TerraBundle; import com.picimako.terra.wdio.ProblemDialogs; import com.picimako.terra.wdio.ToScreenshotUsageNavigator; @@ -43,10 +42,6 @@ */ public class NavigateToScreenshotUsageProjectViewAction extends AnAction { - public NavigateToScreenshotUsageProjectViewAction() { - super(TerraBundle.message("terra.wdio.project.view.screenshot.navigate.to.usage"), null, ImageFileType.INSTANCE.getIcon()); - } - @Override public void actionPerformed(@NotNull AnActionEvent e) { var selectedScreenshot = e.getData(CommonDataKeys.PSI_FILE); @@ -80,4 +75,9 @@ public void update(@NotNull AnActionEvent e) { && isInSnapshotsDirectory(e.getData(CommonDataKeys.VIRTUAL_FILE)) && e.getData(CommonDataKeys.PSI_FILE) instanceof PsiBinaryFile); } + + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } } diff --git a/src/main/java/com/picimako/terra/wdio/screenshot/inspection/DuplicateScreenshotNameInspection.java b/src/main/java/com/picimako/terra/wdio/screenshot/inspection/DuplicateScreenshotNameInspection.java index fcf8035..3a88f4e 100644 --- a/src/main/java/com/picimako/terra/wdio/screenshot/inspection/DuplicateScreenshotNameInspection.java +++ b/src/main/java/com/picimako/terra/wdio/screenshot/inspection/DuplicateScreenshotNameInspection.java @@ -48,7 +48,7 @@ public class DuplicateScreenshotNameInspection extends TerraWdioInspectionBase { return new JSElementVisitor() { @Override - public void visitJSFile(JSFile file) { + public void visitJSFile(@NotNull JSFile file) { final var duplicateNames = new HashMap(); PsiTreeUtil.processElements(session.getFile(), JSLiteralExpression.class, element -> { //The check and reporting is applied only to Terra.validates.element and Terra.validates.screenshot calls, diff --git a/src/main/java/com/picimako/terra/wdio/screenshot/inspection/GlobalTerraSelectorInspection.java b/src/main/java/com/picimako/terra/wdio/screenshot/inspection/GlobalTerraSelectorInspection.java index 7a8a62c..061c946 100644 --- a/src/main/java/com/picimako/terra/wdio/screenshot/inspection/GlobalTerraSelectorInspection.java +++ b/src/main/java/com/picimako/terra/wdio/screenshot/inspection/GlobalTerraSelectorInspection.java @@ -43,7 +43,7 @@ public class GlobalTerraSelectorInspection extends TerraWdioInspectionBase { return new JSElementVisitor() { @Override - public void visitJSExpressionStatement(JSExpressionStatement node) { + public void visitJSExpressionStatement(@NotNull JSExpressionStatement node) { super.visitJSExpressionStatement(node); if (isTerraElementOrScreenshotValidation(node)) { diff --git a/src/main/java/com/picimako/terra/wdio/screenshot/inspection/InvalidTerraValidationPropertiesInspection.java b/src/main/java/com/picimako/terra/wdio/screenshot/inspection/InvalidTerraValidationPropertiesInspection.java index b9c10f8..c60ab3a 100644 --- a/src/main/java/com/picimako/terra/wdio/screenshot/inspection/InvalidTerraValidationPropertiesInspection.java +++ b/src/main/java/com/picimako/terra/wdio/screenshot/inspection/InvalidTerraValidationPropertiesInspection.java @@ -43,7 +43,7 @@ public class InvalidTerraValidationPropertiesInspection extends TerraWdioInspect return new JSElementVisitor() { @Override - public void visitJSExpressionStatement(JSExpressionStatement node) { + public void visitJSExpressionStatement(@NotNull JSExpressionStatement node) { super.visitJSExpressionStatement(node); TerraPropertiesProvider properties = TerraResourceManager.getInstance(node.getProject()).screenshotValidationProperties(); diff --git a/src/main/java/com/picimako/terra/wdio/screenshot/inspection/MissingScreenshotInspection.java b/src/main/java/com/picimako/terra/wdio/screenshot/inspection/MissingScreenshotInspection.java index 3645d94..da1ace7 100644 --- a/src/main/java/com/picimako/terra/wdio/screenshot/inspection/MissingScreenshotInspection.java +++ b/src/main/java/com/picimako/terra/wdio/screenshot/inspection/MissingScreenshotInspection.java @@ -38,7 +38,7 @@ public class MissingScreenshotInspection extends TerraWdioInspectionBase { return new JSElementVisitor() { @Override - public void visitJSExpressionStatement(JSExpressionStatement node) { + public void visitJSExpressionStatement(@NotNull JSExpressionStatement node) { super.visitJSExpressionStatement(node); if (!isTerraElementOrScreenshotValidation(node)) return; diff --git a/src/main/java/com/picimako/terra/wdio/screenshot/inspection/MissingScreenshotNameInspection.java b/src/main/java/com/picimako/terra/wdio/screenshot/inspection/MissingScreenshotNameInspection.java index c6b03bb..fa41fbf 100644 --- a/src/main/java/com/picimako/terra/wdio/screenshot/inspection/MissingScreenshotNameInspection.java +++ b/src/main/java/com/picimako/terra/wdio/screenshot/inspection/MissingScreenshotNameInspection.java @@ -37,7 +37,7 @@ public class MissingScreenshotNameInspection extends TerraWdioInspectionBase { return new JSElementVisitor() { @Override - public void visitJSExpressionStatement(JSExpressionStatement node) { + public void visitJSExpressionStatement(@NotNull JSExpressionStatement node) { if (isNonTerraItElementOrScreenshotValidation(node)) { String nameArgument = getFirstArgumentAsString(getArgumentListOf(node)); if (nameArgument == null) { diff --git a/src/main/java/com/picimako/terra/wdio/screenshot/inspection/ScreenshotMismatchToleranceInspection.java b/src/main/java/com/picimako/terra/wdio/screenshot/inspection/ScreenshotMismatchToleranceInspection.java index 9cd3f96..02e625a 100644 --- a/src/main/java/com/picimako/terra/wdio/screenshot/inspection/ScreenshotMismatchToleranceInspection.java +++ b/src/main/java/com/picimako/terra/wdio/screenshot/inspection/ScreenshotMismatchToleranceInspection.java @@ -84,7 +84,7 @@ public JComponent createOptionsPanel() { return new JSElementVisitor() { @Override - public void visitJSExpressionStatement(JSExpressionStatement node) { + public void visitJSExpressionStatement(@NotNull JSExpressionStatement node) { super.visitJSExpressionStatement(node); if (!isTerraElementOrScreenshotValidation(node)) return; diff --git a/src/main/java/com/picimako/terra/wdio/screenshot/inspection/TerraElementValidationIsPreferredOverScreenshotInspection.java b/src/main/java/com/picimako/terra/wdio/screenshot/inspection/TerraElementValidationIsPreferredOverScreenshotInspection.java index 3c32571..f9ad0a9 100644 --- a/src/main/java/com/picimako/terra/wdio/screenshot/inspection/TerraElementValidationIsPreferredOverScreenshotInspection.java +++ b/src/main/java/com/picimako/terra/wdio/screenshot/inspection/TerraElementValidationIsPreferredOverScreenshotInspection.java @@ -34,7 +34,7 @@ public class TerraElementValidationIsPreferredOverScreenshotInspection extends T return new JSElementVisitor() { @SuppressWarnings("ConstantConditions") @Override - public void visitJSExpressionStatement(JSExpressionStatement node) { + public void visitJSExpressionStatement(@NotNull JSExpressionStatement node) { super.visitJSExpressionStatement(node); if (isTerraItMatchesScreenshot(node)) { diff --git a/src/main/java/com/picimako/terra/wdio/toolwindow/TerraWdioScreenshotsPanel.java b/src/main/java/com/picimako/terra/wdio/toolwindow/TerraWdioScreenshotsPanel.java index 2797c2e..7ce889f 100644 --- a/src/main/java/com/picimako/terra/wdio/toolwindow/TerraWdioScreenshotsPanel.java +++ b/src/main/java/com/picimako/terra/wdio/toolwindow/TerraWdioScreenshotsPanel.java @@ -12,6 +12,7 @@ import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.ui.TreeUIHelper; import com.intellij.ui.components.JBScrollPane; +import lombok.Getter; import com.picimako.terra.wdio.toolwindow.event.KeyboardListeningPopupMenuInvoker; import com.picimako.terra.wdio.toolwindow.event.MouseListeningPopupMenuInvoker; @@ -36,6 +37,7 @@ public class TerraWdioScreenshotsPanel extends JPanel { private static final String SCREENSHOT_ACTIONS_GROUP = "terra.wdio.toolwindow.ScreenshotActionsGroup"; private final transient Project project; + @Getter private TerraWdioTree tree; public TerraWdioScreenshotsPanel(Project project) { @@ -55,10 +57,6 @@ private void buildGUI() { TreeUIHelper.getInstance().installTreeSpeedSearch(tree); } - public TerraWdioTree getTree() { - return tree; - } - /** * Registers actions and listeners to the tool window tree. *

diff --git a/src/main/java/com/picimako/terra/wdio/toolwindow/ToggleStatisticsAction.java b/src/main/java/com/picimako/terra/wdio/toolwindow/ToggleStatisticsAction.java index 8b42d5a..810d4cf 100644 --- a/src/main/java/com/picimako/terra/wdio/toolwindow/ToggleStatisticsAction.java +++ b/src/main/java/com/picimako/terra/wdio/toolwindow/ToggleStatisticsAction.java @@ -1,6 +1,7 @@ package com.picimako.terra.wdio.toolwindow; import com.intellij.icons.AllIcons; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; import com.intellij.openapi.project.Project; @@ -37,4 +38,9 @@ public void setSelected(@NotNull AnActionEvent e, boolean state) { ScreenshotStatisticsProjectService.getInstance(e.getProject()).isShowStatistics = state; updateUICallback.run(); } + + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } } diff --git a/src/main/java/com/picimako/terra/wdio/toolwindow/action/AbstractTerraWdioToolWindowAction.java b/src/main/java/com/picimako/terra/wdio/toolwindow/action/AbstractTerraWdioToolWindowAction.java index cb6338c..e5c4aca 100644 --- a/src/main/java/com/picimako/terra/wdio/toolwindow/action/AbstractTerraWdioToolWindowAction.java +++ b/src/main/java/com/picimako/terra/wdio/toolwindow/action/AbstractTerraWdioToolWindowAction.java @@ -3,6 +3,7 @@ package com.picimako.terra.wdio.toolwindow.action; import com.intellij.openapi.actionSystem.ActionManager; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.PlatformCoreDataKeys; @@ -19,10 +20,6 @@ */ public abstract class AbstractTerraWdioToolWindowAction extends AnAction { - protected AbstractTerraWdioToolWindowAction(String text) { - super(text); - } - public static AbstractTerraWdioToolWindowAction getAction(String actionId) { return (AbstractTerraWdioToolWindowAction) ActionManager.getInstance().getAction(actionId); } @@ -75,6 +72,11 @@ public void update(@NotNull AnActionEvent e) { e.getPresentation().setEnabled(meetsPreconditions(getWdioTreeFrom(e))); } + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + //Helpers /** diff --git a/src/main/java/com/picimako/terra/wdio/toolwindow/action/CompareLatestWithReferenceScreenshotsAction.java b/src/main/java/com/picimako/terra/wdio/toolwindow/action/CompareLatestWithReferenceScreenshotsAction.java index 137cdcf..6b848f8 100644 --- a/src/main/java/com/picimako/terra/wdio/toolwindow/action/CompareLatestWithReferenceScreenshotsAction.java +++ b/src/main/java/com/picimako/terra/wdio/toolwindow/action/CompareLatestWithReferenceScreenshotsAction.java @@ -11,7 +11,6 @@ import com.intellij.openapi.project.Project; import org.jetbrains.annotations.Nullable; -import com.picimako.terra.resources.TerraBundle; import com.picimako.terra.wdio.imagepreview.ReferenceToLatestScreenshotsPreview; import com.picimako.terra.wdio.toolwindow.node.TerraWdioTree; @@ -22,10 +21,6 @@ */ public class CompareLatestWithReferenceScreenshotsAction extends AbstractTerraWdioToolWindowAction { - public CompareLatestWithReferenceScreenshotsAction() { - super(TerraBundle.toolWindow("compare.latests.with.references")); - } - /** * Opens a {@link com.picimako.terra.wdio.imagepreview.ReferenceToLatestScreenshotsPreview} for the * selected screenshot. diff --git a/src/main/java/com/picimako/terra/wdio/toolwindow/action/DeleteScreenshotsAction.java b/src/main/java/com/picimako/terra/wdio/toolwindow/action/DeleteScreenshotsAction.java index bf43d64..b66b03e 100644 --- a/src/main/java/com/picimako/terra/wdio/toolwindow/action/DeleteScreenshotsAction.java +++ b/src/main/java/com/picimako/terra/wdio/toolwindow/action/DeleteScreenshotsAction.java @@ -28,10 +28,6 @@ */ public class DeleteScreenshotsAction extends AbstractTerraWdioToolWindowAction { - public DeleteScreenshotsAction() { - super(TerraBundle.toolWindow("delete.screenshots")); - } - /** * Handles the action when the user clicks the Delete Screenshots menu item. *

diff --git a/src/main/java/com/picimako/terra/wdio/toolwindow/action/NavigateToScreenshotUsageAction.java b/src/main/java/com/picimako/terra/wdio/toolwindow/action/NavigateToScreenshotUsageAction.java index 64edb29..d906c40 100644 --- a/src/main/java/com/picimako/terra/wdio/toolwindow/action/NavigateToScreenshotUsageAction.java +++ b/src/main/java/com/picimako/terra/wdio/toolwindow/action/NavigateToScreenshotUsageAction.java @@ -14,7 +14,6 @@ import com.intellij.psi.PsiManager; import org.jetbrains.annotations.Nullable; -import com.picimako.terra.resources.TerraBundle; import com.picimako.terra.wdio.ToScreenshotUsageNavigator; import com.picimako.terra.wdio.toolwindow.node.TerraWdioTree; import com.picimako.terra.wdio.toolwindow.node.TreeSpecNode; @@ -32,15 +31,6 @@ public class NavigateToScreenshotUsageAction extends AbstractTerraWdioToolWindow private ToScreenshotUsageNavigator navigator; - /** - * Creates a NavigateToScreenshotUsageAction instance. - *

- * Also registers the common Go to Declaration shortcut key for this action. - */ - public NavigateToScreenshotUsageAction() { - super(TerraBundle.toolWindow("screenshot.navigate.to.usage")); - } - /** * Handles the action when the user clicks the Navigate to Usage menu item. *

diff --git a/src/main/java/com/picimako/terra/wdio/toolwindow/action/RenameScreenshotsAction.java b/src/main/java/com/picimako/terra/wdio/toolwindow/action/RenameScreenshotsAction.java index 70bc27d..06b8042 100644 --- a/src/main/java/com/picimako/terra/wdio/toolwindow/action/RenameScreenshotsAction.java +++ b/src/main/java/com/picimako/terra/wdio/toolwindow/action/RenameScreenshotsAction.java @@ -32,10 +32,6 @@ */ public class RenameScreenshotsAction extends AbstractTerraWdioToolWindowAction { - public RenameScreenshotsAction() { - super(TerraBundle.toolWindow("rename.screenshots")); - } - /** * Handles the action when the user clicks the Rename Screenshots menu item. *

diff --git a/src/main/java/com/picimako/terra/wdio/toolwindow/action/ReplaceReferenceWithLatestAction.java b/src/main/java/com/picimako/terra/wdio/toolwindow/action/ReplaceReferenceWithLatestAction.java index 5acc549..a93037b 100644 --- a/src/main/java/com/picimako/terra/wdio/toolwindow/action/ReplaceReferenceWithLatestAction.java +++ b/src/main/java/com/picimako/terra/wdio/toolwindow/action/ReplaceReferenceWithLatestAction.java @@ -33,10 +33,6 @@ */ public class ReplaceReferenceWithLatestAction extends AbstractTerraWdioToolWindowAction { - public ReplaceReferenceWithLatestAction() { - super(TerraBundle.toolWindow("replace.reference")); - } - /** * Handles the action when the user clicks the Replace Reference With Latest menu item. *

diff --git a/src/main/java/com/picimako/terra/wdio/toolwindow/action/ShowDiffScreenshotsAction.java b/src/main/java/com/picimako/terra/wdio/toolwindow/action/ShowDiffScreenshotsAction.java index 19081d3..b464d59 100644 --- a/src/main/java/com/picimako/terra/wdio/toolwindow/action/ShowDiffScreenshotsAction.java +++ b/src/main/java/com/picimako/terra/wdio/toolwindow/action/ShowDiffScreenshotsAction.java @@ -11,7 +11,6 @@ import com.intellij.openapi.project.Project; import org.jetbrains.annotations.Nullable; -import com.picimako.terra.resources.TerraBundle; import com.picimako.terra.wdio.imagepreview.DiffScreenshotsPreview; import com.picimako.terra.wdio.toolwindow.node.TerraWdioTree; @@ -22,10 +21,6 @@ */ public class ShowDiffScreenshotsAction extends AbstractTerraWdioToolWindowAction { - public ShowDiffScreenshotsAction() { - super(TerraBundle.toolWindow("show.diff.title")); - } - /** * Opens a {@link com.picimako.terra.wdio.imagepreview.DiffScreenshotsPreview} for the selected screenshot. *

diff --git a/src/main/java/com/picimako/terra/wdio/toolwindow/node/AbstractTerraWdioTreeNode.java b/src/main/java/com/picimako/terra/wdio/toolwindow/node/AbstractTerraWdioTreeNode.java index dd06dd2..d32fbce 100644 --- a/src/main/java/com/picimako/terra/wdio/toolwindow/node/AbstractTerraWdioTreeNode.java +++ b/src/main/java/com/picimako/terra/wdio/toolwindow/node/AbstractTerraWdioTreeNode.java @@ -8,6 +8,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.SmartList; +import lombok.Getter; import org.jetbrains.annotations.NotNull; /** @@ -24,6 +25,7 @@ * (called references in this context), so that the file system resources can be reached and manipulated easier. */ public abstract class AbstractTerraWdioTreeNode implements TerraWdioTreeNode { + @Getter protected final List references = new SmartList<>(); protected final String displayName; protected final Project project; @@ -47,10 +49,6 @@ public void addReference(VirtualFile virtualFile) { references.add(virtualFile); } - public List getReferences() { - return references; - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/com/picimako/terra/wdio/viewports/inspection/DuplicateDescribeViewportsBlockInspection.java b/src/main/java/com/picimako/terra/wdio/viewports/inspection/DuplicateDescribeViewportsBlockInspection.java index 2527b2c..81e1d78 100644 --- a/src/main/java/com/picimako/terra/wdio/viewports/inspection/DuplicateDescribeViewportsBlockInspection.java +++ b/src/main/java/com/picimako/terra/wdio/viewports/inspection/DuplicateDescribeViewportsBlockInspection.java @@ -45,7 +45,7 @@ public class DuplicateDescribeViewportsBlockInspection extends TerraWdioInspecti return new JSElementVisitor() { @Override - public void visitJSFile(JSFile file) { + public void visitJSFile(@NotNull JSFile file) { super.visitJSFile(file); var describeViewportsBlocks = PsiTreeUtil.collectElements(file, diff --git a/src/main/java/com/picimako/terra/wdio/viewports/inspection/TerraDescribeViewportsInspection.java b/src/main/java/com/picimako/terra/wdio/viewports/inspection/TerraDescribeViewportsInspection.java index b124a92..c61269a 100644 --- a/src/main/java/com/picimako/terra/wdio/viewports/inspection/TerraDescribeViewportsInspection.java +++ b/src/main/java/com/picimako/terra/wdio/viewports/inspection/TerraDescribeViewportsInspection.java @@ -2,6 +2,7 @@ package com.picimako.terra.wdio.viewports.inspection; +import static com.intellij.codeInspection.options.OptPane.*; import static com.intellij.lang.javascript.buildTools.JSPsiUtil.getCallExpression; import static com.intellij.lang.javascript.psi.JSVarStatement.VarKeyword.CONST; import static com.picimako.terra.FileTypePreconditions.isWdioSpecFile; @@ -18,12 +19,11 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; -import javax.swing.*; import com.intellij.codeInspection.LocalInspectionToolSession; import com.intellij.codeInspection.ProblemHighlightType; import com.intellij.codeInspection.ProblemsHolder; -import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel; +import com.intellij.codeInspection.options.OptPane; import com.intellij.lang.javascript.psi.JSArrayLiteralExpression; import com.intellij.lang.javascript.psi.JSCallExpression; import com.intellij.lang.javascript.psi.JSElementVisitor; @@ -62,12 +62,11 @@ public final class TerraDescribeViewportsInspection extends TerraWdioInspectionB public boolean reportViewportsNotInAscendingOrder = true; @Override - public JComponent createOptionsPanel() { - final MultipleCheckboxOptionsPanel panel = new MultipleCheckboxOptionsPanel(this); - panel.addCheckbox("Report empty viewports array", "reportEmptyViewports"); - panel.addCheckbox("Report duplicate viewport values", "reportDuplicateViewports"); - panel.addCheckbox("Report when viewports are not in ascending order", "reportViewportsNotInAscendingOrder"); - return panel; + public @NotNull OptPane getOptionsPane() { + return pane( + checkbox("reportEmptyViewports", "Report empty viewports array"), + checkbox("reportDuplicateViewports", "Report duplicate viewport values"), + checkbox("reportViewportsNotInAscendingOrder", "Report when viewports are not in ascending order")); } @Override @@ -78,7 +77,7 @@ public JComponent createOptionsPanel() { return new JSElementVisitor() { @Override - public void visitJSExpressionStatement(JSExpressionStatement node) { + public void visitJSExpressionStatement(@NotNull JSExpressionStatement node) { super.visitJSExpressionStatement(node); if (isTopLevelTerraDescribeViewportsBlock(node)) { diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index b10e41b..f4d0809 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -2,13 +2,13 @@ Terra Support terra.support - 1.7.0 + 1.8.0 Tamas Balog messages.TerraBundle messages.TerraQuickDocBundle - + Adds dev and test support for Cerner's various Terra libraries. @@ -105,10 +105,11 @@ - + description="Navigates to the Terra call validating this screenshot" + icon="org.intellij.images.ImagesIcons.ImagesFileType"> @@ -116,30 +117,30 @@ - - - - - - diff --git a/src/main/resources/messages/TerraBundle.properties b/src/main/resources/messages/TerraBundle.properties index ec0c649..064efc6 100644 --- a/src/main/resources/messages/TerraBundle.properties +++ b/src/main/resources/messages/TerraBundle.properties @@ -28,22 +28,22 @@ terra.wdio.toolwindow.root.node.name=Wdio Resources terra.wdio.toolwindow.root.node.name.with.stat=Wdio Resources ({0} {0,choice,0#specs|1#spec|2#specs}, {1} {1,choice,0#screenshots|1#screenshot|2#screenshots}) terra.wdio.toolwindow.find.unused.screenshots=Analyze project terra.wdio.toolwindow.find.unused.screenshots.description=Analyzes the project for unused screenshots -terra.wdio.toolwindow.compare.latests.with.references=Compare Latests with References -terra.wdio.toolwindow.delete.screenshots=Delete Screenshots +action.terra.wdio.toolwindow.compare.latests.with.references.text=Compare Latests with References +action.terra.wdio.toolwindow.delete.screenshots.text=Delete Screenshots terra.wdio.toolwindow.delete.are.you.sure=Are you sure you want to delete all screenshots with this name? terra.wdio.toolwindow.delete.error.during.deletion=Error During Screenshot Deletion -terra.wdio.toolwindow.delete.could.not.delete.screenshots=Could not delete the following screenshots:\n\n -terra.wdio.toolwindow.rename.screenshots=Rename Screenshots +.terra.wdio.toolwindow.delete.could.not.delete.screenshots=Could not delete the following screenshots:\n\n +action.terra.wdio.toolwindow.rename.screenshots.text=Rename Screenshots terra.wdio.toolwindow.rename.provide.new.name=Please provide a new (non-blank) name: terra.wdio.toolwindow.rename.could.not.rename.screenshots=Could not rename the following screenshots:\n\n terra.wdio.toolwindow.rename.error.during.rename=Error During Screenshot Rename terra.wdio.toolwindow.rename.non.writable.files.description=One or more screenshot files for this name are not writable.\nPlease check them, until then, the renaming process cannot proceed. terra.wdio.toolwindow.rename.non.writable.files.title=Non-Writable Files Found -terra.wdio.toolwindow.replace.reference=Replace Reference with Latest +action.terra.wdio.toolwindow.replace.reference.text=Replace Reference with Latest terra.wdio.toolwindow.replace.reference.could.not.replace.screenshots=Could not completely replace the following screenshots. Please check your Version Control System for their current status:\n\n terra.wdio.toolwindow.replace.reference.error.during.replacement=Error During Replacement -terra.wdio.toolwindow.show.diff.title=Show Diffs -terra.wdio.toolwindow.screenshot.navigate.to.usage=Navigate to usage +action.terra.wdio.toolwindow.show.diff.title.text=Show Diffs +action.terra.wdio.toolwindow.screenshot.navigate.to.usage.text=Navigate to Usage terra.wdio.toolwindow.screenshot.navigate.to.usage.no.spec.file.title=No Wdio Spec File Available terra.wdio.toolwindow.screenshot.navigate.to.usage.no.spec.file.message=There is no spec file available to navigate to. It may have been removed. terra.wdio.toolwindow.screenshot.navigate.to.usage.no.validation.call.title=No Screenshot Validation Available @@ -52,7 +52,7 @@ terra.wdio.toolwindow.statistics.toggle=Toggle Statistics terra.wdio.toolwindow.statistics.toggle.description=Shows/hides spec and screenshot counts, and overall project wdio statistics # Project view actions -terra.wdio.project.view.screenshot.navigate.to.usage=Navigate to Screenshot Usage +action.terra.wdio.project.view.screenshot.navigate.to.usage.text=Navigate to Screenshot Usage # Gutter icon terra.wdio.screenshot.gutter.navigate.to.related=Navigate to related screenshots diff --git a/src/test/java/com/picimako/terra/DirectoryPsiUtilTest.java b/src/test/java/com/picimako/terra/DirectoryPsiUtilTest.java index 95ddb9a..4909e43 100644 --- a/src/test/java/com/picimako/terra/DirectoryPsiUtilTest.java +++ b/src/test/java/com/picimako/terra/DirectoryPsiUtilTest.java @@ -19,16 +19,14 @@ protected String getTestDataPath() { public void testNotReturnDirectoryWhenDirectoryPathIsNull() { myFixture.configureByFile("tests/wdio/MissingScreenshots-spec.js"); - PsiDirectory tests = DirectoryPsiUtil.findDirectory(getProject(), null); - assertThat(tests).isNull(); + assertThat(DirectoryPsiUtil.findDirectory(getProject(), null)).isNull(); } public void testNotReturnDirectorySubDirectoryIsNull() { myFixture.configureByFile("tests/wdio/MissingScreenshots-spec.js"); - PsiDirectory tests = DirectoryPsiUtil.findDirectory(getProject(), "tests/jest"); - assertThat(tests).isNull(); + assertThat(DirectoryPsiUtil.findDirectory(getProject(), "tests/jest")).isNull(); } public void testReturnDirectoryForName() { diff --git a/src/test/java/com/picimako/terra/JavaScriptTestFileSupport.java b/src/test/java/com/picimako/terra/JavaScriptTestFileSupport.java index d7f4584..09cdd5a 100644 --- a/src/test/java/com/picimako/terra/JavaScriptTestFileSupport.java +++ b/src/test/java/com/picimako/terra/JavaScriptTestFileSupport.java @@ -16,45 +16,48 @@ */ public final class JavaScriptTestFileSupport { - public static final String FILE_WITH_IMPORT = "import React, { useState } from 'react';\n" + - "import Placeholder from '@cerner/terra-docs';\n" + - "import ResponsiveElement from 'terra-responsive-element';\n" + - "import SomeNotTerraComponent from 'not-terra-component';\n" + - "const BreakpointExample = () => {\n" + - " const [breakpoint, setBreakpoint] = useState('');\n" + - " return (\n" + - " setBreakpoint(value)}>\n" + - " \n" + - " \n" + - " \n" + - " );\n" + - "};\n" + - "export default BreakpointExample;"; + public static final String FILE_WITH_IMPORT = """ + import React, { useState } from 'react'; + import Placeholder from '@cerner/terra-docs'; + import ResponsiveElement from 'terra-responsive-element'; + import SomeNotTerraComponent from 'not-terra-component'; + const BreakpointExample = () => { + const [breakpoint, setBreakpoint] = useState(''); + return ( + setBreakpoint(value)}> + + + + ); + }; + export default BreakpointExample;"""; - public static final String FILE_WITHOUT_IMPORT = "import React, { useState } from 'react';\n" + - "import Placeholder from '@cerner/terra-docs';\n" + - "const BreakpointExample = () => {\n" + - " const [breakpoint, setBreakpoint] = useState('');\n" + - " return (\n" + - " setBreakpoint(value)}>\n" + - " \n" + - " \n" + - " );\n" + - "};\n" + - "export default BreakpointExample;"; + public static final String FILE_WITHOUT_IMPORT = """ + import React, { useState } from 'react'; + import Placeholder from '@cerner/terra-docs'; + const BreakpointExample = () => { + const [breakpoint, setBreakpoint] = useState(''); + return ( + setBreakpoint(value)}> + + + ); + }; + export default BreakpointExample;"""; - public static final String FILE_WITHOUT_IMPORT_FROM_CLAUSE = "import React, { useState } from 'react';\n" + - "import Placeholder from '@cerner/terra-docs';\n" + - "import ResponsiveElement;\n" + - "const BreakpointExample = () => {\n" + - " const [breakpoint, setBreakpoint] = useState('');\n" + - " return (\n" + - " setBreakpoint(value)}>\n" + - " \n" + - " \n" + - " );\n" + - "};\n" + - "export default BreakpointExample;"; + public static final String FILE_WITHOUT_IMPORT_FROM_CLAUSE = """ + import React, { useState } from 'react'; + import Placeholder from '@cerner/terra-docs'; + import ResponsiveElement; + const BreakpointExample = () => { + const [breakpoint, setBreakpoint] = useState(''); + return ( + setBreakpoint(value)}> + + + ); + }; + export default BreakpointExample;"""; /** * Creates a {@link PsiFile} object from the argument file content. diff --git a/src/test/java/com/picimako/terra/documentation/DocumentationComponentsTest.java b/src/test/java/com/picimako/terra/documentation/DocumentationComponentsTest.java index dd06ab6..699f770 100644 --- a/src/test/java/com/picimako/terra/documentation/DocumentationComponentsTest.java +++ b/src/test/java/com/picimako/terra/documentation/DocumentationComponentsTest.java @@ -15,43 +15,44 @@ */ public class DocumentationComponentsTest { - private static final String DOCUMENTATION = "{\n" + - " \"components\": [\n" + - " {\n" + - " \"componentName\": \"ActionFooter\",\n" + - " \"properties\": [\n" + - " {\n" + - " \"importPath\": \"terra-action-footer\",\n" + - " \"relativeUrl\": \"/terra-action-footer/action-footer/standard\"\n" + - " }\n" + - " ]\n" + - " },\n" + - " {\n" + - " \"componentName\": \"ActionHeader\",\n" + - " \"properties\": [\n" + - " {\n" + - " \"importPath\": \"terra-action-header\",\n" + - " \"relativeUrl\": \"/terra-action-header/action-header/action-header\"\n" + - " }\n" + - " ]\n" + - " },\n" + - " {\n" + - " \"componentName\": \"Item\",\n" + - " \"properties\": [\n" + - " {\n" + - " \"family\": \"Dropdown Button\",\n" + - " \"importPath\": \"terra-dropdown-button\",\n" + - " \"relativeUrl\": \"/terra-dropdown-button/dropdown-button/dropdown-button\"\n" + - " },\n" + - " {\n" + - " \"family\": \"List\",\n" + - " \"importPath\": \"terra-list/lib/index\",\n" + - " \"relativeUrl\": \"/terra-list/list/list-item\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}"; + private static final String DOCUMENTATION = """ + { + "components": [ + { + "componentName": "ActionFooter", + "properties": [ + { + "importPath": "terra-action-footer", + "relativeUrl": "/terra-action-footer/action-footer/standard" + } + ] + }, + { + "componentName": "ActionHeader", + "properties": [ + { + "importPath": "terra-action-header", + "relativeUrl": "/terra-action-header/action-header/action-header" + } + ] + }, + { + "componentName": "Item", + "properties": [ + { + "family": "Dropdown Button", + "importPath": "terra-dropdown-button", + "relativeUrl": "/terra-dropdown-button/dropdown-button/dropdown-button" + }, + { + "family": "List", + "importPath": "terra-list/lib/index", + "relativeUrl": "/terra-list/list/list-item" + } + ] + } + ] + }"""; private static final DocumentationComponents COMPONENTS = new Gson().fromJson(DOCUMENTATION, DocumentationComponents.class); @Test diff --git a/src/test/java/com/picimako/terra/documentation/TerraDescribeViewportsDocumentationProviderTest.java b/src/test/java/com/picimako/terra/documentation/TerraDescribeViewportsDocumentationProviderTest.java index 734f734..8ba1da2 100644 --- a/src/test/java/com/picimako/terra/documentation/TerraDescribeViewportsDocumentationProviderTest.java +++ b/src/test/java/com/picimako/terra/documentation/TerraDescribeViewportsDocumentationProviderTest.java @@ -85,11 +85,12 @@ public void testShouldReturnNullWhenInputElementIsLiteralButNotStringInDescribeT public void testShouldReturnNullWhenTheStringLiteralIsNotInTerraDescribeViewportsOrDescribeTests() { myFixture.configureByText("WdioDocumentation-spec.js", - "Terra.describeViewports('viewports', ['huge'], () => {\n" + - " describe('terra screenshot', () => {\n" + - " Terra.validates.element('collect');\n" + - " });" + - "});"); + """ + Terra.describeViewports('viewports', ['huge'], () => { + describe('terra screenshot', () => { + Terra.validates.element('collect'); + });\ + });"""); PsiElement element = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent(); diff --git a/src/test/java/com/picimako/terra/documentation/TerraUIComponentDocumentationUrlProviderTest.java b/src/test/java/com/picimako/terra/documentation/TerraUIComponentDocumentationUrlProviderTest.java index 07cabdc..71aa13b 100644 --- a/src/test/java/com/picimako/terra/documentation/TerraUIComponentDocumentationUrlProviderTest.java +++ b/src/test/java/com/picimako/terra/documentation/TerraUIComponentDocumentationUrlProviderTest.java @@ -26,19 +26,20 @@ */ public class TerraUIComponentDocumentationUrlProviderTest extends BasePlatformTestCase { - private static final String DOCUMENTATION = "{\n" + - " \"components\": [\n" + - " {\n" + - " \"componentName\": \"ResponsiveElement\",\n" + - " \"properties\": [\n" + - " {\n" + - " \"importPath\": \"terra-responsive-element\",\n" + - " \"relativeUrl\": \"/terra-responsive-element/responsive-element/responsive-element\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}"; + private static final String DOCUMENTATION = """ + { + "components": [ + { + "componentName": "ResponsiveElement", + "properties": [ + { + "importPath": "terra-responsive-element", + "relativeUrl": "/terra-responsive-element/responsive-element/responsive-element" + } + ] + } + ] + }"""; private static final String DOCUMENTATION_HTML = "C:\\projects\\plugindev\\somefilename.js" + "
" + diff --git a/src/test/java/com/picimako/terra/psi/js/JSArgumentUtilPropertyTest.java b/src/test/java/com/picimako/terra/psi/js/JSArgumentUtilPropertyTest.java index f9491c9..079ee53 100644 --- a/src/test/java/com/picimako/terra/psi/js/JSArgumentUtilPropertyTest.java +++ b/src/test/java/com/picimako/terra/psi/js/JSArgumentUtilPropertyTest.java @@ -16,11 +16,12 @@ public class JSArgumentUtilPropertyTest extends BasePlatformTestCase { public void testNoValueReturnedForNonLiteralExpression() { myFixture.configureByText("Terra-spec.js", - "describe('Terra screenshot', () => {\n" + - " it('Test case', () => {\n" + - " Terra.validates.screenshot('test id', { selector: { } });\n" + - " });\n" + - "});"); + """ + describe('Terra screenshot', () => { + it('Test case', () => { + Terra.validates.screenshot('test id', { selector: { } }); + }); + });"""); JSProperty property = (JSProperty) myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent(); assertThat(JSArgumentUtil.getNumericValueOf(property)).isNull(); @@ -28,11 +29,12 @@ public void testNoValueReturnedForNonLiteralExpression() { public void testNoValueReturnedForNonNumericLiteral() { myFixture.configureByText("Terra-spec.js", - "describe('Terra screenshot', () => {\n" + - " it('Test case', () => {\n" + - " Terra.validates.screenshot('test id', { selector: \"#selector\" });\n" + - " });\n" + - "});"); + """ + describe('Terra screenshot', () => { + it('Test case', () => { + Terra.validates.screenshot('test id', { selector: "#selector" }); + }); + });"""); JSProperty property = (JSProperty) myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent(); assertThat(JSArgumentUtil.getNumericValueOf(property)).isNull(); @@ -40,11 +42,12 @@ public void testNoValueReturnedForNonNumericLiteral() { public void testValueReturnedForNumericLiteral() { myFixture.configureByText("Terra-spec.js", - "describe('Terra screenshot', () => {\n" + - " it('Test case', () => {\n" + - " Terra.validates.screenshot('test id', { mismatchTolerance: 0.5 });\n" + - " });\n" + - "});"); + """ + describe('Terra screenshot', () => { + it('Test case', () => { + Terra.validates.screenshot('test id', { mismatchTolerance: 0.5 }); + }); + });"""); JSProperty property = (JSProperty) myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent(); assertThat(JSArgumentUtil.getNumericValueOf(property)).isEqualTo(0.5); diff --git a/src/test/java/com/picimako/terra/wdio/TerraWdioFoldersTest.java b/src/test/java/com/picimako/terra/wdio/TerraWdioFoldersTest.java index fdcf6b6..aef5b3a 100644 --- a/src/test/java/com/picimako/terra/wdio/TerraWdioFoldersTest.java +++ b/src/test/java/com/picimako/terra/wdio/TerraWdioFoldersTest.java @@ -95,7 +95,7 @@ public void testGetDiffImageForLatestImage() { myFixture.copyFileToProject("tests/wdio/__snapshots__/diff/en/chrome_huge/some-spec/testimage[default].png"); VirtualFile wdioRoot = TerraWdioFolders.projectWdioRoot(getProject()); TerraWdioFolders.setWdioTestRootPath(wdioRoot.getPath()); - VirtualFile latest = FilenameIndex.getVirtualFilesByName(getProject(), "testimage[default].png", GlobalSearchScope.projectScope(getProject())) + VirtualFile latest = FilenameIndex.getVirtualFilesByName("testimage[default].png", GlobalSearchScope.projectScope(getProject())) .stream() .filter(image -> image.getPath().endsWith("latest/en/chrome_huge/some-spec/testimage[default].png")) .findFirst() @@ -113,7 +113,7 @@ public void testGetLatestImageForReferenceImage() { myFixture.copyFileToProject("tests/wdio/__snapshots__/reference/en/chrome_huge/some-spec/testimage[default].png"); VirtualFile wdioRoot = TerraWdioFolders.projectWdioRoot(getProject()); TerraWdioFolders.setWdioTestRootPath(wdioRoot.getPath()); - VirtualFile latest = FilenameIndex.getVirtualFilesByName(getProject(), "testimage[default].png", GlobalSearchScope.projectScope(getProject())) + VirtualFile latest = FilenameIndex.getVirtualFilesByName("testimage[default].png", GlobalSearchScope.projectScope(getProject())) .stream() .filter(image -> image.getPath().endsWith("reference/en/chrome_huge/some-spec/testimage[default].png")) .findFirst() diff --git a/src/test/java/com/picimako/terra/wdio/TerraWdioPsiUtilScreenshotPropertyTest.java b/src/test/java/com/picimako/terra/wdio/TerraWdioPsiUtilScreenshotPropertyTest.java index 6dbf275..4ec60c8 100644 --- a/src/test/java/com/picimako/terra/wdio/TerraWdioPsiUtilScreenshotPropertyTest.java +++ b/src/test/java/com/picimako/terra/wdio/TerraWdioPsiUtilScreenshotPropertyTest.java @@ -21,31 +21,36 @@ public class TerraWdioPsiUtilScreenshotPropertyTest extends BasePlatformTestCase public void testPropertyRetrieval() { Object[][] testCases = new Object[][]{ - {"describe('Terra screenshot', () => {\n" + - " it('Test case', () => {\n" + - " Terra.validates.screenshot('test id');\n" + - " });\n" + - "});", null, null}, - {"describe('Terra screenshot', () => {\n" + - " it('Test case', () => {\n" + - " Terra.validates.screenshot('test id', { });\n" + - " });\n" + - "});", null, null}, - {"describe('Terra screenshot', () => {\n" + - " it('Test case', () => {\n" + - " Terra.validates.screenshot('test id', { selector: '#selector' });\n" + - " });\n" + - "});", "#selector", null}, - {"describe('Terra screenshot', () => {\n" + - " it('Test case', () => {\n" + - " Terra.validates.screenshot('test id', { mismatchTolerance: 0.5 });\n" + - " });\n" + - "});", null, 0.5}, - {"describe('Terra screenshot', () => {\n" + - " it('Test case', () => {\n" + - " Terra.validates.screenshot('test id', { selector: '#selector', mismatchTolerance: 0.5 });\n" + - " });\n" + - "});", "#selector", 0.5} + {""" +describe('Terra screenshot', () => { + it('Test case', () => { + Terra.validates.screenshot('test id'); + }); +});""", null, null}, + {""" +describe('Terra screenshot', () => { + it('Test case', () => { + Terra.validates.screenshot('test id', { }); + }); +});""", null, null}, + {""" +describe('Terra screenshot', () => { + it('Test case', () => { + Terra.validates.screenshot('test id', { selector: '#selector' }); + }); +});""", "#selector", null}, + {""" +describe('Terra screenshot', () => { + it('Test case', () => { + Terra.validates.screenshot('test id', { mismatchTolerance: 0.5 }); + }); +});""", null, 0.5}, + {""" +describe('Terra screenshot', () => { + it('Test case', () => { + Terra.validates.screenshot('test id', { selector: '#selector', mismatchTolerance: 0.5 }); + }); +});""", "#selector", 0.5} }; for (int i = 0; i < testCases.length; i++) { @@ -72,11 +77,12 @@ public void testPropertyRetrieval() { public void testRetrievesTerraValidationProperties() { - myFixture.configureByText("Terra-spec.js", "describe('Terra screenshot', () => {\n" + - " it('Test case', () => {\n" + - " Terra.validates.screenshot('test id', { selector: '#selector', mismatchTolerance: 0.5 });\n" + - " });\n" + - "});"); + myFixture.configureByText("Terra-spec.js", """ + describe('Terra screenshot', () => { + it('Test case', () => { + Terra.validates.screenshot('test id', { selector: '#selector', mismatchTolerance: 0.5 }); + }); + });"""); JSExpressionStatement element = PsiTreeUtil.getParentOfType(myFixture.getFile().findElementAt(myFixture.getCaretOffset()), JSExpressionStatement.class); @@ -84,11 +90,12 @@ public void testRetrievesTerraValidationProperties() { } public void testNoTerraValidationProperties() { - myFixture.configureByText("Terra-spec.js", "describe('Terra screenshot', () => {\n" + - " it('Test case', () => {\n" + - " Terra.validates.screenshot('test id');\n" + - " });\n" + - "});"); + myFixture.configureByText("Terra-spec.js", """ + describe('Terra screenshot', () => { + it('Test case', () => { + Terra.validates.screenshot('test id'); + }); + });"""); JSExpressionStatement element = PsiTreeUtil.getParentOfType(myFixture.getFile().findElementAt(myFixture.getCaretOffset()), JSExpressionStatement.class); diff --git a/src/test/java/com/picimako/terra/wdio/TerraWdioPsiUtilTest.java b/src/test/java/com/picimako/terra/wdio/TerraWdioPsiUtilTest.java index eaa0452..66fb874 100644 --- a/src/test/java/com/picimako/terra/wdio/TerraWdioPsiUtilTest.java +++ b/src/test/java/com/picimako/terra/wdio/TerraWdioPsiUtilTest.java @@ -77,11 +77,12 @@ public void testShouldNotBeATerraWdioFunctionIfThereIsNoParent() { public void testShouldHaveText() { myFixture.configureByText("WdioDocumentation-spec.js", - "Terra.describeViewports('viewports', ['huge'], () => {\n" + - " describe('terra screenshot', () => {\n" + - " Terra.validates.element('collect');\n" + - " });" + - "});"); + """ + Terra.describeViewports('viewports', ['huge'], () => { + describe('terra screenshot', () => { + Terra.validates.element('collect'); + });\ + });"""); PsiElement element = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent().getParent().getParent(); @@ -90,11 +91,12 @@ public void testShouldHaveText() { public void testShouldNotHaveTextWhenThereNoDesiredTextIsMatched() { myFixture.configureByText("WdioDocumentation-spec.js", - "Terra.describeViewports('viewports', ['huge'], () => {\n" + - " describe('terra screenshot', () => {\n" + - " browser.pause(2000);\n" + - " });" + - "});"); + """ + Terra.describeViewports('viewports', ['huge'], () => { + describe('terra screenshot', () => { + browser.pause(2000); + });\ + });"""); PsiElement element = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent().getParent().getParent(); diff --git a/src/test/java/com/picimako/terra/wdio/projectview/action/NavigateToScreenshotUsageProjectViewActionTest.java b/src/test/java/com/picimako/terra/wdio/projectview/action/NavigateToScreenshotUsageProjectViewActionTest.java index 24c4706..b968f6c 100644 --- a/src/test/java/com/picimako/terra/wdio/projectview/action/NavigateToScreenshotUsageProjectViewActionTest.java +++ b/src/test/java/com/picimako/terra/wdio/projectview/action/NavigateToScreenshotUsageProjectViewActionTest.java @@ -6,6 +6,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.psi.PsiFile; @@ -61,7 +62,7 @@ public void testNoNavigationHappensForNoSelectedScreenshot() { PsiFile specFile = myFixture.configureByFile("tests/wdio/NavigateToScreenshotUsage-spec.js"); NavigateToScreenshotUsageProjectViewAction action = new NavigateToScreenshotUsageProjectViewAction(); - action.actionPerformed(new TestActionEvent(dataId -> CommonDataKeys.PROJECT.is(dataId) ? getProject() : null)); + action.actionPerformed(TestActionEvent.createTestEvent(dataId -> CommonDataKeys.PROJECT.is(dataId) ? getProject() : null)); assertThat(FileEditorManager.getInstance(getProject()).isFileOpen(specFile.getVirtualFile())).isTrue(); assertThat(myFixture.getCaretOffset()).isZero(); @@ -78,14 +79,10 @@ public void testShowNoSpecFileToNavigateToDialog() { .withMessage("There is no spec file available to navigate to. It may have been removed."); } - private TestActionEvent doTestActionEvent(PsiFile screenshot) { - return new TestActionEvent(dataId -> { - if (CommonDataKeys.PSI_FILE.is(dataId)) { - return screenshot; - } - if (CommonDataKeys.PROJECT.is(dataId)) { - return getProject(); - } + private AnActionEvent doTestActionEvent(PsiFile screenshot) { + return TestActionEvent.createTestEvent(dataId -> { + if (CommonDataKeys.PSI_FILE.is(dataId)) return screenshot; + if (CommonDataKeys.PROJECT.is(dataId)) return getProject(); return null; }); } diff --git a/src/test/java/com/picimako/terra/wdio/screenshot/TerraScreenshotCollectorTest.java b/src/test/java/com/picimako/terra/wdio/screenshot/TerraScreenshotCollectorTest.java index c0122d5..7cae0a6 100644 --- a/src/test/java/com/picimako/terra/wdio/screenshot/TerraScreenshotCollectorTest.java +++ b/src/test/java/com/picimako/terra/wdio/screenshot/TerraScreenshotCollectorTest.java @@ -69,11 +69,12 @@ public void testReturnsNoScreenshotForNullSourceElement() { public void testReturnsNoScreenshotForEmptyScreenshotName() { myFixture.copyFileToProject("package.json"); myFixture.configureByText("Collect-spec.js", - "describe('terra screenshot', () => {\n" + - " it('Test case', () => {\n" + - " Terra.validates.screenshot('', { selector: '#selector' });\n" + - " });\n" + - "});"); + """ + describe('terra screenshot', () => { + it('Test case', () => { + Terra.validates.screenshot('', { selector: '#selector' }); + }); + });"""); JSLiteralExpression element = (JSLiteralExpression) myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent(); diff --git a/src/test/java/com/picimako/terra/wdio/screenshot/TerraToolkitScreenshotNameResolverTest.java b/src/test/java/com/picimako/terra/wdio/screenshot/TerraToolkitScreenshotNameResolverTest.java index 150723d..7b8e754 100644 --- a/src/test/java/com/picimako/terra/wdio/screenshot/TerraToolkitScreenshotNameResolverTest.java +++ b/src/test/java/com/picimako/terra/wdio/screenshot/TerraToolkitScreenshotNameResolverTest.java @@ -18,29 +18,32 @@ public class TerraToolkitScreenshotNameResolverTest extends BasePlatformTestCase public void testResolveName() { JSLiteralExpression element = configureFileForJSLiteralExpression( - "describe('outer describe', () => {\n" + - " describe('terra screenshot', () => {\n" + - " Terra.it.matchesScreenshot('with name', { selector: '#selector' });\n" + - " });\n" + - "});"); + """ + describe('outer describe', () => { + describe('terra screenshot', () => { + Terra.it.matchesScreenshot('with name', { selector: '#selector' }); + }); + });"""); assertThat(new TerraToolkitScreenshotNameResolver().resolveName(element)).isEqualTo("terra_screenshot[with_name].png"); } public void testResolveNameToEmptyStringIfNoParentDescribeCall() { JSLiteralExpression element = configureFileForJSLiteralExpression( - "{\n" + - " Terra.it.matchesScreenshot('with name', { selector: '#selector' });\n" + - "}"); + """ + { + Terra.it.matchesScreenshot('with name', { selector: '#selector' }); + }"""); assertThat(new TerraToolkitScreenshotNameResolver().resolveName(element)).isEmpty(); } public void testResolveNameToEmptyStringIfParentDescribeCallHasNoNameParameter() { JSLiteralExpression element = configureFileForJSLiteralExpression( - "describe('outer describe', () => {\n" + - " describe(() => {\n" + - " Terra.it.matchesScreenshot('with name', { selector: '#selector' });\n" + - " });\n" + - "});"); + """ + describe('outer describe', () => { + describe(() => { + Terra.it.matchesScreenshot('with name', { selector: '#selector' }); + }); + });"""); assertThat(new TerraToolkitScreenshotNameResolver().resolveName(element)).isEmpty(); } @@ -48,41 +51,45 @@ public void testResolveNameToEmptyStringIfParentDescribeCallHasNoNameParameter() public void testDefaultScreenshotPartialNameWithTestId() { JSLiteralExpression element = configureFileForJSLiteralExpression( - "describe('outer describe', () => {\n" + - " describe('terra screenshot', () => {\n" + - " Terra.it.matchesScreenshot('with name [default]', { selector: '#selector' });\n" + - " });\n" + - "});"); + """ + describe('outer describe', () => { + describe('terra screenshot', () => { + Terra.it.matchesScreenshot('with name [default]', { selector: '#selector' }); + }); + });"""); assertThat(new TerraToolkitScreenshotNameResolver().resolveName(element)).isEqualTo("terra_screenshot[default].png"); } public void testResolvePartialNameWithTestId() { JSLiteralExpression element = configureFileForJSLiteralExpression( - "describe('outer describe', () => {\n" + - " describe('terra screenshot', () => {\n" + - " Terra.it.matchesScreenshot('with name [test id]', { selector: '#selector' });\n" + - " });\n" + - "});"); + """ + describe('outer describe', () => { + describe('terra screenshot', () => { + Terra.it.matchesScreenshot('with name [test id]', { selector: '#selector' }); + }); + });"""); assertThat(new TerraToolkitScreenshotNameResolver().resolveName(element)).isEqualTo("terra_screenshot[test_id].png"); } public void testResolvePartialNameWithMultipleTestIds() { JSLiteralExpression element = configureFileForJSLiteralExpression( - "describe('outer describe', () => {\n" + - " describe('terra screenshot', () => {\n" + - " Terra.it.matchesScreenshot('with [test id] and another [testid]', { selector: '#selector' });\n" + - " });\n" + - "});"); + """ + describe('outer describe', () => { + describe('terra screenshot', () => { + Terra.it.matchesScreenshot('with [test id] and another [testid]', { selector: '#selector' }); + }); + });"""); assertThat(new TerraToolkitScreenshotNameResolver().resolveName(element)).isEqualTo("terra_screenshot[test_id]_and_another_[testid].png"); } public void testResolveFullNameWithNonMatchingPartialTestId() { JSLiteralExpression element = configureFileForJSLiteralExpression( - "describe('outer describe', () => {\n" + - " describe('terra screenshot', () => {\n" + - " Terra.it.matchesScreenshot('with name [tes)t id]', { selector: '#selector' });\n" + - " });\n" + - "});"); + """ + describe('outer describe', () => { + describe('terra screenshot', () => { + Terra.it.matchesScreenshot('with name [tes)t id]', { selector: '#selector' }); + }); + });"""); assertThat(new TerraToolkitScreenshotNameResolver().resolveName(element)).isEqualTo("terra_screenshot[with_name_[tes)t_id]].png"); } @@ -90,39 +97,44 @@ public void testResolveFullNameWithNonMatchingPartialTestId() { public void testResolveDefaultName() { JSExpression element = configureFileForJSExpression( - "describe('outer describe', () => {\n" + - " describe('terra screenshot', () => {\n" + - " Terra.it.matchesScreenshot({ selector: '#selector' });\n" + - " });\n" + - "});"); + """ + describe('outer describe', () => { + describe('terra screenshot', () => { + Terra.it.matchesScreenshot({ selector: '#selector' }); + }); + });"""); assertThat(new TerraToolkitScreenshotNameResolver().resolveDefaultName(element)).isEqualTo("terra_screenshot[default].png"); } public void testResolveDefaultNameForNonDefaultValidation() { JSExpression element = configureFileForJSExpression( - "describe('outer describe', () => {\n" + - " describe('terra screenshot', () => {\n" + - " Terra.it.matchesScreenshot('default', { selector: '#selector' });\n" + - " });\n" + - "});"); + """ + describe('outer describe', () => { + describe('terra screenshot', () => { + Terra.it.matchesScreenshot('default', { selector: '#selector' }); + }); + });"""); assertThat(new TerraToolkitScreenshotNameResolver().resolveDefaultName(element)).isEqualTo("terra_screenshot[default].png"); } public void testResolveDefaultNameToEmptyStringIfNoParentDescribeCall() { JSExpression element = configureFileForJSExpression( - "{\n" + - " Terra.it.matchesScreenshot({ selector: '#selector' });\n" + - "}\n"); + """ + { + Terra.it.matchesScreenshot({ selector: '#selector' }); + } + """); assertThat(new TerraToolkitScreenshotNameResolver().resolveDefaultName(element)).isEmpty(); } public void testResolveDefaultNameToEmptyStringIfParentDescribeCallHasNoNameParameter() { JSExpression element = configureFileForJSExpression( - "describe('outer describe', () => {\n" + - " describe(() => {\n" + - " Terra.it.matchesScreenshot({ selector: '#selector' });\n" + - " });\n" + - "});"); + """ + describe('outer describe', () => { + describe(() => { + Terra.it.matchesScreenshot({ selector: '#selector' }); + }); + });"""); assertThat(new TerraToolkitScreenshotNameResolver().resolveDefaultName(element)).isEmpty(); } @@ -130,21 +142,23 @@ public void testResolveDefaultNameToEmptyStringIfParentDescribeCallHasNoNamePara public void testResolveByLiteralNoFallback() { JSLiteralExpression element = configureFileForJSLiteralExpression( - "describe('outer describe', () => {\n" + - " describe('terra screenshot', () => {\n" + - " Terra.it.matchesScreenshot('with name', { selector: '#selector' });\n" + - " });\n" + - "});"); + """ + describe('outer describe', () => { + describe('terra screenshot', () => { + Terra.it.matchesScreenshot('with name', { selector: '#selector' }); + }); + });"""); assertThat(new TerraToolkitScreenshotNameResolver().resolveWithFallback(element, null)).isEqualTo("terra_screenshot[with_name].png"); } public void testResolveByMethodExpressionFallback() { JSExpression element = configureFileForJSExpression( - "describe('outer describe', () => {\n" + - " describe('terra screenshot', () => {\n" + - " Terra.it.matchesScreenshot({ selector: '#selector' });\n" + - " });\n" + - "});"); + """ + describe('outer describe', () => { + describe('terra screenshot', () => { + Terra.it.matchesScreenshot({ selector: '#selector' }); + }); + });"""); assertThat(new TerraToolkitScreenshotNameResolver().resolveWithFallback(null, element)).isEqualTo("terra_screenshot[default].png"); } diff --git a/src/test/java/com/picimako/terra/wdio/toolwindow/FindUnusedScreenshotsActionTest.java b/src/test/java/com/picimako/terra/wdio/toolwindow/FindUnusedScreenshotsActionTest.java index 9657613..c1ed0ae 100644 --- a/src/test/java/com/picimako/terra/wdio/toolwindow/FindUnusedScreenshotsActionTest.java +++ b/src/test/java/com/picimako/terra/wdio/toolwindow/FindUnusedScreenshotsActionTest.java @@ -43,7 +43,7 @@ public void testMarksScreenshotsUnused() { TreeSpecNode relatedFindUnusedScreenshotSpec = ((TreeModelDataRoot) treeModel.getRoot()).getSpecs().get(0); assertThat(relatedFindUnusedScreenshotSpec.getScreenshots().stream().noneMatch(TreeScreenshotNode::isUnused)).isTrue(); - action.actionPerformed(new TestActionEvent()); + action.actionPerformed(TestActionEvent.createTestEvent()); assertThat(relatedFindUnusedScreenshotSpec.findScreenshotNodeByName("used[default].png").get().isUnused()).isFalse(); assertThat(relatedFindUnusedScreenshotSpec.findScreenshotNodeByName("unused[default].png").get().isUnused()).isTrue(); @@ -67,7 +67,7 @@ public void testUnrelatedIsUnused() { TreeSpecNode nonRelatedSomeSpec = ((TreeModelDataRoot) treeModel.getRoot()).getSpecs().get(0); assertThat(nonRelatedSomeSpec.getScreenshots().stream().noneMatch(TreeScreenshotNode::isUnused)).isTrue(); - action.actionPerformed(new TestActionEvent()); + action.actionPerformed(TestActionEvent.createTestEvent()); //This is marked as unused because there is no spec file present that references this image //Although FindUnusedScreenshot-spec has a validation for terra_screenshot[collect].png, it doesn't have an image for this spec diff --git a/src/test/java/com/picimako/terra/wdio/toolwindow/action/NavigateToScreenshotUsageActionTest.java b/src/test/java/com/picimako/terra/wdio/toolwindow/action/NavigateToScreenshotUsageActionTest.java index d2f0d02..75013a5 100644 --- a/src/test/java/com/picimako/terra/wdio/toolwindow/action/NavigateToScreenshotUsageActionTest.java +++ b/src/test/java/com/picimako/terra/wdio/toolwindow/action/NavigateToScreenshotUsageActionTest.java @@ -8,6 +8,7 @@ import javax.swing.tree.TreePath; +import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.fileEditor.FileEditorManager; @@ -76,17 +77,11 @@ public void testShowNoSpecFileToNavigateToDialog() { .withMessage("There is no spec file available to navigate to. It may have been removed."); } - private TestActionEvent doTestActionEvent(PsiFile screenshot) { - return new TestActionEvent(dataId -> { - if (CommonDataKeys.PSI_FILE.is(dataId)) { - return screenshot; - } - if (CommonDataKeys.PROJECT.is(dataId)) { - return getProject(); - } - if (PlatformDataKeys.CONTEXT_COMPONENT.is(dataId)) { - return wdioTree(); - } + private AnActionEvent doTestActionEvent(PsiFile screenshot) { + return TestActionEvent.createTestEvent(dataId -> { + if (CommonDataKeys.PSI_FILE.is(dataId)) return screenshot; + if (CommonDataKeys.PROJECT.is(dataId)) return getProject(); + if (PlatformDataKeys.CONTEXT_COMPONENT.is(dataId)) return wdioTree(); return null; }); } diff --git a/src/test/java/com/picimako/terra/wdio/viewports/inspection/DuplicateTerraDescribeViewportsInspectionTest.java b/src/test/java/com/picimako/terra/wdio/viewports/inspection/DuplicateTerraDescribeViewportsInspectionTest.java index 81305c9..4cd5c1b 100644 --- a/src/test/java/com/picimako/terra/wdio/viewports/inspection/DuplicateTerraDescribeViewportsInspectionTest.java +++ b/src/test/java/com/picimako/terra/wdio/viewports/inspection/DuplicateTerraDescribeViewportsInspectionTest.java @@ -34,13 +34,14 @@ public void testDuplicateTerraViewports() { public void testDuplicateViewportsInDescribeTests() { doWdioSpecTestByText( - "Terra.describeTests('Name', { formFactors: ['small','huge','tiny','huge'] }, () => {\n" + - "});\n" + - "\n" + - "Terra.describeTests('Another name', { formFactors: ['small','small','huge','tiny'] }, () => {\n" + - "});\n" + - "\n" + - "Terra.describeTests('Another name', { formFactors: ['small','huge','tiny'] }, () => {\n" + - "});"); + """ + Terra.describeTests('Name', { formFactors: ['small','huge','tiny','huge'] }, () => { + }); + + Terra.describeTests('Another name', { formFactors: ['small','small','huge','tiny'] }, () => { + }); + + Terra.describeTests('Another name', { formFactors: ['small','huge','tiny'] }, () => { + });"""); } } diff --git a/src/test/java/com/picimako/terra/wdio/viewports/inspection/NoActualTerraViewportsInspectionTest.java b/src/test/java/com/picimako/terra/wdio/viewports/inspection/NoActualTerraViewportsInspectionTest.java index 6a9c0f6..3fe4397 100644 --- a/src/test/java/com/picimako/terra/wdio/viewports/inspection/NoActualTerraViewportsInspectionTest.java +++ b/src/test/java/com/picimako/terra/wdio/viewports/inspection/NoActualTerraViewportsInspectionTest.java @@ -34,16 +34,17 @@ public void testNoActualTerraViewportDefined() { public void testNoActualTerraViewportDefinedInDescribeTests() { doWdioSpecTestByText( - "Terra.describeTests('Name', { formFactors: [''] }, () => {\n" + - "});\n" + - "\n" + - "Terra.describeTests('Another name', { formFactors: ['', ''] }, () => {\n" + - "});\n" + - "\n" + - "Terra.describeTests('Another name', { formFactors: [] }, () => {\n" + - "});\n" + - "\n" + - "Terra.describeTests('Another name', { formFactors: ['huge'] }, () => {\n" + - "});"); + """ + Terra.describeTests('Name', { formFactors: [''] }, () => { + }); + + Terra.describeTests('Another name', { formFactors: ['', ''] }, () => { + }); + + Terra.describeTests('Another name', { formFactors: [] }, () => { + }); + + Terra.describeTests('Another name', { formFactors: ['huge'] }, () => { + });"""); } } diff --git a/src/test/java/com/picimako/terra/wdio/viewports/inspection/NonArrayTypeViewportsInspectionTest.java b/src/test/java/com/picimako/terra/wdio/viewports/inspection/NonArrayTypeViewportsInspectionTest.java index 3f59114..1b75dcf 100644 --- a/src/test/java/com/picimako/terra/wdio/viewports/inspection/NonArrayTypeViewportsInspectionTest.java +++ b/src/test/java/com/picimako/terra/wdio/viewports/inspection/NonArrayTypeViewportsInspectionTest.java @@ -34,19 +34,20 @@ public void testNonArrayTypeViewports() { public void testNonArrayTypeViewportsInDescribeTests() { doWdioSpecTestByText( - "Terra.describeTests('Name', { formFactors: 'asd' }, () => {\n" + - "});\n" + - "\n" + - "Terra.describeTests('Another name', { formFactors: { } }, () => {\n" + - "});\n" + - "\n" + - "Terra.describeTests('Another name', { formFactors: true }, () => {\n" + - "});\n" + - "\n" + - "Terra.describeTests('Another name', { formFactors: 45 }, () => {\n" + - "});\n" + - "\n" + - "Terra.describeTests('Another name', { formFactors: ['huge'] }, () => {\n" + - "});"); + """ + Terra.describeTests('Name', { formFactors: 'asd' }, () => { + }); + + Terra.describeTests('Another name', { formFactors: { } }, () => { + }); + + Terra.describeTests('Another name', { formFactors: true }, () => { + }); + + Terra.describeTests('Another name', { formFactors: 45 }, () => { + }); + + Terra.describeTests('Another name', { formFactors: ['huge'] }, () => { + });"""); } } diff --git a/src/test/java/com/picimako/terra/wdio/viewports/inspection/NotSupportedTerraDescribeViewportsInspectionTest.java b/src/test/java/com/picimako/terra/wdio/viewports/inspection/NotSupportedTerraDescribeViewportsInspectionTest.java index 4b39bdc..c98f09f 100644 --- a/src/test/java/com/picimako/terra/wdio/viewports/inspection/NotSupportedTerraDescribeViewportsInspectionTest.java +++ b/src/test/java/com/picimako/terra/wdio/viewports/inspection/NotSupportedTerraDescribeViewportsInspectionTest.java @@ -31,16 +31,17 @@ protected InspectionProfileEntry getInspection() { public void testNotSupportedTerraViewports() { doWdioSpecTest(); } - + public void testNotSupportedViewportsInDescribeTests() { doWdioSpecTestByText( - "Terra.describeTests('Name', { formFactors: ['','huge','tiny'] }, () => {\n" + - "});\n" + - "\n" + - "Terra.describeTests('Another name', { formFactors: ['small','gigantic','tiny'] }, () => {\n" + - "});\n" + - "\n" + - "Terra.describeTests('Another name', { formFactors: ['small','huge','tiny'] }, () => {\n" + - "});"); + """ + Terra.describeTests('Name', { formFactors: ['','huge','tiny'] }, () => { + }); + + Terra.describeTests('Another name', { formFactors: ['small','gigantic','tiny'] }, () => { + }); + + Terra.describeTests('Another name', { formFactors: ['small','huge','tiny'] }, () => { + });"""); } } diff --git a/src/test/java/com/picimako/terra/wdio/viewports/inspection/TerraViewportsNotInAscendingOrderInspectionTest.java b/src/test/java/com/picimako/terra/wdio/viewports/inspection/TerraViewportsNotInAscendingOrderInspectionTest.java index 36a6faa..e1f4c4e 100644 --- a/src/test/java/com/picimako/terra/wdio/viewports/inspection/TerraViewportsNotInAscendingOrderInspectionTest.java +++ b/src/test/java/com/picimako/terra/wdio/viewports/inspection/TerraViewportsNotInAscendingOrderInspectionTest.java @@ -34,16 +34,17 @@ public void testTerraViewportsNotInAscendingOrder() { public void testTerraViewportsNotInAscendingOrderInDescribeTests() { doWdioSpecTestByText( - "Terra.describeTests('Name', { formFactors: ['huge','enormous'] }, () => {\n" + - "});\n" + - "\n" + - "Terra.describeTests('Another name', { formFactors: ['small','medium','tiny'] }, () => {\n" + - "});\n" + - "\n" + - "Terra.describeTests('Another name', { formFactors: ['huge','small','tiny'] }, () => {\n" + - "});\n" + - "\n" + - "Terra.describeTests('Another name', { formFactors: ['huge'] }, () => {\n" + - "});"); + """ + Terra.describeTests('Name', { formFactors: ['huge','enormous'] }, () => { + }); + + Terra.describeTests('Another name', { formFactors: ['small','medium','tiny'] }, () => { + }); + + Terra.describeTests('Another name', { formFactors: ['huge','small','tiny'] }, () => { + }); + + Terra.describeTests('Another name', { formFactors: ['huge'] }, () => { + });"""); } }