feat(report): unify display grades and add contour side photos
This commit is contained in:
@@ -68,6 +68,9 @@ try {
|
||||
assert.equal(adminRecord.skin_age_display, result.vm.skinAgeDisplay);
|
||||
assert.equal(adminRecord.total_score, expectedTotal);
|
||||
assert.equal(adminRecord.total_score_rule, 'dimensions-433-v1');
|
||||
assert.equal(adminRecord.grade_rule, ReportUI.gradeRule);
|
||||
for (const dim of Object.values(adminRecord.dims)) assert.equal(dim.level,ReportUI.internalLevel(dim.S));
|
||||
for (const item of Object.values(adminRecord.sub_scores)) assert.equal(item.level,ReportUI.internalLevel(item.S));
|
||||
assert.deepEqual(adminRecord.acne_scoring,result.vm.cats.acne.vars.acne_scoring);
|
||||
assert.deepEqual(adminRecord.tone_scoring,result.vm.cats.tone.vars.tone_scoring);
|
||||
assert.equal(adminRecord.vita_score_rule,'independent-color-water-smooth-min-v1');
|
||||
@@ -94,6 +97,8 @@ try {
|
||||
assert.deepEqual(snapshot.report.presentation, result.presentation);
|
||||
assert.deepEqual(snapshot.report.payload.result.face_maps, result.result.face_maps);
|
||||
assert.equal(snapshot.report.photos[0], fixture.photos[0]);
|
||||
assert.equal(snapshot.report.photos[1],fixture.photos[0]); // This HTTP test submits the same fixture for all three views.
|
||||
assert.equal(snapshot.report.photos[2],fixture.photos[0]);
|
||||
assert.equal(snapshot.report.vm.total, expectedTotal);
|
||||
assert.equal(JSON.parse(fs.readFileSync(path.join(dataRoot, 'records.jsonl'), 'utf8').trim()).total_score, expectedTotal, 'new records persist weighted score');
|
||||
const desktop = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
|
||||
@@ -106,7 +111,7 @@ try {
|
||||
assert((await row.textContent()).includes('展示 ' + expectedAge + '岁'));
|
||||
assert((await row.textContent()).includes("1'me 主场精华 I(25+)"));
|
||||
for (const key of ['firm', 'vita', 'stab']) {
|
||||
assert((await row.textContent()).includes(ReportUI.dimNames[key] + ' ' + ReportUI.dimensionScore(result.vm.dims[key].S) + ' ' + ReportUI.levelMap[result.vm.dims[key].level]));
|
||||
assert((await row.textContent()).includes(ReportUI.dimNames[key] + ' ' + ReportUI.dimensionScore(result.vm.dims[key].S) + ' ' + ReportUI.levelForScore(result.vm.dims[key].S)));
|
||||
}
|
||||
assert.deepEqual(await desktop.locator('#f-dimlevel option').allTextContents(), ['不限档位', '改善', '良好', '优秀']);
|
||||
if (process.env.H5_ARTIFACT_DIR) {
|
||||
@@ -114,10 +119,11 @@ try {
|
||||
await desktop.screenshot({ path: path.join(process.env.H5_ARTIFACT_DIR, 'admin-list.png'), fullPage: true });
|
||||
}
|
||||
await desktop.selectOption('#f-dim', 'firm');
|
||||
await desktop.selectOption('#f-dimlevel', adminRecord.dims.firm.level);
|
||||
await desktop.selectOption('#f-dimlevel', { value: adminRecord.dims.firm.level });
|
||||
const filtered = desktop.waitForResponse(r => r.url().includes('/api/admin/records?'));
|
||||
await desktop.click('#btn-search');
|
||||
assert.equal((await (await filtered).json()).total, 1);
|
||||
const filteredResponse = await filtered;
|
||||
assert.equal((await filteredResponse.json()).total, 1, filteredResponse.url() + ' expected grade=' + adminRecord.dims.firm.level);
|
||||
await row.click();
|
||||
await desktop.waitForFunction(() => document.querySelector('#d-body').textContent.includes('推荐依据'));
|
||||
const detailText = await desktop.locator('#d-body').textContent();
|
||||
@@ -163,6 +169,9 @@ try {
|
||||
await page.click('[data-report-id]');
|
||||
await page.waitForSelector('#s-report.active');
|
||||
assert.equal(await page.locator('#stat-score b').textContent(), String(expectedTotal));
|
||||
await page.waitForFunction(()=>[...document.querySelectorAll('#contour-sides figure')].every(f=>!f.hidden));
|
||||
assert.equal(await page.locator('#contour-left').getAttribute('src'),snapshot.report.photos[1]);
|
||||
assert.equal(await page.locator('#contour-right').getAttribute('src'),snapshot.report.photos[2]);
|
||||
if (process.env.H5_ARTIFACT_DIR) {
|
||||
await page.waitForTimeout(400); // Capture after the report's entrance fade.
|
||||
await page.screenshot({ path: path.join(process.env.H5_ARTIFACT_DIR, 'report-weighted-total.png') });
|
||||
@@ -190,6 +199,9 @@ try {
|
||||
const legacy = JSON.parse(fs.readFileSync(snapshotFile, 'utf8'));
|
||||
legacy.presentation.product = { ...ReportUI.products[1], image: 'assets/img/ui-20261009/product-35.png' };
|
||||
legacy.presentation.views[0].text = '历史报告原文,不应按新文案重新计算。';
|
||||
delete legacy.presentation.gradeRule; // Old copy must regrade for display only.
|
||||
delete legacy.presentation.copyRule;
|
||||
for (const care of legacy.presentation.care) { delete care.key; delete care.level; care.text='旧护理待刷新'; }
|
||||
legacy.vm.skinAgeDisplay = 57; // Old snapshot retains the retired display clamp.
|
||||
legacy.vm.total = 12; // Old stored upstream total must not control the current display.
|
||||
legacy.vm.essence = { name: '35+支撑精华', text: '旧版推荐', triggers: ['最差项约束'] };
|
||||
@@ -214,15 +226,20 @@ try {
|
||||
const legacyDetail = await (await api.get(base + 'api/admin/records/' + result.record_id)).json();
|
||||
assert.equal(legacyDetail.record.skin_age_display, expectedAge);
|
||||
assert.equal(legacyDetail.record.total_score, expectedTotal);
|
||||
assert.equal(legacyDetail.record.presentation.gradeRule,ReportUI.gradeRule);
|
||||
assert.equal(legacyDetail.record.presentation.copyRule,ReportUI.copyRule);
|
||||
for (const item of legacyDetail.record.presentation.care) { assert(item.key); assert(item.level); assert(!item.text.includes('旧护理待刷新')); }
|
||||
for (const view of legacyDetail.record.presentation.views) assert.equal(view.level,ReportUI.levelForScore(view.S));
|
||||
const legacyCsv=(await (await api.get(base + 'api/admin/export')).text()).trim().split('\n')[1].split(',');
|
||||
assert.equal(legacyCsv[12], String(expectedTotal));
|
||||
assert.equal(legacyCsv[14], String(expectedAge));
|
||||
assert.equal(await page.locator('#product-title').textContent(), ReportUI.products[1].title);
|
||||
assert.equal(await page.locator('#product-image').getAttribute('src'), ReportUI.products[1].image, 'refresh artwork crop, never the historical recommendation/copy');
|
||||
assert((await page.locator('.ditem-para').allTextContents()).includes(legacy.presentation.views[0].text));
|
||||
assert((await page.locator('.ditem-para').allTextContents()).includes(ReportUI.forDisplay(legacy.vm,legacy.payload.result,legacy.presentation).views[0].text));
|
||||
assert(!(await page.locator('#care-list').textContent()).includes('旧护理待刷新'));
|
||||
await desktop.goto(base + 'admin.html');
|
||||
await desktop.locator('#tbl-records tbody tr').first().click();
|
||||
await desktop.waitForFunction(() => document.querySelector('#d-body').textContent.includes('历史报告原文'));
|
||||
await desktop.waitForFunction(text => document.querySelector('#d-body').textContent.includes(text), legacyDetail.record.presentation.views[0].text);
|
||||
assert((await desktop.locator('#d-body').textContent()).includes('旧版规则(历史记录)'));
|
||||
assert((await desktop.locator('#d-body').textContent()).includes('前端展示肌龄 ' + expectedAge + '岁'));
|
||||
assert.equal(fs.readFileSync(snapshotFile, 'utf8'), storedBytes);
|
||||
|
||||
Reference in New Issue
Block a user