Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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,85 @@
package com.plainstudio.stackcasino.feature.history

import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollTo
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.plainstudio.stackcasino.ui.theme.StackcasinoTheme
import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class HistoryScreenTest {
@get:Rule
val composeRule = createComposeRule()

@Test
fun renders_summary_and_every_round() {
composeRule.setContent {
StackcasinoTheme {
HistoryScreen(data = historyPreviewData(), onOpenRound = {})
}
}

composeRule.onNodeWithText("Game History").assertIsDisplayed()
composeRule.onNodeWithText("128").assertIsDisplayed()
composeRule.onNodeWithText("54%").assertIsDisplayed()
composeRule.onNodeWithText("Crash").performScrollTo().assertIsDisplayed()
composeRule.onNodeWithText("Coinflip").performScrollTo().assertIsDisplayed()
}

@Test
fun selecting_wins_filter_hides_losing_rounds() {
composeRule.setContent {
StackcasinoTheme {
HistoryScreen(data = historyPreviewData(), onOpenRound = {})
}
}

composeRule.onNodeWithText("WINS").performScrollTo().performClick()
composeRule.waitForIdle()

composeRule.onNodeWithText("Crash").performScrollTo().assertIsDisplayed()
composeRule.onNodeWithText("Roulette").performScrollTo().assertIsDisplayed()
composeRule.onNodeWithText("Mines").performScrollTo().assertIsDisplayed()
composeRule.onAllNodesWithText("Blackjack").assertCountEquals(0)
composeRule.onAllNodesWithText("Coinflip").assertCountEquals(0)
}

@Test
fun selecting_a_game_filter_narrows_to_that_game() {
composeRule.setContent {
StackcasinoTheme {
HistoryScreen(data = historyPreviewData(), onOpenRound = {})
}
}

composeRule.onNodeWithText("BLACKJACK").performScrollTo().performClick()
composeRule.waitForIdle()

composeRule.onNodeWithText("Blackjack").performScrollTo().assertIsDisplayed()
composeRule.onAllNodesWithText("Crash").assertCountEquals(0)
composeRule.onAllNodesWithText("Roulette").assertCountEquals(0)
}

@Test
fun tapping_a_round_invokes_callback_with_round_id() {
var opened: String? = null
composeRule.setContent {
StackcasinoTheme {
HistoryScreen(data = historyPreviewData(), onOpenRound = { opened = it })
}
}

composeRule.onNodeWithText("Crash").performScrollTo().performClick()
composeRule.waitForIdle()

assertEquals("round-001", opened)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.plainstudio.stackcasino.feature.history

import com.plainstudio.stackcasino.model.GameKey
import com.plainstudio.stackcasino.model.RoundOutcome

/**
* Static seed for the history screen previews + live nav-host entry.
* Numbers and labels mirror mockup/js/screens/history.js so the
* rendered screen matches the design source one-for-one.
*/
internal fun historyPreviewData(): HistoryData =
HistoryData(
summary = previewSummary(),
rounds = previewRounds(),
)

private fun previewSummary(): HistorySummary =
HistorySummary(
totalRounds = 128,
winRatePercent = 54,
netLabel = "+$412.30",
)

private fun previewRounds(): List<HistoryRound> =
listOf(
HistoryRound(
id = "round-001",
game = GameKey.Crash,
timestampLabel = "4/16/2026 · 7:30 AM",
betLabel = "$50.00",
payoutLabel = "$125.50",
multiplierLabel = "2.51x",
outcome = RoundOutcome.Win,
),
HistoryRound(
id = "round-002",
game = GameKey.Roulette,
timestampLabel = "4/16/2026 · 6:15 AM",
betLabel = "$25.00",
payoutLabel = "$175.00",
multiplierLabel = "7x",
outcome = RoundOutcome.Win,
),
HistoryRound(
id = "round-003",
game = GameKey.Blackjack,
timestampLabel = "4/15/2026 · 11:20 AM",
betLabel = "$100.00",
payoutLabel = "$0.00",
multiplierLabel = "0x",
outcome = RoundOutcome.Loss,
),
HistoryRound(
id = "round-004",
game = GameKey.Mines,
timestampLabel = "4/15/2026 · 8:45 AM",
betLabel = "$20.00",
payoutLabel = "$48.00",
multiplierLabel = "2.40x",
outcome = RoundOutcome.Win,
),
HistoryRound(
id = "round-005",
game = GameKey.Coinflip,
timestampLabel = "4/14/2026 · 1:30 PM",
betLabel = "$75.00",
payoutLabel = "$0.00",
multiplierLabel = "Heads",
outcome = RoundOutcome.Loss,
),
)
Loading
Loading