Files
SGF/scripts/workshop-delivery-ui-check.mjs
T
2026-11-02 20:29:34 +02:00

17 lines
1.7 KiB
JavaScript

import assert from 'node:assert/strict';
import fs from 'node:fs/promises';
import crypto from 'node:crypto';
import React from 'react';
import {renderToStaticMarkup} from 'react-dom/server';
import {createServer} from 'vite';
const server=await createServer({configFile:false,server:{middlewareMode:true,watch:null},appType:'custom',optimizeDeps:{noDiscovery:true}});
try {
const {WorkshopStockImpact}=await server.ssrLoadModule('/resources/js/WorkshopStockWorkspace.jsx');
const html=renderToStaticMarkup(React.createElement(WorkshopStockImpact,{impact:{mode:'link_existing_delivery',physical_before:'8000',physical_after:'8000',quantity_milli:'0',linked_quantity_milli:'2000',existing_movement_id:42,stock_item_id:1,warehouse_id:11,source_version:1}}));
assert(html.includes('8,000 → 8,000'));assert(html.includes('Nova saída: 0,000'));assert(html.includes('Ligar entrega #42: 2,000, sem novo abatimento.'));
const source=await fs.readFile('resources/js/WorkshopStockWorkspace.jsx','utf8');
assert(source.includes('required defaultValue=""'));assert(source.includes('Seleccione individualmente'));assert(source.includes('/api/workshop-stock/prepare-delivery'));
await fs.writeFile('docs/proofs/workshop-delivery-ui-20261102.json',JSON.stringify({kind:'static_impact_render_and_source_checks',zero_new_physical_effect_visible:true,existing_movement_and_quantity_visible:true,explicit_treatment_selection_in_source:true,component_sha256:crypto.createHash('sha256').update(source).digest('hex'),backend_requests:0,visual_review:false,browser_interactions_tested:false},null,2)+'\n');
console.log('Delivery impact rendering and explicit treatment selection checks passed; visual review pending.');
} finally {await server.close();}