* implement const cbor encoding + decoding for basic types * implement map encoding and decoding * fix map test * all tests passing * dynamically sized arrays * smaller str encoding * swap array and list and add more documentation * move serialization and deserialization for each struct together * support both legacy and new assets * bump const serialize version * fix asset conversion code * pull out manganis symbol struct from tuble * test reading old asset versions * more list/array cleanup and bump rust version * fix clippy * switch cli opt port * install playwright deps * split cli-optimization package to avoid two dioxus' in the same crate * fix clippy * force the toast.png asset to be included in the linker stage #[used] has platform depedant behavior * bundle both formats in the link section and only use the asset the cli changed * remove sudo which doesn't exist on windows * add binstall to the playwright workflow * separate bin target for the old cli * lockfile * cargo update to get versions shaken out * notes on binstalls, add back `.read()` for compat * use 0.8.0-alpha.0 for const-serialize instead of 0.8 this ensures we can still publish breaking changes on 0.8 without taking over the full version * fix clippy in example * small debug nits * update rust-overlay in nix * fix flake? * migrate to new structure * just comment out binstalls * just remove old test harness --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
67 lines
2.4 KiB
JavaScript
67 lines
2.4 KiB
JavaScript
// @ts-check
|
|
const { test, expect } = require("@playwright/test");
|
|
|
|
const test_variants = [
|
|
{ port: 8989, name: "current version" },
|
|
];
|
|
|
|
for (let { port, name } of test_variants) {
|
|
test(`optimized scripts run in ${name}`, async ({ page }) => {
|
|
await page.goto(`http://localhost:${port}`);
|
|
|
|
// // Expect the page to load the script after optimizations have been applied. The script
|
|
// // should add an editor to the page that shows a main function
|
|
// const main = page.locator("#main");
|
|
// await expect(main).toContainText("hi");
|
|
|
|
// Expect the page to contain an image with the id "some_image"
|
|
const image = page.locator("#some_image");
|
|
await expect(image).toBeVisible();
|
|
// Get the image src
|
|
const src = await image.getAttribute("src");
|
|
|
|
// Expect the page to contain an image with the id "some_image_with_the_same_url"
|
|
const image2 = page.locator("#some_image_with_the_same_url");
|
|
await expect(image2).toBeVisible();
|
|
// Get the image src
|
|
const src2 = await image2.getAttribute("src");
|
|
|
|
// Expect the urls to be different
|
|
expect(src).not.toEqual(src2);
|
|
|
|
// Expect the page to contain an image with the id "some_image_without_hash"
|
|
const image3 = page.locator("#some_image_without_hash");
|
|
await expect(image3).toBeVisible();
|
|
// Get the image src
|
|
const src3 = await image3.getAttribute("src");
|
|
// Expect the src to be without a hash
|
|
expect(src3).toEqual("/assets/toasts.avif");
|
|
});
|
|
|
|
test(`unused external assets are bundled in ${name}`, async ({ page }) => {
|
|
await page.goto(`http://localhost:${port}`);
|
|
|
|
// Assert http://localhost:{port}/assets/toasts.png is found even though it is not used in the page
|
|
const response = await page.request.get(
|
|
`http://localhost:${port}/assets/toasts.png`
|
|
);
|
|
// Expect the response to be ok
|
|
expect(response.status()).toBe(200);
|
|
// make sure the response is an image
|
|
expect(response.headers()["content-type"]).toBe("image/png");
|
|
});
|
|
|
|
test(`assets are resolved in ${name}`, async ({ page }) => {
|
|
await page.goto(`http://localhost:${port}`);
|
|
|
|
// Expect the page to contain an element with the id "resolved-data"
|
|
const resolvedData = page.locator("#resolved-data");
|
|
await expect(resolvedData).toBeVisible();
|
|
// Expect the element to contain the text "List: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"
|
|
await expect(resolvedData).toContainText(
|
|
"List: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"
|
|
);
|
|
});
|
|
|
|
}
|