feat: the machine is chosen at sign-in, per session (Dropstar's third round, item 12)
Some checks failed
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Failing after 2m32s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Has been skipped
Some checks failed
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Failing after 2m32s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Has been skipped
After signing in, the Kanban asks "Em qual máquina você está?": required
for the operator, optional for Gestão and Administrador ("Não estou em
máquina"), never for the other profiles. The session keeps it until it
ends or is changed from the header, where the machine shows in green;
one person on two computers runs two machines. Someone else already on
the machine is a warning, not a refusal.
Operators see the whole board (no more per-machine filter). From Arte
conferida they pull any card, which becomes their machine's (a machine
that does not print its product refuses it); they move only their
machine's cards, and the others show without drag or buttons. Their
cards and their machine's row in Imprimindo are outlined in green. The
history records the machine with the person: "Imprimindo · Thales ·
máquina2". Usuários shows who is on each machine now, read-only; the old
operator/machine assignment is no longer read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -116,7 +116,7 @@ def run():
|
||||
admin.call(path, {}, expected=403)
|
||||
admin.call('/operator/events', expected=403)
|
||||
admin.call('/operator/users', {'name': 'Op', 'email': emails['operador'], 'role': 'operador',
|
||||
'password': PASSWORD, 'machines': [uv]})
|
||||
'password': PASSWORD})
|
||||
admin.call('/operator/users', {'name': 'Vendas', 'email': emails['vendedor'], 'role': 'vendedor',
|
||||
'password': PASSWORD})
|
||||
admin.call('/operator/users', {'name': 'Again', 'email': emails['vendedor'], 'role': 'vendedor',
|
||||
@@ -145,26 +145,45 @@ def run():
|
||||
# On the UV machine of this test, whatever the others carry.
|
||||
su.call(f'/operator/orders/{uv_o}/machine', {'machine_id': uv}, operator=True)
|
||||
|
||||
# The operator of the UV machine sees only its orders and prints them:
|
||||
# Arte conferida to Imprimindo to Revisão, nothing else (Dropstar, 2026-10-23).
|
||||
# The operator prints: Arte conferida to Imprimindo to Revisão, nothing
|
||||
# else (Dropstar, 2026-10-23). After signing in they say which machine
|
||||
# they are on, and must (item 12, 2026-10-30); they see the whole board.
|
||||
op = signed_in(emails['operador'])
|
||||
seen = {o['id'] for o in op.call('/operator/board')['orders']}
|
||||
assert str(uv_o) in seen and str(textil_o) not in seen, seen
|
||||
assert sorted(op.call('/operator/me')['moves']) == [['imp', 'rev'], ['imp', 'tra'], ['rev', 'imp'], ['tra', 'imp']]
|
||||
me = op.call('/operator/me')
|
||||
assert (me['machine_question'], me['machine_answered'], me['machine']) == ('required', False, None), me
|
||||
assert {str(uv_o), str(textil_o)} <= {o['id'] for o in op.call('/operator/board')['orders']}
|
||||
assert sorted(me['moves']) == [['imp', 'rev'], ['imp', 'tra'], ['rev', 'imp'], ['tra', 'imp']]
|
||||
op.call(f'/operator/orders/{uv_o}/move', {'state': 'tra', 'version': 0, 'reason': ''}, expected=403)
|
||||
with db.connect() as c:
|
||||
c.execute("UPDATE dtf_local.orders SET state='imp' WHERE id=%s", (uv_o,))
|
||||
op.call(f'/operator/orders/{uv_o}/move', {'state': 'rev', 'version': 0, 'reason': ''}, expected=409)
|
||||
op.call('/operator/me/machine', {'machine_id': None}, expected=422)
|
||||
op.call('/operator/me/machine', {'machine_id': uv})
|
||||
assert op.call('/operator/me')['machine'] == {'id': uv, 'name': f'UV {tag}'}
|
||||
op.call(f'/operator/orders/{uv_o}/move', {'state': 'cor', 'version': 0, 'reason': 'borrou'}, expected=403)
|
||||
printed = op.call(f'/operator/orders/{uv_o}/move', {'state': 'rev', 'version': 0, 'reason': ''})
|
||||
# The history names the machine with the person.
|
||||
last = op.call(f'/operator/orders/{uv_o}/history')[-1]
|
||||
assert (last['operator'], last['machine']) == (emails['operador'], f'UV {tag}'), last
|
||||
refused = op.call(f'/operator/orders/{uv_o}/move', {'state': 'fin', 'version': printed['version'], 'reason': ''},
|
||||
expected=403)
|
||||
assert refused['detail'] == 'Só o Revisor manda o pedido para Finalizado.', refused
|
||||
op.call(f'/operator/orders/{uv_o}/cancel', {'note': 'não pode'}, expected=403)
|
||||
op.call('/operator/users', expected=403)
|
||||
op.call('/operator/payment-events', expected=403)
|
||||
# Sent to the UV machine by hand, the Têxtil order appears for them.
|
||||
su.call(f'/operator/orders/{textil_o}/machine', {'machine_id': uv}, operator=True)
|
||||
assert str(textil_o) in {o['id'] for o in op.call('/operator/board')['orders']}
|
||||
# Another machine's card shows, but only who is on that machine moves it,
|
||||
# and the operator does not send orders to machines.
|
||||
with db.connect() as c:
|
||||
c.execute("UPDATE dtf_local.orders SET state='imp' WHERE id=%s", (textil_o,))
|
||||
refused = op.call(f'/operator/orders/{textil_o}/move', {'state': 'rev', 'version': 0, 'reason': ''}, expected=403)
|
||||
assert 'outra máquina' in refused['detail'], refused
|
||||
op.call(f'/operator/orders/{textil_o}/machine', {'machine_id': uv}, expected=403)
|
||||
with db.connect() as c:
|
||||
c.execute("UPDATE dtf_local.orders SET state='rec' WHERE id=%s", (textil_o,))
|
||||
# Gestão and the administrators may be on no machine; the others are never asked.
|
||||
assert admin.call('/operator/me')['machine_question'] == 'optional'
|
||||
admin.call('/operator/me/machine', {'machine_id': None})
|
||||
assert admin.call('/operator/me')['machine_answered'] and admin.call('/operator/me')['machine'] is None
|
||||
|
||||
# The seller reads and changes nothing.
|
||||
seller = signed_in(emails['vendedor'])
|
||||
@@ -305,15 +324,14 @@ def run():
|
||||
seller.call('/operator/me/password', {'current': 'oito-888', 'new': 'outra-senha-de-teste'})
|
||||
signed_in(emails['vendedor'], 'outra-senha-de-teste').call('/operator/me')
|
||||
|
||||
# A second Têxtil machine, its operators ticked on the machine itself: only
|
||||
# operators are linked, the seller is not.
|
||||
op_id, seller_id = users[emails['operador']]['id'], users[emails['vendedor']]['id']
|
||||
textil2 = admin.call('/operator/machines', {'name': f'Têxtil B {tag}', 'products': ['textil'],
|
||||
'operators': [op_id, seller_id]})['id']
|
||||
# A second Têxtil machine. Who is on each machine is who chose it after
|
||||
# signing in: Usuários only shows it (item 12).
|
||||
op_id = users[emails['operador']]['id']
|
||||
textil2 = admin.call('/operator/machines', {'name': f'Têxtil B {tag}', 'products': ['textil']})['id']
|
||||
machines.append(textil2)
|
||||
listed = {m['id']: m for m in admin.call('/operator/machines')['machines']}
|
||||
assert [o['id'] for o in listed[textil2]['operators']] == [op_id]
|
||||
assert set(next(u for u in admin.call('/operator/users')['users'] if u['id'] == op_id)['machines']) == {uv, textil2}
|
||||
assert listed[textil2]['operators'] == [] and [o['id'] for o in listed[uv]['operators']] == [op_id], listed[uv]
|
||||
assert next(u for u in admin.call('/operator/users')['users'] if u['id'] == op_id)['machines'] == [uv]
|
||||
# The next order goes to the one with fewer metres open.
|
||||
target = expected_machine(su, 'textil')
|
||||
with db.connect() as c:
|
||||
@@ -422,6 +440,37 @@ def run():
|
||||
assert (board[first]['printing'], board[second_in]['printing'], board[third]['printing']) == \
|
||||
(None, 'imprimindo', 'ripando')
|
||||
|
||||
# Pulled by an operator, a queued card becomes their machine's, whatever
|
||||
# machine it had (item 12); a machine that does not print its product
|
||||
# does not take it. Someone already on a machine is a warning, not a refusal.
|
||||
free = admin.call('/operator/machines', {'name': f'Livre {tag}', 'products': ['textil']})['id']
|
||||
machines.append(free)
|
||||
with db.connect() as c:
|
||||
queued = [order_fixture(c, owner, 'file') for _ in range(2)]
|
||||
made.extend(queued)
|
||||
for _, oid in queued:
|
||||
upload = uuid4()
|
||||
c.execute('''INSERT INTO dtf_local.uploads(id,owner,name,size,object_key,multipart_id,complete,
|
||||
expires_at,scan_state) VALUES(%s,%s,'final.pdf',1,%s,'m',true,now()+interval '20 days','clean')''',
|
||||
(upload, owner, f'test/{upload}'))
|
||||
c.execute('''INSERT INTO dtf_local.order_files(id,order_id,upload_id,item_index,kind,note,created_by)
|
||||
VALUES(%s,%s,%s,0,'final','ok','t')''', (uuid4(), oid, upload))
|
||||
c.execute("UPDATE dtf_local.orders SET state='tra', machine_id=%s, machine_chosen=true WHERE id=%s",
|
||||
(textil, oid))
|
||||
taken_id, other_id = (str(oid) for _, oid in queued)
|
||||
wrong = op.call(f'/operator/orders/{other_id}/move', {'state': 'imp', 'version': 0, 'reason': ''}, expected=409)
|
||||
assert wrong['detail'] == f'A UV {tag} não imprime este produto.', wrong
|
||||
op.call('/operator/me/machine', {'machine_id': free})
|
||||
taken = op.call(f'/operator/orders/{taken_id}/move', {'state': 'imp', 'version': 0, 'reason': ''})
|
||||
assert str(taken['machine_id']) == free and taken['machine_chosen'], taken
|
||||
assert op.call(f'/operator/orders/{taken_id}/history')[-1]['machine'] == f'Livre {tag}'
|
||||
warned = admin.call('/operator/me/machine', {'machine_id': free}, expected=409)
|
||||
assert warned['detail'] == f'Livre {tag} já tem Op ligado.', warned
|
||||
admin.call('/operator/me/machine', {'machine_id': free, 'confirm': True})
|
||||
on_free = next(m for m in admin.call('/operator/machines')['machines'] if m['id'] == free)['operators']
|
||||
assert {o['name'] for o in on_free} == {'Op', 'Marcus'}, on_free
|
||||
designer.call('/operator/me/machine', {'machine_id': free}, expected=403)
|
||||
|
||||
# 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))
|
||||
|
||||
Reference in New Issue
Block a user