feat(core-shared): add seoFields group
This commit is contained in:
27
packages/core-shared/src/payload/fields/seo-fields.test.ts
Normal file
27
packages/core-shared/src/payload/fields/seo-fields.test.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { seoFields } from "./seo-fields";
|
||||
|
||||
describe("seoFields", () => {
|
||||
it("is a group field named 'seo'", () => {
|
||||
expect(seoFields.name).toBe("seo");
|
||||
expect(seoFields.type).toBe("group");
|
||||
});
|
||||
|
||||
it("contains required title and optional description", () => {
|
||||
if (seoFields.type !== "group") {
|
||||
throw new Error("seoFields must be a group");
|
||||
}
|
||||
const fieldNames = seoFields.fields.map((f) =>
|
||||
"name" in f ? f.name : null,
|
||||
);
|
||||
expect(fieldNames).toContain("title");
|
||||
expect(fieldNames).toContain("description");
|
||||
|
||||
const titleField = seoFields.fields.find(
|
||||
(f) => "name" in f && f.name === "title",
|
||||
);
|
||||
expect(titleField && "required" in titleField && titleField.required).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
10
packages/core-shared/src/payload/fields/seo-fields.ts
Normal file
10
packages/core-shared/src/payload/fields/seo-fields.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { Field } from "payload";
|
||||
|
||||
export const seoFields: Field = {
|
||||
name: "seo",
|
||||
type: "group",
|
||||
fields: [
|
||||
{ name: "title", type: "text", required: true },
|
||||
{ name: "description", type: "textarea" },
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user