Skip to content

Beautiful Open-Source Form Builder

fix: sync pricing comparison with billing period (#1333)

Julien Nahumbd0f3509c1b1
diff --git a/README.md b/README.md
index 8dbb7350b..140425145 100644
--- a/README.md
+++ b/README.md
@@ -24,6 +24,8 @@ OpnForm is an open-source form builder.
The easiest way to get started with OpnForm is to sign up for our [managed service in the Cloud](https://opnform.com/). You get support, backups, upgrades, and more. Your data is safe and secure, and you don't need to worry about maintenance or infrastructure. Check out our quick overview of [cloud vs self-hosting](https://docs.opnform.com/deployment/cloud-vs-self-hosting).
+The cloud [pricing page](https://opnform.com/pricing) shows monthly equivalents for yearly billing by default. The Monthly / Yearly selector updates both the plan cards and the feature comparison table; yearly plans are billed annually.
+
## Key Features
- 🚀 No-code builder with unlimited forms & submissions
diff --git a/client/components/pages/pricing/FeatureComparison.vue b/client/components/pages/pricing/FeatureComparison.vue
index d328217ff..758160cf6 100644
--- a/client/components/pages/pricing/FeatureComparison.vue
+++ b/client/components/pages/pricing/FeatureComparison.vue
@@ -14,6 +14,10 @@
</p>
</div>
+ <p class="mt-4 text-center text-sm text-neutral-600">
+ Prices per month, billed {{ yearly ? "annually" : "monthly" }}.
+ </p>
+
<div class="relative mt-12 sm:mt-16 overflow-x-auto">
<div class="sticky top-0 z-20 bg-white">
<table class="w-full min-w-108.75 table-fixed border-collapse">
@@ -124,12 +128,19 @@
</template>
<script setup>
+const props = defineProps({
+ yearly: {
+ type: Boolean,
+ default: true,
+ },
+})
+
const { getPlanPrice, getTierDisplayName } = useBillingUpsell()
const formatPlanPrice = (plan) => {
- const price = getPlanPrice(plan, false)
+ const price = getPlanPrice(plan, props.yearly)
if (price == null) return null
- return `$${price}`
+ return price === 0 ? "$0" : `$${Math.round(price)}/mo`
}
const plans = computed(() => [
diff --git a/client/pages/pricing.vue b/client/pages/pricing.vue
index bf23f1577..0441351fe 100644
--- a/client/pages/pricing.vue
+++ b/client/pages/pricing.vue
@@ -544,7 +544,7 @@
</section>
<section class="py-14 sm:py-28 px-8 lg:px-12 bg-white">
- <FeatureComparison />
+ <FeatureComparison :yearly="pricingIsYearly" />
</section>
<section class="pt-10 pb-4 sm:pt-12 sm:pb-6 px-8 lg:px-12 bg-white">
diff --git a/client/test/nuxt/pricing-feature-comparison.spec.ts b/client/test/nuxt/pricing-feature-comparison.spec.ts
new file mode 100644
index 000000000..febd63d4b
--- /dev/null
+++ b/client/test/nuxt/pricing-feature-comparison.spec.ts
@@ -0,0 +1,40 @@
+import { mount } from '@vue/test-utils'
+import { describe, expect, it, vi } from 'vitest'
+
+vi.mock('~/composables/useBillingUpsell.js', () => ({
+ useBillingUpsell: () => ({
+ getTierDisplayName: (plan: string) => plan,
+ getPlanPrice: (plan: string, yearly: boolean) => {
+ const prices = {
+ free: [0, 0],
+ pro: [29, 25],
+ business: [79, 67],
+ enterprise: [250, 220],
+ }
+ return prices[plan][yearly ? 1 : 0]
+ },
+ }),
+}))
+
+import FeatureComparison from '~/components/pages/pricing/FeatureComparison.vue'
+
+describe('pricing feature comparison', () => {
+ it('shows yearly monthly equivalents by default and follows billing changes in both directions', async () => {
+ const wrapper = mount(FeatureComparison, {
+ global: { stubs: { Icon: true } },
+ })
+ const prices = () => wrapper.findAll('thead th').slice(1).map(header => header.text())
+
+ expect(prices()).toEqual(['free ($0)', 'pro ($25/mo)', 'business ($67/mo)', 'enterprise ($220/mo)'])
+ expect(wrapper.text()).toContain('Prices per month, billed annually.')
+
+ await wrapper.setProps({ yearly: false })
+ expect(prices()).toEqual(['free ($0)', 'pro ($29/mo)', 'business ($79/mo)', 'enterprise ($250/mo)'])
+ expect(wrapper.text()).toContain('Prices per month, billed monthly.')
+
+ await wrapper.setProps({ yearly: true })
+ expect(prices()).toEqual(['free ($0)', 'pro ($25/mo)', 'business ($67/mo)', 'enterprise ($220/mo)'])
+ expect(wrapper.text()).toContain('Prices per month, billed annually.')
+ wrapper.unmount()
+ })
+})