feat : fix bug
This commit is contained in:
@@ -13,8 +13,14 @@ describe("structured guide validation", () => {
|
||||
});
|
||||
|
||||
it("requires at least one weapon percentage", () => {
|
||||
expect(weaponSectionSchema.safeParse({ expectedVersion: 1, rows: [{ weaponKey: "1", refinement: 5, overallPercent: null, personalPercent: null }] }).success).toBe(false);
|
||||
expect(weaponSectionSchema.safeParse({ expectedVersion: 1, rows: [{ weaponKey: "1", refinement: 5, overallPercent: 104, personalPercent: null }] }).success).toBe(true);
|
||||
expect(weaponSectionSchema.safeParse({ expectedVersion: 1, rows: [{ weaponKey: "1", refinement: 5, overallPercent: null, personalPercent: null, note: null }] }).success).toBe(false);
|
||||
expect(weaponSectionSchema.safeParse({ expectedVersion: 1, rows: [{ weaponKey: "1", refinement: 5, overallPercent: 104, personalPercent: null, note: "Best free-to-play option" }] }).success).toBe(true);
|
||||
});
|
||||
|
||||
it("limits an optional note on each weapon", () => {
|
||||
const row = { weaponKey: "1", refinement: 1, overallPercent: 100, personalPercent: null };
|
||||
expect(weaponSectionSchema.safeParse({ expectedVersion: 1, rows: [{ ...row, note: null }] }).success).toBe(true);
|
||||
expect(weaponSectionSchema.safeParse({ expectedVersion: 1, rows: [{ ...row, note: "x".repeat(2_001) }] }).success).toBe(false);
|
||||
});
|
||||
|
||||
it("limits artifact main stats to two per slot", () => {
|
||||
@@ -22,6 +28,13 @@ describe("structured guide validation", () => {
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it("limits an optional note on each artifact recommendation", () => {
|
||||
const row = { firstArtifactKey: "1", secondArtifactKey: null, percent: 100 };
|
||||
const base = { expectedVersion: 1, sands: [], goblet: [], circlet: [], substats: [], targets: [], talents: [], note: null };
|
||||
expect(artifactSectionSchema.safeParse({ ...base, groups: [{ name: "Late Game", rows: [{ ...row, note: null }] }, artifactGroups[1]] }).success).toBe(true);
|
||||
expect(artifactSectionSchema.safeParse({ ...base, groups: [{ name: "Late Game", rows: [{ ...row, note: "x".repeat(2_001) }] }, artifactGroups[1]] }).success).toBe(false);
|
||||
});
|
||||
|
||||
it("requires the fixed Late Game and Early Game artifact groups", () => {
|
||||
const base = { expectedVersion: 1, sands: [], goblet: [], circlet: [], substats: [], targets: [], talents: [], note: null };
|
||||
expect(artifactSectionSchema.safeParse({ ...base, groups: artifactGroups }).success).toBe(true);
|
||||
|
||||
@@ -25,6 +25,7 @@ export const weaponSectionSchema = z.strictObject({
|
||||
refinement: z.number().int().min(1).max(5),
|
||||
overallPercent: percent.nullable(),
|
||||
personalPercent: percent.nullable(),
|
||||
note: z.string().trim().max(2_000).nullable(),
|
||||
}).refine((row) => row.overallPercent !== null || row.personalPercent !== null, {
|
||||
message: "อาวุธต้องมีเปอร์เซ็นต์อย่างน้อยหนึ่งค่า",
|
||||
})).max(100),
|
||||
@@ -46,6 +47,7 @@ const artifactGroupSchema = (name: "Late Game" | "Early Game") => z.strictObject
|
||||
firstArtifactKey: catalogKey,
|
||||
secondArtifactKey: catalogKey.nullable(),
|
||||
percent,
|
||||
note: z.string().trim().max(2_000).nullable(),
|
||||
})).max(50),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user