Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
@@ -241,6 +241,143 @@ describe("evaluateEntitlement", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("falls back to the generic message when an active trial omits a trial message", () => {
|
||||
expect(
|
||||
evaluateEntitlement({
|
||||
featureKey: "api",
|
||||
trialActive: true,
|
||||
limitType: entitlementLimitTypes.included,
|
||||
message: "Generic upgrade hint",
|
||||
}),
|
||||
).toEqual({
|
||||
allowed: true,
|
||||
reason: "trial-active",
|
||||
featureKey: "api",
|
||||
limitType: 1,
|
||||
period: undefined,
|
||||
trialPeriod: undefined,
|
||||
message: "Generic upgrade hint",
|
||||
});
|
||||
});
|
||||
|
||||
it("prefers the trial message over the generic message when an expired trial provides one", () => {
|
||||
expect(
|
||||
evaluateEntitlement({
|
||||
featureKey: "api",
|
||||
trialActive: false,
|
||||
trialPeriod: "trial-ended",
|
||||
trialMessage: "Your trial has ended",
|
||||
message: "Generic upgrade hint",
|
||||
limitType: entitlementLimitTypes.included,
|
||||
}),
|
||||
).toMatchObject({
|
||||
allowed: false,
|
||||
reason: "trial-expired",
|
||||
featureKey: "api",
|
||||
limitType: 1,
|
||||
trialPeriod: "trial-ended",
|
||||
message: "Your trial has ended",
|
||||
});
|
||||
});
|
||||
|
||||
it("treats non-finite usage counters as zero for max-limited features", () => {
|
||||
expect(
|
||||
evaluateEntitlement({
|
||||
featureKey: "users",
|
||||
hasSubscription: true,
|
||||
limitType: entitlementLimitTypes.max,
|
||||
limit: Number.NaN,
|
||||
used: Number.POSITIVE_INFINITY,
|
||||
}),
|
||||
).toMatchObject({
|
||||
allowed: false,
|
||||
reason: "max-exhausted",
|
||||
featureKey: "users",
|
||||
limitType: 3,
|
||||
limit: 0,
|
||||
used: 0,
|
||||
remaining: 0,
|
||||
});
|
||||
});
|
||||
|
||||
it("clamps negative limit and usage counters to zero", () => {
|
||||
expect(
|
||||
evaluateEntitlement({
|
||||
featureKey: "ai-credits",
|
||||
hasSubscription: true,
|
||||
limitType: entitlementLimitTypes.monthly,
|
||||
limit: -100,
|
||||
used: -50,
|
||||
period: "2026-06",
|
||||
}),
|
||||
).toMatchObject({
|
||||
allowed: false,
|
||||
reason: "monthly-exhausted",
|
||||
featureKey: "ai-credits",
|
||||
limitType: 2,
|
||||
limit: 0,
|
||||
used: 0,
|
||||
remaining: 0,
|
||||
period: "2026-06",
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to a missing limit as an exhausted quota for usage-limited features", () => {
|
||||
expect(
|
||||
evaluateEntitlement({
|
||||
featureKey: "users",
|
||||
hasSubscription: true,
|
||||
limitType: entitlementLimitTypes.max,
|
||||
}),
|
||||
).toMatchObject({
|
||||
allowed: false,
|
||||
reason: "max-exhausted",
|
||||
featureKey: "users",
|
||||
limitType: 3,
|
||||
limit: 0,
|
||||
used: 0,
|
||||
remaining: 0,
|
||||
});
|
||||
});
|
||||
|
||||
it("denies subscribed features when the limit type is unset (default branch)", () => {
|
||||
expect(
|
||||
evaluateEntitlement({
|
||||
featureKey: "api",
|
||||
hasSubscription: true,
|
||||
}),
|
||||
).toMatchObject({
|
||||
allowed: false,
|
||||
reason: "not-included",
|
||||
featureKey: "api",
|
||||
limitType: undefined,
|
||||
limit: undefined,
|
||||
used: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it("denies subscribed features for an unsupported limit type and reports normalized counters", () => {
|
||||
expect(
|
||||
evaluateEntitlement({
|
||||
featureKey: "users",
|
||||
hasSubscription: true,
|
||||
limitType: 99 as never,
|
||||
limit: 7,
|
||||
used: 2,
|
||||
period: "2026-06",
|
||||
message: "Unsupported plan limit",
|
||||
}),
|
||||
).toMatchObject({
|
||||
allowed: false,
|
||||
reason: "not-included",
|
||||
featureKey: "users",
|
||||
limit: 7,
|
||||
used: 2,
|
||||
period: "2026-06",
|
||||
message: "Unsupported plan limit",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps reason codes stable for package-boundary consumers", () => {
|
||||
expect(stableReasonCodes).toEqual([
|
||||
"included",
|
||||
|
||||
Reference in new issue
Block a user