feat: stateful / sequential mocks
I maintainer di solito rispondono entro 17 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start with NetworkMockState.kt, MockStateRepository.kt, and NetworkMockPlugin.kt to trace state persistence, reset behavior, and response resolution; then inspect NetworkMockEndpointScreen.kt for the UI entry point. Confirm the naming after #3 and dependencies on #78, then define the sequence, exhaustion, persistence, and reset behavior. Done means ordered responses advance correctly, stick on the last response, reset to position 0, and have tests covering those cases.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Part of #72
Depends on #78 (the DataStore key-shape migration — this issue adds a new piece of persisted state, better to land after that migration than alongside it).
Summary
Add stateful/sequential mocks: an operation can be configured to return a different response on successive calls (e.g. first call returns 202 Pending, second call returns 200 Success, further calls stay at 200 Success). This is a new capability — nothing in DevView supports it today.
Why this is useful
The most common manual-testing gap this fills: polling flows (order status, upload progress, async job completion) where the interesting behavior is the transition between states across repeated calls to the same endpoint, not any single response in isolation. Today, an operation's mock is static for the duration it's selected — there's no way to make "call it three times and watch the state progress" happen without manually flipping the selected mock between calls.
Verified: this doesn't exist anywhere today
NetworkMockState (devview-networkmock-core/src/commonMain/kotlin/com/worldline/devview/networkmock/core/model/NetworkMockState.kt:68-72) holds only globalMockingEnabled, endpointStates, lastModified — no counter of any kind. EndpointMockState/OperationMockState (:204-262) is a two-variant sealed interface (Network/Mock) with no sequence concept. The plugin resolves a response once per request with no per-call state (NetworkMockPlugin.kt:223-293).
What to build
- A new
OperationMockStatevariant, e.g.Sequence(responses: List<Mock>, currentIndex: Int)(naming/shape to be finalized against whatever #3's rename settles on), alongsideNetworkandMock. - A per-operation call counter, keyed by
OperationKey, incremented each time the sequence variant is matched and served. This needs a persisted or at-least-session-scoped counter — decide whether it lives in DataStore (survives app restart, consistent with how the rest ofNetworkMockStatepersists) or in-memory only (resets on process death) and document the choice; recommend DataStore for consistency with everything else inNetworkMockState. - Exhaustion behavior: decide what happens once the sequence is exhausted. Recommend stick on last (matches the "third call onward stays at 200 Success" example above) over looping back to the start or falling through to the real network — stick-on-last is the least surprising default and matches how most real async-completion flows behave (the terminal state is stable, not cyclic).
- Reset interaction: the counter must reset alongside existing mock-state resets —
MockStateRepository.resetKnownEndpointsToNetwork()(devview-networkmock-core/src/commonMain/kotlin/com/worldline/devview/networkmock/core/repository/MockStateRepository.kt:362-369) andNetworkMockState.resetAllToNetwork()(devview-networkmock-core/src/commonMain/kotlin/com/worldline/devview/networkmock/core/model/NetworkMockState.kt:148-151) both need to clear any in-progress sequence position, not just revert toNetwork— otherwise a reset followed by re-selecting the same sequence resumes mid-sequence instead of restarting at index 0. - UI: a way to declare/reorder the sequence of responses for an operation in the endpoint detail screen (#79), and to see/reset the current position.
Acceptance criteria
- An operation can be configured with an ordered sequence of responses.
- Repeated calls to the operation advance through the sequence in order.
- The sequence sticks on the last response once exhausted (or documents a different, deliberately chosen behavior).
- Resetting an operation's mock state (individually or via "reset all") also resets its sequence position to 0.
- Tests cover: advancing through a sequence, exhaustion behavior, and reset-clears-position.
Files likely touched
devview-networkmock-core/src/commonMain/kotlin/com/worldline/devview/networkmock/core/model/NetworkMockState.ktdevview-networkmock-core/src/commonMain/kotlin/com/worldline/devview/networkmock/core/repository/MockStateRepository.ktdevview-networkmock-ktor/src/commonMain/kotlin/com/worldline/devview/networkmock/ktor/plugin/NetworkMockPlugin.ktdevview-networkmock/src/commonMain/kotlin/com/worldline/devview/networkmock/NetworkMockEndpointScreen.kt
- Lingua principale
- Kotlin
- Stelle
- 11
- Fork
- 3
- Merge medio
- 10g 9h
- PR unite (30g)
- 18
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di worldline/devview
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
worldline/devview#99 · 4 commenti ·
I maintainer di solito rispondono entro 17 giorni
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
worldline/devview#97 · 4 commenti ·
I maintainer di solito rispondono entro 17 giorni
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
worldline/devview#95 · 4 commenti ·
I maintainer di solito rispondono entro 17 giorni
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
worldline/devview#85 · 3 commenti ·
I maintainer di solito rispondono entro 17 giorni
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
worldline/devview#84 · 3 commenti ·
I maintainer di solito rispondono entro 17 giorni
Tutte le issue di worldline/devview
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
ankidroid/Anki-Android#22408 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 72/100
afarber/OpenMapView#22 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
nightscout/AndroidAPS#5245 ·
I maintainer di solito rispondono entro 1 giorno
-
Feature:Resolution
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
intellij-elixir/intellij-elixir#4396 ·
I maintainer di solito rispondono entro 1 giorno