diff --git a/bubble-server/src/main/java/bubble/resources/bill/AccountPlansResource.java b/bubble-server/src/main/java/bubble/resources/bill/AccountPlansResource.java index a4e9ee11..537e3443 100644 --- a/bubble-server/src/main/java/bubble/resources/bill/AccountPlansResource.java +++ b/bubble-server/src/main/java/bubble/resources/bill/AccountPlansResource.java @@ -184,7 +184,13 @@ public class AccountPlansResource extends AccountOwnedResource bubblePlans = planDAO.findAll(); + if (empty(bubblePlans)) { + errors.addViolation("err.plan.required"); + } else { + plan = bubblePlans.get(0); + request.setPlan(plan.getUuid()); + } } else { request.setPlan(plan.getUuid()); } diff --git a/bubble-server/src/test/java/bubble/test/system/NetworkTest.java b/bubble-server/src/test/java/bubble/test/system/NetworkTest.java index 4c95574f..e5d5808d 100644 --- a/bubble-server/src/test/java/bubble/test/system/NetworkTest.java +++ b/bubble-server/src/test/java/bubble/test/system/NetworkTest.java @@ -10,8 +10,9 @@ import org.junit.Test; @Slf4j public class NetworkTest extends NetworkTestBase { - @Test public void testRegions () throws Exception { modelTest("network/network_regions"); } - @Test public void testGetNetworkKeys () throws Exception { modelTest("network/network_keys"); } - @Test public void testMinimalLaunch () throws Exception { modelTest("network/minimal_launch"); } + @Test public void testRegions () throws Exception { modelTest("network/network_regions"); } + @Test public void testGetNetworkKeys () throws Exception { modelTest("network/network_keys"); } + @Test public void testPreferredPlanLaunch () throws Exception { modelTest("network/preferred_plan_launch"); } + @Test public void testMinimalLaunch () throws Exception { modelTest("network/minimal_launch"); } } diff --git a/bubble-server/src/test/resources/models/tests/network/minimal_launch.json b/bubble-server/src/test/resources/models/tests/network/minimal_launch.json index 2a4135db..8d53f6e2 100644 --- a/bubble-server/src/test/resources/models/tests/network/minimal_launch.json +++ b/bubble-server/src/test/resources/models/tests/network/minimal_launch.json @@ -9,26 +9,14 @@ }, { - "comment": "list plans", - "request": { "uri": "plans" }, - "response": { - "store": "plans", - "check": [ - {"condition": "json.length > 0"} - ] - } - }, - - { - "comment": "add a payment method and preferred plan", + "comment": "add a payment method", "before": "stripe_tokenize_card", "request": { "uri": "me/paymentMethods", "method": "put", "entity": { "paymentMethodType": "credit", - "paymentInfo": "{{stripeToken}}", - "preferredPlan": "{{plans.[0].name}}" + "paymentInfo": "{{stripeToken}}" } } }, diff --git a/bubble-server/src/test/resources/models/tests/network/preferred_plan_launch.json b/bubble-server/src/test/resources/models/tests/network/preferred_plan_launch.json new file mode 100644 index 00000000..4ffb782d --- /dev/null +++ b/bubble-server/src/test/resources/models/tests/network/preferred_plan_launch.json @@ -0,0 +1,69 @@ +[ + { + "comment": "create another account and login", + "include": "new_account", + "params": { + "email": "pref_plan_launch@example.com", + "verifyEmail": true + } + }, + + { + "comment": "list plans", + "request": { "uri": "plans" }, + "response": { + "store": "plans", + "check": [ + {"condition": "json.length > 0"} + ] + } + }, + + { + "comment": "add a payment method and preferred plan", + "before": "stripe_tokenize_card", + "request": { + "uri": "me/paymentMethods", + "method": "put", + "entity": { + "paymentMethodType": "credit", + "paymentInfo": "{{stripeToken}}", + "preferredPlan": "{{plans.[0].name}}" + } + } + }, + + { + "comment": "add account plan", + "request": { + "uri": "me/plans", + "method": "put", + "entity": {} + }, + "response": { "store": "plan" } + }, + + { + "comment": "start the network. sets up the first node, which does the rest", + "request": { + "uri": "me/networks/{{ plan.name }}/actions/start", + "method": "post" + }, + "response": { + "store": "<>" + } + }, + + { + "comment": "list networks, verify new network is starting", + "before": "sleep 10s", + "request": { "uri": "me/networks" }, + "response": { + "check": [ + {"condition": "json.length === 1"}, + {"condition": "json[0].getName() === '{{plan.name}}'"}, + {"condition": "json[0].getState().name() === 'starting'"} + ] + } + } +] \ No newline at end of file