mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
test: cover clean Discord asset generation
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user