[mod-commands] ModOpenUrl command

GitOrigin-RevId: 164a69f1d570e08a8e7af108c24e6c3f312f405e
This commit is contained in:
Tagir Valeev
2024-06-27 13:12:46 +02:00
committed by intellij-monorepo-bot
parent 86e193d79f
commit edec77df83
7 changed files with 58 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ package com.intellij.modcommand;
import com.intellij.codeInsight.intention.preview.IntentionPreviewInfo;
import com.intellij.openapi.fileTypes.UserBinaryFileType;
import com.intellij.openapi.util.text.HtmlChunk;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
@@ -25,4 +26,15 @@ public final class ModCommandTest extends LightPlatformCodeInsightTestCase {
assertNotNull(child);
assertOrderedEquals(content, child.contentsToByteArray());
}
public void testBrowse() {
configureFromFileText("dummy.txt", "");
ActionContext context = ActionContext.from(null, getFile());
ModCommand command = ModCommand.openUrl("https://example.com");
ModCommandExecutor executor = ModCommandExecutor.getInstance();
IntentionPreviewInfo preview = executor.getPreview(command, context);
assertEquals(new IntentionPreviewInfo.Html(HtmlChunk.text("Browse \"https://example.com\"")), preview);
ModCommandExecutor.BatchExecutionResult result = executor.executeInBatch(context, command);
assertEquals(ModCommandExecutor.Result.INTERACTIVE, result);
}
}