fix: align sofia certificate print fields
This commit is contained in:
parent
592b53f0ac
commit
a252c00ac2
@ -1,6 +1,52 @@
|
||||
import { __barcodePrintCertificateTestUtils } from "./barcodePrintCertificate";
|
||||
import { SOFIA_CARTON_BARCODE_QR_LAYOUT } from "./barcodePrintSofiaCartonLayout";
|
||||
|
||||
describe("Sofia certificate field positioning", () => {
|
||||
afterEach(() => {
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
it("moves all six values upward by three rows without changing their data or horizontal layout", () => {
|
||||
jest.useFakeTimers().setSystemTime(new Date("2026-09-04T12:00:00.000Z"));
|
||||
const element = __barcodePrintCertificateTestUtils.renderSofiaCertificate(
|
||||
{
|
||||
barcode: "GBSFY-SJ038036N1410V01",
|
||||
productCategory: "书架",
|
||||
color: "经典北美黑胡桃色",
|
||||
procode: "SFY-001",
|
||||
brandProcode: "SFY-BRAND-001",
|
||||
size: "100*40*180",
|
||||
productSpec: "100*40*180",
|
||||
hangtagMaterial: "人造板",
|
||||
qualifiedCertMainMaterial: "人造板",
|
||||
executionStandard: "GB/T 3324-2017",
|
||||
},
|
||||
"",
|
||||
{},
|
||||
"data:image/png;base64,background",
|
||||
);
|
||||
const values = Array.from(element.querySelectorAll<HTMLElement>(".item"));
|
||||
|
||||
expect(values.map((value) => value.style.top)).toEqual([
|
||||
"200px",
|
||||
"266px",
|
||||
"332px",
|
||||
"398px",
|
||||
"464px",
|
||||
"530px",
|
||||
]);
|
||||
expect(values.map((value) => value.style.left)).toEqual(Array(6).fill("310px"));
|
||||
expect(values.map((value) => value.textContent)).toEqual([
|
||||
"书架-经典北美黑胡桃色",
|
||||
"SFY-001",
|
||||
"100*40*180",
|
||||
"GB/T 3324-2017",
|
||||
"QC01",
|
||||
"2026-08-25",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Sofia carton certificate rendering", () => {
|
||||
it("renders the current barcode QR code to the left of the fixed official-account QR code", () => {
|
||||
const qrCodeDataUrl = "data:image/png;base64,barcode-qr";
|
||||
|
||||
@ -110,6 +110,8 @@ const PORTRAIT_FIELD_TOP = 883;
|
||||
const PORTRAIT_FIELD_ROW_GAP = 68;
|
||||
const PORTRAIT_RIGHT_FIRST_ROW_TOP_OFFSET = 0;
|
||||
const PORTRAIT_VALUE_VISUAL_OFFSET = -8;
|
||||
const SOFIA_CERTIFICATE_FIELD_TOP = 200;
|
||||
const SOFIA_CERTIFICATE_FIELD_ROW_GAP = 66;
|
||||
|
||||
function trimText(value: unknown) {
|
||||
return String(value ?? "").trim();
|
||||
@ -524,7 +526,7 @@ function renderSofiaCertificate(
|
||||
color: "#000000",
|
||||
lineHeight: "32px",
|
||||
left: "310px",
|
||||
top: `${398 + index * 66}px`,
|
||||
top: `${SOFIA_CERTIFICATE_FIELD_TOP + index * SOFIA_CERTIFICATE_FIELD_ROW_GAP}px`,
|
||||
});
|
||||
});
|
||||
|
||||
@ -641,6 +643,7 @@ export const __barcodePrintCertificateTestUtils = {
|
||||
getLandscapeProductNameFontSize,
|
||||
renderCommonWithMaker,
|
||||
renderCommonWithoutMaker,
|
||||
renderSofiaCertificate,
|
||||
renderSofiaCarton,
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user