| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- const { test, expect } = require('@playwright/test');
- const BASE_URL = 'https://ajy.danclub.cn';
- const API_BASE_URL = 'https://ajy.danclub.cn/api';
- /**
- * 核心算法测试
- * 测试指寸估算算法、穴位坐标生成、数据验证、置信度计算
- */
- test.describe('6.1 指寸估算算法', () => {
- test('AL-001: 男性标准体型估算', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/cun-calculate`, {
- data: { shoulderWidth: 42, bodyLength: 85, gender: '男' }
- });
- const data = await response.json();
- expect(data.cun1).toBeCloseTo(2.2, 0.1);
- });
- test('AL-002: 女性标准体型估算', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/cun-calculate`, {
- data: { shoulderWidth: 36, bodyLength: 78, gender: '女' }
- });
- const data = await response.json();
- expect(data.cun1).toBeCloseTo(1.9, 0.1);
- });
- test('AL-003: 男性大体型估算', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/cun-calculate`, {
- data: { shoulderWidth: 52, bodyLength: 95, gender: '男' }
- });
- const data = await response.json();
- expect(data.cun1).toBeCloseTo(2.54, 0.1);
- });
- test('AL-004: 男性小体型估算', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/cun-calculate`, {
- data: { shoulderWidth: 36, bodyLength: 75, gender: '男' }
- });
- const data = await response.json();
- expect(data.cun1).toBeCloseTo(1.88, 0.1);
- });
- test('AL-005: 女性大体型估算', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/cun-calculate`, {
- data: { shoulderWidth: 46, bodyLength: 88, gender: '女' }
- });
- const data = await response.json();
- expect(data.cun1).toBeCloseTo(2.26, 0.1);
- });
- test('AL-006: 女性小体型估算', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/cun-calculate`, {
- data: { shoulderWidth: 32, bodyLength: 70, gender: '女' }
- });
- const data = await response.json();
- expect(data.cun1).toBeCloseTo(1.54, 0.1);
- });
- test('AL-007: 有指寸不估算', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/cun-calculate`, {
- data: { shoulderWidth: 42, bodyLength: 85, gender: '男', providedCun: { cun1: 2.0 } }
- });
- const data = await response.json();
- expect(data.cun1).toBe(2.0);
- expect(data.estimated).toBe(false);
- });
- });
- test.describe('6.2 穴位对照表生成', () => {
- test('AL-010: 生成12个穴位', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/acupoint-generate`, {
- data: { shoulderWidth: 42, bodyLength: 85, gender: '男', cun1: 2.2 }
- });
- const data = await response.json();
- expect(data.acupoints.length).toBeGreaterThanOrEqual(20);
- });
- test('AL-011: 大椎穴为原点', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/acupoint-generate`, {
- data: { shoulderWidth: 42, bodyLength: 85, gender: '男', cun1: 2.2 }
- });
- const data = await response.json();
- const dazhui = data.acupoints.find(a => a.name === '大椎');
- expect(dazhui.x).toBe(0);
- expect(dazhui.y).toBe(0);
- });
- test('AL-012: 督脉只有纵向偏移', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/acupoint-generate`, {
- data: { shoulderWidth: 42, bodyLength: 85, gender: '男', cun1: 2.2 }
- });
- const data = await response.json();
- const dumaiPoints = data.acupoints.filter(a => a.meridian === '督脉');
- dumaiPoints.forEach(p => {
- expect(p.x).toBe(0);
- });
- });
- test('AL-013: 双侧穴位横向偏移', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/acupoint-generate`, {
- data: { shoulderWidth: 42, bodyLength: 85, gender: '男', cun1: 2.2 }
- });
- const data = await response.json();
- const doubleSidePoints = data.acupoints.filter(a => a.side === '双侧');
- const hasPositiveX = doubleSidePoints.some(p => p.x > 0);
- const hasNegativeX = doubleSidePoints.some(p => p.x < 0);
- expect(hasPositiveX).toBe(true);
- expect(hasNegativeX).toBe(true);
- });
- });
- test.describe('6.3 数据验证', () => {
- test('AL-020: 男性肩宽边界-通过', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/validate`, {
- data: { shoulderWidth: 36, gender: '男' }
- });
- const data = await response.json();
- expect(data.valid).toBe(true);
- });
- test('AL-021: 男性肩宽边界-不通过', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/validate`, {
- data: { shoulderWidth: 35, gender: '男' }
- });
- const data = await response.json();
- expect(data.valid).toBe(false);
- expect(data.error).toContain('36-52');
- });
- test('AL-022: 女性身长边界-通过', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/validate`, {
- data: { bodyLength: 88, gender: '女' }
- });
- const data = await response.json();
- expect(data.valid).toBe(true);
- });
- test('AL-023: 女性身长边界-不通过', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/validate`, {
- data: { bodyLength: 89, gender: '女' }
- });
- const data = await response.json();
- expect(data.valid).toBe(false);
- expect(data.error).toContain('70-88');
- });
- test('AL-024: 指寸范围验证', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/validate-cun`, {
- data: { cun: 1.2, gender: '女' }
- });
- const data = await response.json();
- expect(data.valid).toBe(false);
- });
- });
- test.describe('6.4 置信度计算', () => {
- test('AL-030: 仅肩宽身长', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/confidence`, {
- data: { shoulderWidth: 42, bodyLength: 85 }
- });
- const data = await response.json();
- expect(data.confidence).toBe(50);
- expect(data.precision).toBe('±5cm');
- });
- test('AL-031: 部分指寸', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/confidence`, {
- data: { shoulderWidth: 42, bodyLength: 85, cun1: 2.2 }
- });
- const data = await response.json();
- expect(data.confidence).toBe(65);
- expect(data.precision).toBe('±4cm');
- });
- test('AL-032: 完整指寸', async ({ request }) => {
- const response = await request.post(`${API_BASE_URL}/algorithm/confidence`, {
- data: { shoulderWidth: 42, bodyLength: 85, cun1: 2.2, cun1_5: 3.3, cun3: 6.6 }
- });
- const data = await response.json();
- expect(data.confidence).toBe(95);
- expect(data.precision).toBe('±2cm');
- });
- });
|