# Integrations pass (S009): spell check. Offline: a tiny en_US hunspell dictionary (tests/smoke/data/dict) is copied
# into the throwaway cache first. Run:
#   h=target/smoke/integ-spell-home; rm -rf $h; mkdir -p $h/.cache/nacre-servo/dictionaries
#   cp tests/smoke/data/dict/en_US.* $h/.cache/nacre-servo/dictionaries/
#   python3 -m http.server 8768 --bind 127.0.0.1 --directory tests/smoke/pages &
#   SMOKE_HOME=$PWD/$h tools/smoke.sh tests/smoke/integ-spell.txt target/smoke/integ-spell
# Read spell-menu.png: the page menu over the misspelled word lists "mistake" and "Add ... to the dictionary".
set /spell/langs ["en_US"]
wait 3
open http://127.0.0.1:8768/spell.html
waitload
locate #area
wait 1
click @
pagetype hello wrold this is a mistaek
wait 2
shot spell-marked
# The mirror underlines the two wrong words only.
assert document.querySelectorAll('.__nacre_spell_mirror u').length === 2
assert [...document.querySelectorAll('.__nacre_spell_mirror u')].map(u => u.textContent).join() === 'wrold,mistaek'
js window.__nacre.spell.replace('wrold', 'world'); document.getElementById('area').value
wait 1
assert document.getElementById('area').value === 'hello world this is a mistaek'
# Right-click the misspelled word at the end of the text: the menu offers suggestions.
rclick 215 33
wait 1
shot spell-menu
# Choosing the suggestion replaces the word.
tap 299 154
wait 1
assert document.getElementById('area').value === 'hello world this is a mistake'
status done
quit
