fix: align proof, treatment, metrics and site videos with PDF
All checks were successful
Build and deploy / Validate source (push) Successful in 11s
Build and deploy / Integration suite on a real stack (push) Successful in 5m44s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m22s
All checks were successful
Build and deploy / Validate source (push) Successful in 11s
Build and deploy / Integration suite on a real stack (push) Successful in 5m44s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m22s
This commit is contained in:
@@ -116,8 +116,19 @@ try{
|
||||
await call('Emulation.setDeviceMetricsOverride',{width:1440,height:1100,deviceScaleFactor:1,mobile:false});
|
||||
await call('Page.navigate',{url:`http://127.0.0.1:${server.address().port}/`});
|
||||
await waitFor(()=>evaluate(`typeof sel==='function' && typeof pintaEntrega==='function'`),'Site scripts');
|
||||
assert.equal(await evaluate(`document.querySelectorAll('#videosGrid .videoCard').length`),6);
|
||||
assert.equal(await evaluate(`document.querySelector('#videosGrid').textContent.includes('Subindo a arte pelo celular')`),true);
|
||||
await evaluate('window.siteVideosReady');
|
||||
assert.equal(await evaluate(`document.querySelectorAll('#videosGrid .videoCard').length`),0);
|
||||
assert.equal(await evaluate(`document.querySelector('#videos').hidden`),true);
|
||||
await evaluate(`VIDEOS[0].src='/preview.mp4';videosSection()`);
|
||||
await evaluate(`document.querySelector('#videosGrid .videoCard').focus()`);
|
||||
await click('#videosGrid .videoCard');
|
||||
assert.deepEqual(await evaluate(`({dialog:document.querySelector('.videoModal').getAttribute('role'),
|
||||
focus:document.activeElement.className,open:!document.querySelector('.videoModal').hidden})`),
|
||||
{dialog:'dialog',focus:'vmClose',open:true});
|
||||
await call('Input.dispatchKeyEvent',{type:'keyDown',key:'Escape',code:'Escape',windowsVirtualKeyCode:27});
|
||||
assert.equal(await evaluate(`document.querySelector('.videoModal').hidden &&
|
||||
document.activeElement.classList.contains('videoCard')`),true);
|
||||
await evaluate(`VIDEOS[0].src=null;videosSection()`);
|
||||
// Observe the actual engine, without replacing its placement or rendering.
|
||||
await evaluate(`(()=>{
|
||||
const original=encaixar;
|
||||
@@ -172,6 +183,19 @@ try{
|
||||
return [(await medir(...linhas(2))).px,(await medir(...linhas(5))).px,(await medir(...linhas(6))).px,
|
||||
(await medir(...linhas(20))).classe,(await medir(...linhas(20),...ciscos)).classe];})()`),[2,5,6,'C3','C3']);
|
||||
await click('[data-modo="file"]');
|
||||
// A ready sheet with two source files stores the finest stroke's position
|
||||
// on the combined film, not its position within the second file.
|
||||
assert.deepEqual(await evaluate(`(()=>{
|
||||
const old=folhas,oldLayout=montagemLayout;
|
||||
folhas=[{an:{traco:{px:9,classe:'C2',proofYFraction:0.2}}},
|
||||
{an:{traco:{px:3,classe:'C1',proofYFraction:0.5}}}];
|
||||
montagemLayout=null;
|
||||
try{return tracoDoItem(null,{height_cm:100,placements:[
|
||||
{source_index:0,y_cm:0,length_cm:50,rotation_degrees:0},
|
||||
{source_index:1,y_cm:50,length_cm:50,rotation_degrees:0}]});}
|
||||
finally{folhas=old;montagemLayout=oldLayout;}
|
||||
})()`),{strokePx:3,strokeClass:'C1',strokeChoice:null,
|
||||
proofSourceIndex:1,proofYFraction:0.75});
|
||||
// Opening a product paints on the next frame; on a busy runner the check
|
||||
// must wait for it rather than race it.
|
||||
await waitFor(()=>evaluate(`!$('tipoEnvio').hidden`),'by-metre product open');
|
||||
|
||||
@@ -165,6 +165,13 @@ try{
|
||||
await waitFor(()=>kanban.eval('!document.getElementById("app").hidden'),'Kanban sign-in');
|
||||
assert.equal(await kanban.eval('sessionStorage.getItem("dtf-operator")'),null);
|
||||
assert.equal(await kanban.eval('document.getElementById("password").value'),'');
|
||||
await kanban.click('[data-tab="integrations"]');
|
||||
await waitFor(()=>kanban.eval('document.querySelectorAll("#site-videos-list .siteVideoRow").length===6'),
|
||||
'six video slots in Gestão');
|
||||
assert.equal(await kanban.eval('document.querySelectorAll("#site-videos-list input[type=file]").length'),12);
|
||||
await mkdir('output/local',{recursive:true});
|
||||
await kanban.eval('document.getElementById("site-videos-panel").scrollIntoView()');
|
||||
await kanban.screenshot('output/local/kanban-videos.png');
|
||||
await kanban.click('[data-tab="quotes"]');
|
||||
await waitFor(()=>kanban.eval('document.querySelectorAll("#quote-filters button").length===2'),'quote filters');
|
||||
await kanban.eval('document.querySelectorAll("#quote-filters button")[1].click()');
|
||||
|
||||
@@ -171,15 +171,15 @@ def run():
|
||||
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,%s::timestamptz)''', (order_id, frm, to, f'{alone} {hour}:00-03'))
|
||||
day = client.call(f'/operator/stats?start={alone}&end={alone}', operator=True)
|
||||
assert day['stages']['tra'] == {'orders': 1, 'passages': 2, 'median_hours': 2.0}, day['stages']
|
||||
assert day['stages']['rec']['median_hours'] == 1.0, day['stages']
|
||||
assert day['stages']['tra'] == {'orders': 1, 'passages': 2, 'average_hours': 2.0}, day['stages']
|
||||
assert day['stages']['rec']['average_hours'] == 1.0, day['stages']
|
||||
# Half an hour of it waiting for the customer does not count (D-38).
|
||||
with db.connect() as c:
|
||||
c.execute('''INSERT INTO dtf_local.contact_waits(order_id, started_at, ended_at)
|
||||
VALUES(%s, %s::timestamptz, %s::timestamptz)''', (order_id, f'{alone} 09:15-03', f'{alone} 09:45-03'))
|
||||
day = client.call(f'/operator/stats?start={alone}&end={alone}', operator=True)
|
||||
assert day['stages']['tra']['median_hours'] == 1.5, day['stages']
|
||||
assert day['stages']['rec']['median_hours'] == 1.0, day['stages']
|
||||
assert day['stages']['tra']['average_hours'] == 1.5, day['stages']
|
||||
assert day['stages']['rec']['average_hours'] == 1.0, day['stages']
|
||||
|
||||
# The company's name from the registry: on the board, and found by the search.
|
||||
from app import cnpj as registry
|
||||
|
||||
@@ -304,6 +304,29 @@ def run():
|
||||
assert final['created_by'] == 'Prumo' and 'prova' in final['note'].lower(), final
|
||||
print('PASS: Prova OK turns Prumo\'s full file into the parent final and queues it')
|
||||
|
||||
# A CDR cannot be decoded by the worker. The designer prepares the full
|
||||
# parent PNG, then the worker automatically cuts the child's proof from it.
|
||||
manual_source = upload_bytes(client, b'LOCAL PRINT TEST - NOT AN IMAGE', name='MANUAL-PROOF.cdr')
|
||||
manual_parent = paid_order(client, loose_item(manual_source, copies=1))
|
||||
with db.connect() as c:
|
||||
c.execute("UPDATE dtf_local.orders SET snapshot=jsonb_set(snapshot,'{proof}','true') WHERE id=%s",
|
||||
(manual_parent['id'],))
|
||||
manual_child = client.call('/operator/orders/' + manual_parent['id'] + '/proof-card', {}, operator=True)
|
||||
wait_print(client, manual_child['id'], 'manual')
|
||||
retry = client.call('/operator/orders/' + manual_child['id'] + '/print-files', {}, operator=True, expected=409)
|
||||
assert 'pedido pai' in retry['detail'], retry
|
||||
prepared = upload_bytes(client, artwork(), name='MANUAL-PROOF-FINAL.png', order_id=manual_parent['id'])
|
||||
client.call('/operator/orders/' + manual_parent['id'] + '/final-files',
|
||||
{'version': manual_parent['version'],
|
||||
'files': [{'item_index': 0, 'upload_id': prepared}],
|
||||
'note': 'PNG completo para a prova'}, operator=True)
|
||||
client.call('/operator/orders/' + manual_child['id'] + '/print-files', {}, operator=True)
|
||||
wait_print(client, manual_child['id'], 'ready')
|
||||
proof_card = next(o for o in client.call('/operator/board', operator=True)['orders']
|
||||
if o['id'] == manual_child['id'])
|
||||
assert proof_card['final_items'] == [0], proof_card
|
||||
print('PASS: manual parent PNG produces the child proof automatically')
|
||||
|
||||
# A customer cannot see or reuse another order's generated file.
|
||||
other = Client()
|
||||
other.call('/session')
|
||||
|
||||
74
tests/site_video_test.py
Normal file
74
tests/site_video_test.py
Normal file
@@ -0,0 +1,74 @@
|
||||
"""Published site videos retain their file and expose same-origin captions.
|
||||
|
||||
Run against the local stack with an internal S3 public endpoint:
|
||||
SITE_BASE_URL=http://site SITE_HOST_HEADER=localhost python -m tests.site_video_test
|
||||
"""
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
from app.core import db
|
||||
from app.runtime import storage
|
||||
from tests.smoke_test import BASE, Client, with_host, wait_scan
|
||||
|
||||
|
||||
VIDEO = b'\x00\x00\x00\x18ftypisom\x00\x00\x00\x00isomiso2'
|
||||
CAPTIONS = b'WEBVTT\n\n00:00:00.000 --> 00:00:01.000\nTeste de legenda.\n'
|
||||
|
||||
|
||||
def upload(operator, name, content):
|
||||
start = operator.call('/operator/site-videos/uploads', {'name': name, 'size': len(content)})
|
||||
uid = start['id']
|
||||
url = operator.call(f'/operator/uploads/{uid}/parts/1', {})['url']
|
||||
with urlopen(Request(url, data=content, method='PUT'), timeout=30) as response:
|
||||
assert response.status == 200
|
||||
operator.call(f'/operator/uploads/{uid}/complete', {})
|
||||
wait_scan(operator, uid, operator=True)
|
||||
return uid
|
||||
|
||||
|
||||
def run():
|
||||
client = Client()
|
||||
client.call('/session')
|
||||
with db.connect() as c:
|
||||
assert not c.execute("SELECT 1 FROM dtf_local.site_videos WHERE id='sala'").fetchone(), \
|
||||
'The isolated test catalog entry is already configured'
|
||||
ids = []
|
||||
keys = []
|
||||
try:
|
||||
client.call('/operator/site-videos/sala', {'enabled': True}, expected=401)
|
||||
operator = client.operator_client or Client()
|
||||
# Client.call(operator=True) signs in and forwards to its own client.
|
||||
client.call('/operator/site-videos', operator=True)
|
||||
operator = client.operator_client
|
||||
video = upload(operator, 'LOCAL-VIDEO.mp4', VIDEO)
|
||||
captions = upload(operator, 'LOCAL-VIDEO.vtt', CAPTIONS)
|
||||
ids = [video, captions]
|
||||
operator.call('/operator/site-videos/sala', {'upload_id': video,
|
||||
'captions_id': captions, 'product': 'file', 'enabled': True})
|
||||
published = client.call('/site/videos')['videos']
|
||||
entry = next(row for row in published if row['id'] == 'sala')
|
||||
assert entry['product'] == 'file'
|
||||
assert entry['captions'] == '/api/site/videos/sala/captions'
|
||||
with urlopen(entry['src'], timeout=30) as response:
|
||||
assert response.read() == VIDEO
|
||||
with urlopen(Request(BASE + entry['captions'], headers=with_host()), timeout=30) as response:
|
||||
assert response.headers['Content-Type'].startswith('text/vtt')
|
||||
assert response.read() == CAPTIONS
|
||||
operator.call('/operator/site-videos/sala', {'upload_id': video,
|
||||
'captions_id': captions, 'product': 'file', 'enabled': False})
|
||||
assert not any(row['id'] == 'sala' for row in client.call('/site/videos')['videos'])
|
||||
print('PASS: Gestão publishes a scanned video, signed media and same-origin VTT; hiding removes it from the Site')
|
||||
finally:
|
||||
with db.connect() as c:
|
||||
row = c.execute("DELETE FROM dtf_local.site_videos WHERE id='sala' RETURNING video_key,captions_key").fetchone()
|
||||
if row:
|
||||
keys.extend(key for key in row.values() if key)
|
||||
if ids:
|
||||
sources = c.execute('DELETE FROM dtf_local.uploads WHERE id=ANY(%s) RETURNING object_key',
|
||||
(ids,)).fetchall()
|
||||
keys.extend(row['object_key'] for row in sources)
|
||||
for key in keys:
|
||||
storage.client.delete_object(Bucket=storage.bucket, Key=key)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
@@ -17,7 +17,7 @@ class PrumoReportTests(unittest.TestCase):
|
||||
}
|
||||
started = datetime(2026, 11, 5, 14, 0, tzinfo=timezone.utc)
|
||||
return {'snapshot': {'items': [item]}, 'print_files': [{
|
||||
'item_index': 0, 'created_at': started, 'finished_at': started + timedelta(seconds=41),
|
||||
'item_index': 0, 'status': 'ready', 'created_at': started, 'finished_at': started + timedelta(seconds=41),
|
||||
'detail': {'format': 'png', 'dpi': 300, 'parts': [
|
||||
{'from_cm': '0', 'to_cm': '15'}, {'from_cm': '15', 'to_cm': '16'}]},
|
||||
}]}
|
||||
@@ -27,7 +27,7 @@ class PrumoReportTests(unittest.TestCase):
|
||||
text = '\n'.join(lines)
|
||||
self.assertIn('Chegou CDR, era PDF por dentro', text)
|
||||
self.assertIn('PDF → PNG 300 DPI', text)
|
||||
self.assertIn('Veio em 96 DPI, ampliado para 300', text)
|
||||
self.assertIn('Resolução detectada: 96 DPI', text)
|
||||
self.assertIn('3 pontos < 2 mm — cliente aceitou', text)
|
||||
self.assertIn('2 artes, 1 girada', text)
|
||||
self.assertIn('Menor traço 6 px → C2', text)
|
||||
@@ -42,6 +42,17 @@ class PrumoReportTests(unittest.TestCase):
|
||||
self.assertIn('3 pontinhos', text)
|
||||
self.assertIn('C2', text)
|
||||
self.assertIn('C1', text)
|
||||
self.assertIn('será preparado', text)
|
||||
self.assertNotIn('foi ampliada', text)
|
||||
|
||||
def test_unfinished_job_does_not_claim_a_conversion_or_background_check(self):
|
||||
order = self.order()
|
||||
order['print_files'] = [{'item_index': 0, 'status': 'manual', 'detail': {}}]
|
||||
lines = report(order, {'u1': {'name': 'arte.pdf', 'original_name': 'arte.cdr'}})
|
||||
text = '\n'.join(lines)
|
||||
self.assertIn('Arquivo exige preparo manual', text)
|
||||
self.assertNotIn('PDF → PNG', text)
|
||||
self.assertNotIn('Fundo transparente', text)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -15,7 +15,7 @@ class SpeedFiguresTests(unittest.TestCase):
|
||||
rows = {row['key']: row for row in speed_figures(site, generation, card)}
|
||||
self.assertEqual(rows['page']['average'], 1.5)
|
||||
self.assertEqual(rows['page']['p95'], 3.0)
|
||||
self.assertEqual(rows['upload']['unit'], 'MB/s')
|
||||
self.assertEqual(rows['upload']['unit'], 's/MB')
|
||||
self.assertEqual(rows['analysis']['average'], 12.0)
|
||||
self.assertEqual(rows['montage']['p95'], 9.0)
|
||||
self.assertEqual(rows['print']['average'], 90)
|
||||
|
||||
38
tests/treatment_gate_test.py
Normal file
38
tests/treatment_gate_test.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""A paid treatment needs a designer-prepared final before the print queue.
|
||||
|
||||
Run against the local stack: SITE_BASE_URL=http://site SITE_HOST_HEADER=localhost
|
||||
python -m tests.treatment_gate_test
|
||||
"""
|
||||
from app.core import db
|
||||
from tests.print_file_test import artwork, loose_item, paid_order, wait_print
|
||||
from tests.smoke_test import Client, upload_bytes
|
||||
|
||||
|
||||
def run():
|
||||
client = Client()
|
||||
client.call('/session')
|
||||
original = upload_bytes(client, artwork(), name='LOCAL-TREATMENT-ORIGINAL.png')
|
||||
order = paid_order(client, loose_item(original, copies=1))
|
||||
_, generated = wait_print(client, order['id'], 'ready')
|
||||
# The local price is normally zero. Mark this paid fixture as having bought
|
||||
# treatment to exercise the production gate, not the checkout price rule.
|
||||
with db.connect() as c:
|
||||
c.execute("""UPDATE dtf_local.orders SET snapshot=jsonb_set(snapshot,'{treatment}',
|
||||
'{"cents":990,"hours":24}'::jsonb) WHERE id=%s""", (order['id'],))
|
||||
approved = client.call('/operator/orders/' + order['id'] + '/final-files',
|
||||
{'version': order['version'], 'files': [{'item_index': 0, 'upload_id': generated['upload_id']}],
|
||||
'note': 'Gerado pelo Prumo'}, operator=True)
|
||||
blocked = client.call('/operator/orders/' + order['id'] + '/move',
|
||||
{'state': 'tra', 'version': approved['version']}, operator=True, expected=409)
|
||||
assert 'Tratamento pago' in blocked['detail'], blocked
|
||||
prepared = upload_bytes(client, artwork(), name='LOCAL-TREATMENT-FINAL.png', order_id=order['id'])
|
||||
approved = client.call('/operator/orders/' + order['id'] + '/final-files',
|
||||
{'version': approved['version'], 'files': [{'item_index': 0, 'upload_id': prepared}],
|
||||
'note': 'PNG tratado pelo designer'}, operator=True)
|
||||
client.call('/operator/orders/' + order['id'] + '/move',
|
||||
{'state': 'tra', 'version': approved['version']}, operator=True)
|
||||
print('PASS: generated artwork cannot satisfy paid treatment; designer PNG opens the print queue')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
Reference in New Issue
Block a user