Merge pull request #27643 from overleaf/rh-pause-cancel

Terminate Recurly subscription when cancelling during final month of pause

GitOrigin-RevId: 39e4c9534621f57b3e2783599ebe521959d7401f
This commit is contained in:
roo hutton
2025-08-29 08:06:17 +00:00
committed by Copybot
parent 3279f997bb
commit 467102fd1b
5 changed files with 61 additions and 66 deletions
@@ -516,35 +516,6 @@ describe('<ActiveSubscription />', function () {
})
})
describe('contact support for paused subscription with 0 remaining cycles', function () {
beforeEach(function () {
this.locationWrapperSandbox = sinon.createSandbox()
this.locationWrapperStub = this.locationWrapperSandbox.stub(location)
})
afterEach(function () {
this.locationWrapperSandbox.restore()
})
it('redirects to contact page when cancel button clicked', function () {
const pausedSubscription = cloneDeep(annualActiveSubscription)
pausedSubscription.payment.state = 'paused'
pausedSubscription.payment.remainingPauseCycles = 0
renderActiveSubscription(pausedSubscription)
const button = screen.getByRole('button', {
name: 'Cancel your subscription',
})
fireEvent.click(button)
expect(sendMBSpy).to.be.calledOnceWith(
'subscription-page-cancel-button-click'
)
expect(this.locationWrapperStub.assign).to.be.calledOnceWith('/contact')
})
})
describe('group plans', function () {
it('does not show "Change plan" option for group plans', function () {
renderActiveSubscription(groupActiveSubscription)
@@ -560,6 +560,30 @@ describe('RecurlyClient', function () {
'uuid-' + this.subscription.uuid
)
})
it('should terminate subscription when cancellation fails due to being in last cycle of paused term', async function () {
const validationError = new recurly.errors.ValidationError()
validationError.message =
'Cannot cancel a paused subscription in the last cycle of the term'
this.client.cancelSubscription = sinon.stub().throws(validationError)
this.client.terminateSubscription = sinon
.stub()
.resolves(this.recurlySubscription)
const subscription =
await this.RecurlyClient.promises.cancelSubscriptionByUuid(
this.subscription.uuid
)
expect(this.client.cancelSubscription).to.be.calledWith(
'uuid-' + this.subscription.uuid
)
expect(this.client.terminateSubscription).to.be.calledWith(
'uuid-' + this.subscription.uuid
)
expect(subscription).to.deep.equal(this.recurlySubscription)
})
})
describe('pauseSubscriptionByUuid', function () {