Skip to content

Commit d0dd703

Browse files
committed
rm test
1 parent adbae99 commit d0dd703

1 file changed

Lines changed: 0 additions & 119 deletions

File tree

ghost/core/test/e2e-api/admin/members.test.js

Lines changed: 0 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,125 +1601,6 @@ describe('Members API', function () {
16011601
});
16021602
});
16031603

1604-
it('Can create a comped member from a Stripe customer with a paid subscription', async function () {
1605-
// Regression test: when creating a member with both stripe_customer_id (pointing to a
1606-
// customer with an existing paid subscription) AND comped: true, the setComplimentarySubscription
1607-
// method needs to convert the paid subscription to a $0 complimentary price. Previously,
1608-
// the full options object (including withRelated: ['labels', 'newsletters']) was passed to
1609-
// setComplimentarySubscription, which caused a "labels is not defined on the model" error
1610-
// when fetching stripeSubscriptions. The fix passes only shared options (context + transacting).
1611-
const stripeService = require('../../../core/server/services/stripe');
1612-
1613-
const fakePaidPrice = {
1614-
id: 'price_paid_comped_test',
1615-
product: 'product_1234',
1616-
active: true,
1617-
nickname: 'Monthly',
1618-
unit_amount: 500,
1619-
currency: 'usd',
1620-
type: 'recurring',
1621-
recurring: {
1622-
interval: 'month'
1623-
}
1624-
};
1625-
1626-
const fakeCompPrice = {
1627-
id: 'price_comp_comped_test',
1628-
product: '',
1629-
active: true,
1630-
nickname: 'Complimentary',
1631-
unit_amount: 0,
1632-
currency: 'usd',
1633-
type: 'recurring',
1634-
recurring: {
1635-
interval: 'year'
1636-
}
1637-
};
1638-
1639-
const fakePaidSubscription = {
1640-
id: 'sub_comped_test',
1641-
customer: 'cus_comped_test',
1642-
status: 'active',
1643-
cancel_at_period_end: false,
1644-
metadata: {},
1645-
current_period_end: Date.now() / 1000 + 1000,
1646-
start_date: Date.now() / 1000,
1647-
plan: fakePaidPrice,
1648-
items: {
1649-
data: [{
1650-
id: 'item_comped_test',
1651-
price: fakePaidPrice
1652-
}]
1653-
}
1654-
};
1655-
1656-
const fakeCompSubscription = {
1657-
...fakePaidSubscription,
1658-
plan: fakeCompPrice,
1659-
items: {
1660-
data: [{
1661-
id: 'item_comped_test',
1662-
price: fakeCompPrice
1663-
}]
1664-
}
1665-
};
1666-
1667-
const fakeCustomer = {
1668-
id: 'cus_comped_test',
1669-
name: 'Paid To Comped',
1670-
email: 'paid-to-comped-test@email.com',
1671-
subscriptions: {
1672-
type: 'list',
1673-
data: [fakePaidSubscription]
1674-
},
1675-
invoice_settings: {
1676-
default_payment_method: null
1677-
}
1678-
};
1679-
1680-
// Track whether the subscription has been updated to comp
1681-
let subscriptionUpdated = false;
1682-
1683-
sinon.stub(stripeService.api, 'getCustomer').resolves(fakeCustomer);
1684-
sinon.stub(stripeService.api, 'getSubscription').callsFake(async () => {
1685-
return subscriptionUpdated ? fakeCompSubscription : fakePaidSubscription;
1686-
});
1687-
sinon.stub(stripeService.api, 'updateSubscriptionItemPrice').callsFake(async () => {
1688-
subscriptionUpdated = true;
1689-
return fakeCompSubscription;
1690-
});
1691-
sinon.stub(stripeService.api, 'createPrice').resolves(fakeCompPrice);
1692-
1693-
const initialMember = {
1694-
name: fakeCustomer.name,
1695-
email: fakeCustomer.email,
1696-
subscribed: true,
1697-
newsletters: [newsletters[0]],
1698-
stripe_customer_id: fakeCustomer.id,
1699-
comped: true
1700-
};
1701-
1702-
const {body} = await agent
1703-
.post(`/members/`)
1704-
.body({members: [initialMember]})
1705-
.expectStatus(201);
1706-
1707-
const newMember = body.members[0];
1708-
1709-
assert.equal(newMember.status, 'comped',
1710-
'Member should be comped after paid-to-comp conversion');
1711-
1712-
await assertMemberEvents({
1713-
eventType: 'MemberStatusEvent',
1714-
memberId: newMember.id,
1715-
asserts: [
1716-
{from_status: null, to_status: 'free'},
1717-
{from_status: 'free', to_status: 'paid'},
1718-
{from_status: 'paid', to_status: 'comped'}
1719-
]
1720-
});
1721-
});
1722-
17231604
let memberWithPaidSubscription;
17241605

17251606
it('Can create a member with an existing paid subscription', async function () {

0 commit comments

Comments
 (0)