| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- const { test, expect } = require('@playwright/test');
- function base() { return 'http' + String.fromCharCode(58, 47, 47) + 'cfc.iwintrue.com'; }
- function token(page) {
- return page.request.post(base() + '/api/admin-auth/login-by-password', {
- data: { phone: '13800138000', password: 'admin123' }
- }).then(r => r.ok() ? r.json() : Promise.resolve({ data: { token: null } })).then(j => j.data.token);
- }
- function auth(token) { return token ? { Authorization: 'Bearer ' + token } : {}; }
- test.describe('activity review', () => {
- test('login and list draft', async ({ page }) => {
- const res = await page.request.post(base() + '/api/admin-auth/login-by-password', {
- data: { phone: '13800138000', password: 'admin123' }
- });
- expect(res.ok()).toBeTruthy();
- const j = await res.json();
- expect(j.code).toBe(200);
- const t = j.data.token;
- expect(t).toBeTruthy();
- const list = await page.request.post(base() + '/api/admin/activity/list', {
- data: { status: 'draft', page: 1, size: 10 },
- headers: auth(t)
- });
- expect(list.ok()).toBeTruthy();
- const lj = await list.json();
- expect(lj.data).toHaveProperty('records');
- expect(lj.data).toHaveProperty('total');
- });
- test('review action', async ({ page }) => {
- const res = await page.request.post(base() + '/api/admin-auth/login-by-password', {
- data: { phone: '13800138000', password: 'admin123' }
- });
- const t = (await res.json()).data.token;
- const list = await page.request.post(base() + '/api/admin/activity/list', {
- data: { status: 'draft', page: 1, size: 1 },
- headers: auth(t)
- });
- const first = (await list.json()).data.records[0];
- if (!first) { expect(true).toBeTruthy(); return; }
- const rr = await page.request.post(base() + '/api/admin/activity/review', {
- data: { id: first.id, action: 'reject' },
- headers: auth(t)
- });
- expect(rr.ok()).toBeTruthy();
- expect((await rr.json()).code).toBe(200);
- });
- });
|