[web] Remove SubscriptionFormatters, format subscription dates in the frontend (#36409)

* [web] Remove SubscriptionFormatters, format subscription dates in the frontend

Replace the server-formatted nextPaymentDueAt/nextPaymentDueDate/
trialEndsAtFormatted fields with the raw periodEnd date and format in
the React dashboard (same strings as before, English + UTC). Also
consolidate hand-rolled trial checks onto isInFreeTrial /
SubscriptionHelper.isInTrial.

* [web] Remove the now-unused dateformat dependency

* [web] Address review: payment-dates unit test, UTC dates in acceptance test

Add a dedicated unit test asserting the exact formatted strings from
formatPaymentDate/formatPaymentDateTime, and use explicit UTC timestamps
in the SubscriptionDashboard acceptance fixtures instead of
local-timezone Date constructors.

GitOrigin-RevId: 16ac4f1098b14ef9f1478d22cf39c1357ead7dea
This commit is contained in:
Antoine Clausse
2026-09-17 11:52:44 +00:00
committed by Copybot
parent d0399bd09f
commit ba4f024f34
26 changed files with 149 additions and 203 deletions
@@ -1,30 +0,0 @@
import { describe, expect, it } from 'vitest'
import SubscriptionFormatters from '../../../../app/src/Features/Subscription/SubscriptionFormatters.mjs'
describe('SubscriptionFormatters', function () {
describe('formatDateTime', function () {
it('should return null if no date', function () {
const result = SubscriptionFormatters.formatDateTime(null)
expect(result).to.equal(null)
})
it('should format date with time', function () {
const date = new Date(1639904485000)
const result = SubscriptionFormatters.formatDateTime(date)
expect(result).to.equal('December 19th, 2021 9:01 AM UTC')
})
})
describe('formatDate', function () {
it('should return null if no date', function () {
const result = SubscriptionFormatters.formatDate(null)
expect(result).to.equal(null)
})
it('should format date', function () {
const date = new Date(1639904485000)
const result = SubscriptionFormatters.formatDate(date)
expect(result).to.equal('December 19th, 2021')
})
})
})
@@ -745,12 +745,10 @@ describe('SubscriptionViewModelBuilder', function () {
},
],
totalLicenses: 0,
nextPaymentDueAt: 'February 20th, 2025 12:00 PM UTC',
nextPaymentDueDate: 'February 20th, 2025',
periodEnd: new Date('2025-02-20T12:00:00.000Z'),
currency: 'EUR',
planPrice: 13,
state: 'active',
trialEndsAtFormatted: null,
trialEndsAt: null,
activeCoupons: [],
accountEmail: 'example@example.com',