Files
youtube-generator/tests/utils/rig-validation.test.ts
T
poli0981andClaude Opus 5.5 7e6c12152f fix(data): hardware names, YouTube's tag count, chapters, history duplicates, validation
Hardware
- GPU catalog rewritten with stable ids and official names: descriptions
  read "NVIDIA GeForce RTX 5080", "AMD Radeon RX 9070 XT", "Apple M4 Pro"
  instead of "NVIDIA RTX 5080" / "AMD RX 9070 XT" / "Apple Silicon M4 Pro".
  Cards that never shipped (RX 9080, RX 9090 XT, Arc B380) are gone;
  RTX 50/40/30 laptop GPUs, RX 9070 GRE, VRAM variants, Radeon/Intel
  integrated graphics, handheld APUs and Apple M5 (Pro/Max/Ultra) added.
  One searchable picker ("5080", "rog ally") replaces Brand › Series ›
  Model, with free text for anything else.
- Old `brand|series|model` values are migrated (editor v19, profiles v3,
  templates v2, and on load/import); unknown cards keep their full name.
- RAM: 24/48/192 GB, LPDDR4/4X/5/5X, optional speed ("32 GB DDR5-6000");
  no DDR6/DDR7; plain "DDR"; "48GB GB" fixed; changing the size no longer
  clears the type. OS: SteamOS, Bazzite, CachyOS, Nobara, openSUSE,
  Fedora 43/44; Linux reads "Ubuntu 24.04 LTS". CPU: suggestions, and
  Windows' "Intel(R) Core(TM) … CPU @ 3.60GHz" is tidied on blur.
- The rig block uses translated labels in a fixed order (CPU, GPU, RAM…)
  in both the description and the social captions.

Tags
- Measured the way YouTube counts (quotes around multi-word tags, one
  comma between): 15 of 51 real tag sets were over 500 by YouTube's count
  while showing under. Counters and the limit warning use the same count.
- Trimming keeps trying shorter tags after one that doesn't fit.
- "Elden Ring Steam", "itch.io gameplay" (was STEAM / ITCHIO); no platform
  tags for a publisher site; "best open world games" (was "openworld");
  RPG/simulation/card pools no longer carry other genres' tags.

Timestamps
- Keywords need a word boundary: "Final Fantasy VII" stays a title (was
  "Ending Fantasy VII"), "Introduction" stays whole.
- Accepts [0:00], 0:00 - label and editor frame counts; pt-BR and
  Indonesian keywords; a Tidy up button; a live check of YouTube's
  chapter rules (0:00 first, 3+, 10 s apart, in order).

Output and data
- History keeps one entry per video (updated in place) instead of one per
  Output visit; existing duplicates are folded (history v3). The History
  Limit is healed on every load.
- A field over its limit blocks only its own copy button (Copy All: title
  or description); a warning when YouTube would reject "<" or ">".
- Validation: Steam /sub/, /bundle/ and s.team links, GOG/Humble/xbox.com
  without www, regional Nintendo sites, Microsoft Store, Luna; social
  links with www./m./twitter.com; phone, YouTube Music and
  video-in-playlist links (normalised); email domains need a TLD; the live
  URL is validated; no bare "#" hashtag.
- The engine takes the year from the caller; "Ending N" follows the output
  language.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 21:11:58 +07:00

53 lines
2.0 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { validateRamValue, validateCompositeField } from "@utils/rig-validation";
describe("validateRamValue", () => {
it("flags a size with no DDR generation", () => {
expect(validateRamValue("32|")?.messageKey).toBe("editor.validation.ramMissingDdr");
});
it("flags a DDR generation with no size", () => {
expect(validateRamValue("|DDR5")?.messageKey).toBe("editor.validation.ramMissingSize");
});
it("flags an empty custom size", () => {
expect(validateRamValue("custom:|DDR5")?.messageKey).toBe("editor.validation.ramCustomEmpty");
});
it("passes a complete size + DDR", () => {
expect(validateRamValue("16|DDR5")).toBeNull();
});
it("passes a fully blank value (deliberate skip)", () => {
expect(validateRamValue("")).toBeNull();
});
it("passes legacy pipeless free-text", () => {
expect(validateRamValue("32GB DDR5-6000")).toBeNull();
});
});
describe("validateCompositeField (v0.24.0 — per-field validator selection)", () => {
it("validates the RAM composite", () => {
expect(validateCompositeField("ram", "32|")?.messageKey).toBe(
"editor.validation.ramMissingDdr",
);
expect(validateCompositeField("ram", "16|DDR5")).toBeNull();
});
it("does NOT run the RAM validator on the OS composite (the bug)", () => {
// Regression guard: "windows||" (OS name selected, no version) parses
// as size="windows", ddr="" under the RAM parser → previously tripped
// "Pick a DDR generation." on the OS field. The OS composite has no
// validator, so every shape must return null.
expect(validateCompositeField("os", "windows||")).toBeNull();
expect(validateCompositeField("os", "macos|15 Sequoia|")).toBeNull();
expect(validateCompositeField("os", "linux|ubuntu|22.04 LTS")).toBeNull();
expect(validateCompositeField("os", "")).toBeNull();
});
it("returns null for any unknown composite id", () => {
expect(validateCompositeField("future_field", "a|b")).toBeNull();
});
});