Skip to content

Commit

Permalink
fix wrong names being shown in team 2 column of results detail view (#12
Browse files Browse the repository at this point in the history
)

fixes #10

move test result processing to post_ci

Signed-off-by: John Burns <[email protected]>
  • Loading branch information
wakingrufus authored Jan 12, 2018
1 parent f605d1d commit 561e45a
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repositories {
maven { url 'https://jitpack.io' }
}

version = "0.5.0"
version = "0.5.1"

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
Expand Down
4 changes: 4 additions & 0 deletions shippable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ build:
- rm -rf build
- gradle wrapper
- ./gradlew clean build
post_ci:
- cp build/test-results/test/*.xml shippable/testresults
- cp build/reports/jacoco/test/jacocoTestReport.xml shippable/codecoverage
- cp -r build/jacoco/test.exec shippable/codecoverage/target/site/jacoco
- cp -r build/classes shippable/codecoverage/target
on_failure:
- cp build/test-results/test/*.xml shippable/testresults
on_success:
- export TAG_NAME=`git describe --exact-match --tags HEAD`
- export BRANCH_NAME=`git rev-parse --abbrev-ref HEAD`
Expand All @@ -32,3 +35,4 @@ build:
- if [ "$BRANCH_NAME" = "master" ]; then aws s3 cp $SHIPPABLE_BUILD_DIR/build/distributions/elo-league-jfx-*.zip s3://$CD_BUCKET/$CD_KEY; fi
- if [ "$TAG_NAME" != "" ]; then aws s3 cp $SHIPPABLE_BUILD_DIR/build/distributions/elo-league-jfx-*.zip s3://$CD_BUCKET/$RELEASE_KEY; fi
- if [ "$TAG_NAME" != "" ]; then aws s3 cp $SHIPPABLE_BUILD_DIR/build/jfx/native/elo-league-jfx-*.deb s3://$CD_BUCKET/$RELEASE_KEY_DEB; fi
advancedReporting: true
Binary file added src/main/deploy/package/linux/elo-league-jfx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/main/deploy/package/linux/mastodon-jfx.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ class ResultsDetailsView : Fragment() {
column<GameResultItem, String>("Player") { it.value.player.nameProperty }
column("starting Rating", GameResultItem::startingRating)
column("Adjustment", GameResultItem::ratingAdjustment)
column<GameResultItem, String>("Team 1") {
val t1 = column<GameResultItem, String>("Team 1") {
ReadOnlyStringWrapper(it.value.team1Players.
joinToString(transform = { player -> player.name }))
}
t1.id = "team-1"
column("Score", GameResultItem::team1Score)
column<GameResultItem, String>("Team 2") {
ReadOnlyStringWrapper(it.value.team1Players.
val t2 = column<GameResultItem, String>("Team 2") {
ReadOnlyStringWrapper(it.value.team2Players.
joinToString(transform = { player -> player.name }))
}
t2.id = "team-2"
column("Score", GameResultItem::team2Score)
columnResizePolicy = SmartResize.POLICY
}
Expand Down
21 changes: 17 additions & 4 deletions src/test/kotlin/com/github/wakingrufus/eloleague/TornadoFxTest.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package com.github.wakingrufus.eloleague

import com.github.wakingrufus.eloleague.results.ResultsDetailsViewTest
import javafx.application.Platform
import javafx.scene.Node
import javafx.scene.Parent
import javafx.scene.Scene
import javafx.stage.Stage
import org.testfx.framework.junit.ApplicationTest
import tornadofx.UIComponent
import tornadofx.View
import tornadofx.stackpane
import tornadofx.*
import java.time.Instant

open class TornadoFxTest : ApplicationTest() {
lateinit var wrapper: TestView
var scene: Scene? = null
override fun start(stage: Stage) {
wrapper = TestView()
val scene = Scene(wrapper.root, 800.0, 600.0)
scene = Scene(wrapper.root, 800.0, 600.0)
stage.scene = scene
stage.show()
}
Expand All @@ -37,4 +39,15 @@ fun waitFor(condition: () -> Boolean, maxMillis: Long = 10000) {
while (!condition() && Instant.now().isBefore(startTime.plusMillis(maxMillis))) {
Thread.sleep(1000)
}
}

fun printNodes(node: Node, level: Int = 0) {

ResultsDetailsViewTest.logger.info { " ".repeat(level) + node.toString() }
if (node is Parent) {
node.childrenUnmodifiable.forEach {
printNodes(it, level + 1)
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.github.wakingrufus.eloleague.results

import com.github.wakingrufus.eloleague.TornadoFxTest
import com.github.wakingrufus.eloleague.player.PlayerItem
import com.github.wakingrufus.eloleague.printNodes
import com.github.wakingrufus.eloleague.waitFor
import javafx.collections.FXCollections
import javafx.collections.ObservableList
import javafx.scene.Node
import javafx.scene.Parent
import mu.KLogging
import org.junit.Test
import org.testfx.api.FxAssert
import org.testfx.matcher.base.NodeMatchers
import java.time.Instant
import java.time.ZoneOffset
import java.time.format.DateTimeFormatter
import java.util.*

class ResultsDetailsViewTest : TornadoFxTest() {
companion object : KLogging()

@Test
fun test() {
val result1 = GameResultItem(
id = UUID.randomUUID().toString(),
player = PlayerItem(id = UUID.randomUUID().toString(), name = "Adam"),
ratingAdjustment = 1,
entryDate = DateTimeFormatter.ISO_DATE_TIME.format(Instant.now().atOffset(ZoneOffset.UTC)),
win = true,
startingRating = 1500,
team1Score = 5,
team2Score = 3,
team1Players = listOf(
PlayerItem(id = UUID.randomUUID().toString(), name = "Adam"),
PlayerItem(id = UUID.randomUUID().toString(), name = "Beth")),
team2Players = listOf(
PlayerItem(id = UUID.randomUUID().toString(), name = "Alice"),
PlayerItem(id = UUID.randomUUID().toString(), name = "Bob"))
)
val resultDetails: ObservableList<GameResultItem> = FXCollections.observableArrayList(
result1
)
showViewWithParams<ResultsDetailsView>(mapOf(
"gameResults" to resultDetails
))
waitFor({scene!!.root.childrenUnmodifiable[0].isVisible})
FxAssert.verifyThat("#result-details-wrapper", NodeMatchers.isVisible())
printNodes(scene!!.root)
FxAssert.verifyThat("#result-details-wrapper .table-view .table-row-cell #team-1",
NodeMatchers.hasText("Adam, Beth"))
FxAssert.verifyThat("#result-details-wrapper .table-view .table-row-cell #team-2",
NodeMatchers.hasText("Alice, Bob"))
}
}

0 comments on commit 561e45a

Please sign in to comment.