32 lines
4.2 KiB
Python
32 lines
4.2 KiB
Python
|
|
"""Comprueba la edición de uso en la auditoría desechable de cuentas."""
|
||
|
|
import json
|
||
|
|
|
||
|
|
|
||
|
|
def verify(context, fixture, accounts, client, code):
|
||
|
|
tool, capture = context['tool'], context['capture']
|
||
|
|
company = fixture['company']
|
||
|
|
endpoint = context['origin'] + '/api/access/' + company
|
||
|
|
account = accounts[3]
|
||
|
|
checks, screenshots = [], []
|
||
|
|
tool(client, 'browser_navigate', {'url': context['origin'] + '/companies/' + company + '/access?kind=account'})
|
||
|
|
code(client, "await page.getByRole('textbox',{name:'Buscar',exact:true}).fill('AUDIT-ACCOUNT-03'); await page.getByRole('button',{name:'Editar',exact:true}).click(); await page.getByRole('dialog',{name:'Editar',exact:true}).waitFor(); if(await page.getByRole('combobox',{name:'Uso',exact:true}).isDisabled())throw Error('Uso bloqueado'); if(!await page.getByRole('combobox',{name:'Sistema',exact:true}).isDisabled())throw Error('Sistema editable');")
|
||
|
|
for width in [1440, 390, 320]:
|
||
|
|
tool(client, 'browser_resize', {'width': width, 'height': 844})
|
||
|
|
code(client, "await page.getByRole('combobox',{name:'Uso',exact:true}).scrollIntoViewIfNeeded(); if(await page.getByRole('dialog').evaluate(e=>e.scrollWidth>e.clientWidth+1))throw Error('Desbordamiento horizontal');")
|
||
|
|
screenshots.append(capture(client, context['directory'], 'account-usage-' + str(width)))
|
||
|
|
code(client, "await page.getByRole('combobox',{name:'Uso',exact:true}).focus(); await page.keyboard.press('Enter'); await page.getByRole('option',{name:'Compartida',exact:true}).click(); await page.getByRole('button',{name:'Guardar',exact:true}).click(); await page.getByRole('dialog').waitFor({state:'hidden'});")
|
||
|
|
saved = code(client, "const a=await(await page.request.get(" + json.dumps(endpoint) + ")).json(); const i=a.items.find(i=>i.id===" + json.dumps(account['id']) + "); return {usage:i.values.usage,history:i.history.length,previous:i.history[0].values.usage};")
|
||
|
|
if saved != {'usage': 'shared', 'history': 2, 'previous': 'personal'}:
|
||
|
|
raise RuntimeError('El uso o su historial no se conservaron')
|
||
|
|
checks.extend(['usage-enabled-on-edit', 'system-stays-fixed', 'three-responsive-widths',
|
||
|
|
'keyboard-select-save', 'same-account-history-preserved'])
|
||
|
|
code(client, "await page.getByRole('button',{name:'Editar',exact:true}).click(); await page.getByRole('combobox',{name:'Uso',exact:true}).click(); await page.getByRole('option',{name:'Técnica',exact:true}).click(); await page.getByRole('button',{name:'Cancelar',exact:true}).click(); await page.getByRole('dialog').waitFor({state:'hidden'}); await page.getByRole('button',{name:'Editar',exact:true}).click(); if(!await page.getByRole('combobox',{name:'Uso',exact:true}).textContent().then(v=>v.includes('Compartida')))throw Error('Cancelar cambió el uso'); await page.getByRole('button',{name:'Cancelar',exact:true}).click();")
|
||
|
|
checks.append('cancel-preserves-usage')
|
||
|
|
code(client, "await page.getByRole('textbox',{name:'Buscar',exact:true}).fill('AUDIT-ACCOUNT-00'); await page.getByRole('button',{name:'Editar',exact:true}).click(); await page.getByRole('combobox',{name:'Uso',exact:true}).click(); await page.getByRole('option',{name:'Técnica',exact:true}).click(); await page.getByRole('button',{name:'Guardar',exact:true}).click(); await page.getByRole('alert').filter({hasText:'El uso seleccionado es incompatible'}).waitFor(); if(!await page.getByRole('combobox',{name:'Uso',exact:true}).textContent().then(v=>v.includes('Técnica')))throw Error('Borrador perdido');")
|
||
|
|
screenshots.append(capture(client, context['directory'], 'account-usage-incompatible'))
|
||
|
|
code(client, "await page.getByRole('combobox',{name:'Uso',exact:true}).click(); await page.getByRole('option',{name:'Compartida',exact:true}).click(); await page.getByRole('button',{name:'Guardar',exact:true}).click(); await page.getByRole('dialog').waitFor({state:'hidden'});")
|
||
|
|
checks.extend(['incompatible-usage-keeps-draft', 'recover-with-compatible-usage'])
|
||
|
|
report = {'checks': checks, 'screenshots': screenshots, 'database': 'metis_desk_test'}
|
||
|
|
(context['directory'] / 'account-usage-report.json').write_text(json.dumps(report, ensure_ascii=False, indent=2) + '\n')
|
||
|
|
print('Edición de uso: ' + str(len(checks)) + ' comprobaciones. Evidencias: ' + str(context['directory']), flush=True)
|