test: cover clean Discord asset generation

This commit is contained in:
Shakker
2026-07-16 22:48:03 +01:00
committed by Shakker
parent 107820b2bd
commit 8bf82d9e07
3 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ const repoRoot = path.resolve(path.dirname(modulePath), "..");
const discordDir = path.join(repoRoot, "extensions/discord");
const outputPath = path.join(repoRoot, "extensions/discord/assets/embedded-app-sdk.mjs");
/** Builds the browser SDK bundle without rewriting an identical tracked asset. */
/** Builds the browser SDK bundle without rewriting an identical generated asset. */
export async function buildDiscordActivitySdk(params = {}) {
const buildImpl = params.build ?? build;
const targetPath = params.outputPath ?? outputPath;
+1 -1
View File
@@ -40,7 +40,7 @@ const ignoredRunNodeRepoPathPatterns = [
/^extensions\/[^/]+\/src\/host\/.+\/\.bundle\.hash$/u,
/^extensions\/[^/]+\/src\/host\/.+\/[^/]+\.bundle\.js$/u,
];
// Asset build hooks write these tracked runtime bundles. They are outputs, not
// Asset build hooks write these generated runtime bundles. They are outputs, not
// source inputs; watching them makes the dev build react to its own writes.
const generatedPluginAssetPaths = new Set([
"extensions/diffs-language-pack/assets/viewer-runtime.js",
+4 -2
View File
@@ -44,7 +44,7 @@ async function withPluginAssetFixture(run: (rootDir: string) => Promise<void>) {
}
describe("bundled plugin assets", () => {
it("does not rewrite an unchanged Discord SDK bundle", async () => {
it("creates a missing Discord SDK bundle without rewriting it when unchanged", async () => {
const rootDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-discord-sdk-"));
const outputPath = path.join(rootDir, "embedded-app-sdk.mjs");
const build = vi.fn(async () => ({
@@ -52,7 +52,9 @@ describe("bundled plugin assets", () => {
}));
try {
fs.writeFileSync(outputPath, "export const sdk = true;\n");
await expect(buildDiscordActivitySdk({ build, outputPath })).resolves.toBe(true);
expect(fs.readFileSync(outputPath, "utf8")).toBe("export const sdk = true;\n");
const initialTime = new Date("2026-07-16T12:00:00.000Z");
fs.utimesSync(outputPath, initialTime, initialTime);