Resolve account subscription sync state

This commit is contained in:
2569718930@qq.com
2026-06-14 05:28:48 +08:00
parent 0084235b57
commit e783f35a4f
4 changed files with 60 additions and 1 deletions
@@ -1,6 +1,7 @@
import {
buildAuthMePath,
mergeAccountAuthSnapshot,
shouldResolveAccountUnknownWithFullProfile,
} from "@/lib/auth-snapshot";
import type { AuthSnapshotLike } from "@/lib/auth-snapshot";
@@ -64,4 +65,33 @@ export function runTests() {
inactive.subscription_active === false,
"account snapshot merge must still accept a confirmed inactive subscription response",
);
assert(
shouldResolveAccountUnknownWithFullProfile(
{ authenticated: true, subscription_active: null },
true,
),
"account center must resolve an unknown local-user subscription snapshot with the full auth profile",
);
assert(
!shouldResolveAccountUnknownWithFullProfile(
{ authenticated: true, subscription_active: false },
true,
),
"account center must not re-resolve an explicitly inactive subscription snapshot",
);
assert(
!shouldResolveAccountUnknownWithFullProfile(
{ authenticated: false, subscription_active: null },
true,
),
"account center must not re-resolve an unauthenticated backend snapshot",
);
assert(
!shouldResolveAccountUnknownWithFullProfile(
{ authenticated: true, subscription_active: null },
false,
),
"account center must only resolve unknown subscription snapshots when a local Supabase user exists",
);
}