@@ -10,7 +10,7 @@ import (
1010 "github.com/supabase/cli/internal/testing/apitest"
1111)
1212
13- var projectJSON = map [string ]interface {}{
13+ var planGateProjectJSON = map [string ]interface {}{
1414 "ref" : "test-ref" ,
1515 "organization_slug" : "my-org" ,
1616 "name" : "test" ,
@@ -28,7 +28,7 @@ func TestGetOrgSlugFromProjectRef(t *testing.T) {
2828 gock .New (DefaultApiHost ).
2929 Get ("/v1/projects/" + ref ).
3030 Reply (http .StatusOK ).
31- JSON (projectJSON )
31+ JSON (planGateProjectJSON )
3232 slug , err := GetOrgSlugFromProjectRef (context .Background (), ref )
3333 assert .NoError (t , err )
3434 assert .Equal (t , "my-org" , slug )
@@ -80,7 +80,7 @@ func TestSuggestUpgradeOnError(t *testing.T) {
8080 gock .New (DefaultApiHost ).
8181 Get ("/v1/projects/" + ref ).
8282 Reply (http .StatusOK ).
83- JSON (projectJSON )
83+ JSON (planGateProjectJSON )
8484 gock .New (DefaultApiHost ).
8585 Get ("/v1/organizations/my-org/entitlements" ).
8686 Reply (http .StatusOK ).
@@ -96,7 +96,7 @@ func TestSuggestUpgradeOnError(t *testing.T) {
9696 gock .New (DefaultApiHost ).
9797 Get ("/v1/projects/" + ref ).
9898 Reply (http .StatusOK ).
99- JSON (projectJSON )
99+ JSON (planGateProjectJSON )
100100 gock .New (DefaultApiHost ).
101101 Get ("/v1/organizations/my-org/entitlements" ).
102102 Reply (http .StatusInternalServerError )
@@ -113,9 +113,26 @@ func TestSuggestUpgradeOnError(t *testing.T) {
113113 Reply (http .StatusNotFound )
114114 SuggestUpgradeOnError (context .Background (), ref , "branching_limit" , http .StatusPaymentRequired )
115115 assert .Contains (t , CmdSuggestion , "plan upgrade" )
116+ assert .Contains (t , CmdSuggestion , GetSupabaseDashboardURL ())
116117 assert .NotContains (t , CmdSuggestion , "/org/" )
117118 })
118119
120+ t .Run ("sets generic suggestion when feature has access" , func (t * testing.T ) {
121+ t .Cleanup (apitest .MockPlatformAPI (t ))
122+ t .Cleanup (func () { CmdSuggestion = "" })
123+ gock .New (DefaultApiHost ).
124+ Get ("/v1/projects/" + ref ).
125+ Reply (http .StatusOK ).
126+ JSON (planGateProjectJSON )
127+ gock .New (DefaultApiHost ).
128+ Get ("/v1/organizations/my-org/entitlements" ).
129+ Reply (http .StatusOK ).
130+ JSON (entitlementsJSON ("branching_limit" , true ))
131+ SuggestUpgradeOnError (context .Background (), ref , "branching_limit" , http .StatusPaymentRequired )
132+ assert .Contains (t , CmdSuggestion , "/org/my-org/billing" )
133+ assert .Contains (t , CmdSuggestion , "may require a plan upgrade" )
134+ })
135+
119136 t .Run ("skips suggestion on 403 forbidden" , func (t * testing.T ) {
120137 CmdSuggestion = ""
121138 SuggestUpgradeOnError (context .Background (), ref , "branching_limit" , http .StatusForbidden )
0 commit comments