perf : improve more
This commit is contained in:
@@ -2,6 +2,8 @@ import { readFile } from "node:fs/promises";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import robots from "@/app/robots";
|
||||
|
||||
async function repositoryFile(path: string): Promise<string> {
|
||||
return readFile(new URL(`../${path}`, import.meta.url), "utf8");
|
||||
}
|
||||
@@ -27,11 +29,24 @@ describe("public rendering performance", () => {
|
||||
expect(header).toContain("<AdminEditLink");
|
||||
});
|
||||
|
||||
it("preloads only the first directory cover", async () => {
|
||||
it("gives only the first directory cover high fetch priority", async () => {
|
||||
const directory = await repositoryFile(
|
||||
"components/public/structured-directory.tsx",
|
||||
);
|
||||
|
||||
expect(directory).toContain("preload={index === 0}");
|
||||
expect(directory).toContain(
|
||||
'fetchPriority={index === 0 ? "high" : undefined}',
|
||||
);
|
||||
expect(directory).not.toContain("preload={index === 0}");
|
||||
});
|
||||
|
||||
it("publishes a public-only crawler policy", () => {
|
||||
expect(robots()).toEqual({
|
||||
rules: {
|
||||
userAgent: "*",
|
||||
allow: "/",
|
||||
disallow: ["/admin", "/api", "/register"],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user