Skip to content

test(workflows): fill test gaps from code review of 4xx stale-restore fix#6948

Merged
facumenzella merged 1 commit into
facu/workflow-list-4xx-no-stalefrom
cesar/workflow-list-4xx-test-coverage
Jun 8, 2026
Merged

test(workflows): fill test gaps from code review of 4xx stale-restore fix#6948
facumenzella merged 1 commit into
facu/workflow-list-4xx-no-stalefrom
cesar/workflow-list-4xx-test-coverage

Conversation

@vegaro

@vegaro vegaro commented Jun 8, 2026

Copy link
Copy Markdown
Member

Checklist

  • If applicable, unit tests
  • If applicable, create follow-up issues for purchases-android and hybrids

Motivation

Code review of # surfaced two test gaps in the 4xx stale-restore fix:

  1. testGetWorkflowsListDoesNotRestoreFromDiskOnClientError never asserted onComplete() fires on 4xx — if that call were accidentally dropped, callers would hang with no test catching it.
  2. testGetWorkflowsListRestoresFromDiskOnServerError only checked that the list mapping was restored on 5xx, but not that workflow details were also restored from disk.

Description

Adds two targeted tests to close those gaps:

  • testGetWorkflowsListCallsOnCompleteOnClientError: verifies onComplete() fires on a 4xx even though disk restore is skipped.
  • testGetWorkflowsListRestoresDetailsFromDiskOnServerError: verifies that on 5xx both the list mapping and workflow details are restored from disk, not just the list.

Note

Low Risk
Test-only changes with no production code modifications.

Overview
Adds two unit tests in WorkflowManagerTests to cover behaviors from the workflows 4xx stale-restore fix that were missing from review.

testGetWorkflowsListRestoresDetailsFromDiskOnServerError asserts that on a 5xx workflows-list failure, prefetched workflow details on disk are restored into WorkflowsCache, not only the offering→workflow list mapping (which an existing test already covered).

testGetWorkflowsListCallsOnCompleteOnClientError asserts that onComplete still runs on a 4xx when disk restore is skipped, so callers such as offerings delivery are not left waiting indefinitely.

Reviewed by Cursor Bugbot for commit 5e3f924. Bugbot is set up for automated code reviews on this repo. Configure here.

- testGetWorkflowsListCallsOnCompleteOnClientError: verifies onComplete()
  fires on 4xx even though disk restore is skipped (callers must not block)
- testGetWorkflowsListRestoresDetailsFromDiskOnServerError: verifies that
  on 5xx both list mapping AND workflow details are restored from disk, not
  just the list mapping

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vegaro vegaro added the pr:other label Jun 8, 2026
@facumenzella facumenzella marked this pull request as ready for review June 8, 2026 19:23
@facumenzella facumenzella requested a review from a team as a code owner June 8, 2026 19:23
@facumenzella facumenzella merged commit 27de0b8 into facu/workflow-list-4xx-no-stale Jun 8, 2026
18 of 20 checks passed
@facumenzella facumenzella deleted the cesar/workflow-list-4xx-test-coverage branch June 8, 2026 19:23
facumenzella added a commit that referenced this pull request Jun 8, 2026
…the request (#6946)

* fix(workflows): don't restore stale workflows from disk on a 4xx

The getWorkflowsList failure branch restored the cached list + details
on any error. That's right for transient errors (5xx / offline) but
wrong for a 4xx, where the backend is authoritatively rejecting the
request (workflows disabled, unauthorized), so we shouldn't serve stale
prefetched data.

Generalize the existing offerings classification into
BackendError/NetworkError.shouldFallBackToCache (the offerings property
now delegates to it, no behavior change) and gate the workflows disk
restore on it. 4xx skips the restore; 5xx and connection failures still
restore.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(workflows): fill gaps found in code review of 4xx stale-restore fix (#6948)

- testGetWorkflowsListCallsOnCompleteOnClientError: verifies onComplete()
  fires on 4xx even though disk restore is skipped (callers must not block)
- testGetWorkflowsListRestoresDetailsFromDiskOnServerError: verifies that
  on 5xx both list mapping AND workflow details are restored from disk, not
  just the list mapping

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor: drop redundant shouldFallBackToCachedOfferings alias

Per review: shouldFallBackToCachedOfferings was only a thin delegate to
shouldFallBackToCache after the prior refactor. Remove it on NetworkError
and BackendError and point callers (OfferingsManager, tests) at
shouldFallBackToCache directly. Behavior-preserving.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Cesar de la Vega <664544+vegaro@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants