mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Add cancel subscription to my account
This commit is contained in:
parent
74d1b03463
commit
1cea0ff8d0
3 changed files with 186 additions and 46 deletions
|
@ -218,4 +218,36 @@ test.describe('Subscriber purchase a Subscription', () => {
|
|||
details = await subscription.json();
|
||||
await expect(details.status).toBe('SUSPENDED');
|
||||
});
|
||||
|
||||
test('Subscriber Cancel Subscription', async ({page, request}) => {
|
||||
await loginAsCustomer(page);
|
||||
await page.goto('/my-account/subscriptions');
|
||||
await page.locator('text=View').first().click();
|
||||
|
||||
const subscriptionId = await page.locator('#ppcp-subscription-id').textContent();
|
||||
let subscription = await request.get(`https://api.sandbox.paypal.com/v1/billing/subscriptions/${subscriptionId}`, {
|
||||
headers: {
|
||||
'Authorization': AUTHORIZATION,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
expect(subscription.ok()).toBeTruthy();
|
||||
let details = await subscription.json();
|
||||
await expect(details.status).toBe('ACTIVE');
|
||||
|
||||
await page.locator('text=Cancel').click();
|
||||
const title = page.locator('.woocommerce-message');
|
||||
await expect(title).toHaveText('Your subscription has been cancelled.');
|
||||
|
||||
subscription = await request.get(`https://api.sandbox.paypal.com/v1/billing/subscriptions/${subscriptionId}`, {
|
||||
headers: {
|
||||
'Authorization': AUTHORIZATION,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
expect(subscription.ok()).toBeTruthy();
|
||||
|
||||
details = await subscription.json();
|
||||
await expect(details.status).toBe('CANCELLED');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue