Update test suite (#2181)

* pyscript.web tests pass with upytest.
* Refactor of old integration tests to new Python tests.
* Added comprehensive test suite for Python based `pyscript` module.
* Add integration tests to Makefile (and CI)
* Remove un-needed upload action.
* Ensure fails are properly logged as an array. Remove the explicit test step, since this is already built into the build step.
* Bump polyscript.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Andrea Giammarchi <andrea.giammarchi@gmail.com>
This commit is contained in:
Nicholas Tollervey
2024-09-25 16:23:59 +01:00
committed by GitHub
parent ae66d13d57
commit 06138bbb48
91 changed files with 2390 additions and 7707 deletions

View File

@@ -1,7 +1,43 @@
import { test, expect } from '@playwright/test';
test('Python unit tests - MicroPython on MAIN thread', async ({ page }) => {
await page.goto('http://localhost:8080/tests/python/index.html');
test.setTimeout(120*1000); // Increase timeout for this test.
const result = page.locator("#result"); // Payload for results will be here.
await result.waitFor(); // wait for the result.
const data = JSON.parse(await result.textContent()); // get the result data.
await expect(data.fails).toMatchObject([]); // ensure no test failed.
});
test('Python unit tests - Pyodide on MAIN thread', async ({ page }) => {
await page.goto('http://localhost:8080/tests/python/index.html?type=py');
test.setTimeout(120*1000); // Increase timeout for this test.
const result = page.locator("#result"); // Payload for results will be here.
await result.waitFor(); // wait for the result.
const data = JSON.parse(await result.textContent()); // get the result data.
await expect(data.fails).toMatchObject([]); // ensure no test failed.
});
test('Python unit tests - MicroPython on WORKER', async ({ page }) => {
await page.goto('http://localhost:8080/tests/python/index.html?worker');
test.setTimeout(120*1000); // Increase timeout for this test.
const result = page.locator("#result"); // Payload for results will be here.
await result.waitFor(); // wait for the result.
const data = JSON.parse(await result.textContent()); // get the result data.
await expect(data.fails).toMatchObject([]); // ensure no test failed.
});
test('Python unit tests - Pyodide on WORKER', async ({ page }) => {
await page.goto('http://localhost:8080/tests/python/index.html?type=py&worker');
test.setTimeout(120*1000); // Increase timeout for this test.
const result = page.locator("#result"); // Payload for results will be here.
await result.waitFor(); // wait for the result.
const data = JSON.parse(await result.textContent()); // get the result data.
await expect(data.fails).toMatchObject([]); // ensure no test failed.
});
test('MicroPython display', async ({ page }) => {
await page.goto('http://localhost:8080/tests/js-integration/mpy.html');
await page.goto('http://localhost:8080/tests/javascript/mpy.html');
await page.waitForSelector('html.done.worker');
const body = await page.evaluate(() => document.body.innerText);
await expect(body.trim()).toBe([
@@ -18,7 +54,7 @@ test('MicroPython hooks', async ({ page }) => {
if (!text.startsWith('['))
logs.push(text);
});
await page.goto('http://localhost:8080/tests/js-integration/hooks.html');
await page.goto('http://localhost:8080/tests/javascript/hooks.html');
await page.waitForSelector('html.done.worker');
await expect(logs.join('\n')).toBe([
'main onReady',
@@ -43,7 +79,7 @@ test('MicroPython + Pyodide js_modules', async ({ page }) => {
if (!text.startsWith('['))
logs.push(text);
});
await page.goto('http://localhost:8080/tests/js-integration/js_modules.html');
await page.goto('http://localhost:8080/tests/javascript/js_modules.html');
await page.waitForSelector('html.done');
await expect(logs.length).toBe(6);
await expect(logs[0]).toBe(logs[1]);
@@ -53,69 +89,70 @@ test('MicroPython + Pyodide js_modules', async ({ page }) => {
});
test('MicroPython + configURL', async ({ page }) => {
await page.goto('http://localhost:8080/tests/js-integration/config-url.html');
await page.goto('http://localhost:8080/tests/javascript/config-url.html');
await page.waitForSelector('html.main.worker');
});
test('Pyodide + terminal on Main', async ({ page }) => {
await page.goto('http://localhost:8080/tests/js-integration/py-terminal-main.html');
await page.goto('http://localhost:8080/tests/javascript/py-terminal-main.html');
await page.waitForSelector('html.ok');
});
test('Pyodide + terminal on Worker', async ({ page }) => {
await page.goto('http://localhost:8080/tests/js-integration/py-terminal-worker.html');
await page.goto('http://localhost:8080/tests/javascript/py-terminal-worker.html');
await page.waitForSelector('html.ok');
});
test('Pyodide + multiple terminals via Worker', async ({ page }) => {
await page.goto('http://localhost:8080/tests/js-integration/py-terminals.html');
await page.goto('http://localhost:8080/tests/javascript/py-terminals.html');
await page.waitForSelector('html.first.second');
});
test('MicroPython + Pyodide fetch', async ({ page }) => {
await page.goto('http://localhost:8080/tests/js-integration/fetch/index.html');
await page.goto('http://localhost:8080/tests/javascript/fetch/index.html');
await page.waitForSelector('html.mpy.py');
});
test('MicroPython + Pyodide ffi', async ({ page }) => {
await page.goto('http://localhost:8080/tests/js-integration/ffi.html');
await page.goto('http://localhost:8080/tests/javascript/ffi.html');
await page.waitForSelector('html.mpy.py');
});
test('MicroPython + Storage', async ({ page }) => {
await page.goto('http://localhost:8080/tests/js-integration/storage.html');
await page.goto('http://localhost:8080/tests/javascript/storage.html');
await page.waitForSelector('html.ok');
});
test('MicroPython + JS Storage', async ({ page }) => {
await page.goto('http://localhost:8080/tests/js-integration/js-storage.html');
await page.goto('http://localhost:8080/tests/javascript/js-storage.html');
await page.waitForSelector('html.ok');
});
test('MicroPython + workers', async ({ page }) => {
await page.goto('http://localhost:8080/tests/js-integration/workers/index.html');
test.setTimeout(120*1000); // Increase timeout for this test.
await page.goto('http://localhost:8080/tests/javascript/workers/index.html');
await page.waitForSelector('html.mpy.py');
});
test('MicroPython Editor setup error', async ({ page }) => {
await page.goto('http://localhost:8080/tests/js-integration/issue-2093/index.html');
await page.goto('http://localhost:8080/tests/javascript/issue-2093/index.html');
await page.waitForSelector('html.errored');
});
test('MicroPython async @when listener', async ({ page }) => {
await page.goto('http://localhost:8080/tests/js-integration/async-listener.html');
await page.goto('http://localhost:8080/tests/javascript/async-listener.html');
await page.waitForSelector('html.ok');
});
test('Pyodide loader', async ({ page }) => {
await page.goto('http://localhost:8080/tests/js-integration/loader/index.html');
await page.goto('http://localhost:8080/tests/javascript/loader/index.html');
await page.waitForSelector('html.ok');
const body = await page.evaluate(() => document.body.textContent);
await expect(body.includes('Loaded Pyodide')).toBe(true);
});
test('Py and Mpy config["type"]', async ({ page }) => {
await page.goto('http://localhost:8080/tests/js-integration/config_type.html');
await page.goto('http://localhost:8080/tests/javascript/config_type.html');
await page.waitForSelector('html.mpy.py');
});