-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Smoke test for Skate Plugin #468
Changes from 14 commits
a0ec785
52f6983
0613136
5687d4d
267ae32
c27e74d
36c089b
9cfcad8
512300b
a224cd2
ae4058a
d088b29
ed58373
2441899
fb23450
4b3b396
be80063
2a378fe
3acf967
129a0d0
349c7ca
9930a77
c81b6f4
e5bfa6e
404ba35
b134b07
d2d5fc8
602dcb4
c8dc4a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.slack.sgp.intellij | ||
|
||
import com.google.common.truth.Truth.assertThat | ||
import com.intellij.openapi.components.service | ||
import com.intellij.testFramework.fixtures.BasePlatformTestCase | ||
import org.junit.Test | ||
|
||
class SkatePluginInitializationTest : BasePlatformTestCase() { | ||
|
||
@Test | ||
fun `test Skate Plugin Service Initialization to ensure SkateProjectService is properly registered & initialized`() { | ||
val skateService = project.service<SkateProjectService>() | ||
|
||
// Service should be an instance of SkateProjectServiceImpl | ||
assertThat(skateService).isInstanceOf(SkateProjectServiceImpl::class.java) | ||
} | ||
|
||
@Test | ||
fun `test Skate Plugin Settings Initialization`() { | ||
val settings = project.service<SkatePluginSettings>() | ||
|
||
// Assert that settings is not null | ||
assertThat(settings).isNotNull() | ||
|
||
// Check the default values | ||
assertThat(settings.whatsNewFilePath).isEqualTo("CHANGELOG.md") | ||
assertThat(settings.isWhatsNewEnabled).isTrue() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import com.google.common.truth.Truth.assertThat | ||
import com.intellij.openapi.components.service | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.wm.ToolWindowAnchor | ||
import com.intellij.openapi.wm.ToolWindowManager | ||
import com.intellij.testFramework.fixtures.BasePlatformTestCase | ||
import com.intellij.util.ui.UIUtil | ||
import com.slack.sgp.intellij.SkatePluginSettings | ||
import com.slack.sgp.intellij.SkateProjectService | ||
import java.io.File | ||
import java.util.function.Supplier | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
class SkatePluginTest : BasePlatformTestCase() { | ||
|
||
@Before | ||
fun setUpToolWindow() { | ||
val toolWindowManager = ToolWindowManager.getInstance(project) | ||
toolWindowManager.registerToolWindow("skate-whats-new") { | ||
stripeTitle = Supplier { "What's New in Slack!" } | ||
anchor = ToolWindowAnchor.RIGHT | ||
} | ||
} | ||
|
||
@Test | ||
fun `test opening project shows changelog panel`() { | ||
val project = myFixture.project | ||
|
||
val changelogFile = createChangelogFile(project) | ||
|
||
val settings = project.service<SkatePluginSettings>() | ||
|
||
// set default skate config settings | ||
settings.isWhatsNewEnabled = true | ||
settings.whatsNewFilePath = changelogFile.absolutePath | ||
|
||
val skateService = project.service<SkateProjectService>() | ||
skateService.showWhatsNewWindow() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The plugin should do thus automatically when we open the project, right? Otherwise our test is implementing what we're trying to test |
||
|
||
// account for async functions? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this referencing? |
||
UIUtil.dispatchAllInvocationEvents() | ||
|
||
// test that the panel is opened. | ||
val toolWindowManager = ToolWindowManager.getInstance(project) | ||
val toolWindow = toolWindowManager.getToolWindow("skate-whats-new") | ||
assertThat(toolWindow).isNotNull() | ||
if (toolWindow != null) { | ||
assertThat(toolWindow.isVisible).isTrue() | ||
} | ||
|
||
val contentManager = toolWindow?.contentManager | ||
val content = contentManager?.getContent(0) | ||
assertThat(content).isNotNull() | ||
if (content != null) { | ||
assertThat(changelogFile.name).isEqualTo(content.displayName) | ||
} | ||
} | ||
|
||
private fun createChangelogFile(project: Project): File { | ||
val changelogFile = File(project.basePath!!, "changelog.md") | ||
changelogFile.writeText("# Changelog Sample") | ||
return changelogFile | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this test run without
@Test
on it?