Skip to content

Commit

Permalink
updating to match new function names from action mint
Browse files Browse the repository at this point in the history
  • Loading branch information
robertfmurdock committed Jul 15, 2023
1 parent eb72f48 commit b278268
Show file tree
Hide file tree
Showing 39 changed files with 115 additions and 100 deletions.
19 changes: 19 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface DispatchFunc<D> {

operator fun <C, R> invoke(
commandFunc: () -> C,
fireCommand: suspend ActionCannon<D>.(C) -> R,
fireFunc: suspend ActionCannon<D>.(C) -> R,
response: (R) -> Unit,
): () -> Unit
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.zegreatrob.coupling.client.components.pairassignments

import com.zegreatrob.coupling.action.pairassignmentdocument.DeletePairAssignmentsCommand
import com.zegreatrob.coupling.action.pairassignmentdocument.fire
import com.zegreatrob.coupling.action.pairassignmentdocument.perform
import com.zegreatrob.coupling.client.components.CouplingButton
import com.zegreatrob.coupling.client.components.DispatchFunc
import com.zegreatrob.coupling.client.components.Paths.currentPairsPage
Expand Down Expand Up @@ -42,7 +42,7 @@ val CurrentPairAssignmentsPanel by nfc<CurrentPairAssignmentsPanelProps> { props
val redirectToCurrentFunc = { setRedirectUrl(party.id.currentPairsPage()) }
val onCancel = dispatchFunc(
commandFunc = { DeletePairAssignmentsCommand(party.id, pairAssignments.id) },
fireCommand = ::fire,
fireFunc = ::perform,
response = { redirectToCurrentFunc() },
)
if (redirectUrl != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.zegreatrob.coupling.client.components.pairassignments

import com.zegreatrob.coupling.action.pairassignmentdocument.DeletePairAssignmentsCommand
import com.zegreatrob.coupling.action.pairassignmentdocument.fire
import com.zegreatrob.coupling.action.pairassignmentdocument.perform
import com.zegreatrob.coupling.client.components.Controls
import com.zegreatrob.coupling.client.components.CouplingButton
import com.zegreatrob.coupling.client.components.external.w3c.WindowFunctions
Expand Down Expand Up @@ -58,7 +58,7 @@ val PairAssignmentRow by nfc<PairAssignmentRowProps> { props ->
val onDeleteClick: () -> Unit = useCallback {
val deleteFunc = dispatchFunc(
commandFunc = { DeletePairAssignmentsCommand(party.id, document.id) },
fireCommand = ::fire,
fireFunc = ::perform,
response = { reload() },
)
if (windowFuncs.window.confirm("Are you sure you want to delete these pair assignments?")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.zegreatrob.coupling.client.components.pin

import com.zegreatrob.coupling.action.pin.DeletePinCommand
import com.zegreatrob.coupling.action.pin.SavePinCommand
import com.zegreatrob.coupling.action.pin.fire
import com.zegreatrob.coupling.action.pin.perform
import com.zegreatrob.coupling.client.components.DispatchFunc
import com.zegreatrob.coupling.client.components.Paths.pinListPath
import com.zegreatrob.coupling.client.components.external.w3c.requireConfirmation
Expand Down Expand Up @@ -40,13 +40,13 @@ val PinConfig by nfc<PinConfigProps<*>> { props ->
val (redirectUrl, setRedirectUrl) = useState<String?>(null)
val onSubmit = dispatchFunc(
commandFunc = { SavePinCommand(party.id, updatedPin) },
fireCommand = ::fire,
fireFunc = ::perform,
response = { reload() },
)
val onRemove = pin.id?.let { pinId ->
dispatchFunc(
commandFunc = { DeletePinCommand(party.id, pinId) },
fireCommand = ::fire,
fireFunc = ::perform,
response = { setRedirectUrl(party.id.pinListPath()) },
)
.requireConfirmation("Are you sure you want to delete this pin?")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.zegreatrob.coupling.client.components.slack
import com.benasher44.uuid.uuid4
import com.zegreatrob.coupling.action.VoidResult
import com.zegreatrob.coupling.action.party.SaveSlackIntegrationCommand
import com.zegreatrob.coupling.action.party.fire
import com.zegreatrob.coupling.action.party.perform
import com.zegreatrob.coupling.client.components.ConfigForm
import com.zegreatrob.coupling.client.components.CouplingButton
import com.zegreatrob.coupling.client.components.DispatchFunc
Expand Down Expand Up @@ -52,7 +52,7 @@ val SlackConnectPageContent by nfc<SlackConnectPageContentProps> { props ->
var result by useState<VoidResult?>(null)
val onSave = props.dispatchFunc(
commandFunc = { command },
fireCommand = ::fire,
fireFunc = ::perform,
response = { result = it },
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.zegreatrob.coupling.client.components.spin

import com.zegreatrob.coupling.action.pairassignmentdocument.SpinCommand
import com.zegreatrob.coupling.action.pairassignmentdocument.fire
import com.zegreatrob.coupling.action.pairassignmentdocument.perform
import com.zegreatrob.coupling.client.components.DispatchFunc
import com.zegreatrob.coupling.client.components.Paths.newPairAssignmentsPath
import com.zegreatrob.coupling.model.pairassignmentdocument.PairAssignmentDocument
Expand Down Expand Up @@ -69,6 +69,6 @@ private fun onSpin(
setRedirectUrl: (String) -> Unit,
) = dispatchFunc(
commandFunc = { SpinCommand(party.id, playerSelections.playerIds(), pinSelections.filterNotNull()) },
fireCommand = ::fire,
fireFunc = ::perform,
response = { setRedirectUrl(party.newPairAssignmentsPath()) },
)
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class StubDispatchFunc<D>(private val stubber: StubDispatcher = StubDispatcher()

override fun <C, R> invoke(
commandFunc: () -> C,
fireCommand: suspend ActionCannon<D>.(C) -> R,
fireFunc: suspend ActionCannon<D>.(C) -> R,
response: (R) -> Unit,
): () -> Unit = {
stubber.dispatchList.add(DispatchedFunc(commandFunc(), response))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class DecoratedDispatchFunc<D>(

override fun <C, R> invoke(
commandFunc: () -> C,
fireCommand: suspend ActionCannon<D>.(C) -> R,
fireFunc: suspend ActionCannon<D>.(C) -> R,
response: (R) -> Unit,
): () -> Unit = fun() {
val cannon = cannonFunc()
val command = commandFunc()
tools.performAsyncWork(
{ fireCommand(cannon, command) },
{ fireFunc(cannon, command) },
{ handler: Throwable -> throw handler },
response,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class NoOpDispatcherDispatchFunc : DispatchFunc<NoOpDispatcher> {

override fun <C, R> invoke(
commandFunc: () -> C,
fireCommand: suspend ActionCannon<NoOpDispatcher>.(C) -> R,
fireFunc: suspend ActionCannon<NoOpDispatcher>.(C) -> R,
response: (R) -> Unit,
) = {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.zegreatrob.coupling.client.pairassignments

import com.zegreatrob.coupling.action.pairassignmentdocument.DeletePairAssignmentsCommand
import com.zegreatrob.coupling.action.pairassignmentdocument.SavePairAssignmentsCommand
import com.zegreatrob.coupling.action.pairassignmentdocument.fire
import com.zegreatrob.coupling.action.pairassignmentdocument.perform
import com.zegreatrob.coupling.client.components.Controls
import com.zegreatrob.coupling.client.components.CouplingWebsocket
import com.zegreatrob.coupling.client.components.disconnectedMessage
Expand Down Expand Up @@ -44,7 +44,7 @@ val SocketedPairAssignments by nfc<SocketedPairAssignmentsProps<*>> { (party, pl
setPairAssignments(new)
controls.dispatchFunc(
commandFunc = { SavePairAssignmentsCommand(party.id, new) },
fireCommand = ::fire,
fireFunc = ::perform,
response = {},
).invoke()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ val SlackCallbackPage by nfc<PageProps> { props ->
} else {
DataLoader(
getDataAsync = {
fire(
props.commander.tracingDispatcher().sdk,
GrantSlackAccessCommand(code, state),
)
props.commander.tracingDispatcher().sdk
.fire(GrantSlackAccessCommand(code, state))
},
errorData = { VoidResult.Rejected },
child = SlackCallbackLoadContent::create,
Expand Down
2 changes: 1 addition & 1 deletion coupling-plugins/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ com-fasterxml-jackson-core-jackson-databind = "com.fasterxml.jackson.core:jackso
com-github-ben-manes-gradle-versions-plugin = "com.github.ben-manes:gradle-versions-plugin:0.47.0"
com-soywiz-korlibs-klock = "com.soywiz.korlibs.klock:klock:4.0.8"
com-zegreatrob-jsmints-jsmints-bom = "com.zegreatrob.jsmints:jsmints-bom:4.3.13"
com-zegreatrob-testmints-testmints-bom = "com.zegreatrob.testmints:testmints-bom:10.0.20"
com-zegreatrob-testmints-testmints-bom = "com.zegreatrob.testmints:testmints-bom:10.1.0"
com-zegreatrob-tools-tools-bom = "com.zegreatrob.tools:tools-bom:0.5.4"
org-ajoberstar-grgit-gradle-plugin = "org.ajoberstar.grgit:org.ajoberstar.grgit.gradle.plugin:5.0.0"
org-apache-logging-log4j-log4j-core = { module = "org.apache.logging.log4j:log4j-core", version.ref = "org-apache-logging-log4j" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class HistoryPageE2ETest {
),
),
),
).onEach { fire(sdk, SavePairAssignmentsCommand(party.id, it)) }
).onEach { sdk.fire(SavePairAssignmentsCommand(party.id, it)) }

private fun buildPairAssignmentDocument(number: Int, pairs: List<CouplingPair>) = PairAssignmentDocument(
PairAssignmentDocumentId("${DateTime.now().milliseconds}-HistoryPageE2ETest-$number"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class PairAssignmentsPageE2ETest {
fire(SavePartyCommand(party))
coroutineScope {
launch { players.forEach { fire(SavePlayerCommand(party.id, it)) } }
launch { fire(sdk.await(), SavePairAssignmentsCommand(party.id, pairAssignmentDocument)) }
launch { sdk.await().fire(SavePairAssignmentsCommand(party.id, pairAssignmentDocument)) }
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PinConfigE2ETest {
val pin = randomPin()
}.attachParty(),
) {
fire(sdk, SavePinCommand(party.id, pin))
sdk.fire(SavePinCommand(party.id, pin))
} exercise {
PinConfigPage.goTo(party.id, pin.id)
} verify {
Expand All @@ -91,7 +91,7 @@ class PinConfigE2ETest {
val pin = randomPin()
}.attachParty(),
) {
fire(sdk, SavePinCommand(party.id, pin))
sdk.fire(SavePinCommand(party.id, pin))
PinConfigPage.goTo(party.id, pin.id)
} exercise {
getDeleteButton().click()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PrepareToSpinPageE2ETest {
val sdk = sdk.await().apply {
fire(SavePartyCommand(party))
players.forEach { fire(SavePlayerCommand(party.id, it)) }
fire(sdk.await(), SavePinCommand(party.id, pin))
sdk.await().fire(SavePinCommand(party.id, pin))
}

FullPartyData(players, listOf(pin), party, sdk)
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ com-fasterxml-jackson-core-jackson-databind = "com.fasterxml.jackson.core:jackso
com-github-ajalt-clikt-clikt = "com.github.ajalt.clikt:clikt:4.0.0"
com-soywiz-korlibs-klock = "com.soywiz.korlibs.klock:klock:4.0.9"
com-zegreatrob-jsmints-jsmints-bom = "com.zegreatrob.jsmints:jsmints-bom:4.3.14"
com-zegreatrob-testmints-testmints-bom = "com.zegreatrob.testmints:testmints-bom:10.0.20"
com-zegreatrob-testmints-testmints-bom = "com.zegreatrob.testmints:testmints-bom:10.1.0"
io-github-microutils-kotlin-logging = "io.github.microutils:kotlin-logging:3.0.5"
io-ktor-ktor-bom = "io.ktor:ktor-bom:2.3.2"
org-jetbrains-kotlin-wrappers-kotlin-wrappers-bom = "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:1.0.0-pre.597"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class RequestCombineEndpointTest {
}
}) {
sdk.fire(SavePartyCommand(party))
pinsToSave.forEach { fire(cannon = sdk, action = SavePinCommand(party.id, it)) }
pinsToSave.forEach { sdk.fire(SavePinCommand(party.id, it)) }
playersToSave.forEach { sdk.fire(SavePlayerCommand(party.id, it)) }
} exercise {
coroutineScope {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ class SdkBoostTest {
@Test
fun deleteWillMakeBoostNotRecoverableThroughGet() = setupWithUser {
} exercise {
fire(sdk, SaveBoostCommand(setOf(PartyId("${uuid4()}"), PartyId("${uuid4()}"))))
fire(sdk, DeleteBoostCommand())
sdk.fire(SaveBoostCommand(setOf(PartyId("${uuid4()}"), PartyId("${uuid4()}"))))
sdk.fire(DeleteBoostCommand())
} verifyWithWait {
fire(sdk, BoostQuery())
sdk.fire(BoostQuery())
.assertIsEqualTo(null)
}

@Test
fun getBoostWhenThereIsNoneReturnsNull() = setupWithUser {
} exercise {
fire(sdk, DeleteBoostCommand())
sdk.fire(DeleteBoostCommand())
} verifyWithWait {
fire(sdk, BoostQuery())
sdk.fire(BoostQuery())
.assertIsEqualTo(null)
}

Expand All @@ -53,9 +53,9 @@ class SdkBoostTest {
val partyIds = setOf(PartyId("${uuid4()}"), PartyId("${uuid4()}"))
}
}) exercise {
fire(sdk, SaveBoostCommand(partyIds))
sdk.fire(SaveBoostCommand(partyIds))
} verifyWithWait {
fire(sdk, BoostQuery())
sdk.fire(BoostQuery())
?.data
.assertIsEqualTo(
Boost(
Expand All @@ -75,11 +75,11 @@ class SdkBoostTest {
val updatedBoostParties2 = setOf(PartyId("${uuid4()}"))
}
}) exercise {
fire(sdk, SaveBoostCommand(initialBoostParties))
fire(sdk, SaveBoostCommand(updatedBoostParties1))
fire(sdk, SaveBoostCommand(updatedBoostParties2))
sdk.fire(SaveBoostCommand(initialBoostParties))
sdk.fire(SaveBoostCommand(updatedBoostParties1))
sdk.fire(SaveBoostCommand(updatedBoostParties2))
} verifyWithWait {
fire(sdk, BoostQuery())
sdk.fire(BoostQuery())
?.data
.assertIsEqualTo(
Boost(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ class SdkGlobalStatsTest {
val party = stubPartyDetails()
}) {
sdk().fire(SavePartyCommand(party))
fire(
sdk(),
sdk().fire(
SavePairAssignmentsCommand(
partyId = party.id,
pairAssignments = stubPairAssignmentDoc().copy(date = DateTime.now().minus(2.days)),
),
)
fire(
sdk(),
sdk().fire(
SavePairAssignmentsCommand(
partyId = party.id,
pairAssignments = stubPairAssignmentDoc().copy(date = DateTime.now()),
Expand Down
Loading

0 comments on commit b278268

Please sign in to comment.