Gitea Actions Runner Test / test-job (push) Successful in 1s
CI / check (push) Successful in 29s
CI / tests-unit (push) Failing after 1m37s
CI / tests-integration (push) Successful in 1m37s
CI / tests-ui (push) Successful in 2m17s
CI / preflight (push) Skipped
CI / deploy (push) Skipped
Every bundle the CMS writes — upload, clone, sync, repair and the pet / effect / figure importers — now lands as `<classname>.hab`, the extension this deployment's renderer asks for. `.hab` and `.nitro` are the same container, so an upload of either extension is accepted. Resolution goes through one module, src/lib/furni/bundle-file.ts, so nothing has to know the extension twice. Every existence check probes `.hab` first and falls back to `.nitro`: the on-disk asset set is still predominantly `.nitro`, and without the fallback Studio would report every imported item as missing and the cleanup scan would classify 18k live bundles as fake leftovers. Downloads are unchanged — Habbo's CDN and every configured clone source still serve `.nitro`, so the conversion happens on write, not on request. Deliberately unchanged: the staged-attachment store in furni-attachment.ts keys on a UUID and never reaches the client, so renaming it would break in-flight recovery jobs. Adds scripts/migrate-nitro-to-hab.ts to rename the existing asset set. It refuses to run without --dry-run or --yes, never overwrites an existing .hab, never deletes, and is idempotent. Note: renderer-config.json lives outside this repo and was patched to .hab separately; that file is served with a 30-day max-age, so returning clients need a cms-client cache purge to pick the change up.
93 lines
2.8 KiB
TypeScript
93 lines
2.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
getBaseClassname,
|
|
getBundleFileName,
|
|
getHabboCdnIconUrl,
|
|
getIconFileName,
|
|
getLocalBundleFileNames,
|
|
getLocalIconUrl,
|
|
getNitroFileName,
|
|
getSafeClassnameStem,
|
|
getSwfFileName,
|
|
isValidClassname,
|
|
normalizeClassname,
|
|
SOURCE_BUNDLE_EXT,
|
|
} from "./classname";
|
|
|
|
describe("getBaseClassname", () => {
|
|
it("strips the * suffix", () => {
|
|
expect(getBaseClassname("chair_basic*")).toBe("chair_basic");
|
|
});
|
|
it("returns the classname unchanged when no * is present", () => {
|
|
expect(getBaseClassname("chair_basic")).toBe("chair_basic");
|
|
});
|
|
});
|
|
|
|
describe("getSafeClassnameStem", () => {
|
|
it("replaces * with underscore", () => {
|
|
expect(getSafeClassnameStem("wall_plant*")).toBe("wall_plant_");
|
|
});
|
|
it("leaves plain classnames untouched", () => {
|
|
expect(getSafeClassnameStem("lamp_floor")).toBe("lamp_floor");
|
|
});
|
|
});
|
|
|
|
describe("file name helpers", () => {
|
|
it("builds icon file names from the safe stem", () => {
|
|
expect(getIconFileName("sofa_blue*")).toBe("sofa_blue__icon.png");
|
|
});
|
|
it("builds swf file names from the base classname", () => {
|
|
expect(getSwfFileName("sofa_blue*")).toBe("sofa_blue.swf");
|
|
});
|
|
it("builds the primary (`.hab`) bundle name from the base classname", () => {
|
|
expect(getNitroFileName("sofa_blue*")).toBe("sofa_blue.hab");
|
|
});
|
|
it("offers `.hab` first and keeps legacy `.nitro` resolvable", () => {
|
|
expect(getLocalBundleFileNames("sofa_blue*")).toEqual([
|
|
"sofa_blue.hab",
|
|
"sofa_blue.nitro",
|
|
]);
|
|
});
|
|
it("builds a bundle name for an explicit extension", () => {
|
|
expect(getBundleFileName("sofa_blue*", SOURCE_BUNDLE_EXT)).toBe(
|
|
"sofa_blue.nitro",
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("normalizeClassname", () => {
|
|
it("trims and lowercases", () => {
|
|
expect(normalizeClassname(" Chair_Basic ")).toBe("chair_basic");
|
|
});
|
|
});
|
|
|
|
describe("isValidClassname", () => {
|
|
it("accepts lowercase letters, digits and allowed symbols", () => {
|
|
expect(isValidClassname("chair_basic")).toBe(true);
|
|
expect(isValidClassname("sofa*")).toBe(true);
|
|
expect(isValidClassname("wall.part-1")).toBe(true);
|
|
});
|
|
it("rejects uppercase, spaces and invalid characters", () => {
|
|
expect(isValidClassname("Chair")).toBe(false);
|
|
expect(isValidClassname("sofa basic")).toBe(false);
|
|
expect(isValidClassname("sofa/basic")).toBe(false);
|
|
expect(isValidClassname("")).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("icon URLs", () => {
|
|
it("builds a local icon URL with encoding", () => {
|
|
expect(getLocalIconUrl("sofa_blue")).toBe(
|
|
"/swf/dcr/hof_furni/icons/sofa_blue_icon.png",
|
|
);
|
|
expect(getLocalIconUrl("wall*")).toBe(
|
|
"/swf/dcr/hof_furni/icons/wall__icon.png",
|
|
);
|
|
});
|
|
it("builds a Habbo CDN icon URL with revision and base classname", () => {
|
|
expect(getHabboCdnIconUrl("sofa_blue*", 567)).toBe(
|
|
"https://images.habbo.com/dcr/hof_furni/567/sofa_blue_icon.png",
|
|
);
|
|
});
|
|
});
|