feat: add tags workflow

This commit is contained in:
2026-07-16 03:34:23 +05:00
parent 7c0584707a
commit 6eedfb2bc5
29 changed files with 1153 additions and 22 deletions
+30 -1
View File
@@ -1,11 +1,17 @@
import { describe, expect, it } from "vitest";
import { findFieldRange, replaceFrontmatterField } from "./frontmatterFields";
import {
findFieldRange,
formatTagsYamlValue,
replaceFrontmatterField,
setFrontmatterTags,
} from "./frontmatterFields";
const sample = `---
id: abc
title: Hello
status: todo
priority: medium
tags: [old]
---
Body
@@ -47,3 +53,26 @@ describe("findFieldRange", () => {
expect(line.slice(range!.startCol, range!.endCol)).toBe("todo");
});
});
describe("formatTagsYamlValue", () => {
it("formats empty and simple lists", () => {
expect(formatTagsYamlValue([])).toBe("[]");
expect(formatTagsYamlValue(["bug", "frontend"])).toBe(
"[bug, frontend]",
);
});
it("quotes tags with spaces", () => {
expect(formatTagsYamlValue(["my tag"])).toBe('["my tag"]');
});
});
describe("setFrontmatterTags", () => {
it("replaces the tags line", () => {
const result = setFrontmatterTags(sample, ["bug", "docs"]);
expect(result.ok).toBe(true);
if (!result.ok) return;
expect(result.content).toContain("tags: [bug, docs]");
expect(result.content).not.toContain("tags: [old]");
});
});