Re-enable CI tests (#1760)

This re-enables CI tests on every PR 🎉.
This uses make test-integration, which runs tests sequentially.

In theory, we also have test-integration-parallel but it seems to be very flaky: many tests randomly timeout. I didn't spend too much time investigating this, it's probably worth its own investigation in a separate PR, but for now it's important to re-enable CI tests, even if they are a bit slower.
This commit is contained in:
Antonio Cuni
2023-09-27 15:02:49 +00:00
committed by GitHub
parent abfc68765f
commit c6aaacdbf1
8 changed files with 141 additions and 52 deletions

View File

@@ -169,7 +169,7 @@ class PyScriptTest:
creates an HTML page to run the specified snippet.
"""
DEFAULT_TIMEOUT = 20000
DEFAULT_TIMEOUT = 30 * 1000
@pytest.fixture()
def init(self, request, tmpdir, logger, page, execution_thread):
@@ -240,10 +240,7 @@ class PyScriptTest:
def init_page(self, page):
self.page = page
# set default timeout to 60000 millliseconds from 30000
page.set_default_timeout(self.DEFAULT_TIMEOUT)
self.console = ConsoleMessageCollection(self.logger)
self._js_errors = []
self._py_errors = []
@@ -424,7 +421,7 @@ class PyScriptTest:
return text in self.console.all.lines
if timeout is None:
timeout = 10 * 1000
timeout = self.DEFAULT_TIMEOUT
# NOTE: we cannot use playwright's own page.expect_console_message(),
# because if you call it AFTER the text has already been emitted, it
# waits forever. Instead, we have to use our own custom logic.

View File

@@ -11,26 +11,22 @@ class TestBasic(PyScriptTest):
"""
<script type="py">
import js
js.console.log('1. hello from script py')
js.console.log('hello from script py')
</script>
"""
)
assert self.console.log.lines == ["hello from script py"]
def test_py_script_hello(self):
self.pyscript_run(
"""
<py-script>
import js
js.console.log('2. hello from py-script')
js.console.log('hello from py-script')
</py-script>
"""
)
if self.execution_thread == "main":
# in main, the order of execution is guaranteed
assert self.console.log.lines == [
"1. hello from script py",
"2. hello from py-script",
]
else:
# in workers, each tag is executed by its own worker, so they can
# come out of order
lines = sorted(self.console.log.lines)
assert lines == ["1. hello from script py", "2. hello from py-script"]
assert self.console.log.lines == ["hello from py-script"]
def test_execution_thread(self):
self.pyscript_run(
@@ -47,20 +43,25 @@ class TestBasic(PyScriptTest):
in_worker = str(in_worker).lower()
assert self.console.log.lines[-1] == f"worker? {in_worker}"
# TODO: if there's no py-script there are surely no plugins neither
# this test must be discussed or rewritten to make sense now
@pytest.mark.skip(reason="NEXT: No banner and should also add a WARNING about CORS")
@skip_worker('NEXT: it should show a nice error on the page')
def test_no_cors_headers(self):
self.disable_cors_headers()
self.pyscript_run(
"""
<!-- we don't really need anything here, we just want to check that
pyscript starts -->
<script type="py">
import js
js.console.log("hello")
</script>
""",
wait_for_pyscript=False,
)
assert self.headers == {}
if self.execution_thread == "worker":
if self.execution_thread == "main":
self.wait_for_pyscript()
assert self.console.log.lines == ['hello']
self.assert_no_banners()
else:
# XXX adapt and fix the test
expected_alert_banner_msg = (
'(PY1000): When execution_thread is "worker", the site must be cross origin '
"isolated, but crossOriginIsolated is false. To be cross origin isolated, "
@@ -71,8 +72,7 @@ class TestBasic(PyScriptTest):
)
alert_banner = self.page.wait_for_selector(".alert-banner")
assert expected_alert_banner_msg in alert_banner.inner_text()
else:
self.assert_no_banners()
def test_print(self):
self.pyscript_run(

View File

@@ -457,7 +457,7 @@ class TestDisplay(PyScriptTest):
img = Image.new("RGB", (4, 4), color=(0, 0, 0))
display(img, target='img-target', append=False)
</script>
"""
""",
)
img_src = self.page.locator("img").get_attribute("src")

View File

@@ -67,7 +67,6 @@ class TestConfig(PyScriptTest):
)
assert self.console.log.lines[-1] == "config name: app with external config"
@pytest.mark.skip("NEXT: We need to restore the banner.")
def test_invalid_json_config(self):
# we need wait_for_pyscript=False because we bail out very soon,
# before being able to write 'PyScript page fully initialized'