feat: release design system engine, studio and component contracts
This commit is contained in:
1 parent
ff1065fb27
commit
3943b946d6
693 files changed
+175546
-3894
No files matched your search
@@ -58,6 +58,20 @@ beforeEach(() => {
|
||||
}
|
||||
});
|
||||
|
||||
test("loads a new page script even when its inert tag is copied inside app content", async () => {
|
||||
install('<div id="app"><a href="/report" id="lnk">Report</a></div>', (window) => {
|
||||
window.happyDOM.settings.disableJavaScriptFileLoading = true;
|
||||
});
|
||||
nextHtml =
|
||||
'<html><body><div id="app"><button>Download</button><script type="module" src="/reports.js?v=1"></script></div></body></html>';
|
||||
win.document.getElementById("lnk").click();
|
||||
await flush();
|
||||
expect(win.document.body.querySelectorAll('script[src="/reports.js?v=1"]')).toHaveLength(2);
|
||||
win.__wrnexusNavigate("/report?environment=live");
|
||||
await flush();
|
||||
expect(win.document.body.querySelectorAll('script[src="/reports.js?v=1"]')).toHaveLength(2);
|
||||
});
|
||||
|
||||
test("intercepts an internal link click and swaps #app in place", async () => {
|
||||
install(`<div id="app"><h1>Home</h1><a href="/about" id="lnk">About</a></div>`);
|
||||
nextHtml =
|
||||
@@ -84,10 +98,12 @@ test("fragment history navigation preserves the page without fetching", async ()
|
||||
test("navigation supplies TrustedHTML to the document parser", async () => {
|
||||
let parses = 0;
|
||||
install('<div id="app"><a href="/next" id="lnk">Next</a></div>', (window) => {
|
||||
window.trustedTypes = { createPolicy: (_name: string, rules: any) => ({
|
||||
createHTML: (value: string) => ({ trusted: true, value: rules.createHTML(value) }),
|
||||
createScriptURL: rules.createScriptURL,
|
||||
}) };
|
||||
window.trustedTypes = {
|
||||
createPolicy: (_name: string, rules: any) => ({
|
||||
createHTML: (value: string) => ({ trusted: true, value: rules.createHTML(value) }),
|
||||
createScriptURL: rules.createScriptURL,
|
||||
}),
|
||||
};
|
||||
const Parser = window.DOMParser;
|
||||
(globalThis as any).DOMParser = class {
|
||||
parseFromString(value: any, type: string) {
|
||||
@@ -105,13 +121,17 @@ test("navigation supplies TrustedHTML to the document parser", async () => {
|
||||
});
|
||||
|
||||
test("navigation replaces document control registries before hydration", async () => {
|
||||
install('<div id="app"><a href="/next" id="lnk">Next</a></div><script type="application/json" data-wrn-controls id="old">[]</script>');
|
||||
install(
|
||||
'<div id="app"><a href="/next" id="lnk">Next</a></div><script type="application/json" data-wrn-controls id="old">[]</script>',
|
||||
);
|
||||
const importNode = win.document.importNode.bind(win.document);
|
||||
win.document.importNode = (node: any, deep: boolean) => {
|
||||
if (node.nodeName === "SCRIPT") throw new Error("Script text must not be cloned under Trusted Types");
|
||||
if (node.nodeName === "SCRIPT")
|
||||
throw new Error("Script text must not be cloned under Trusted Types");
|
||||
return importNode(node, deep);
|
||||
};
|
||||
nextHtml = '<html><body><div id="app">Next</div><script type="application/json" data-wrn-controls id="new">[[{"cond":null,"body":"Ready"}]]</script><script data-wrn-controls id="executable">window.bad = true</script></body></html>';
|
||||
nextHtml =
|
||||
'<html><body><div id="app">Next</div><script type="application/json" data-wrn-controls id="new">[[{"cond":null,"body":"Ready"}]]</script><script data-wrn-controls id="executable">window.bad = true</script></body></html>';
|
||||
win.document.getElementById("lnk").click();
|
||||
await flush();
|
||||
expect(win.document.getElementById("old")).toBeNull();
|
||||
|
||||
Reference in new issue
Block a user