From 1f26ecdd01a66f10dbd6ddf862a3702c61bc05e9 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Tue, 29 Sep 2026 09:13:32 +0000 Subject: [PATCH] test(agent): make the grant no-persistence check order-independent and pin the sign-out clear (#19184) *PR Created by the Glary-Bot Agent* --- Test-only follow-up to [#19074](https://github.com/Comfy-Org/ComfyUI_frontend/pull/19074), which stopped Agent access granted to one signed-in account from persisting for another account. ## What this changes The grant-persistence regression test now runs independently of test order. Each test clears browser storage and resets the module-scoped cached feature values. The persistence case primes only the two feature flags that are intentionally stored, takes complete storage snapshots, and performs one authenticated refresh with Agent access enabled. Any new persisted key still changes the snapshot and fails the test. The identity-invalidation test now seeds both the transient Agent grant and its expiry time before checking that `invalidateRemoteConfig()` clears them. This prevents either assertion from passing on empty setup. No production code changes. ## Regression evidence | Mutation | Result | |---|---| | Persist the Agent grant under `agent-in-app-experience` | Caught by the full-file and isolated test | | Persist it under `session_whitelist` | Caught by the full-file and isolated test | | Persist it under an arbitrary key | Caught by the full-file and isolated test | | Stop clearing the grant during identity invalidation | Caught by the invalidation test | | Stop clearing the grant expiry during identity invalidation | Caught independently by the invalidation test | ## Verification - `src/platform/remoteConfig/refreshRemoteConfig.test.ts`: 24/24 passed - `src/platform/remoteConfig`: 24/24 passed - Isolated grant-persistence regression: 1/1 passed - Format, lint, typecheck, Fallow, hosted unit-test shards, Codecov, and automated review passed on the reviewed head --------- Co-authored-by: Glary-Bot Co-authored-by: Alexander Brown --- .../remoteConfig/refreshRemoteConfig.test.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/platform/remoteConfig/refreshRemoteConfig.test.ts b/src/platform/remoteConfig/refreshRemoteConfig.test.ts index 37f9a7c294b..75426c856f2 100644 --- a/src/platform/remoteConfig/refreshRemoteConfig.test.ts +++ b/src/platform/remoteConfig/refreshRemoteConfig.test.ts @@ -8,7 +8,9 @@ import { } from './refreshRemoteConfig' import { authenticatedRemoteConfigState, + cachedBillingControlEnabled, cachedLegacyBillingMigrationEnabled, + cachedV1PaymentRecovery, remoteConfig, remoteConfigErrorStatus, remoteConfigRevision, @@ -66,6 +68,8 @@ describe('refreshRemoteConfig', () => { authenticatedRemoteConfigState.value = 'unloaded' remoteConfigRevision.value = 0 cachedLegacyBillingMigrationEnabled.value = undefined + cachedBillingControlEnabled.value = undefined + cachedV1PaymentRecovery.value = undefined sessionAgentGrant.value = undefined sessionAgentGrantValidUntil.value = undefined window.__CONFIG__ = {} @@ -79,6 +83,8 @@ describe('refreshRemoteConfig', () => { comfy_platform_base_url: 'https://platform.example.com' } window.__CONFIG__ = remoteConfig.value + sessionAgentGrant.value = true + sessionAgentGrantValidUntil.value = Date.now() + 60_000 invalidateRemoteConfig() @@ -89,6 +95,7 @@ describe('refreshRemoteConfig', () => { }) expect(window.__CONFIG__).toEqual(remoteConfig.value) expect(remoteConfigState.value).toBe('unloaded') + expect(sessionAgentGrant.value).toBeUndefined() expect(authenticatedRemoteConfigState.value).toBe('unloaded') expect(sessionAgentGrantValidUntil.value).toBeUndefined() }) @@ -365,7 +372,12 @@ describe('refreshRemoteConfig', () => { }) it("records this session's grant without persisting it anywhere", async () => { - sessionAgentGrant.value = undefined + // Prime the two feature values that are intentionally backed by storage, + // so any storage delta below can only come from the session grant. + localStorage.setItem('billing_control_enabled', 'false') + localStorage.setItem('v1_payment_recovery', 'false') + cachedBillingControlEnabled.value = false + cachedV1PaymentRecovery.value = false const localStorageBefore = storageEntries(localStorage) const sessionStorageBefore = storageEntries(sessionStorage) mockAuthenticatedFetch(