diff --git a/furniture-3d-system/src/app/intake/barcode-print/BarcodePrintTemplateDialog.test.tsx b/furniture-3d-system/src/app/intake/barcode-print/BarcodePrintTemplateDialog.test.tsx index 72664389..83b8824c 100644 --- a/furniture-3d-system/src/app/intake/barcode-print/BarcodePrintTemplateDialog.test.tsx +++ b/furniture-3d-system/src/app/intake/barcode-print/BarcodePrintTemplateDialog.test.tsx @@ -1,12 +1,13 @@ import { fireEvent, render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { BarcodePrintTemplateDialog } from './BarcodePrintTemplateDialog' +import { CERTIFICATE_PRINT_TEMPLATE_OPTIONS } from './barcodePrintCertificate' describe('BarcodePrintTemplateDialog', () => { it('marks a disabled certificate unavailable, skips a stale default and prevents submission', async () => { const actor = userEvent.setup() const onSubmit = jest.fn() - const disabledTitle = '顾家合格证卡片2026新版(11cm*13cm)' + const disabledTitle = '测试停用模板' const legacyTitle = '顾家合格证卡片(11cm*13cm)' render( { expect(onSubmit).toHaveBeenCalledWith(expect.objectContaining({ templateTitle: legacyTitle })) }) + it('selects and submits the available 2026 Gujia certificate from the actual template options', async () => { + const actor = userEvent.setup() + const onSubmit = jest.fn() + const title = '顾家合格证卡片2026新版(11cm*13cm)' + render( + , + ) + + const select = screen.getByLabelText('打印模板') + expect(screen.getByRole('option', { name: title })).toBeEnabled() + expect(select).toHaveValue(title) + expect(screen.queryByRole('option', { name: `${title}(暂时不可用)` })).not.toBeInTheDocument() + await actor.selectOptions(select, '顾家合格证卡片(11cm*13cm)') + await actor.selectOptions(select, title) + await actor.click(screen.getByRole('button', { name: '确定' })) + expect(onSubmit).toHaveBeenCalledWith(expect.objectContaining({ templateTitle: title })) + }) + it('submits the selected barcode template', async () => { const actor = userEvent.setup() const onSubmit = jest.fn() diff --git a/furniture-3d-system/src/app/intake/barcode-print/barcodePrintCertificate.test.ts b/furniture-3d-system/src/app/intake/barcode-print/barcodePrintCertificate.test.ts index e0cfc797..ac77a530 100644 --- a/furniture-3d-system/src/app/intake/barcode-print/barcodePrintCertificate.test.ts +++ b/furniture-3d-system/src/app/intake/barcode-print/barcodePrintCertificate.test.ts @@ -1,10 +1,7 @@ import { __barcodePrintCertificateTestUtils, CERTIFICATE_PRINT_TEMPLATE_OPTIONS, - createCertificatePrintPreview, - printCertificatePreview, } from "./barcodePrintCertificate"; -import type { BarcodePrintRow } from "./barcodePrintRows"; import { applyGujiaCertificate2026Content } from "./barcodePrintGujiaCertificate2026"; import { SOFIA_CARTON_BARCODE_QR_LAYOUT } from "./barcodePrintSofiaCartonLayout"; import { @@ -13,7 +10,7 @@ import { } from "./barcodePrintSofiaCertificateLayout"; describe("Gujia certificate availability and calibration", () => { - const disabledTitle = "顾家合格证卡片2026新版(11cm*13cm)"; + const newCardTitle = "顾家合格证卡片2026新版(11cm*13cm)"; const record = { barcode: "GBGJ-TEST", productCategory: "电脑桌", color: "经典北美黑胡桃色+黑架", procode: "DS5147BG", brandProcode: "DS5147BG-C4", size: "120*60*75", @@ -21,13 +18,13 @@ describe("Gujia certificate availability and calibration", () => { qualifiedCertMainMaterial: "", executionStandard: "T/CZFA 0002-2025", }; - it("disables only the new card and rejects generation and previously generated previews", async () => { - expect(CERTIFICATE_PRINT_TEMPLATE_OPTIONS.filter((option) => option.disabled).map((option) => option.title)) - .toEqual([disabledTitle]); - await expect(createCertificatePrintPreview({} as BarcodePrintRow, disabledTitle)) - .rejects.toThrow("暂时不可用"); - await expect(printCertificatePreview({ title: disabledTitle, pageSize: "110mm 130mm", imageDataUrl: "data:image/png;base64,old" })) - .rejects.toThrow("暂时不可用"); + it("offers both Gujia cards as available certificate templates", () => { + const newCard = CERTIFICATE_PRINT_TEMPLATE_OPTIONS.find((option) => option.title === newCardTitle); + const legacyCard = CERTIFICATE_PRINT_TEMPLATE_OPTIONS.find((option) => option.title === "顾家合格证卡片(11cm*13cm)"); + expect(newCard).toBeDefined(); + expect(legacyCard).toBeDefined(); + expect(newCard?.disabled).toBeFalsy(); + expect(legacyCard?.disabled).toBeFalsy(); }); it("applies one calibrated offset to the legacy card while retaining all original printed values", () => { @@ -41,7 +38,7 @@ describe("Gujia certificate availability and calibration", () => { expect(values.every((value) => value.style.left === "474px" && value.style.fontSize === "42px")).toBe(true); }); - it("retains the disabled new card content and coordinates for future use", () => { + it("retains the new card content and coordinates", () => { const base = __barcodePrintCertificateTestUtils.renderGujiaCertificate(record, "", {}, "background", -72); const card = applyGujiaCertificate2026Content(base, record.executionStandard); const values = Array.from(card.querySelectorAll(".item")); diff --git a/furniture-3d-system/src/app/intake/barcode-print/barcodePrintCertificate.ts b/furniture-3d-system/src/app/intake/barcode-print/barcodePrintCertificate.ts index 6adc7ee9..9ad42120 100644 --- a/furniture-3d-system/src/app/intake/barcode-print/barcodePrintCertificate.ts +++ b/furniture-3d-system/src/app/intake/barcode-print/barcodePrintCertificate.ts @@ -750,7 +750,6 @@ const CERTIFICATE_TEMPLATES: CertificateTemplate[] = [ }, { title: GUJIA_CERTIFICATE_2026_TITLE, - disabled: true, pageSize: "110mm 130mm", background: "hgz_gj.jpg", render: (record, qrCodeBase64, options, backgroundDataUrl) => diff --git a/furniture-3d-system/src/app/intake/barcode-print/barcodePrintGujiaCertificateLayout.test.ts b/furniture-3d-system/src/app/intake/barcode-print/barcodePrintGujiaCertificateLayout.test.ts index b48af7b7..5d6036f7 100644 --- a/furniture-3d-system/src/app/intake/barcode-print/barcodePrintGujiaCertificateLayout.test.ts +++ b/furniture-3d-system/src/app/intake/barcode-print/barcodePrintGujiaCertificateLayout.test.ts @@ -20,7 +20,7 @@ describe("Gujia certificate layout", () => { } }); - it("preserves the disabled 2026 template coordinates", () => { + it("preserves the 2026 template coordinates", () => { expect(GUJIA_FIELD_PRINT_VERTICAL_OFFSET).toBe(-72); expect(getGujiaCertificateFieldStyle(0).top).toBe("436px"); expect(getGujiaCertificateFieldStyle(1).top).toBe("554.5px"); diff --git a/furniture-3d-system/src/app/intake/barcode-print/barcodePrintGujiaCertificateLayout.ts b/furniture-3d-system/src/app/intake/barcode-print/barcodePrintGujiaCertificateLayout.ts index 1521bd41..c335b713 100644 --- a/furniture-3d-system/src/app/intake/barcode-print/barcodePrintGujiaCertificateLayout.ts +++ b/furniture-3d-system/src/app/intake/barcode-print/barcodePrintGujiaCertificateLayout.ts @@ -4,7 +4,7 @@ export const GUJIA_CERTIFICATE_CANVAS = { } as const; const GUJIA_FIELD_LEFT = 474; -// 保留已停用2026新版的现有坐标,旧版校准单独传入下方偏移量。 +// 2026新版使用现有坐标,旧版校准单独传入下方偏移量。 export const GUJIA_FIELD_PRINT_VERTICAL_OFFSET = -72; // 最新实物与正确样张按红线行距对比,在已上线-20px基础上再整体上移20px。 // 累计偏移-40px,待同一打印机试打确认;这不是物理毫米换算。