Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { readFileSync, statSync } from "node:fs";
|
||||
import { gzipSync } from "node:zlib";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { dirname, join } from "node:path";
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url));
|
||||
const widgetPath = join(here, "..", "public", "embed", "widget.js");
|
||||
|
||||
describe("widget.js bootstrap loader", () => {
|
||||
it("is checked into apps/web/public/embed/widget.js", () => {
|
||||
expect(statSync(widgetPath).isFile()).toBe(true);
|
||||
});
|
||||
|
||||
it("stays under the 3KB gzipped budget", () => {
|
||||
const raw = readFileSync(widgetPath);
|
||||
const gz = gzipSync(raw);
|
||||
// 3 KB = 3 * 1024 = 3072 bytes
|
||||
expect(gz.byteLength).toBeLessThan(3072);
|
||||
});
|
||||
|
||||
it("stays under the 5KB raw budget", () => {
|
||||
const raw = readFileSync(widgetPath);
|
||||
expect(raw.byteLength).toBeLessThan(5 * 1024);
|
||||
});
|
||||
|
||||
it("references the embed forms route path", () => {
|
||||
const text = readFileSync(widgetPath, "utf8");
|
||||
expect(text).toContain("/embed/forms/");
|
||||
});
|
||||
|
||||
it("uses a sandboxed iframe", () => {
|
||||
const text = readFileSync(widgetPath, "utf8");
|
||||
expect(text).toContain("sandbox");
|
||||
expect(text).toContain("allow-scripts");
|
||||
});
|
||||
|
||||
it("listens for postMessage resize / submitted / error events", () => {
|
||||
const text = readFileSync(widgetPath, "utf8");
|
||||
expect(text).toContain("tcform:resize");
|
||||
expect(text).toContain("tcform:submitted");
|
||||
expect(text).toContain("tcform:error");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user