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 all 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
27 changes: 26 additions & 1 deletion skate-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ group = "com.slack.sgp.intellij"

version = "1.0-SNAPSHOT"

repositories { mavenCentral() }
repositories {
mavenCentral()
maven(url = "https://packages.jetbrains.team/maven/p/ij/intellij-dependencies")
}

// Configure Gradle IntelliJ Plugin
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
Expand All @@ -34,6 +37,12 @@ tasks {
}

publishPlugin { token.set(System.getenv("PUBLISH_TOKEN")) }

runIdeForUiTests { systemProperty("robot-server.port", "8082") }

downloadRobotServerPlugin { "0.11.19" }

test { useJUnitPlatform() }
}

// region Version.kt template for setting the project version in the build
Expand Down Expand Up @@ -65,4 +74,20 @@ dependencies {
implementation(libs.bugsnag)
testImplementation(libs.junit)
testImplementation(libs.truth)
testImplementation(libs.okhttp)
testImplementation("com.intellij.remoterobot:remote-robot:0.11.19")
testImplementation("com.intellij.remoterobot:remote-fixtures:0.11.19")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.9.3")

// Logging Network Calls
testImplementation("com.squareup.okhttp3:logging-interceptor:4.11.0")

// Video Recording
implementation("com.automation-remarks:video-recorder-junit5:2.0")
}
java {
sourceCompatibility = JavaVersion.VERSION_19
targetCompatibility = JavaVersion.VERSION_19
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ interface SkateProjectService {
class SkateProjectServiceImpl(private val project: Project) : SkateProjectService {

override fun showWhatsNewWindow() {
// TODO
// Only show when changed
// Only show latest changes
val settings = project.service<SkatePluginSettings>()
if (!settings.isWhatsNewEnabled) return
val projectDir = project.guessProjectDir() ?: return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal class SkateConfigUI(

private fun Panel.checkBoxRow() {
row(SkateBundle.message("skate.configuration.enableWhatsNew.title")) {
checkBox("skate.configuration.enableWhatsNew.description")
checkBox(SkateBundle.message("skate.configuration.enableWhatsNew.description"))
.bindSelected(
getter = { settings.isWhatsNewEnabled },
setter = { settings.isWhatsNewEnabled = it }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.slack.sgp.intellij

import com.google.common.truth.Truth.assertThat
import com.intellij.openapi.components.service
import com.intellij.testFramework.fixtures.BasePlatformTestCase

class SkatePluginInitializationTest : BasePlatformTestCase() {

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)
}

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,90 @@
package com.slack.sgp.intellij

import com.google.common.truth.Truth.assertThat
import com.intellij.remoterobot.RemoteRobot
import com.intellij.remoterobot.utils.keyboard
import com.intellij.remoterobot.utils.waitForIgnoringError
import com.slack.sgp.intellij.pages.ToolWindowFixture
import com.slack.sgp.intellij.pages.idea
import com.slack.sgp.intellij.utils.RemoteRobotExtension
import com.slack.sgp.intellij.utils.StepsLogger
import java.awt.event.KeyEvent.VK_A
import java.awt.event.KeyEvent.VK_META
import java.awt.event.KeyEvent.VK_SHIFT
import java.time.Duration.ofSeconds
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith

// TODO:
// Writes a sample changelog file to the project dir (before opening the project)
// Writes the setting to the skate config
// Opens the project
// Asserts that the panel opened and showed the changelog

@ExtendWith(RemoteRobotExtension::class)
class SkatePluginTest {

init {
StepsLogger.init()
}

@BeforeEach
fun waitForIde(remoteRobot: RemoteRobot) {
waitForIgnoringError(
ofSeconds(10),
ofSeconds(2),
"Wait for Ide started",
"Ide is not started"
) {
remoteRobot.callJs("true")
}
}

@AfterEach
fun closeProject(remoteRobot: RemoteRobot) =
with(remoteRobot) {
idea {
if (remoteRobot.isMac()) {
keyboard {
hotKey(VK_SHIFT, VK_META, VK_A)
enterText("Close Project")
enter()
}
} else {
menuBar.select("File", "Close Project")
}
}
}

@Test
// @Video
fun checkToolWindow(remoteRobot: RemoteRobot) {
with(remoteRobot) {
val toolWindow = find(ToolWindowFixture::class.java, timeout = ofSeconds(10))
assertThat(toolWindow.window.isShowing).isTrue()
}
}

// @Test
// fun testToolWindowExists() {
// val robot = RemoteRobot("http://127.0.0.1:8082")
// checkToolWindow(robot)
// }
// @Test
// fun checkToolWindow() {
// // Create a RemoteRobot instance with the default URL (localhost:8082)
// val robot = RemoteRobot("http://127.0.0.1:8082")
//
// // See if Tool Window has the same name it's supposed to
// val toolWindow =
// robot.find(
// ComponentFixture::class.java,
// byXpath("//div[@accessibilityName=\"What's New in Slack!\"]")
// )
//
// // Check if the Tool Window is showing
// assertThat(toolWindow.isShowing).isTrue()
// }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.

package com.slack.sgp.intellij.pages

import com.intellij.remoterobot.RemoteRobot
import com.intellij.remoterobot.data.RemoteComponent
import com.intellij.remoterobot.fixtures.*
import com.intellij.remoterobot.search.locators.byXpath
import com.intellij.remoterobot.stepsProcessing.step
import com.intellij.remoterobot.utils.waitFor
import java.time.Duration

fun RemoteRobot.idea(function: IdeaFrame.() -> Unit) {
find<IdeaFrame>(timeout = Duration.ofSeconds(10)).apply(function)
}

@FixtureName("Idea frame")
@DefaultXpath("IdeFrameImpl type", "//div[@class='IdeFrameImpl']")
class IdeaFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) :
CommonContainerFixture(remoteRobot, remoteComponent) {

val projectViewTree
get() = find<ContainerFixture>(byXpath("ProjectViewTree", "//div[@class='ProjectViewTree']"))

val projectName
get() =
step("Get project name") {
return@step callJs<String>("component.getProject().getName()")
}

val menuBar: JMenuBarFixture
get() =
step("Menu...") {
return@step remoteRobot.find(JMenuBarFixture::class.java, JMenuBarFixture.byType())
}

@JvmOverloads
fun dumbAware(timeout: Duration = Duration.ofMinutes(5), function: () -> Unit) {
step("Wait for smart mode") {
waitFor(duration = timeout, interval = Duration.ofSeconds(5)) {
runCatching { isDumbMode().not() }.getOrDefault(false)
}
function()
step("..wait for smart mode again") {
waitFor(duration = timeout, interval = Duration.ofSeconds(5)) { isDumbMode().not() }
}
}
}

fun isDumbMode(): Boolean {
return callJs(
"""
const frameHelper = com.intellij.openapi.wm.impl.ProjectFrameHelper.getFrameHelper(component)
if (frameHelper) {
const project = frameHelper.getProject()
project ? com.intellij.openapi.project.DumbService.isDumb(project) : true
} else {
true
}
""",
true
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.slack.sgp.intellij.pages

import com.intellij.remoterobot.RemoteRobot
import com.intellij.remoterobot.data.RemoteComponent
import com.intellij.remoterobot.fixtures.CommonContainerFixture
import com.intellij.remoterobot.fixtures.ComponentFixture
import com.intellij.remoterobot.fixtures.DefaultXpath
import com.intellij.remoterobot.fixtures.FixtureName
import com.intellij.remoterobot.search.locators.byXpath
import java.time.Duration

fun RemoteRobot.toolWindow(function: ToolWindowFixture.() -> Unit) {
find(ToolWindowFixture::class.java, Duration.ofSeconds(10)).apply(function)
}

@FixtureName("Tool Window")
@DefaultXpath("type", "//div[@accessibilityName=\"What's New in Slack!\"]")
class ToolWindowFixture(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) :
CommonContainerFixture(remoteRobot, remoteComponent) {
val window
get() =
find(
ComponentFixture::class.java,
byXpath("//div[@accessibilityName=\"What's New in Slack!\"]")
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.

package com.slack.sgp.intellij.pages

import com.intellij.remoterobot.RemoteRobot
import com.intellij.remoterobot.data.RemoteComponent
import com.intellij.remoterobot.fixtures.*
import com.intellij.remoterobot.search.locators.byXpath
import java.time.Duration

fun RemoteRobot.welcomeFrame(function: WelcomeFrame.() -> Unit) {
find(WelcomeFrame::class.java, Duration.ofSeconds(10)).apply(function)
}

@FixtureName("Welcome Frame")
@DefaultXpath("type", "//div[@class='FlatWelcomeFrame']")
class WelcomeFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) :
CommonContainerFixture(remoteRobot, remoteComponent) {
val createNewProjectLink
get() =
actionLink(
byXpath(
"New Project",
"//div[(@class='MainButton' and @text='New Project') or (@accessiblename='New Project' and @class='JButton')]"
)
)
val moreActions
get() = button(byXpath("More Action", "//div[@accessiblename='More Actions']"))

val heavyWeightPopup
get() =
remoteRobot.find(ComponentFixture::class.java, byXpath("//div[@class='HeavyWeightWindow']"))
}
Loading