mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Add update subscription (WIP)
This commit is contained in:
parent
8ceb7e0664
commit
b5e1f1530a
8 changed files with 171 additions and 44 deletions
|
@ -15,11 +15,14 @@ async function loginAsAdmin(page) {
|
|||
]);
|
||||
}
|
||||
|
||||
test.describe('Merchant', () => {
|
||||
test.describe.serial('Merchant', () => {
|
||||
const title = (Math.random() + 1).toString(36).substring(7);
|
||||
let product_id = '';
|
||||
let plan_id = '';
|
||||
|
||||
test('Create new subscription product', async ({page, request}) => {
|
||||
await loginAsAdmin(page);
|
||||
|
||||
const title = (Math.random() + 1).toString(36).substring(7);
|
||||
await page.goto('/wp-admin/post-new.php?post_type=product');
|
||||
await page.fill('#title', title);
|
||||
await page.selectOption('select#product-type', 'subscription');
|
||||
|
@ -47,7 +50,9 @@ test.describe('Merchant', () => {
|
|||
});
|
||||
await expect(product.id).toBeTruthy;
|
||||
|
||||
const plans = await request.get(`https://api.sandbox.paypal.com/v1/billing/plans?product_id=${product.id}&page_size=10&page=1&total_required=true`, {
|
||||
product_id = product.id;
|
||||
|
||||
const plans = await request.get(`https://api.sandbox.paypal.com/v1/billing/plans?product_id=${product_id}&page_size=10&page=1&total_required=true`, {
|
||||
headers: {
|
||||
'Authorization': AUTHORIZATION,
|
||||
'Content-Type': 'application/json'
|
||||
|
@ -60,5 +65,35 @@ test.describe('Merchant', () => {
|
|||
return p.product_id === product.id;
|
||||
});
|
||||
await expect(plan.id).toBeTruthy;
|
||||
|
||||
plan_id = plan.id;
|
||||
});
|
||||
|
||||
test('Update subscription product', async ({page, request}) => {
|
||||
await loginAsAdmin(page);
|
||||
|
||||
await page.goto('/wp-admin/edit.php?post_type=product');
|
||||
await page.getByRole('link', { name: title, exact: true }).click();
|
||||
|
||||
await page.fill('#_subscription_price', '20');
|
||||
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
page.locator('#publish').click(),
|
||||
]);
|
||||
|
||||
const message = await page.locator('.notice-success');
|
||||
await expect(message).toContainText('Product updated.');
|
||||
|
||||
const plan = await request.get(`https://api.sandbox.paypal.com/v1/billing/plans/${plan_id}`, {
|
||||
headers: {
|
||||
'Authorization': AUTHORIZATION,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
expect(plan.ok()).toBeTruthy();
|
||||
|
||||
const plan_content = await plan.json();
|
||||
await expect(plan_content.billing_cycles[0].pricing_scheme.fixed_price.value).toBe('20.0')
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue