mirror of
https://github.com/formbricks/formbricks.git
synced 2026-03-13 19:30:36 -05:00
refactor: rename hobby start action
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { beforeEach, describe, expect, test, vi } from "vitest";
|
||||
import { startScaleTrialAction, stayOnHobbyAction } from "./actions";
|
||||
import { startHobbyAction, startScaleTrialAction } from "./actions";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
checkAuthorizationUpdated: vi.fn(),
|
||||
@@ -83,8 +83,8 @@ describe("billing actions", () => {
|
||||
mocks.syncOrganizationBillingFromStripe.mockResolvedValue(undefined);
|
||||
});
|
||||
|
||||
test("stayOnHobbyAction ensures a customer, reconciles hobby, and syncs billing", async () => {
|
||||
const result = await stayOnHobbyAction({
|
||||
test("startHobbyAction ensures a customer, reconciles hobby, and syncs billing", async () => {
|
||||
const result = await startHobbyAction({
|
||||
ctx: { user: { id: "user_1" } },
|
||||
parsedInput: { organizationId: "org_1" },
|
||||
} as any);
|
||||
@@ -103,7 +103,7 @@ describe("billing actions", () => {
|
||||
expect(mocks.ensureStripeCustomerForOrganization).toHaveBeenCalledWith("org_1");
|
||||
expect(mocks.reconcileCloudStripeSubscriptionsForOrganization).toHaveBeenCalledWith(
|
||||
"org_1",
|
||||
"stay-on-hobby"
|
||||
"start-hobby"
|
||||
);
|
||||
expect(mocks.syncOrganizationBillingFromStripe).toHaveBeenCalledWith("org_1");
|
||||
expect(result).toEqual({ success: true });
|
||||
|
||||
@@ -150,7 +150,7 @@ const ZStartScaleTrialAction = z.object({
|
||||
organizationId: ZId,
|
||||
});
|
||||
|
||||
export const stayOnHobbyAction = authenticatedActionClient
|
||||
export const startHobbyAction = authenticatedActionClient
|
||||
.inputSchema(ZStartScaleTrialAction)
|
||||
.action(async ({ ctx, parsedInput }) => {
|
||||
await checkAuthorizationUpdated({
|
||||
@@ -174,7 +174,7 @@ export const stayOnHobbyAction = authenticatedActionClient
|
||||
throw new ResourceNotFoundError("OrganizationBilling", parsedInput.organizationId);
|
||||
}
|
||||
|
||||
await reconcileCloudStripeSubscriptionsForOrganization(parsedInput.organizationId, "stay-on-hobby");
|
||||
await reconcileCloudStripeSubscriptionsForOrganization(parsedInput.organizationId, "start-hobby");
|
||||
await syncOrganizationBillingFromStripe(parsedInput.organizationId);
|
||||
return { success: true };
|
||||
});
|
||||
|
||||
@@ -11,7 +11,7 @@ import ethereumLogo from "@/images/customer-logos/ethereum-logo.png";
|
||||
import flixbusLogo from "@/images/customer-logos/flixbus-white.svg";
|
||||
import githubLogo from "@/images/customer-logos/github-logo.png";
|
||||
import siemensLogo from "@/images/customer-logos/siemens.png";
|
||||
import { startScaleTrialAction, stayOnHobbyAction } from "@/modules/ee/billing/actions";
|
||||
import { startHobbyAction, startScaleTrialAction } from "@/modules/ee/billing/actions";
|
||||
import { Button } from "@/modules/ui/components/button";
|
||||
|
||||
interface SelectPlanCardProps {
|
||||
@@ -64,7 +64,7 @@ export const SelectPlanCard = ({ nextUrl, organizationId }: SelectPlanCardProps)
|
||||
const handleContinueFree = async () => {
|
||||
setIsStayingOnHobby(true);
|
||||
try {
|
||||
const result = await stayOnHobbyAction({ organizationId });
|
||||
const result = await startHobbyAction({ organizationId });
|
||||
if (result?.data) {
|
||||
router.push(nextUrl);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user