import test from 'node:test' import assert from 'node:assert/strict' import {productAttachmentError,productAttachmentMaximum,productEditionSpec,productVersionLabel,productAttachmentPath,uncertainEditionResult} from '../../src/utils/product-editions.js' test('product editions are freely named rather than restricted to numeric generations',()=>{for(const name of ['V1.2','试制版','量产版','2026改进款']){assert.equal(productEditionSpec('机器人',name),'机器人 / '+name);assert.equal(productVersionLabel({seriesName:'协作机器人',editionTag:name}),'协作机器人 · '+name)}}) test('product attachments accept exactly fifty MiB and reject empty, oversized and executable files',()=>{assert.equal(productAttachmentMaximum,50*1024*1024);assert.equal(productAttachmentError({name:'工程图纸.STEP',size:productAttachmentMaximum}),'');assert.ok(productAttachmentError({name:'图纸.pdf',size:productAttachmentMaximum+1}));assert.ok(productAttachmentError({name:'空.pdf',size:0}));for(const name of ['run.exe','网页.html','矢量.svg'])assert.ok(productAttachmentError({name,size:100}))}) test('product paths remain owner scoped and uncertain creation keeps the original request',()=>{assert.equal(productAttachmentPath(4),'/production/product/4/attachments');for(const id of ['../4',0,NaN,1.2])assert.throws(()=>productAttachmentPath(id));assert.equal(uncertainEditionResult({code:'ECONNABORTED'}),true);assert.equal(uncertainEditionResult(new Error('版本名重复')),false)})