feat: Dropstar's corrections of 21/10 that need no answer from them
All checks were successful
Build and deploy / Validate source (push) Successful in 1m30s
Build and deploy / Integration suite on a real stack (push) Successful in 4m2s
Build and deploy / Secret scan and release gate (push) Successful in 14s
Build and deploy / Publish images (push) Successful in 1m48s

- the home example priced as the ready sheet it shows (nota 92, R$ 14,90)
- opening hours 7h to 18h, and art sent at any time
- uploads up to 1 GB, every file scanned
- a Designer profile: artwork and corrections on every order, moving only
  among Arte recebida, Arte conferida and Correção
- Números by date range, per machine, and orders apart from passages

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-22 10:09:15 -03:00
parent a2382f4834
commit d4494a0654
21 changed files with 279 additions and 89 deletions

View File

@@ -156,14 +156,14 @@ try{
assert.deepEqual(await evaluate(`({shown:!$('tipoEnvio').hidden,
on:[...document.querySelectorAll('#tipoEnvio .cam.on')].map(b=>b.dataset.tipo)})`),
{shown:true,on:['folha']});
await evaluate(`(()=>{const f=new File(['x'],'oversize.cdr');Object.defineProperty(f,'size',{value:5*1073741824+1});sel([f]);})()`);
assert.equal(await evaluate(`folhas.length===0 && $('recusa').textContent.includes('5 GB')`),true,
'files beyond the 5 GB upload limit are rejected before browser analysis');
// A multi-GB sheet is the normal order: graded from the pixel size in its
await evaluate(`(()=>{const f=new File(['x'],'oversize.cdr');Object.defineProperty(f,'size',{value:1073741824+1});sel([f]);})()`);
assert.equal(await evaluate(`folhas.length===0 && $('recusa').textContent.includes('1 GB')`),true,
'files beyond the 1 GB upload limit are rejected before browser analysis');
// A large sheet (here 900 MB) is the normal order: graded from the pixel size in its
// header, never decoded. 6732 x 35433 px across 57 cm is 3 m at 300 DPI.
await evaluate(`(()=>{const h=new Uint8Array(33);h.set([0x89,0x50,0x4E,0x47,0x0D,0x0A,0x1A,0x0A,0,0,0,13,0x49,0x48,0x44,0x52]);
const v=new DataView(h.buffer);v.setUint32(16,6732);v.setUint32(20,35433);h.set([8,6,0,0,0],24);
const f=new File([h],'folha-grande.png');Object.defineProperty(f,'size',{value:3*1073741824});sel([f]);})()`);
const f=new File([h],'folha-grande.png');Object.defineProperty(f,'size',{value:900*1048576});sel([f]);})()`);
await waitFor(()=>evaluate(`folhas.length===1 && !!folhas[0].an`),'large sheet graded from its header');
assert.deepEqual(await evaluate(`({grande:folhas[0].an.grande,dpi:folhas[0].an.dpi,alt:folhas[0].med.alt,preview:!!folhas[0].previewSrc})`),
{grande:true,dpi:300,alt:300,preview:false});

View File

@@ -126,6 +126,24 @@ def run():
assert after['daily'][-1]['orders'] == before['daily'][-1]['orders'] + 1
assert after['waiting']['rec']['orders'] == before.get('waiting', {}).get('rec', {}).get('orders', 0) + 1
client.call('/operator/stats?days=3', operator=True, expected=422)
# Or two dates: the same week asked as a range gives the same numbers.
week = client.call(f"/operator/stats?start={after['start']}&end={after['end']}", operator=True)
assert (week['orders'], week['cents'], len(week['daily'])) == (after['orders'], after['cents'], 7), week
one = client.call(f"/operator/stats?start={after['end']}&end={after['end']}", operator=True)
assert len(one['daily']) == 1 and one['daily'][0] == after['daily'][-1]
client.call(f"/operator/stats?start={after['end']}&end={after['start']}", operator=True, expected=422)
client.call(f"/operator/stats?start={after['start']}", operator=True, expected=422)
client.call('/operator/stats?start=2025-01-01&end=2026-12-31', operator=True, expected=422)
assert isinstance(after['machines'], list)
# An order sent back counts once per stage; its passages are counted apart.
with db.connect() as c:
for step, (frm, to) in enumerate((('rec', 'tra'), ('tra', 'cor'), ('cor', 'tra'), ('tra', 'fil'))):
c.execute('''INSERT INTO dtf_local.movements(order_id,from_state,to_state,operator,reason,back,created_at)
VALUES(%s,%s,%s,'kanban-test','',false,now()+%s*interval '1 second')''', (order_id, frm, to, step + 1))
moved = client.call('/operator/stats?days=7', operator=True)
tra_before = after['stages'].get('tra', {'orders': 0, 'passages': 0})
assert moved['stages']['tra']['orders'] == tra_before['orders'] + 1, moved['stages']
assert moved['stages']['tra']['passages'] == tra_before['passages'] + 2, moved['stages']
# The company's name from the registry: on the board, and found by the search.
from app import cnpj as registry
@@ -158,6 +176,7 @@ def run():
'and a backup asked for now')
finally:
with db.connect() as c:
c.execute('DELETE FROM dtf_local.movements WHERE order_id=%s', (order_id,))
c.execute('DELETE FROM dtf_local.orders WHERE id=%s', (order_id,))
c.execute('DELETE FROM dtf_local.quotes WHERE id=ANY(%s)', ([pending, approved, paid],))
c.execute('DELETE FROM dtf_local.upload_thumbnails WHERE upload_id=%s', (uid,))

View File

@@ -117,8 +117,8 @@ def run():
client=Client();other=Client()
config=client.call('/session');other.call('/session')
assert client.call('/health')['integrations']=='fake'
# Sheets of several GB are the normal order: 5 GB per file.
assert config['max_upload_bytes'] == 5 * 1024 ** 3
# 1 GB per file: a 57 cm x 5 m sheet at 300 DPI is 200 to 300 MB.
assert config['max_upload_bytes'] == 1024 ** 3
client.call('/uploads',{'name':'too-large.cdr',
'size':config['max_upload_bytes']+1},expected=413)
cancelled=client.call('/uploads',{'name':'CANCELLED-PART.cdr','size':3})['id']

View File

@@ -67,7 +67,7 @@ def run():
su = Client()
su.call('/session')
assert su.call('/operator/me', operator=True)['role'] == 'superadmin'
emails = {r: f'{r}-{tag}@example.test' for r in ('admin', 'operador', 'vendedor')}
emails = {r: f'{r}-{tag}@example.test' for r in ('admin', 'operador', 'vendedor', 'designer')}
owner = uuid4()
machines, made = [], []
try:
@@ -140,6 +140,24 @@ def run():
seller.call(f'/operator/orders/{textil_o}/machine', {'machine_id': None}, expected=403)
seller.call(f'/operator/orders/{textil_o}/contact', {'waiting': True, 'note': 'Ligar'}, expected=403)
assert seller.call('/operator/me')['can'] == ['view']
# The designer: every order, whatever its machine; the artwork stages only.
admin.call('/operator/users', {'name': 'Arte', 'email': emails['designer'], 'role': 'designer',
'password': PASSWORD, 'machines': [uv]})
assert next(u for u in admin.call('/operator/users')['users'] if u['email'] == emails['designer'])['machines'] == []
designer = signed_in(emails['designer'])
assert set(designer.call('/operator/me')['can']) == {'view', 'produce'}
assert {str(uv_o), str(textil_o)} <= {o['id'] for o in designer.call('/operator/board')['orders']}
version = next(o for o in designer.call('/operator/board')['orders'] if o['id'] == str(textil_o))['version']
moved = designer.call(f'/operator/orders/{textil_o}/move', {'state': 'tra', 'version': version, 'reason': ''})
designer.call(f'/operator/orders/{textil_o}/move', {'state': 'fil', 'version': moved['version'], 'reason': ''},
expected=403)
designer.call(f'/operator/orders/{textil_o}/move', {'state': 'rec', 'version': moved['version'],
'reason': 'arte trocada'})
designer.call(f'/operator/orders/{textil_o}/machine', {'machine_id': None}, expected=403)
designer.call(f'/operator/orders/{textil_o}/cancel', {'note': 'não pode'}, expected=403)
designer.call('/operator/queue/finals', expected=403)
designer.call('/operator/users', expected=403)
# Their own password: the current one is asked for.
seller.call('/operator/me/password', {'current': 'errada', 'new': 'outra-senha-de-teste'}, expected=403)
# Eight characters or more.
@@ -191,6 +209,21 @@ def run():
board = {o['id']: o for o in su.call('/operator/board', operator=True)['orders']}
assert not board[second]['machine']['chosen']
# Números per machine: an order printed for half an hour on its machine, then finished.
before = {m['id']: m for m in su.call('/operator/stats?days=7', operator=True)['machines']}
with db.connect() as c:
# A real payment: Números leaves test orders out.
c.execute('UPDATE dtf_local.orders SET payment=%s WHERE id=%s',
(Jsonb({'provider': 'mercadopago', 'id': f'users-{tag}'}), third))
for frm, to, at in (('rec', 'imp', "now()-interval '30 minutes'"), ('imp', 'fin', 'now()')):
c.execute(f'''INSERT INTO dtf_local.movements(order_id,from_state,to_state,operator,reason,back,created_at)
VALUES(%s,%s,%s,'users-test','',false,{at})''', (third, frm, to))
after = {m['id']: m for m in su.call('/operator/stats?days=7', operator=True)['machines']}
assert after[target]['orders'] == before[target]['orders'] + 1
assert after[target]['metres'] == before[target]['metres'] + 1.0
assert after[target]['last_finished'] and after[target]['metres_per_hour'] is not None
assert after[target]['printing_hours'] >= before[target]['printing_hours'] + 0.49
# Switched off, a machine gives its automatic orders to another one.
with db.connect() as c:
c.execute('UPDATE dtf_local.orders SET machine_id=%s, machine_chosen=false WHERE id=%s', (textil2, second))