mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-10-30 17:27:09 +00:00
* fix(studio): reload the preview only when a file it loaded changes * test(studio): read the owner id from the new change-owner shape * refactor(studio): drop a comment the parser name already says * fix(studio): keep reloading until the preview is built, and count what its document names * style(studio): format the reference pattern and name the kept reload * fix(studio-server): scan preview references in linear time and refresh all thumbnails on a merged reload * fix(studio): keep a waiting film change when a file the preview never loaded arrives behind it * test(studio): name the preview ownership test for what it checks * chore(ci): allow the watchIgnore removals and trim the new comments * fix(studio-server): reload the preview when a folder holding a file it loaded moves in or out * perf(studio-server): check a changed folder in one lookup and cover every reference form * fix(studio-server): record read folders for a project at the filesystem root * fix(studio-server): reload the preview when the file a symlinked asset points at changes * fix(studio-server): resolve symlinks on every preview read and key projects by their real folder * fix(studio-server): record every link a preview read passes through, resolved as the system does
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import { mkdtempSync, mkdirSync, rmSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
import { previewChangeOwner } from "./vite.preview-watch";
|
|
|
|
const dirs: string[] = [];
|
|
afterEach(() => {
|
|
for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true });
|
|
});
|
|
|
|
describe("Vite preview change ownership", () => {
|
|
it("names the project that owns a path, and none for a path outside every project", () => {
|
|
const root = mkdtempSync(join(tmpdir(), "hf-vite-watch-"));
|
|
dirs.push(root);
|
|
const a = join(root, "external");
|
|
const b = join(root, "external-other");
|
|
for (const path of [a, b]) mkdirSync(path);
|
|
const projects = new Map([
|
|
[a, "symlink-project"],
|
|
[b, "other-project"],
|
|
]);
|
|
expect(previewChangeOwner(projects, join(a, "index.html"))).toEqual({
|
|
projectDir: a,
|
|
projectId: "symlink-project",
|
|
});
|
|
expect(previewChangeOwner(projects, join(b, "docs", "report.json"))?.projectId).toBe(
|
|
"other-project",
|
|
);
|
|
expect(previewChangeOwner(projects, join(root, "outside.html"))).toBeNull();
|
|
});
|
|
|
|
it("uses the nearest project when watched directories are nested", () => {
|
|
const root = mkdtempSync(join(tmpdir(), "hf-vite-watch-"));
|
|
dirs.push(root);
|
|
const nested = join(root, "nested");
|
|
mkdirSync(nested);
|
|
expect(
|
|
previewChangeOwner(
|
|
new Map([
|
|
[root, "root"],
|
|
[nested, "nested"],
|
|
]),
|
|
join(nested, "index.html"),
|
|
)?.projectId,
|
|
).toBe("nested");
|
|
});
|
|
});
|