Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/commands/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
11 changes: 10 additions & 1 deletion test/domain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
Expand Down
Loading