Skip to content
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

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a0ec785
Initial copy paste of SqlDelightErrorHandler
Jul 14, 2023
52f6983
Added libs.bugsnag to the build.gradle.kts and added sdk as a dependency
Jul 14, 2023
0613136
Documentation added
Jul 14, 2023
5687d4d
Change order of dependency implementations
Jul 14, 2023
267ae32
Adjust names to be Skate
Jul 14, 2023
c27e74d
Remove unnecessary space with plugin.xml
Jul 14, 2023
36c089b
Restore copyright header
Jul 14, 2023
9cfcad8
Running spotlessApply
Jul 14, 2023
512300b
Added link to original source
Jul 17, 2023
a224cd2
Initial addition of tool Window test
Jul 17, 2023
ae4058a
Skate plugin initialization test
Jul 17, 2023
d088b29
merge conflicts
Jul 17, 2023
ed58373
Add initialization for skate config settings
Jul 18, 2023
2441899
write test that writes a sample changelog file to the project, write …
Jul 18, 2023
fb23450
Remove todos and fix configuration settings
Jul 18, 2023
4b3b396
reset skate plugin test
Jul 18, 2023
be80063
integrating remote robot and creating an instance
Jul 18, 2023
2a378fe
Add comments and account for tool Window
Jul 19, 2023
3acf967
Merge branch 'main' of github.com:slackhq/slack-gradle-plugin into kl…
Jul 19, 2023
129a0d0
Add dependencies
Jul 19, 2023
349c7ca
Copy remote robot repo files
Jul 19, 2023
9930a77
Implement custom ToolWindowFixture
Jul 19, 2023
c81b6f4
Modify testing
Jul 19, 2023
e5bfa6e
Fixes
ZacSweers Jul 21, 2023
404ba35
Initial creation of test fixture project
Jul 24, 2023
b134b07
Modifying build.gradle.kts to match skate-plugin
Jul 24, 2023
d2d5fc8
Deleting test fixture plugin project
Jul 24, 2023
602dcb4
creation of test fixture project within skate-plugin tests
Jul 24, 2023
c8dc4a6
deletion of test-fixture plugin
Jul 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`() {
Copy link
Collaborator

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?

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()
Copy link
Collaborator

Choose a reason for hiding this comment

The 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?
Copy link
Collaborator

Choose a reason for hiding this comment

The 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
}
}
Loading