Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(account): the failed payment notice names the plan as the web and the invoice do

purplebe7936159588
diff --git a/src/components/auth/__tests__/a-failed-payment-is-shown-as-one.test.tsx b/src/components/auth/__tests__/a-failed-payment-is-shown-as-one.test.tsx
index e2e4a634..dd20634f 100644
--- a/src/components/auth/__tests__/a-failed-payment-is-shown-as-one.test.tsx
+++ b/src/components/auth/__tests__/a-failed-payment-is-shown-as-one.test.tsx
@@ -23,7 +23,7 @@ vi.mock('../../../api/backend', () => ({ openExternal }))
const { AccountPanel } = await import('../AccountPanel')
const { useCloudAuthStore } = await import('../../../stores/cloudAuthStore')
-const SENTENCE = 'The last payment for your Pro plan failed, so the plan is paused. Pay the open invoice to bring it back.'
+const SENTENCE = 'The last payment for your Hosted Pro plan failed, so the plan is paused. Pay the open invoice to bring it back.'
const WALLET = 'Credits you bought stay usable in the meantime.'
const walletQuota: CloudQuota = {
diff --git a/src/lib/__tests__/past-due.test.ts b/src/lib/__tests__/past-due.test.ts
index 7cebcec3..1ec3e8df 100644
--- a/src/lib/__tests__/past-due.test.ts
+++ b/src/lib/__tests__/past-due.test.ts
@@ -12,6 +12,7 @@ import { describe, it, expect } from 'vitest'
import { existsSync, readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import {
+ PLAN_NAMES,
PAST_DUE_ACTION,
PAST_DUE_BADGE,
PAST_DUE_WALLET_LINE,
@@ -52,12 +53,12 @@ describe('reading the fields off /api/me', () => {
})
describe('the sentence', () => {
- it('names the plan the way the Cloud gate names it', () => {
+ it('names the plan the way the web and the invoice name it', () => {
expect(pastDueLine('hosted')).toBe(
'The last payment for your Hosted plan failed, so the plan is paused. Pay the open invoice to bring it back.',
)
- expect(pastDueLine('hosted-pro')).toContain('your Pro plan')
- expect(pastDueLine('hosted-max')).toContain('your Max plan')
+ expect(pastDueLine('hosted-pro')).toContain('your Hosted Pro plan')
+ expect(pastDueLine('hosted-max')).toContain('your Hosted Max plan')
})
it('says "your plan" when the plan is unknown', () => {
@@ -70,11 +71,15 @@ describe('the sentence', () => {
})
const REL_PATH = 'apps/web/lib/billing/past-due.ts'
+const PRICING_PATH = 'apps/web/lib/pricing.ts'
const WEB = process.env.LU_WEB_REPO?.trim() ? resolve(process.env.LU_WEB_REPO.trim()) : undefined
const WEB_FILE = WEB ? resolve(WEB, REL_PATH) : ''
-const HAS_WEB = WEB_FILE !== '' && existsSync(WEB_FILE)
+const PRICING_FILE = WEB ? resolve(WEB, PRICING_PATH) : ''
+const HAS_WEB = WEB_FILE !== '' && existsSync(WEB_FILE) && existsSync(PRICING_FILE)
if (!HAS_WEB) {
- process.stderr.write('[past-due] wording parity skipped: set LU_WEB_REPO to a web checkout that has ' + REL_PATH + '.\n')
+ process.stderr.write(
+ '[past-due] wording parity skipped: set LU_WEB_REPO to a web checkout that has ' + REL_PATH + ' and ' + PRICING_PATH + '.\n',
+ )
}
describe.skipIf(!HAS_WEB)('the wording is the web wording', () => {
@@ -91,4 +96,20 @@ describe.skipIf(!HAS_WEB)('the wording is the web wording', () => {
expect(web).toContain("'your plan'")
expect(web).toContain('`' + head + '${plan}' + tail + '`')
})
+
+ it('the plan in the sentence carries the name the web gives that tier', () => {
+ // The web builds the name with tierDisplayName, which reads TIERS.
+ expect(web).toContain('`your ${tierDisplayName(tier)} plan`')
+ const pricing = readFileSync(PRICING_FILE, 'utf8')
+ const webNames: Record<string, string> = {}
+ for (const m of pricing.matchAll(/\bid: '([a-z-]+)',\s*name: '([^']+)',\s*monthlyEUR: \d/g)) {
+ webNames[m[1]] = m[2]
+ }
+ // Every tier a subscription pays for, and no other.
+ expect(Object.keys(webNames).sort()).toEqual(['hosted', 'hosted-max', 'hosted-pro'])
+ expect(PLAN_NAMES).toEqual(webNames)
+ for (const [tier, name] of Object.entries(webNames)) {
+ expect(pastDueLine(tier)).toContain(`your ${name} plan`)
+ }
+ })
})
diff --git a/src/lib/past-due.ts b/src/lib/past-due.ts
index db518d6c..10845be5 100644
--- a/src/lib/past-due.ts
+++ b/src/lib/past-due.ts
@@ -7,11 +7,12 @@
import type { CloudMe } from '../api/cloud/jobs'
-/** Plan names as the Cloud gate writes them on its plan buttons. */
-const PLAN_NAMES: Record<string, string> = {
+/** Plan names as the web writes them (TIERS in apps/web/lib/pricing.ts), which
+ * is also how they stand on the invoice. */
+export const PLAN_NAMES: Record<string, string> = {
hosted: 'Hosted',
- 'hosted-pro': 'Pro',
- 'hosted-max': 'Max',
+ 'hosted-pro': 'Hosted Pro',
+ 'hosted-max': 'Hosted Max',
}
/** The sentence that replaces "No active plan" while a renewal is unpaid. */