admin-promotion-config.spec.js 1.1 KB

1234567891011121314151617181920212223242526
  1. const { test, expect } = require('@playwright/test');
  2. function base() { return 'http' + String.fromCharCode(58, 47, 47) + 'cfc.iwintrue.com'; }
  3. function auth(token) { return token ? { Authorization: 'Bearer ' + token } : {}; }
  4. async function login(page) {
  5. const res = await page.request.post(base() + '/api/admin-auth/login-by-password', {
  6. data: { phone: '13800138000', password: 'admin123' }
  7. });
  8. return (await res.json()).data.token;
  9. }
  10. test.describe('promotion config', () => {
  11. test('get config', async ({ page }) => {
  12. const t = await login(page);
  13. const res = await page.request.post(base() + '/api/admin/promotion/config', { headers: auth(t) });
  14. expect(res.ok()).toBeTruthy();
  15. expect((await res.json()).code).toBe(200);
  16. });
  17. test('update config', async ({ page }) => {
  18. const t = await login(page);
  19. const res = await page.request.post(base() + '/api/admin/promotion/config/update', {
  20. data: { configValue: JSON.stringify({ banner: 'e2e-' + Date.now() }) },
  21. headers: auth(t)
  22. });
  23. expect(res.ok()).toBeTruthy();
  24. expect((await res.json()).code).toBe(200);
  25. });
  26. });