# Integrations pass (S009): Discord Rich Presence against a fake IPC server, plus media state.
# Offline. Run:
#   python3 -m http.server 8768 --bind 127.0.0.1 --directory tests/smoke/pages &
#   SMOKE_FAKE_DISCORD=1 tools/smoke.sh tests/smoke/integ-discord.txt <outdir>
# Then check <outdir>/discord.log (see tests/smoke/integ-discord-check.sh): handshake (op 0) with the test client
# ID, SET_ACTIVITY with details "Smoke Track", state "by Smoke Artist", and assets.large_image
# https://127.0.0.1/favicon.ico (the page's favicon is a data: URL).
set /rpc/enabled true
set /rpc/client_id "100000000000000001"
set /rpc/custom ["127.0.0.1"]
set /rpc/browsing "site"
wait 2
open http://127.0.0.1:8768/media.html
waitload
waitfor 15 (window.__nacre && window.__nacre.media && window.__nacre.media.state() && !window.__nacre.media.state().paused)
log media state follows
js JSON.stringify(window.__nacre.media.state())
wait 6
status presence
# Media pause: the activity becomes "Paused".
js document.getElementById('v').pause()
wait 4
# A plain page (not a media site) is reported as browsing.
set /rpc/custom []
open http://127.0.0.1:8768/hello.html
waitload
wait 6
status done
quit
