From d0c32463270762f21f79609c5daf17a8992a5cd8 Mon Sep 17 00:00:00 2001 From: Lyu Date: Thu, 1 Oct 2026 21:40:46 -0700 Subject: [PATCH] fix: always show purchased domain renewal state --- src/commands/domain.ts | 2 +- test/domain.test.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/commands/domain.ts b/src/commands/domain.ts index 475b8d5..f395051 100644 --- a/src/commands/domain.ts +++ b/src/commands/domain.ts @@ -101,7 +101,7 @@ export async function domainAttach(host: string, opts: { branch?: string; group? // ---- list / status ---- function domainLines(d: Purchased, linked = true): string[] { - const out = [`${d.domainName} ${d.status}${d.expiresAt ? ` (expires ${d.expiresAt.slice(0, 10)}${d.autorenew ? ', auto-renews' : ''})` : ''}`] + const out = [`${d.domainName} ${d.status}${d.expiresAt ? ` (expires ${d.expiresAt.slice(0, 10)})` : ''} auto-renew ${d.autorenew ? 'on' : 'off'}`] // Vacuously true for a domain with no hostnames, which is every domain until something attaches. // Not while delegated: the platform fails every hostname on the way out, and refuses the attach. if (linked && !d.delegated && d.hostnames.every((h) => h.state === 'failed')) { diff --git a/test/domain.test.ts b/test/domain.test.ts index bb96950..aed473e 100644 --- a/test/domain.test.ts +++ b/test/domain.test.ts @@ -210,7 +210,7 @@ describe('domain list / status', () => { hostnames: [{ hostname: 'both.com', state: 'failed', service: 'web' }, { hostname: 'www.both.com', state: 'failed', service: 'web' }] } const { deps: d } = deps({ '/orgs/org1/domains': { items: [purchased, empty, moving, sub, both] } }) await domainList({}, d) - expect(out()).toContain('myapp.com attaching (expires 2027-09-10, auto-renews)') + expect(out()).toContain('myapp.com attaching (expires 2027-09-10) auto-renew on') expect(out()).toContain('api.myapp.com active → api') expect(out()).toContain('www.myapp.com failed → web — already attached to another compute service') expect(out()).toContain('nothing serving — insta domain attach old.com\n') @@ -228,6 +228,15 @@ describe('domain list / status', () => { expect(out()).not.toContain('order o1') expect(out()).toContain('api.myapp.com active → api') }) + it.each([true, false])('list and status show auto-renew=%s without an expiry date', async (autorenew) => { + const { deps: d } = deps({ '/domains/orders': { items: [] }, '/orgs/org1/domains': { items: [{ ...purchased, expiresAt: null, autorenew }] } }) + await domainList({}, d) + await domainStatus('myapp.com', {}, d) + expect(out().match(/myapp\.com attaching auto-renew (on|off)/g)).toEqual([ + `myapp.com attaching auto-renew ${autorenew ? 'on' : 'off'}`, + `myapp.com attaching auto-renew ${autorenew ? 'on' : 'off'}`, + ]) + }) it('a canceled checkout says how to order again', async () => { const { deps: d } = deps({ '/domains/orders': { items: [{ ...order, status: 'canceled', failedReason: 'checkout expired before payment' }] }, '/orgs/org1/domains': { items: [] } }) await domainStatus('myapp.com', {}, d)