up
This commit is contained in:
@@ -197,7 +197,59 @@ def check_browser_flow(stand, fixtures):
|
||||
assert js("return document.querySelector('.questions-block')===null"), 'Finished game exposes questions'
|
||||
navigate(f'/team-story/{captain["ID"]}?password=wrong')
|
||||
wait("document.body.innerText.includes('Не удалось загрузить дело')", 'wrong-password error')
|
||||
print(f'PASS: real Firefox {width}px {data["format"]}: export/download/import, tickets, moves, pause, clues, grading/results, errors and keyboard', flush=True)
|
||||
def download_results():
|
||||
navigate(f'/games/{game}?tab=settings')
|
||||
wait("document.body.innerText.includes('Скачать результаты')", 'results download button')
|
||||
before = {p.name for p in downloads.glob('*.zip')}
|
||||
click('Скачать результаты')
|
||||
until = time.monotonic() + 15
|
||||
while time.monotonic() < until:
|
||||
files = [p for p in downloads.glob('*.zip') if p.name not in before and p.stat().st_size and not p.with_suffix(p.suffix + '.part').exists()]
|
||||
if files:
|
||||
return max(files, key=lambda p: p.stat().st_mtime).read_bytes()
|
||||
time.sleep(.1)
|
||||
raise AssertionError('Results download missing')
|
||||
|
||||
def apply_results(raw):
|
||||
navigate(f'/games/{game}?tab=settings')
|
||||
wait("document.body.innerText.includes('Возврат результатов с площадки')", 'return block')
|
||||
assert js("return document.body.innerText.includes('Онлайн-правки этих данных потеряются') && document.body.innerText.includes('Оформление и музыка сохраняются')"), 'Replacement warning missing'
|
||||
js("const dt=new DataTransfer();dt.items.add(new File([new Uint8Array(arguments[0])],'results.zip',{type:'application/zip'}));const input=document.querySelector('input[type=file]');input.files=dt.files;input.dispatchEvent(new Event('change',{bubbles:true}));return true;", list(raw))
|
||||
stand.delay_results = .5
|
||||
click('Применить ZIP и перезаписать результаты')
|
||||
assert js("return [...document.querySelectorAll('button')].find(b=>b.textContent.trim()==='Применить ZIP и перезаписать результаты').disabled"), 'Repeat apply is not blocked'
|
||||
wait("document.body.innerText.includes('Результаты приняты')", 'results accepted')
|
||||
stand.delay_results = 0
|
||||
wait("!document.body.innerText.includes('Игра в офлайн-режиме')", 'offline mark cleared')
|
||||
assert stand.apis['prod'].game(game)['status'] == 'finish'
|
||||
|
||||
first_results = download_results()
|
||||
login('prod')
|
||||
stand.sql('prod', f"UPDATE games SET name='TEST Preserved presentation', description='TEST Preserved description' WHERE id={game};")
|
||||
apply_results(first_results)
|
||||
assert stand.apis['prod'].game(game)['name'] == 'TEST Preserved presentation'
|
||||
assert stand.apis['prod'].story(captain)['game']['status'] == 'finish'
|
||||
assert stand.apis['prod'].request('/api' + urllib.parse.urlparse(data['tickets'][1]['URL']).path)['ticket']['status'] == 'used'
|
||||
assert stand.apis['prod'].request(f'/api/games/{game}/results')['teams'][0]['totalScore'] == 5
|
||||
login('venue')
|
||||
navigate(f'/games/{game}?tab=answers')
|
||||
wait("document.querySelector('.answers-score-input input')!==null", 'corrected grading')
|
||||
input_value('.answers-score-input input', '0')
|
||||
click('Сохранить баллы')
|
||||
wait("document.body.innerText.includes('Баллы сохранены')", 'correction saved')
|
||||
corrected_results = download_results()
|
||||
assert corrected_results != first_results, 'Results are not fresh'
|
||||
login('prod')
|
||||
stand.sql('prod', f"UPDATE team_answers SET answer='Online edit', score=9 WHERE team_id={captain['ID']};")
|
||||
apply_results(corrected_results)
|
||||
scores = stand.apis['prod'].request(f'/api/games/{game}/results')['teams']
|
||||
assert next(t for t in scores if t['team']['ID'] == captain['ID'])['totalScore'] == 0
|
||||
accepted = stand.sql('prod', f"SELECT applied_at FROM game_returns WHERE source_game_id={game} ORDER BY applied_at DESC LIMIT 1;")
|
||||
stand.restart('prod')
|
||||
apply_results(first_results)
|
||||
assert stand.sql('prod', f"SELECT applied_at FROM game_returns WHERE source_game_id={game} ORDER BY applied_at DESC LIMIT 1;") == accepted
|
||||
assert next(t for t in stand.apis['prod'].request(f'/api/games/{game}/results')['teams'] if t['team']['ID'] == captain['ID'])['totalScore'] == 0
|
||||
print(f'PASS: real Firefox {width}px {data["format"]}: export/download/import, tickets, moves, pause, clues, grading/results, result ZIP return, correction, online overwrite, preserved presentation, restart repeat, errors and keyboard', flush=True)
|
||||
command('Marionette:Quit', {'flags': ['eForceQuit']})
|
||||
finally:
|
||||
if sock:
|
||||
|
||||
Reference in New Issue
Block a user