Initial commit: Epson ePOS Node backend + Vue3 UI (printer matricial2)

This commit is contained in:
2025-09-27 16:06:57 -06:00
commit f3c13b356b
26 changed files with 5015 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
const { post, ensureOk } = require('./common');
async function run() {
const data = await post('/api/print/text', { text: 'Test 1: texto simple', options: { feedLines: 1 } });
console.log('01_text_simple ->', data);
ensureOk(data, '01_text_simple');
}
if (require.main === module) {
run().catch((e) => { console.error(e.message); process.exit(1); });
}
module.exports = run;

View File

@@ -0,0 +1,14 @@
const { post, ensureOk } = require('./common');
async function run() {
const data = await post('/api/print/text', { text: 'Test 2: center + cut', options: { align: 'center', feedLines: 1, cut: 'feed' } });
console.log('02_align_cut ->', data);
ensureOk(data, '02_align_cut');
}
if (require.main === module) {
run().catch((e) => { console.error(e.message); process.exit(1); });
}
module.exports = run;

View File

@@ -0,0 +1,17 @@
const { post, ensureOk } = require('./common');
async function run() {
const data = await post('/api/print/text', {
text: 'Test 3: font_b w2 h2',
options: { font: 'font_b', size: { width: 2, height: 2 }, style: { em: true }, feedLines: 1 }
});
console.log('03_font_size ->', data);
ensureOk(data, '03_font_size');
}
if (require.main === module) {
run().catch((e) => { console.error(e.message); process.exit(1); });
}
module.exports = run;

View File

@@ -0,0 +1,21 @@
const { post, ensureOk } = require('./common');
async function run() {
const data = await post('/api/print', {
operations: [
{ op: 'text', value: 'Test 4: linea 1' },
{ op: 'feedLine', line: 1 },
{ op: 'text', value: 'Test 4: linea 2' },
{ op: 'feedLine', line: 1 }
]
});
console.log('04_batch_feeds ->', data);
ensureOk(data, '04_batch_feeds');
}
if (require.main === module) {
run().catch((e) => { console.error(e.message); process.exit(1); });
}
module.exports = run;

View File

@@ -0,0 +1,22 @@
const { post, ensureOk } = require('./common');
async function run() {
const data = await post('/api/print', {
operations: [
{ op: 'textAlign', align: 'center' },
{ op: 'text', value: 'Test 5: EAN13' },
{ op: 'feedLine', line: 1 },
{ op: 'barcode', data: '490123456789', type: 'ean13', hri: 'below', width: 3, height: 80 },
{ op: 'feedLine', line: 2 }
]
});
console.log('05_barcode ->', data);
ensureOk(data, '05_barcode');
}
if (require.main === module) {
run().catch((e) => { console.error(e.message); process.exit(1); });
}
module.exports = run;

22
scripts/tests/06_qr.js Normal file
View File

@@ -0,0 +1,22 @@
const { post, ensureOk } = require('./common');
async function run() {
const data = await post('/api/print', {
operations: [
{ op: 'textAlign', align: 'center' },
{ op: 'text', value: 'Test 6: QR' },
{ op: 'feedLine', line: 1 },
{ op: 'qrcode', data: 'https://example.com/test6', model: 'qrcode_model_2', level: 'level_m', size: 6 },
{ op: 'feedLine', line: 2 }
]
});
console.log('06_qr ->', data);
ensureOk(data, '06_qr');
}
if (require.main === module) {
run().catch((e) => { console.error(e.message); process.exit(1); });
}
module.exports = run;

14
scripts/tests/07_pulse.js Normal file
View File

@@ -0,0 +1,14 @@
const { post, ensureOk } = require('./common');
async function run() {
const data = await post('/api/print/pulse', { drawer: 'drawer_1', time: 'pulse_200' });
console.log('07_pulse ->', data);
ensureOk(data, '07_pulse');
}
if (require.main === module) {
run().catch((e) => { console.error(e.message); process.exit(1); });
}
module.exports = run;

19
scripts/tests/common.js Normal file
View File

@@ -0,0 +1,19 @@
const axios = require('axios');
const baseURL = process.env.TEST_BASE_URL || 'http://localhost:3000';
const client = axios.create({ baseURL, timeout: 120000 });
async function post(path, body) {
const res = await client.post(path, body);
return res.data;
}
function ensureOk(data, stepName) {
if (!data || data.ok !== true) {
const msg = `Printer did not confirm success on step: ${stepName} -> ${JSON.stringify(data)}`;
throw new Error(msg);
}
}
module.exports = { post, ensureOk };