Skip to content

Commit 4e8bdd2

Browse files
feat: Always show plan cancelled confirmation (#3949)
1 parent 97cc92a commit 4e8bdd2

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

src/pages/PlanPage/subRoutes/CurrentOrgPlan/CurrentOrgPlan.test.tsx

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ describe('CurrentOrgPlan', () => {
236236
})
237237

238238
describe('when info message cancellation should be shown', () => {
239-
it('renders when subscription detail data is available', async () => {
239+
it('renders when subscription has just been canceled', async () => {
240240
setup({
241241
accountDetails: {
242242
subscriptionDetail: {
@@ -246,11 +246,39 @@ describe('CurrentOrgPlan', () => {
246246
} as z.infer<typeof AccountDetailsSchema>,
247247
})
248248

249+
// isCancellation is true to simulate the subscription has just been canceled
249250
render(<CurrentOrgPlan />, { wrapper: cancellationPlanWrapper })
250-
const pendingCancellation = await screen.findByText(
251+
const cancellationConfirmation = await screen.findByText(
252+
/Cancellation confirmation/
253+
)
254+
const cancellationTime = await screen.findByText(
255+
/on August 2nd 2024, 8:52 p.m./
256+
)
257+
expect(cancellationConfirmation).toBeInTheDocument()
258+
expect(cancellationTime).toBeInTheDocument()
259+
})
260+
261+
it('renders when cancelAtPeriodEnd is true without having just been canceled', async () => {
262+
setup({
263+
accountDetails: {
264+
subscriptionDetail: {
265+
cancelAtPeriodEnd: true,
266+
currentPeriodEnd: 1722631954,
267+
},
268+
} as z.infer<typeof AccountDetailsSchema>,
269+
})
270+
271+
// isCancellation is false to simulate the subscription was previously canceled
272+
render(<CurrentOrgPlan />, { wrapper: noUpdatedPlanWrapper })
273+
const cancellationConfirmation = await screen.findByText(
274+
/Cancellation confirmation/
275+
)
276+
expect(cancellationConfirmation).toBeInTheDocument()
277+
const cancellationTime = await screen.findByText(
251278
/on August 2nd 2024, 8:52 p.m./
252279
)
253-
expect(pendingCancellation).toBeInTheDocument()
280+
expect(cancellationConfirmation).toBeInTheDocument()
281+
expect(cancellationTime).toBeInTheDocument()
254282
})
255283
})
256284

src/pages/PlanPage/subRoutes/CurrentOrgPlan/CurrentOrgPlan.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ function CurrentOrgPlan() {
7070

7171
return (
7272
<div className="w-full lg:w-4/5">
73-
{planUpdatedNotification.isCancellation ? (
73+
{planUpdatedNotification.isCancellation ||
74+
accountDetails?.subscriptionDetail?.cancelAtPeriodEnd ? (
7475
<InfoAlertCancellation
7576
subscriptionDetail={accountDetails?.subscriptionDetail}
7677
/>

0 commit comments

Comments
 (0)