stack/apps
BilalG1 f146ff21f1
fix ungrouped include by default (#924)
<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->

<!-- RECURSEML_SUMMARY:START -->
## High-level PR Summary
This PR fixes a bug where ungrouped offers with `include-by-default`
pricing were not being automatically included in subscription lists. The
fix ensures that ungrouped default offers are now properly added to the
subscriptions array when no explicit database subscription exists for
them, matching the existing behavior for grouped offers. Additionally,
it adds validation to prevent multiple `include-by-default` offers from
being configured within the same group.

⏱️ Estimated Review Time: 15-30 minutes

<details>
<summary>💡 Review Order Suggestion</summary>

| Order | File Path |
|-------|-----------|
| 1 | `apps/backend/src/lib/payments.tsx` |
| 2 | `apps/backend/src/lib/payments.test.tsx` |
</details>



[![Need help? Join our
Discord](https://img.shields.io/badge/Need%20help%3F%20Join%20our%20Discord-5865F2?style=plastic&logo=discord&logoColor=white)](https://discord.gg/n3SsVDAW6U)

<!-- RECURSEML_SUMMARY:END -->
<!-- ELLIPSIS_HIDDEN -->


----

> [!IMPORTANT]
> Fixes bug to include ungrouped `include-by-default` offers in
subscriptions and adds validation for multiple offers in the same group.
> 
>   - **Behavior**:
> - Fixes bug in `getSubscriptions()` in `payments.tsx` to include
ungrouped `include-by-default` offers in subscriptions when no explicit
subscription exists.
> - Adds validation in `getSubscriptions()` to prevent multiple
`include-by-default` offers in the same group.
>   - **Tests**:
> - Adds test cases in `payments.test.tsx` to verify inclusion of
ungrouped `include-by-default` offers and validation of multiple offers
in the same group.
>   - **Misc**:
> - Updates import in `payments.test.tsx` to include `getSubscriptions`.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for 565acc31cb. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>


<!-- ELLIPSIS_HIDDEN -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* New Features
* Subscriptions now automatically include eligible “include-by-default”
items even when they aren’t tied to a catalog, granting access without
requiring an explicit subscription.
* Consistent handling of catalog-level default items when no prior
subscriptions exist.

* Improvements
* Expanded subscriptions data to ensure all applicable default products
are surfaced to users.

* Tests
* Added comprehensive tests for default-inclusion behavior and edge
cases to improve reliability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-10-07 09:19:40 -07:00
..
backend fix ungrouped include by default (#924) 2025-10-07 09:19:40 -07:00
dashboard Payments return url (#923) 2025-10-06 14:34:11 -07:00
dev-launchpad chore: update package versions 2025-09-26 23:16:39 -05:00
e2e Payments return url (#923) 2025-10-06 14:34:11 -07:00
mock-oauth-server chore: update package versions 2025-09-26 23:16:39 -05:00
oauth-mock-server In-source unit tests (#429) 2025-02-14 11:47:52 -08:00