feat: one order, one machine: UV and textile never share an order (Marcus, 2026-11-26)
All checks were successful
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 7m56s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m16s
All checks were successful
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 7m56s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m16s
The server refuses a cart (and a review) with UV and textile items; the Site says so as soon as the customer opens a product of the other line, or adds it, with "Finalizar este pedido" and "Trocar o carrinho por este item". Basic and premium textile still go together. Proof cards copy their order's items, so they follow. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -101,7 +101,7 @@ jobs:
|
||||
# the generator's geometry. The provider suites use a fake transport: they
|
||||
# prove the documented contract, not the integration.
|
||||
- name: Print-file geometry and provider adapters
|
||||
run: $COMPOSE exec -T api python -m unittest tests.test_printfile tests.test_printpng tests.test_mercadopago tests.test_tiny tests.test_cnpj tests.test_payment_messages tests.test_jadlog tests.test_correios tests.test_quote_review tests.test_moves tests.test_large_files tests.test_grade_check tests.test_schema tests.test_customer_document tests.test_mail_html tests.test_layout_rules tests.test_proof_cut tests.test_proof_render tests.test_sheet_trim tests.test_prumo tests.test_speed tests.test_printpng_validate tests.test_machine_log tests.test_machine_stats tests.test_label tests.test_observability tests.test_worker_drain tests.test_db_outage tests.test_health -v
|
||||
run: $COMPOSE exec -T api python -m unittest tests.test_printfile tests.test_printpng tests.test_mercadopago tests.test_tiny tests.test_cnpj tests.test_payment_messages tests.test_jadlog tests.test_correios tests.test_quote_review tests.test_moves tests.test_large_files tests.test_grade_check tests.test_schema tests.test_customer_document tests.test_mail_html tests.test_layout_rules tests.test_proof_cut tests.test_proof_render tests.test_sheet_trim tests.test_one_machine tests.test_prumo tests.test_speed tests.test_printpng_validate tests.test_machine_log tests.test_machine_stats tests.test_label tests.test_observability tests.test_worker_drain tests.test_db_outage tests.test_health -v
|
||||
|
||||
- name: Runtime and retention regressions
|
||||
run: |
|
||||
|
||||
@@ -165,6 +165,19 @@ class Split(StrictModel):
|
||||
of: int = Field(ge=2, le=10, strict=True)
|
||||
|
||||
|
||||
UV_MODES = ('uvfile', 'uv')
|
||||
ONE_MACHINE = ('Esse produto é impresso em outra máquina e precisa de um pedido separado. '
|
||||
'Finalize este pedido e faça um novo com ele.')
|
||||
|
||||
|
||||
def check_one_machine(items):
|
||||
"""One order, one machine (Marcus, 2026-11-26): UV and textile never share
|
||||
an order, since its card goes to one machine. Basic and premium textile
|
||||
print on the same machines and may."""
|
||||
if len({item.mode in UV_MODES for item in items}) > 1:
|
||||
raise ValueError(ONE_MACHINE)
|
||||
|
||||
|
||||
def check_splits(items):
|
||||
"""Every split group has each of its parts once, of one product."""
|
||||
groups = {}
|
||||
@@ -309,6 +322,7 @@ class QuoteRequest(StrictModel):
|
||||
@model_validator(mode='after')
|
||||
def splits_complete(self):
|
||||
check_splits(self.items)
|
||||
check_one_machine(self.items)
|
||||
return self
|
||||
|
||||
@model_validator(mode='after')
|
||||
@@ -399,6 +413,7 @@ class Review(StrictModel):
|
||||
@model_validator(mode='after')
|
||||
def splits_complete(self):
|
||||
check_splits(self.items)
|
||||
check_one_machine(self.items)
|
||||
return self
|
||||
|
||||
class Pay(StrictModel):
|
||||
|
||||
@@ -196,12 +196,16 @@ def run():
|
||||
print('PASS: multipart resume, incomplete rejection, immutable completion, ownership, private/downloaded bytes')
|
||||
|
||||
# Above QUOTE_AUTO_MAX_METRES (50 m by default), so a person reviews it.
|
||||
items=[item_spec(m,'13',90,uid) for m in ('file','avulsa','uvfile','uv')]
|
||||
# One order, one machine (Marcus, 2026-11-26): the two textile products;
|
||||
# UV goes in an order of its own.
|
||||
items=[item_spec(m,'26',90,uid) for m in ('file','avulsa')]
|
||||
draft={'request_key':str(uuid4()),'customer':{'cnpj':'11222333000181','zap':'11999999999','mail':'local-smoke@example.test'},
|
||||
'items':items,'freight':{'service':'mock-standard','postal_code':'14400000'},
|
||||
'destination':{'recipient':'Local Smoke Ltda','street':'Rua de Teste','number':'100',
|
||||
'district':'Centro','city':'Franca','state':'SP','postal_code':'14400000'}}
|
||||
client.call('/quotes',{**draft,'total_cents':1},expected=422)
|
||||
mixed_cart=client.call('/quotes',{**draft,'items':[items[0],item_spec('uvfile','13',90,uid)]},expected=422)['detail']
|
||||
assert any('outra máquina' in str(e.get('msg','')) for e in mixed_cart), mixed_cart
|
||||
# Freight quoted by CEP alone cannot ship: the address is required, must be
|
||||
# the quoted CEP, and a pickup order takes none.
|
||||
client.call('/quotes',{**draft,'destination':None},expected=422)
|
||||
@@ -237,8 +241,8 @@ def run():
|
||||
corrected=[{**items[0],'metres':'1.01','grade':0},*items[1:]]
|
||||
approved=client.call('/operator/quotes/'+qid+'/approve',{'items':corrected},operator=True)
|
||||
assert approved['items'][0]['total_cents']==2189 and approved['items'][0]['grade']==0
|
||||
assert [i['unit_cents'] for i in approved['items'][1:]]==[2190,7990,8990]
|
||||
assert approved['total_cents']==2189+28470+103870+116870+int(os.environ.get('MOCK_FREIGHT_CENTS','1500'))
|
||||
assert [i['unit_cents'] for i in approved['items'][1:]]==[2190]
|
||||
assert approved['total_cents']==2189+56940+int(os.environ.get('MOCK_FREIGHT_CENTS','1500'))
|
||||
assert approved['destination']=={**draft['destination'],'complement':''}
|
||||
client.call('/operator/quotes/'+qid+'/approve',{'items':items},operator=True,expected=409)
|
||||
assert not client.call('/quotes/'+qid)['auto_approved']
|
||||
@@ -331,7 +335,7 @@ def run():
|
||||
if state=='tra':
|
||||
# The queue takes approved final files only.
|
||||
client.call('/operator/orders/'+oid+'/move',{'state':'tra','version':version},operator=True,expected=409)
|
||||
files=[{'item_index':i,'upload_id':upload_bytes(client,final_png_bytes(str(i)),name=f'LOCAL-FINAL-{i}.png',order_id=oid)} for i in range(4)]
|
||||
files=[{'item_index':i,'upload_id':upload_bytes(client,final_png_bytes(str(i)),name=f'LOCAL-FINAL-{i}.png',order_id=oid)} for i in range(len(items))]
|
||||
result=client.call('/operator/orders/'+oid+'/final-files',{'version':version,'files':files,'note':'Local test manual final-file approval'},operator=True)
|
||||
version=result['version']
|
||||
body={'state':state,'version':version,'reason':'Local test correction' if state=='cor' else ''}
|
||||
|
||||
29
tests/test_one_machine.py
Normal file
29
tests/test_one_machine.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""One order, one machine (Marcus, 2026-11-26): UV and textile never share an
|
||||
order; basic and premium textile may.
|
||||
|
||||
Run from the repository root: python3 -m unittest tests.test_one_machine -v.
|
||||
"""
|
||||
import unittest
|
||||
|
||||
from app.core.models import ONE_MACHINE, Item, check_one_machine
|
||||
from tests.test_sheet_trim import sheet_item
|
||||
|
||||
|
||||
def items(*modes):
|
||||
return [Item.model_validate(sheet_item(mode=mode)) for mode in modes]
|
||||
|
||||
|
||||
class OneMachineTests(unittest.TestCase):
|
||||
def test_uv_and_textile_never_share_an_order(self):
|
||||
for modes in (('file', 'uvfile'), ('premium', 'uvfile'), ('uvfile', 'file', 'file')):
|
||||
with self.assertRaises(ValueError) as caught:
|
||||
check_one_machine(items(*modes))
|
||||
self.assertEqual(str(caught.exception), ONE_MACHINE)
|
||||
|
||||
def test_one_line_passes(self):
|
||||
check_one_machine(items('file', 'premium', 'file'))
|
||||
check_one_machine(items('uvfile', 'uvfile'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -974,6 +974,13 @@ h2 em{font-style:normal;color:var(--laranja)}
|
||||
<div class="mistaBot"><button type="button" class="ec-go" id="mistaSegue">Imprimir assim mesmo (C1)</button><button type="button" id="mistaSep">Quero subir em dois arquivos</button></div>
|
||||
</div>
|
||||
</dialog>
|
||||
<dialog class="ampliaDlg mistaDlg" id="linhaDlg" aria-labelledby="linhaTit">
|
||||
<div class="ampliaCab"><b id="linhaTit">Pedido separado</b></div>
|
||||
<div class="mistaCorpo">
|
||||
<p>Esse produto é impresso em outra máquina e precisa de um pedido separado. Finalize este pedido e faça um novo com ele.</p>
|
||||
<div class="mistaBot"><button type="button" class="ec-go" id="linhaFim">Finalizar este pedido</button><button type="button" id="linhaTroca">Trocar o carrinho por este item</button></div>
|
||||
</div>
|
||||
</dialog>
|
||||
<dialog class="ampliaDlg" id="ampliaDlg" aria-labelledby="ampliaTit">
|
||||
<div class="ampliaCab"><b id="ampliaTit">Sua folha</b>
|
||||
<button type="button" id="ampliaFecha" aria-label="Fechar"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg></button></div>
|
||||
|
||||
@@ -24,6 +24,7 @@ function guardaItem(){
|
||||
$('ciente').scrollIntoView({behavior:'smooth',block:'center'});
|
||||
return false;
|
||||
}
|
||||
if(itemAtual && outraMaquina(itemAtual.modo)){ avisaOutraMaquina(itemAtual.modo,adicionaAoCarrinho); return false; }
|
||||
if(itemAtual){ pedido.push(itemAtual); itemAtual=null; }
|
||||
$('atual').style.display='none'; $('carrLin').innerHTML='';
|
||||
$('foco').classList.remove('on');
|
||||
|
||||
@@ -9,6 +9,25 @@ function escolheProduto(m){
|
||||
if(modo===m && $('foco').classList.contains('on')) vaiPara(PAGINAS[m]);
|
||||
else abrir(m);
|
||||
}
|
||||
// Um pedido, uma máquina (Marcus, 26/11/2026): UV e têxtil nunca no mesmo
|
||||
// pedido, que vira um card numa máquina só. Têxtil e Premium vão juntos.
|
||||
// Conta todo o carrinho, também o que ficou guardado para depois; o servidor
|
||||
// recusa o mesmo pedido misto (app/core/models.py check_one_machine).
|
||||
const linhaUV=m=>m==='uvfile'||m==='uv';
|
||||
function outraMaquina(m){ return pedido.some(it=>linhaUV(it.modo)!==linhaUV(m)); }
|
||||
function avisaOutraMaquina(m,depois){
|
||||
const dlg=$('linhaDlg');
|
||||
if(!dlg || dlg.open) return;
|
||||
$('linhaFim').onclick=()=>{ dlg.close(); vaiPara(CARRINHO); };
|
||||
$('linhaTroca').onclick=()=>{
|
||||
dlg.close();
|
||||
const antes=pedido.slice();
|
||||
pedido=[]; pintaPedido();
|
||||
avisaDesfazer('Carrinho trocado por '+MODOS[m].tit+'.',()=>{ pedido=antes; pintaPedido(); });
|
||||
if(depois) depois();
|
||||
};
|
||||
dlg.showModal();
|
||||
}
|
||||
function abrir(m){
|
||||
modo=m; artes=[]; folhas=[]; metros=0; nota=0; reencaixado=false;
|
||||
montagemCm=0;
|
||||
@@ -19,6 +38,8 @@ function abrir(m){
|
||||
$('vMt').textContent='—'; previaAoVivo(); agendaAvaliacao();
|
||||
limpaPaineis(); // o carrinho só some se o pedido estiver vazio
|
||||
vaiPara(PAGINAS[m]);
|
||||
// Produto da outra máquina: avisa já ao abrir, antes de o cliente subir arquivos.
|
||||
if(outraMaquina(m)) avisaOutraMaquina(m);
|
||||
}
|
||||
function pintaModo(){
|
||||
const m=modo;
|
||||
|
||||
Reference in New Issue
Block a user