const { test, expect } = require('@playwright/test'); function base() { return 'http' + String.fromCharCode(58, 47, 47) + 'cfc.iwintrue.com'; } function auth(token) { return token ? { Authorization: 'Bearer ' + token } : {}; } async function login(page) { const res = await page.request.post(base() + '/api/admin-auth/login-by-password', { data: { phone: '13800138000', password: 'admin123' } }); return (await res.json()).data.token; } test.describe('commission config', () => { test('get config', async ({ page }) => { const t = await login(page); const res = await page.request.post(base() + '/api/admin/commission/config', { headers: auth(t) }); expect(res.ok()).toBeTruthy(); expect((await res.json()).code).toBe(200); }); test('records', async ({ page }) => { const t = await login(page); const res = await page.request.post(base() + '/api/admin/commission/records', { headers: auth(t) }); expect(res.ok()).toBeTruthy(); expect((await res.json()).code).toBe(200); }); test('update config', async ({ page }) => { const t = await login(page); const res = await page.request.post(base() + '/api/admin/commission/config/update', { data: { id: null, percent: 10, ratio: 1, label: 'e2e-' + Date.now(), status: 1, remark: 'up' }, headers: auth(t) }); expect(res.ok()).toBeTruthy(); expect((await res.json()).code).toBe(200); }); test('settle and refund', async ({ page }) => { const t = await login(page); const settle = await page.request.post(base() + '/api/admin/commission/settle', { data: {}, headers: auth(t) }); expect(settle.ok()).toBeTruthy(); expect((await settle.json()).code).toBe(200); const refund = await page.request.post(base() + '/api/admin/commission/refund', { data: {}, headers: auth(t) }); expect(refund.ok()).toBeTruthy(); expect((await refund.json()).code).toBe(200); }); });