Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

feat: stateful / sequential mocks

Chiusa
#96 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
kotlin
Ambito
testing, tooling

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

enhancement stale

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 OperationMockState variant, e.g. Sequence(responses: List<Mock>, currentIndex: Int) (naming/shape to be finalized against whatever #3's rename settles on), alongside Network and Mock.
  • 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 of NetworkMockState persists) or in-memory only (resets on process death) and document the choice; recommend DataStore for consistency with everything else in NetworkMockState.
  • 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) and NetworkMockState.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 to Network — 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.kt
  • devview-networkmock-core/src/commonMain/kotlin/com/worldline/devview/networkmock/core/repository/MockStateRepository.kt
  • devview-networkmock-ktor/src/commonMain/kotlin/com/worldline/devview/networkmock/ktor/plugin/NetworkMockPlugin.kt
  • devview-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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di worldline/devview

Tutte le issue di worldline/devview

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.