| 1234567891011121314151617181920212223242526 |
- 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('promotion config', () => {
- test('get config', async ({ page }) => {
- const t = await login(page);
- const res = await page.request.post(base() + '/api/admin/promotion/config', { 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/promotion/config/update', {
- data: { configValue: JSON.stringify({ banner: 'e2e-' + Date.now() }) },
- headers: auth(t)
- });
- expect(res.ok()).toBeTruthy();
- expect((await res.json()).code).toBe(200);
- });
- });
|