| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- 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' }
- });
- expect(res.ok()).toBeTruthy();
- return (await res.json()).data.token;
- }
- test.describe('butler review', () => {
- test('list pending', async ({ page }) => {
- const t = await login(page);
- const res = await page.request.post(base() + '/api/admin/butler/list', {
- data: { status: 'pending', page: 1, size: 10 },
- headers: auth(t)
- });
- expect(res.ok()).toBeTruthy();
- const j = await res.json();
- expect(j.data).toHaveProperty('records');
- expect(j.data).toHaveProperty('total');
- });
- test('list approved for assignment', async ({ page }) => {
- const t = await login(page);
- const res = await page.request.post(base() + '/api/admin/butler/list', {
- data: { status: 'approved', page: 1, size: 10 },
- headers: auth(t)
- });
- expect(res.ok()).toBeTruthy();
- const j = await res.json();
- expect(j.data).toHaveProperty('records');
- expect(j.data).toHaveProperty('total');
- });
- test('review action (approve)', async ({ page }) => {
- const t = await login(page);
- const list = await page.request.post(base() + '/api/admin/butler/list', {
- data: { status: 'pending', page: 1, size: 1 },
- headers: auth(t)
- });
- const first = (await list.json()).data.records[0];
- if (!first) { expect(true).toBeTruthy(); return; }
- const res = await page.request.post(base() + '/api/admin/butler/review', {
- data: { id: first.id, action: 'approve' },
- headers: auth(t)
- });
- expect(res.ok()).toBeTruthy();
- expect((await res.json()).code).toBe(200);
- });
- test('assign member to approved butler', async ({ page }) => {
- const t = await login(page);
- const list = await page.request.post(base() + '/api/admin/butler/list', {
- data: { status: 'approved', page: 1, size: 1 },
- headers: auth(t)
- });
- const first = (await list.json()).data.records[0];
- if (!first) { expect(true).toBeTruthy(); return; }
- const res = await page.request.post(base() + '/api/admin/butler/assign-member', {
- data: { butlerId: first.id, memberIds: [] },
- headers: auth(t)
- });
- expect(res.ok()).toBeTruthy();
- expect((await res.json()).code).toBe(200);
- });
- test('service records exist', async ({ page }) => {
- const t = await login(page);
- const res = await page.request.post(base() + '/api/admin/butler/service-records', {
- data: { page: 1, size: 10 },
- headers: auth(t)
- });
- expect(res.ok()).toBeTruthy();
- expect((await res.json()).code).toBe(200);
- });
- test('settlements endpoint reachable', async ({ page }) => {
- const t = await login(page);
- const res = await page.request.post(base() + '/api/admin/butler/settlements', {
- data: { page: 1, size: 10 },
- headers: auth(t)
- });
- expect(res.ok()).toBeTruthy();
- expect((await res.json()).code).toBe(200);
- });
- });
|