| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- 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('ecom supplier', () => {
- test('list pagination schema', async ({ page }) => {
- const t = await login(page);
- const res = await page.request.post(base() + '/api/admin/supplier/list', {
- data: { page: 1, size: 5 },
- headers: auth(t)
- });
- expect(res.ok()).toBeTruthy();
- const j = await res.json();
- expect(j.data).toHaveProperty('records');
- expect(j.data).toHaveProperty('total');
- });
- test('create supplier', async ({ page }) => {
- const t = await login(page);
- const res = await page.request.post(base() + '/api/admin/supplier/save', {
- data: { name: 'PlaywrightSupplier ' + Date.now(), contactName: 'Sisy', contactPhone: '74955953457', status: 1, remark: 'e2e' },
- headers: auth(t)
- });
- expect(res.ok()).toBeTruthy();
- expect((await res.json()).code).toBe(200);
- });
- test('update supplier', async ({ page }) => {
- const t = await login(page);
- const list = await page.request.post(base() + '/api/admin/supplier/list', {
- data: { 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/supplier/update', {
- data: { id: first.id, remark: 'updated ' + Date.now() },
- headers: auth(t)
- });
- expect(res.ok()).toBeTruthy();
- expect((await res.json()).code).toBe(200);
- });
- });
|