diff --git a/composeApp/src/commonMain/composeResources/values/strings.xml b/composeApp/src/commonMain/composeResources/values/strings.xml
index e4a9cdc4..5327edad 100644
--- a/composeApp/src/commonMain/composeResources/values/strings.xml
+++ b/composeApp/src/commonMain/composeResources/values/strings.xml
@@ -40,6 +40,7 @@
Backup confirmation
Be sure to keep this nsec safe.
Be the first to comment.
+ Being signed
Bio
BIP39 seed with the standard BIP84 derivation path. The profile\'s nostr key comes off the same seed, so these 12 words restore both.
Block user
@@ -110,7 +111,6 @@
I have saved my recovery phrase somewhere safe.
I understand that if I lose this phone and my recovery phrase, I lose this profile and the funds in its wallet.
If you are new to Curare or just want to create a fresh profile
- In progress
Initial version label
Input npub... or nip05
Introduce yourself
@@ -156,6 +156,8 @@
Name of artifact
Needs you
Network relays
+ No proposal is being signed.
+ No proposal is waiting on members.
No wallet is open on this device, so there is no phrase to show.
Not backed up yet
New chat
@@ -172,7 +174,6 @@
No one to add yet.
No projects exists in this group.
No proposal has been abandoned.
- No proposal is in progress.
No translations yet.
No versions.
Not now
@@ -310,6 +311,7 @@
View invites
Waiting for you
Waiting for your signature
+ Waiting on members
We are looking for your profile on as many relays as possible. Nostr aims to be decentralized by distributing data to multiple nodse.
We are searching the internet to find your profile and complete sign in.
We couldn't find the local profile. Please try again later.
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/ProposalListScreen.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/ProposalListScreen.kt
index 72611630..ae2d738e 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/ProposalListScreen.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/ProposalListScreen.kt
@@ -15,6 +15,7 @@ import androidx.compose.material.icons.filled.CheckCircle
import androidx.compose.material.icons.filled.ChevronRight
import androidx.compose.material.icons.filled.Draw
import androidx.compose.material.icons.filled.ErrorOutline
+import androidx.compose.material.icons.filled.Groups
import androidx.compose.material.icons.filled.HourglassEmpty
import androidx.compose.material.icons.filled.Inbox
import androidx.compose.material3.Card
@@ -61,13 +62,15 @@ import curare.composeapp.generated.resources.abandoned
import curare.composeapp.generated.resources.everything_else
import curare.composeapp.generated.resources.filter_all
import curare.composeapp.generated.resources.filter_and_count
-import curare.composeapp.generated.resources.in_progress
+import curare.composeapp.generated.resources.being_signed
import curare.composeapp.generated.resources.needs_you
import curare.composeapp.generated.resources.no_proposal_has_been_abandoned
-import curare.composeapp.generated.resources.no_proposal_is_in_progress
+import curare.composeapp.generated.resources.no_proposal_is_being_signed
+import curare.composeapp.generated.resources.no_proposal_is_waiting_on_members
import curare.composeapp.generated.resources.nothing_is_waiting_for_your_signature
import curare.composeapp.generated.resources.signed
import curare.composeapp.generated.resources.this_group_has_not_signed_anything_yet
+import curare.composeapp.generated.resources.waiting_on_members
import curare.composeapp.generated.resources.proposals
import curare.composeapp.generated.resources.review
import curare.composeapp.generated.resources.this_group_has_not_been_asked_to_sign
@@ -223,7 +226,9 @@ private fun ProposalList(
message = when (state.filter) {
ProposalFilter.ALL -> stringResource(Res.string.this_group_has_not_been_asked_to_sign)
ProposalFilter.NEEDS_YOU -> stringResource(Res.string.nothing_is_waiting_for_your_signature)
- ProposalFilter.IN_PROGRESS -> stringResource(Res.string.no_proposal_is_in_progress)
+ ProposalFilter.WAITING_ON_MEMBERS ->
+ stringResource(Res.string.no_proposal_is_waiting_on_members)
+ ProposalFilter.BEING_SIGNED -> stringResource(Res.string.no_proposal_is_being_signed)
ProposalFilter.SIGNED -> stringResource(Res.string.this_group_has_not_signed_anything_yet)
ProposalFilter.ABANDONED -> stringResource(Res.string.no_proposal_has_been_abandoned)
},
@@ -350,7 +355,8 @@ private fun ProposalFilterRow(
private fun labelOf(filter: ProposalFilter): String = when (filter) {
ProposalFilter.ALL -> stringResource(Res.string.filter_all)
ProposalFilter.NEEDS_YOU -> stringResource(Res.string.needs_you)
- ProposalFilter.IN_PROGRESS -> stringResource(Res.string.in_progress)
+ ProposalFilter.WAITING_ON_MEMBERS -> stringResource(Res.string.waiting_on_members)
+ ProposalFilter.BEING_SIGNED -> stringResource(Res.string.being_signed)
ProposalFilter.SIGNED -> stringResource(Res.string.signed)
ProposalFilter.ABANDONED -> stringResource(Res.string.abandoned)
}
@@ -421,7 +427,12 @@ private fun ProposalCard(
ProposalState.NEEDS_YOU -> Icons.Default.Draw
ProposalState.SIGNED -> Icons.Default.CheckCircle
ProposalState.ABANDONED -> Icons.Default.ErrorOutline
- ProposalState.IN_PROGRESS -> Icons.Default.HourglassEmpty
+ // People against machinery: one is short of members
+ // willing to sign, the other is the chosen ones
+ // finishing. The shapes say which without the colour,
+ // which is the only signal a monochrome display has.
+ ProposalState.WAITING_ON_MEMBERS -> Icons.Default.Groups
+ ProposalState.BEING_SIGNED -> Icons.Default.HourglassEmpty
},
// Carries the stage on its own, and carries it alone on the
// highlighted card where the failure state has no colour to spare.
@@ -429,7 +440,8 @@ private fun ProposalCard(
ProposalState.NEEDS_YOU -> "Awaiting your signature"
ProposalState.SIGNED -> "Signed"
ProposalState.ABANDONED -> "Failed"
- ProposalState.IN_PROGRESS -> "Waiting on others"
+ ProposalState.WAITING_ON_MEMBERS -> "Waiting on members"
+ ProposalState.BEING_SIGNED -> "Being signed"
},
tint = when (proposal.state) {
// `error` is 2.67:1 on the highlighted card, so on that one the
@@ -518,10 +530,13 @@ private fun ProposalCard(
* deciding on. What it must never do is call a session finished when it is not,
* or waiting when the decision has gone.
*
- * Still switches on the stage rather than on `Proposal.state`, and has to: the
- * three things it says about an open session -- you agreed, you declined, you
- * were picked to sign -- are exactly the distinctions [ProposalState.IN_PROGRESS]
- * collapses. The classification picks the arm; the stage writes the sentence.
+ * Still switches on the stage rather than on `Proposal.state`, and still has to,
+ * though for less than it used to. What is left collapsed inside a state is who
+ * the reader was in it: whether they agreed or declined, under
+ * [ProposalState.WAITING_ON_MEMBERS], and whether they were picked to sign,
+ * under [ProposalState.BEING_SIGNED]. Those are facts about the reader rather
+ * than about the proposal, which is why they are a sentence on the row and not a
+ * chip above it.
*/
private fun statusOf(proposal: ProposalListUIState.Proposal): String {
val session = proposal.session
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/ProposalFilter.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/ProposalFilter.kt
index 0cb3e4d0..03f61d4e 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/ProposalFilter.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/ProposalFilter.kt
@@ -15,7 +15,8 @@ package to.curare.compose.ui.view.state
enum class ProposalFilter(val state: ProposalState?) {
ALL(null),
NEEDS_YOU(ProposalState.NEEDS_YOU),
- IN_PROGRESS(ProposalState.IN_PROGRESS),
+ WAITING_ON_MEMBERS(ProposalState.WAITING_ON_MEMBERS),
+ BEING_SIGNED(ProposalState.BEING_SIGNED),
SIGNED(ProposalState.SIGNED),
ABANDONED(ProposalState.ABANDONED),
;
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/ProposalListUIState.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/ProposalListUIState.kt
index 89380f4e..95a13d8c 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/ProposalListUIState.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/ProposalListUIState.kt
@@ -113,16 +113,15 @@ sealed interface ProposalListUIState {
*
* The inner `when` is exhaustive on purpose, with no `else`. A stage
* added to `FrostSigningStage` later should fail to compile here rather
- * than quietly land in [ProposalState.IN_PROGRESS], because whether it
- * is an ending is the one thing this file cannot guess.
+ * than quietly land in whichever arm happened to be last, because what
+ * the reader is waiting on is the one thing this file cannot guess.
*/
val state: ProposalState get() = when {
awaitsYou -> ProposalState.NEEDS_YOU
else -> when (session.stage) {
- FrostSigningStage.COLLECTING_NONCES,
- FrostSigningStage.COLLECTING_PARTIAL_SIGNATURES -> ProposalState.IN_PROGRESS
-
+ FrostSigningStage.COLLECTING_NONCES -> ProposalState.WAITING_ON_MEMBERS
+ FrostSigningStage.COLLECTING_PARTIAL_SIGNATURES -> ProposalState.BEING_SIGNED
FrostSigningStage.COMPLETE -> ProposalState.SIGNED
FrostSigningStage.FAILED -> ProposalState.ABANDONED
}
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/ProposalState.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/ProposalState.kt
index f41311cb..b1358f3e 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/ProposalState.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/ProposalState.kt
@@ -3,17 +3,16 @@ package to.curare.compose.ui.view.state
/**
* Where a proposal has got to, as a reader scanning a list of them cares.
*
- * Deliberately not [to.curare.compose.database.model.types.FrostSigningStage].
- * The stage is how far the protocol has run; this is what there is to do about
- * it, and the two part company on the only state anybody comes to this screen
- * looking for: a proposal waiting on *this* member is `COLLECTING_NONCES` like
- * every other open one, and what sets it apart is
- * `FrostSigningSession.signApprovedAt` and `signDeclinedAt` being null. So
- * [NEEDS_YOU] cannot be read off the stage at all, and a filter keyed on the
- * enum would be a filter missing its reason to exist.
+ * Deliberately not [to.curare.compose.database.model.types.FrostSigningStage],
+ * although it has come to be the stage plus one. The one is the point: a
+ * proposal waiting on *this* member is `COLLECTING_NONCES` like every other open
+ * one, and what sets it apart is `FrostSigningSession.signApprovedAt` and
+ * `signDeclinedAt` being null. So [NEEDS_YOU] cannot be read off the stage at
+ * all, and a filter keyed on the enum would be a filter missing its reason to
+ * exist.
*
- * Exhaustive and ordered by how much it asks of the reader, which is the order
- * the chips are offered in.
+ * Exhaustive and in lifecycle order, which is the order the chips are offered
+ * in.
*/
enum class ProposalState {
/**
@@ -26,14 +25,32 @@ enum class ProposalState {
NEEDS_YOU,
/**
- * Open, and this member has already said their piece -- or was never needed.
+ * Open, answered by this member, and short of members willing to sign it.
*
- * Covers more than it looks like: agreed and waiting on others, refused and
- * left the others to it, picked to sign, not picked and watching. All of them
- * are the same thing to a reader deciding where to look, which is "not here",
- * and the row's own status line says which one it is.
+ * The stage where a proposal can still die of indifference. Refusals are
+ * counted against `FrostSigningSession.declinesThatAbandon`, so one more may
+ * end it; and a member who is simply offline is indistinguishable from one
+ * who has not looked. It is also the only stage the coordinator's resend is
+ * for, which is the practical reason this is not merged with
+ * [BEING_SIGNED]: these are the proposals somebody may have to do something
+ * about.
*/
- IN_PROGRESS,
+ WAITING_ON_MEMBERS,
+
+ /**
+ * The signer set is fixed, and the chosen signers are producing signatures.
+ *
+ * Nothing anybody can be asked here. `signerIds` is written once and never
+ * revised, so no further refusal is counted against it -- what is left is
+ * the signers' devices finishing arithmetic they have already committed to.
+ * Where [WAITING_ON_MEMBERS] asks whether this will happen, this one says it
+ * is happening.
+ *
+ * Whether *this* device was among the chosen is not a state of the proposal
+ * but a fact about the reader, and the row's status line says it. Splitting
+ * on it would be splitting every state by who is looking.
+ */
+ BEING_SIGNED,
/** Aggregated and verified. The group signed it. */
SIGNED,
diff --git a/composeApp/src/commonTest/kotlin/to/curare/compose/ui/view/state/ProposalFilterTest.kt b/composeApp/src/commonTest/kotlin/to/curare/compose/ui/view/state/ProposalFilterTest.kt
index edfea3a6..3d848dca 100644
--- a/composeApp/src/commonTest/kotlin/to/curare/compose/ui/view/state/ProposalFilterTest.kt
+++ b/composeApp/src/commonTest/kotlin/to/curare/compose/ui/view/state/ProposalFilterTest.kt
@@ -68,15 +68,52 @@ class ProposalFilterTest {
private val open = proposal("open").copy(
session = session("open").copy(signApprovedAt = Clock.System.now())
)
+ private val beingSigned = proposal(
+ "signing",
+ stage = FrostSigningStage.COLLECTING_PARTIAL_SIGNATURES,
+ ).copy(
+ session = session("signing", FrostSigningStage.COLLECTING_PARTIAL_SIGNATURES)
+ .copy(signApprovedAt = Clock.System.now(), signerIds = "1,2")
+ )
private val signed = proposal("signed", stage = FrostSigningStage.COMPLETE)
private val abandoned = proposal("abandoned", stage = FrostSigningStage.FAILED)
private fun loaded(filter: ProposalFilter = ProposalFilter.ALL) = ProposalListUIState.Loaded(
localChatRoom = room,
- proposals = listOf(needsYou, alsoNeedsYou, open, signed, abandoned),
+ proposals = listOf(needsYou, alsoNeedsYou, open, beingSigned, signed, abandoned),
filter = filter,
)
+ /**
+ * The chips run in lifecycle order behind "all", which is the order a reader
+ * scans them in and the order the states actually happen in.
+ *
+ * Pinned here rather than on the screen: the row scrolls, so a chip past the
+ * right edge has no measurable position, and the order is a property of the
+ * enum anyway.
+ */
+ @Test
+ fun `the chips run in lifecycle order, with all of them first`() {
+ assertEquals(
+ listOf(
+ ProposalFilter.ALL,
+ ProposalFilter.NEEDS_YOU,
+ ProposalFilter.WAITING_ON_MEMBERS,
+ ProposalFilter.BEING_SIGNED,
+ ProposalFilter.SIGNED,
+ ProposalFilter.ABANDONED,
+ ),
+ ProposalFilter.entries
+ )
+
+ // And the states they select are in their own declaration order, so the
+ // two enums cannot drift into disagreeing about what follows what.
+ assertEquals(
+ ProposalState.entries,
+ ProposalFilter.entries.mapNotNull { it.state }
+ )
+ }
+
@Test
fun `every filter but ALL names exactly one state, and ALL names none`() {
assertEquals(null, ProposalFilter.ALL.state)
@@ -97,6 +134,25 @@ class ProposalFilterTest {
}
}
+ /**
+ * The two open stages are two chips.
+ *
+ * Short of members, a proposal can still die of indifference and the
+ * coordinator's resend is the lever for it; once the signer set is fixed
+ * there is nothing to do but wait. One chip over both would file "somebody
+ * may have to chase this" with "nothing to do".
+ */
+ @Test
+ fun `an open proposal is filed by whether it is still short of members`() {
+ assertEquals(ProposalState.WAITING_ON_MEMBERS, open.state)
+ assertEquals(ProposalState.BEING_SIGNED, beingSigned.state)
+
+ assertEquals(
+ listOf(ProposalFilter.WAITING_ON_MEMBERS, ProposalFilter.BEING_SIGNED),
+ ProposalFilter.entries.filter { it.state in setOf(open.state, beingSigned.state) }
+ )
+ }
+
@Test
fun `the default shows everything, in the order it arrived`() {
val state = loaded()
@@ -108,7 +164,8 @@ class ProposalFilterTest {
@Test
fun `a filter narrows the rows to its own state`() {
assertEquals(listOf(needsYou, alsoNeedsYou), loaded(ProposalFilter.NEEDS_YOU).visible)
- assertEquals(listOf(open), loaded(ProposalFilter.IN_PROGRESS).visible)
+ assertEquals(listOf(open), loaded(ProposalFilter.WAITING_ON_MEMBERS).visible)
+ assertEquals(listOf(beingSigned), loaded(ProposalFilter.BEING_SIGNED).visible)
assertEquals(listOf(signed), loaded(ProposalFilter.SIGNED).visible)
assertEquals(listOf(abandoned), loaded(ProposalFilter.ABANDONED).visible)
}
@@ -118,19 +175,20 @@ class ProposalFilterTest {
val state = loaded(ProposalFilter.SIGNED)
assertEquals(1, state.visible.size)
- assertEquals(5, state.proposals.size)
+ assertEquals(6, state.proposals.size)
// The split is the room's, not the selection's: it is what ALL renders,
// and a filtered screen does not draw it at all.
assertEquals(2, state.waitingForYou.size)
- assertEquals(3, state.rest.size)
+ assertEquals(4, state.rest.size)
}
@Test
fun `the counts are of the room, so they do not move when the filter does`() {
val expected = mapOf(
ProposalState.NEEDS_YOU to 2,
- ProposalState.IN_PROGRESS to 1,
+ ProposalState.WAITING_ON_MEMBERS to 1,
+ ProposalState.BEING_SIGNED to 1,
ProposalState.SIGNED to 1,
ProposalState.ABANDONED to 1,
)
diff --git a/composeApp/src/commonTest/kotlin/to/curare/compose/ui/view/state/ProposalStateTest.kt b/composeApp/src/commonTest/kotlin/to/curare/compose/ui/view/state/ProposalStateTest.kt
index 8d9ab019..2dcb1eb8 100644
--- a/composeApp/src/commonTest/kotlin/to/curare/compose/ui/view/state/ProposalStateTest.kt
+++ b/composeApp/src/commonTest/kotlin/to/curare/compose/ui/view/state/ProposalStateTest.kt
@@ -2,6 +2,7 @@ package to.curare.compose.ui.view.state
import kotlin.test.Test
import kotlin.test.assertEquals
+import kotlin.test.assertFalse
import kotlin.test.assertTrue
import kotlin.time.Clock
import to.curare.compose.database.model.ChatRoom
@@ -95,26 +96,66 @@ class ProposalStateTest {
}
@Test
- fun `agreeing moves it out of your queue without closing it`() {
+ fun `agreeing moves it out of your queue, still short of members`() {
val agreed = session().copy(signApprovedAt = Clock.System.now())
- assertEquals(ProposalState.IN_PROGRESS, proposal(agreed).state)
+ assertEquals(ProposalState.WAITING_ON_MEMBERS, proposal(agreed).state)
}
@Test
fun `refusing moves it out of your queue too, because either answer is an answer`() {
val declined = session().copy(signDeclinedAt = Clock.System.now())
- assertEquals(ProposalState.IN_PROGRESS, proposal(declined).state)
+ assertEquals(ProposalState.WAITING_ON_MEMBERS, proposal(declined).state)
}
+ /**
+ * The two open stages are two states, and this is the pair that carries the
+ * distinction.
+ *
+ * Short of members, the proposal can still die of indifference: refusals are
+ * counted against `declinesThatAbandon`, and an offline member is
+ * indistinguishable from one who has not looked. It is also the only stage
+ * the coordinator's resend is for. Once the signer set is written neither is
+ * true -- `signerIds` is written once and never revised -- so what is left is
+ * arithmetic the chosen devices have already committed to.
+ *
+ * Collapsing the two would file "somebody may have to chase this" and
+ * "nothing to do but wait" under one chip.
+ */
@Test
- fun `a session gathering signatures is in progress whether or not you were picked`() {
+ fun `fixing the signer set is what moves it from waiting on members to being signed`() {
+ val answered = session().copy(signApprovedAt = Clock.System.now())
+
+ assertEquals(ProposalState.WAITING_ON_MEMBERS, proposal(answered).state)
+
+ val fixed = answered.copy(
+ stage = FrostSigningStage.COLLECTING_PARTIAL_SIGNATURES,
+ signerIds = "1,2",
+ )
+
+ assertEquals(ProposalState.BEING_SIGNED, proposal(fixed).state)
+ }
+
+ /**
+ * Whether this device was picked is a fact about the reader, not a state of
+ * the proposal, so it does not move it between chips. The row's status line
+ * says which it is -- "you are signing" against "enough members took part
+ * without you" -- and that is where a fact about the reader belongs.
+ */
+ @Test
+ fun `being signed does not depend on whether you were picked to sign it`() {
val collecting = session(stage = FrostSigningStage.COLLECTING_PARTIAL_SIGNATURES)
.copy(signApprovedAt = Clock.System.now())
- assertEquals(ProposalState.IN_PROGRESS, proposal(collecting.copy(signerIds = "1,2")).state)
- assertEquals(ProposalState.IN_PROGRESS, proposal(collecting.copy(signerIds = "1,3")).state)
+ val picked = collecting.copy(signerIds = "1,2")
+ val passedOver = collecting.copy(signerIds = "1,3")
+
+ assertTrue(picked.isSigner(), "the fixture should have this device signing")
+ assertFalse(passedOver.isSigner(), "the fixture should have this device passed over")
+
+ assertEquals(ProposalState.BEING_SIGNED, proposal(picked).state)
+ assertEquals(ProposalState.BEING_SIGNED, proposal(passedOver).state)
}
@Test
@@ -159,15 +200,15 @@ class ProposalStateTest {
* `isAwaitingApproval` stops asking once every item carries a signature,
* because `advance` closes the session on its next pass and the only answers
* left to give are a nonce nobody is waiting for or a refusal nobody counts.
- * The stage has not caught up yet, so this is in progress -- which is also
- * what the row says: "enough members took part without you".
+ * The stage has not caught up yet, so it is still being signed -- which is
+ * also what the row says: "enough members took part without you".
*/
@Test
- fun `a fully signed batch is in progress until advance closes it`() {
+ fun `a fully signed batch is still being signed until advance closes it`() {
val signed = session(stage = FrostSigningStage.COLLECTING_PARTIAL_SIGNATURES)
val items = listOf(item(signature = "ab".repeat(32)))
- assertEquals(ProposalState.IN_PROGRESS, proposal(signed, items).state)
+ assertEquals(ProposalState.BEING_SIGNED, proposal(signed, items).state)
}
/**
@@ -194,6 +235,10 @@ class ProposalStateTest {
val proposals = listOf(
proposal(session(id = "needs")),
proposal(session(id = "open").copy(signApprovedAt = Clock.System.now())),
+ proposal(
+ session(id = "signing", stage = FrostSigningStage.COLLECTING_PARTIAL_SIGNATURES)
+ .copy(signApprovedAt = Clock.System.now(), signerIds = "1,2")
+ ),
proposal(session(id = "done", stage = FrostSigningStage.COMPLETE)),
proposal(session(id = "gone", stage = FrostSigningStage.FAILED)),
)
@@ -204,17 +249,12 @@ class ProposalStateTest {
)
assertEquals(1, loaded.waitingForYou.size)
- assertEquals(3, loaded.rest.size)
+ assertEquals(4, loaded.rest.size)
assertEquals(proposals.size, loaded.waitingForYou.size + loaded.rest.size)
- assertEquals(
- setOf(
- ProposalState.NEEDS_YOU,
- ProposalState.IN_PROGRESS,
- ProposalState.SIGNED,
- ProposalState.ABANDONED,
- ),
- proposals.map { it.state }.toSet()
- )
+
+ // One of each, and every state reached: five proposals, five states.
+ assertEquals(ProposalState.entries.toSet(), proposals.map { it.state }.toSet())
+ assertEquals(proposals.size, proposals.map { it.state }.distinct().size)
}
/** The split is the classification, not a second reading of `awaitsYou`. */
diff --git a/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/composable/ProposalListScreenJvmTest.kt b/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/composable/ProposalListScreenJvmTest.kt
index b4239dac..fe2db71e 100644
--- a/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/composable/ProposalListScreenJvmTest.kt
+++ b/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/composable/ProposalListScreenJvmTest.kt
@@ -71,10 +71,12 @@ class ProposalListScreenJvmTest {
stage: FrostSigningStage = FrostSigningStage.COLLECTING_NONCES,
awaitsYou: Boolean = false,
approved: Boolean = false,
+ signerIds: String? = null,
) = ProposalListUIState.Proposal(
session = session.copy(
id = id,
stage = stage,
+ signerIds = signerIds,
signApprovedAt = Clock.System.now().takeIf { approved },
),
proposerName = "Ada",
@@ -85,9 +87,15 @@ class ProposalListScreenJvmTest {
private val needsYou = proposal("needs", "New chapter", "Genesis 1", awaitsYou = true)
private val alsoNeedsYou = proposal("also", "New chapter", "Genesis 2", awaitsYou = true)
private val open = proposal("open", "New translation", "isiZulu", approved = true)
+ private val beingSigned = proposal(
+ "signing", "New chapter", "Genesis 4",
+ stage = FrostSigningStage.COLLECTING_PARTIAL_SIGNATURES,
+ approved = true,
+ signerIds = "1,2",
+ )
private val signed = proposal("signed", "New post", "A note", stage = FrostSigningStage.COMPLETE)
- private val mixed = listOf(needsYou, alsoNeedsYou, open, signed)
+ private val mixed = listOf(needsYou, alsoNeedsYou, open, beingSigned, signed)
/**
* Scrolls a chip into view and returns it.
@@ -101,24 +109,34 @@ class ProposalListScreenJvmTest {
@Test
fun `every state is offered with its own count, zero included`() = render(loaded(mixed)) {
- // Two in the queue, one in progress, one signed -- and nothing abandoned,
- // which still gets a chip rather than vanishing.
+ // Two in the queue, one short of members, one being signed, one signed --
+ // and nothing abandoned, which still gets a chip rather than vanishing.
chip("All")
chip("Needs you · 2")
- chip("In progress · 1")
+ chip("Waiting on members · 1")
+ chip("Being signed · 1")
chip("Signed · 1")
chip("Abandoned · 0")
}
+ /**
+ * Order is asserted on the chips the viewport actually lays out.
+ *
+ * The row scrolls, and a chip entirely past the right edge reports zero
+ * bounds rather than an off-screen position -- so the ones beyond the fold
+ * cannot be measured here and are not what this test is for. That the six
+ * run in lifecycle order is `ProposalFilterTest`'s to say, where it is a
+ * property of the enum and no viewport is involved.
+ */
@Test
fun `the chips are offered above the rows, in the order the states run`() =
render(loaded(mixed)) {
- val chips = listOf("All", "Needs you · 2", "In progress · 1", "Signed · 1", "Abandoned · 0")
- .map { onNodeWithText(it).getBoundsInRoot().left }
+ val laidOut = listOf("All", "Needs you · 2", "Waiting on members · 1")
+ .map { onNodeWithText(it).assertIsDisplayed().getBoundsInRoot().left }
assertTrue(
- chips.zipWithNext().all { (left, right) -> left < right },
- "the chips were drawn out of order: $chips"
+ laidOut.zipWithNext().all { (left, right) -> left < right },
+ "the chips were drawn out of order: $laidOut"
)
val chipBottom = onNodeWithText("All").getBoundsInRoot().bottom
@@ -134,9 +152,29 @@ class ProposalListScreenJvmTest {
onNodeWithText("Genesis 1").assertIsDisplayed()
onNodeWithText("Genesis 2").assertIsDisplayed()
onNodeWithText("isiZulu").assertIsDisplayed()
+ onNodeWithText("Genesis 4").assertIsDisplayed()
onNodeWithText("A note").assertIsDisplayed()
}
+ /**
+ * The two open stages are two chips, and they hold different proposals.
+ *
+ * Short of members, somebody may have to chase it -- refusals can still end
+ * it, and the coordinator's resend is for exactly this. Once the signer set
+ * is fixed there is nothing to do but wait. One chip over both would file
+ * those together.
+ */
+ @Test
+ fun `the two open stages are told apart`() = render(loaded(mixed)) {
+ chip("Waiting on members · 1").performClick()
+ onNodeWithText("isiZulu").assertIsDisplayed()
+ onAllNodesWithText("Genesis 4").assertCountEquals(0)
+
+ chip("Being signed · 1").performClick()
+ onNodeWithText("Genesis 4").assertIsDisplayed()
+ onAllNodesWithText("isiZulu").assertCountEquals(0)
+ }
+
@Test
fun `tapping a chip narrows the rows to its state`() = render(loaded(mixed)) {
chip("Signed · 1").performClick()
@@ -145,6 +183,7 @@ class ProposalListScreenJvmTest {
onAllNodesWithText("Genesis 1").assertCountEquals(0)
onAllNodesWithText("Genesis 2").assertCountEquals(0)
onAllNodesWithText("isiZulu").assertCountEquals(0)
+ onAllNodesWithText("Genesis 4").assertCountEquals(0)
}
@Test
@@ -176,7 +215,8 @@ class ProposalListScreenJvmTest {
chip("Signed · 1").performClick()
chip("Needs you · 2")
- chip("In progress · 1")
+ chip("Waiting on members · 1")
+ chip("Being signed · 1")
chip("Abandoned · 0")
}
@@ -200,15 +240,20 @@ class ProposalListScreenJvmTest {
chip("Needs you · 0").performClick()
onNodeWithText("Nothing is waiting for your signature.").assertIsDisplayed()
- chip("In progress · 1")
+ chip("Waiting on members · 1")
chip("Signed · 1")
}
@Test
fun `each filter has its own words for being empty`() {
render(loaded(listOf(needsYou))) {
- chip("In progress · 0").performClick()
- onNodeWithText("No proposal is in progress.").assertIsDisplayed()
+ chip("Waiting on members · 0").performClick()
+ onNodeWithText("No proposal is waiting on members.").assertIsDisplayed()
+ }
+
+ render(loaded(listOf(needsYou))) {
+ chip("Being signed · 0").performClick()
+ onNodeWithText("No proposal is being signed.").assertIsDisplayed()
}
render(loaded(listOf(needsYou))) {
@@ -236,6 +281,7 @@ class ProposalListScreenJvmTest {
onNodeWithText("Genesis 1").assertIsDisplayed()
onNodeWithText("Genesis 2").assertIsDisplayed()
onAllNodesWithText("A note").assertCountEquals(0)
+ onAllNodesWithText("Genesis 4").assertCountEquals(0)
onAllNodesWithText("Waiting for you").assertCountEquals(0)
}
diff --git a/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/view/model/ProposalListViewModelJvmTest.kt b/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/view/model/ProposalListViewModelJvmTest.kt
index dd3b4481..ceea09c6 100644
--- a/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/view/model/ProposalListViewModelJvmTest.kt
+++ b/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/view/model/ProposalListViewModelJvmTest.kt
@@ -94,6 +94,7 @@ class ProposalListViewModelJvmTest {
id: String,
stage: FrostSigningStage = FrostSigningStage.COLLECTING_NONCES,
approved: Boolean = false,
+ signerIds: String? = null,
) = FrostSigningSession(
id = id,
chatRoomId = chatRoomId,
@@ -104,6 +105,7 @@ class ProposalListViewModelJvmTest {
participantCount = 3,
signerId = 2,
stage = stage,
+ signerIds = signerIds,
signApprovedAt = Clock.System.now().takeIf { approved },
)
@@ -112,8 +114,9 @@ class ProposalListViewModelJvmTest {
id: String,
stage: FrostSigningStage = FrostSigningStage.COLLECTING_NONCES,
approved: Boolean = false,
+ signerIds: String? = null,
) = LocalFrostSigningSession(
- session = session(id, stage, approved),
+ session = session(id, stage, approved, signerIds),
unorderedItems = listOf(
FrostSigningItem(
sessionId = id,
@@ -132,6 +135,12 @@ class ProposalListViewModelJvmTest {
private val mixed = listOf(
local("needs"),
local("open", approved = true),
+ local(
+ "signing",
+ stage = FrostSigningStage.COLLECTING_PARTIAL_SIGNATURES,
+ approved = true,
+ signerIds = "1,2",
+ ),
local("signed", stage = FrostSigningStage.COMPLETE),
local("gone", stage = FrostSigningStage.FAILED),
)
@@ -183,11 +192,12 @@ class ProposalListViewModelJvmTest {
val loaded = model.awaitLoaded()
assertEquals(ProposalFilter.ALL, loaded.filter)
- assertEquals(4, loaded.visible.size)
+ assertEquals(5, loaded.visible.size)
assertEquals(
listOf(
ProposalState.NEEDS_YOU,
- ProposalState.IN_PROGRESS,
+ ProposalState.WAITING_ON_MEMBERS,
+ ProposalState.BEING_SIGNED,
ProposalState.SIGNED,
ProposalState.ABANDONED,
),
@@ -213,7 +223,7 @@ class ProposalListViewModelJvmTest {
val loaded = assertIs(model.proposalListUIState)
assertEquals(ProposalFilter.SIGNED, loaded.filter)
assertEquals(listOf("signed"), loaded.visible.map { it.session.id })
- assertEquals(4, loaded.proposals.size, "the room is still whole behind the filter")
+ assertEquals(5, loaded.proposals.size, "the room is still whole behind the filter")
model.viewModelScope.cancel()
}
@@ -236,14 +246,26 @@ class ProposalListViewModelJvmTest {
model.select(ProposalFilter.NEEDS_YOU)
assertEquals(listOf("needs"), model.loaded().visible.map { it.session.id })
- // Somebody else signs the open one, and a fresh proposal arrives.
+ // The coordinator fixes the signer set on the open one, and a fresh
+ // proposal arrives. The first is a move between two chips, which is the
+ // emission most likely to arrive while somebody is reading.
flow.emit(
- mixed.map { if (it.session.id == "open") local("open", FrostSigningStage.COMPLETE) else it } +
- local("fresh")
+ mixed.map {
+ if (it.session.id == "open") {
+ local(
+ "open",
+ FrostSigningStage.COLLECTING_PARTIAL_SIGNATURES,
+ approved = true,
+ signerIds = "1,2",
+ )
+ } else {
+ it
+ }
+ } + local("fresh")
)
model.await("the new proposal") {
- it is ProposalListUIState.Loaded && it.proposals.size == 5
+ it is ProposalListUIState.Loaded && it.proposals.size == 6
}
val after = model.loaded()
@@ -253,7 +275,12 @@ class ProposalListViewModelJvmTest {
after.visible.map { it.session.id },
"the filter was kept but not applied to the new rows"
)
- assertEquals(2, after.counts[ProposalState.SIGNED], "the counts did not follow the room")
+ assertEquals(
+ 0,
+ after.counts[ProposalState.WAITING_ON_MEMBERS],
+ "the counts did not follow the room"
+ )
+ assertEquals(2, after.counts[ProposalState.BEING_SIGNED])
model.viewModelScope.cancel()
}
@@ -288,7 +315,7 @@ class ProposalListViewModelJvmTest {
assertEquals(ProposalFilter.NEEDS_YOU, after.filter)
assertTrue(after.visible.isEmpty())
assertEquals(1, after.proposals.size)
- assertEquals(1, after.counts[ProposalState.IN_PROGRESS])
+ assertEquals(1, after.counts[ProposalState.WAITING_ON_MEMBERS])
model.viewModelScope.cancel()
}