This repository has been archived by the owner on Apr 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Cache list topic in cluster scope * Add refresh button * Add test refresh button in topic list * Add test for refresh schema registry list * Fix PR lint * Add unit test for register schema * Remove code duplication * Rename buttons * Fix text in button alignment Co-authored-by: Auto Lint <[email protected]>
- Loading branch information
1 parent
0891e09
commit d6df59d
Showing
13 changed files
with
198 additions
and
47 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
app/src/integrationTest/kotlin/insulator/integrationtest/RefreshButtonTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package insulator.integrationtest | ||
|
||
import insulator.integrationtest.helpers.IntegrationTestFixture | ||
import insulator.integrationtest.helpers.click | ||
import insulator.integrationtest.helpers.lookupFirst | ||
import insulator.integrationtest.helpers.screenShoot | ||
import insulator.integrationtest.helpers.selectCluster | ||
import insulator.integrationtest.helpers.waitWindowWithTitle | ||
import io.kotest.core.spec.style.FreeSpec | ||
import io.kotest.matchers.shouldBe | ||
import javafx.scene.Node | ||
import javafx.scene.control.Button | ||
import javafx.scene.control.Label | ||
import javafx.scene.control.ListView | ||
import kotlinx.coroutines.delay | ||
import tornadofx.CssRule | ||
import tornadofx.Stylesheet.Companion.listView | ||
import kotlin.time.ExperimentalTime | ||
|
||
@ExperimentalTime | ||
class RefreshButtonTests : FreeSpec({ | ||
|
||
"Test refresh topic button" - { | ||
IntegrationTestFixture().use { fixture -> | ||
fixture.startAppWithKafkaCuster("Test cluster") | ||
selectCluster(fixture.currentKafkaCluster) | ||
|
||
val mainView = waitWindowWithTitle("Insulator") | ||
suspend fun getListViewItems() = mainView.lookupFirst<ListView<String>>(listView).items | ||
|
||
"Refresh topic list" { | ||
val topicName = "test-new-topic" | ||
// create topic | ||
fixture.createTopic(topicName) | ||
delay(1_000) | ||
// the topic shouldn't be visible | ||
getListViewItems().count { it == topicName } shouldBe 0 | ||
// click the refresh button wil load the new topic | ||
mainView.lookupFirst<Button>(CssRule.id("button-refresh")).click() | ||
screenShoot("refresh-topic-list") | ||
// the list of topic is now updated | ||
getListViewItems().count { it == topicName } shouldBe 1 | ||
mainView.lookupFirst<Label>(CssRule.id("topic-$topicName")).text shouldBe topicName | ||
} | ||
|
||
"Refresh schema list" { | ||
val schemaName = "test-new-topic-schema" | ||
// select schema registry | ||
mainView.lookupFirst<Node>(CssRule.id("sidebar-item-schema-registry")).click() | ||
// create the schema | ||
fixture.createTestSchema(schemaName) | ||
delay(1_000) | ||
// the topic shouldn't be visible | ||
getListViewItems().count { it == schemaName } shouldBe 0 | ||
// click the refresh button wil load the new topic | ||
mainView.lookupFirst<Button>(CssRule.id("button-refresh")).click() | ||
screenShoot("refresh-schema-registry-list") | ||
// the list of topic is now updated | ||
getListViewItems().count { it == schemaName } shouldBe 1 | ||
mainView.lookupFirst<Label>(CssRule.id("schema-$schemaName")).text shouldBe schemaName | ||
} | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
package insulator.ui.component | ||
|
||
import insulator.ui.style.AppBarStyle | ||
import javafx.beans.value.ObservableStringValue | ||
import javafx.event.EventTarget | ||
import javafx.geometry.Pos | ||
import javafx.scene.layout.Priority | ||
import javafx.scene.control.Button | ||
import tornadofx.addClass | ||
import tornadofx.hgrow | ||
import tornadofx.borderpane | ||
import tornadofx.buttonbar | ||
import tornadofx.vbox | ||
|
||
fun EventTarget.appBar(op: EventTarget.() -> Unit) = | ||
vbox(alignment = Pos.TOP_LEFT) { | ||
op() | ||
hgrow = Priority.ALWAYS | ||
data class AppBarBuilder( | ||
var title: String = "", | ||
var subtitle: ObservableStringValue? = null, | ||
var buttons: List<Button> = emptyList() | ||
) | ||
|
||
fun EventTarget.appBar(op: AppBarBuilder.() -> Unit) { | ||
val builder = AppBarBuilder().apply(op) | ||
this.borderpane { | ||
center = vbox { | ||
h1(builder.title) | ||
builder.subtitle?.let { subTitle(builder.subtitle!!) } | ||
alignment = Pos.CENTER_LEFT | ||
} | ||
right = buttonbar { | ||
buttons.addAll(builder.buttons) | ||
} | ||
addClass(AppBarStyle.appBar) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.