feat : update
CI / Verify (push) Successful in 1m58s
CI / Build immutable images and deploy (push) Failing after 2m32s

This commit is contained in:
2026-09-06 17:26:26 +07:00 Unverified
parent ce126810bb
commit 6dc46ca2a7
10 changed files with 4114 additions and 224 deletions
+1 -1
View File
@@ -149,7 +149,7 @@ export async function updateGuideBasics(guideId: string, input: unknown) {
await tx.update(guides).set({
overview: data.overview,
coverMediaId: data.coverMediaId,
...(data.youtubeUrl !== undefined ? { youtubeUrl: data.youtubeUrl } : {}),
youtubeUrls: data.youtubeUrls,
...(data.posterArtMediaId !== undefined ? { posterArtMediaId } : {}),
...(data.posterArtOffsetX !== undefined ? { posterArtOffsetX: Math.round(data.posterArtOffsetX) } : {}),
...(data.posterArtOffsetY !== undefined ? { posterArtOffsetY: Math.round(data.posterArtOffsetY) } : {}),
+7 -5
View File
@@ -29,16 +29,18 @@ describe("structured guide validation", () => {
expect(createGuideSchema.safeParse({ characterKey: "1", coverMediaId: "550e8400-e29b-41d4-a716-446655440000", overview: "" }).success).toBe(true);
});
it("normalizes, clears, and omits an optional YouTube video", () => {
it("normalizes and orders multiple optional YouTube videos", () => {
const base = {
expectedVersion: 1,
coverMediaId: "550e8400-e29b-41d4-a716-446655440000",
overview: "Overview",
};
expect(updateGuideSchema.parse({ ...base, youtubeUrl: "https://youtu.be/dQw4w9WgXcQ?si=share" }).youtubeUrl).toBe("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
expect(updateGuideSchema.parse({ ...base, youtubeUrl: "" }).youtubeUrl).toBeNull();
expect(updateGuideSchema.parse(base).youtubeUrl).toBeUndefined();
expect(updateGuideSchema.safeParse({ ...base, youtubeUrl: "https://example.com/video" }).success).toBe(false);
expect(updateGuideSchema.parse({ ...base, youtubeUrls: ["https://youtu.be/dQw4w9WgXcQ?si=share", "https://youtube.com/shorts/aqz-KE-bpKQ"] }).youtubeUrls).toEqual([
"https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"https://www.youtube.com/watch?v=aqz-KE-bpKQ",
]);
expect(updateGuideSchema.parse({ ...base, youtubeUrls: [] }).youtubeUrls).toEqual([]);
expect(updateGuideSchema.safeParse({ ...base, youtubeUrls: ["https://example.com/video"] }).success).toBe(false);
});
it("requires at least one weapon percentage", () => {
+2 -4
View File
@@ -22,9 +22,7 @@ export const createGuideSchema = z.strictObject({
overview: z.string().trim().max(500),
});
const youtubeUrlSchema = z.string().trim().max(2_048).optional().transform((value, context) => {
if (value === undefined) return undefined;
if (!value) return null;
const youtubeUrlSchema = z.string().trim().min(1).max(2_048).transform((value, context) => {
const video = parseYouTubeUrl(value);
if (video) return video.watchUrl;
context.addIssue({ code: "custom", message: "กรุณาใส่ลิงก์วิดีโอ YouTube ที่ถูกต้อง" });
@@ -35,7 +33,7 @@ export const updateGuideSchema = z.strictObject({
expectedVersion: z.number().int().positive(),
coverMediaId: z.string().uuid(),
overview: z.string().trim().min(1).max(500),
youtubeUrl: youtubeUrlSchema,
youtubeUrls: z.array(youtubeUrlSchema).max(20),
posterArtMediaId: z.string().uuid().nullable().optional(),
posterArtOffsetX: z.number().finite().min(-1000).max(1000).optional(),
posterArtOffsetY: z.number().finite().min(-1000).max(1000).optional(),