Don't create custom elements in main and fix various small issues on tests (#747)

* Create custom elements when the runtime finishes loading

* Remove xfails and fix repl integration test

* Fix commented ignore

* Address Antonio's comments

* Fix bad rebase

* Make ure to wait for repl to be in attached state before asserting content

* Move createCustomeElement up so it runs before we close the loader, xfail flaky d3 test

* Fix xfail
This commit is contained in:
Fábio Rosado
2022-09-13 15:59:33 +01:00
committed by GitHub
parent 5c1b785b4b
commit c566977749
8 changed files with 59 additions and 95 deletions

View File

@@ -1,5 +1,3 @@
import pytest
from .support import PyScriptTest
@@ -15,22 +13,7 @@ class TestPyRepl(PyScriptTest):
assert py_repl
assert "Python" in py_repl.inner_text()
@pytest.mark.xfail
def test_repl_runs_on_button_press(self):
"""
Current this test fails due to an exception when we iterate over
'importmaps'
[ 2.28 JS exception ] TypeError: importmaps is not iterable
at PyRepl._register_esm (http://127.0.0.1:8080/build/pyscript.js:227:37)
at PyRepl.evaluate (http://127.0.0.1:8080/build/pyscript.js:252:22)
at http://127.0.0.1:8080/build/pyscript.js:23678:21
at runFor (http://127.0.0.1:8080/build/pyscript.js:11780:25)
at runHandlers (http://127.0.0.1:8080/build/pyscript.js:11789:17)
at Object.keydown (http://127.0.0.1:8080/build/pyscript.js:11691:20)
at InputState.runCustomHandlers (http://127.0.0.1:8080/build/pyscript.js:8194:37)
at HTMLDivElement.<anonymous> (http://127.0.0.1:8080/build/pyscript.js:8156:30)
"""
self.pyscript_run(
"""
<py-repl id="my-repl" auto-generate="true"> </py-repl>
@@ -43,26 +26,11 @@ class TestPyRepl(PyScriptTest):
self.page.locator("button").click()
# The result gets the id of the repl + n
repl_result = self.page.locator("#my-repl-1")
repl_result = self.page.wait_for_selector("#my-repl-1", state="attached")
assert repl_result.inner_text() == "4"
@pytest.mark.xfail
def test_repl_runs_with_shift_enter(self):
"""
Current this test fails due to an exception when we iterate over
'importmaps'
[ 2.28 JS exception ] TypeError: importmaps is not iterable
at PyRepl._register_esm (http://127.0.0.1:8080/build/pyscript.js:227:37)
at PyRepl.evaluate (http://127.0.0.1:8080/build/pyscript.js:252:22)
at http://127.0.0.1:8080/build/pyscript.js:23678:21
at runFor (http://127.0.0.1:8080/build/pyscript.js:11780:25)
at runHandlers (http://127.0.0.1:8080/build/pyscript.js:11789:17)
at Object.keydown (http://127.0.0.1:8080/build/pyscript.js:11691:20)
at InputState.runCustomHandlers (http://127.0.0.1:8080/build/pyscript.js:8194:37)
at HTMLDivElement.<anonymous> (http://127.0.0.1:8080/build/pyscript.js:8156:30)
"""
self.pyscript_run(
"""
<py-repl id="my-repl" auto-generate="true"> </py-repl>
@@ -72,6 +40,6 @@ class TestPyRepl(PyScriptTest):
# Confirm that we get a result by using the keys shortcut
self.page.keyboard.press("Shift+Enter")
repl_result = self.page.locator("#my-repl-1")
repl_result = self.page.wait_for_selector("#my-repl-1", state="attached")
assert repl_result.text_content() == "4"