diff --git a/src/main/kotlin/io/snyk/plugin/ui/toolwindow/SnykToolWindowSnykScanListenerLS.kt b/src/main/kotlin/io/snyk/plugin/ui/toolwindow/SnykToolWindowSnykScanListenerLS.kt index fc6abc2dd..ae02db22e 100644 --- a/src/main/kotlin/io/snyk/plugin/ui/toolwindow/SnykToolWindowSnykScanListenerLS.kt +++ b/src/main/kotlin/io/snyk/plugin/ui/toolwindow/SnykToolWindowSnykScanListenerLS.kt @@ -286,11 +286,12 @@ class SnykToolWindowSnykScanListenerLS( val issuesCount = issues.size val ignoredIssuesCount = issues.count { it.isIgnored() } if (issuesCount != 0) { - text = if (issuesCount == 1) { - "$issuesCount vulnerability found by Snyk" + val plural = if (issuesCount == 1) { + "y" } else { - "✋ $issuesCount vulnerabilities found by Snyk" + "ies" } + text = "✋ $issuesCount vulnerabilit$plural found by Snyk" if (pluginSettings().isGlobalIgnoresFeatureEnabled) { text += ", $ignoredIssuesCount ignored" } diff --git a/src/test/kotlin/io/snyk/plugin/extensions/SnykControllerImplTest.kt b/src/test/kotlin/io/snyk/plugin/extensions/SnykControllerImplTest.kt index 83c5e605b..2918772a7 100644 --- a/src/test/kotlin/io/snyk/plugin/extensions/SnykControllerImplTest.kt +++ b/src/test/kotlin/io/snyk/plugin/extensions/SnykControllerImplTest.kt @@ -53,8 +53,8 @@ class SnykControllerImplTest : LightPlatformTestCase() { val controller = SnykControllerImpl(project) controller.scan() - PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue() + PlatformTestUtil.dispatchAllEventsInIdeEventQueue() - verify { languageServerWrapper.sendScanCommand(project) } + verify (timeout = 5000){ languageServerWrapper.sendScanCommand(project) } } } diff --git a/src/test/kotlin/io/snyk/plugin/ui/BranchChooserComboBoxDialogTest.kt b/src/test/kotlin/io/snyk/plugin/ui/BranchChooserComboBoxDialogTest.kt index 17c14e897..c55631bb7 100644 --- a/src/test/kotlin/io/snyk/plugin/ui/BranchChooserComboBoxDialogTest.kt +++ b/src/test/kotlin/io/snyk/plugin/ui/BranchChooserComboBoxDialogTest.kt @@ -3,12 +3,15 @@ package io.snyk.plugin.ui import com.intellij.openapi.components.service import com.intellij.openapi.ui.ComboBox import com.intellij.openapi.util.io.toNioPathOrNull +import com.intellij.openapi.vfs.VirtualFileManager +import com.intellij.openapi.vfs.VirtualFileSystem import com.intellij.testFramework.LightPlatform4TestCase import com.intellij.testFramework.PlatformTestUtil import io.mockk.CapturingSlot import io.mockk.mockk import io.mockk.unmockkAll import io.mockk.verify +import io.snyk.plugin.toVirtualFile import okio.Path.Companion.toPath import org.eclipse.lsp4j.DidChangeConfigurationParams import org.eclipse.lsp4j.services.LanguageServer @@ -30,10 +33,10 @@ class BranchChooserComboBoxDialogTest : LightPlatform4TestCase() { unmockkAll() folderConfig = FolderConfig(project.basePath.toString(), "testBranch") service().addFolderConfig(folderConfig) - project.basePath?.let { service().addTrustedPath(it.toNioPathOrNull()!!) } val languageServerWrapper = LanguageServerWrapper.getInstance() languageServerWrapper.isInitialized = true languageServerWrapper.languageServer = lsMock + project.basePath?.let { service().addTrustedPath(it.toPath().parent!!.toNioPath()) } cut = BranchChooserComboBoxDialog(project) } diff --git a/src/test/kotlin/io/snyk/plugin/ui/toolwindow/SnykToolWindowSnykScanListenerLSTest.kt b/src/test/kotlin/io/snyk/plugin/ui/toolwindow/SnykToolWindowSnykScanListenerLSTest.kt index 0a876e8e6..967ddd64b 100644 --- a/src/test/kotlin/io/snyk/plugin/ui/toolwindow/SnykToolWindowSnykScanListenerLSTest.kt +++ b/src/test/kotlin/io/snyk/plugin/ui/toolwindow/SnykToolWindowSnykScanListenerLSTest.kt @@ -148,8 +148,8 @@ class SnykToolWindowSnykScanListenerLSTest : BasePlatformTestCase() { TestCase.assertEquals(rootTreeNode.children().toList()[1].toString(), " Code Security") TestCase.assertEquals(rootTreeNode.children().toList()[2].toString(), " Code Quality") TestCase.assertEquals( + "✋ 1 vulnerability found by Snyk, 0 ignored", rootTreeNode.children().toList()[4].toString(), - "1 vulnerability found by Snyk, 0 ignored", ) TestCase.assertEquals( rootTreeNode.children().toList()[5].toString(), @@ -188,12 +188,12 @@ class SnykToolWindowSnykScanListenerLSTest : BasePlatformTestCase() { TestCase.assertEquals(rootTreeNode.children().toList()[2].toString(), " Code Quality") TestCase.assertTrue(rootTreeNode.children().toList()[3].toString().contains("Click to choose base branch for")) TestCase.assertEquals( + "✋ 1 vulnerability found by Snyk, 0 ignored", rootTreeNode.children().toList()[4].toString(), - "1 vulnerability found by Snyk, 0 ignored", ) TestCase.assertEquals( - rootTreeNode.children().toList()[5].toString(), "⚡ 1 vulnerabilities can be fixed automatically", + rootTreeNode.children().toList()[5].toString(), ) } diff --git a/src/test/kotlin/snyk/container/ContainerBulkFileListenerTest.kt b/src/test/kotlin/snyk/container/ContainerBulkFileListenerTest.kt index 6c05e2797..0e2ec34a1 100644 --- a/src/test/kotlin/snyk/container/ContainerBulkFileListenerTest.kt +++ b/src/test/kotlin/snyk/container/ContainerBulkFileListenerTest.kt @@ -1,6 +1,9 @@ package snyk.container import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.application.WriteAction +import com.intellij.openapi.application.invokeAndWaitIfNeeded +import com.intellij.openapi.application.invokeLater import com.intellij.openapi.components.service import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.vfs.VirtualFile @@ -28,6 +31,7 @@ import java.io.File import java.nio.file.Files import java.nio.file.LinkOption import java.nio.file.Paths +import java.time.Duration import java.util.concurrent.TimeUnit import kotlin.io.path.notExists @@ -70,12 +74,14 @@ class ContainerBulkFileListenerTest : BasePlatformTestCase() { setUpContainerTest() val path = createNewFileInProjectRoot().toPath() Files.write(path, "\n".toByteArray(Charsets.UTF_8)) - VirtualFileManager.getInstance().syncRefresh() var virtualFile: VirtualFile? = null - await().atMost(2, TimeUnit.SECONDS).until { + invokeLater { + VirtualFileManager.getInstance().syncRefresh() virtualFile = VirtualFileManager.getInstance().findFileByNioPath(path) - virtualFile?.isValid ?: false } + PlatformTestUtil.dispatchAllEventsInIdeEventQueue() + await().timeout(5, TimeUnit.SECONDS).until { virtualFile?.isValid ?: false } + ApplicationManager.getApplication().runWriteAction { val file = PsiManager.getInstance(project).findFile(virtualFile!!)