Files
pdfme/packages/generator/__tests__/integration-segmenter.test.ts
Kyohei Fukuda ff363fda63 chore(deps): major version bumps for v5 (Tailwind 4, TS 6 in playground, Sentry 10, react-router 7, etc.) (#1455)
* chore(deps): major version bumps for v5

Consolidates 10 unique major-version Dependabot PRs into one.

Bumps:
- color 4 -> 5 (packages/pdf-lib)
- signature_pad 4 -> 5 (packages/schemas, playground)
- vite-plugin-css-injected-by-js 4 -> 5 (packages/ui)
- jsdom 26 -> 29 (root)
- @sentry/react 9 -> 10 (playground)
- react-router-dom 6 -> 7 (playground)
- tailwindcss 3 -> 4 (playground) -- migrated to @tailwindcss/postcss plugin and @import "tailwindcss" syntax
- typescript 5 -> 6 (playground; root already on 6)

Snapshot updates:
- jsdom 29 normalises CSS slightly (border: medium, background-position: center center, etc.) -- updated UI snapshots
- color 5 produces a 0.34% pixel diff in barcodes-1.png -- regenerated image snapshot

Note: React 19 (#1437, #1438, #1445, #1446, #1447, #1449) deferred to a follow-up. The form-render -> rc-color-picker peer chain pins react@16.x, which forces a dual-instance install incompatible with @dnd-kit/core's hooks dispatcher in tests. Will revisit once form-render is replaced or removed.

Supersedes: #1439, #1440, #1441, #1442, #1443, #1444, #1448, #1450, #1451, #1452, #1453

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* test(generator): relax integration-segmenter perf threshold 2.5s -> 3s

CIで2.8秒前後で稳定的にflakyになっており、main上でも落ちている。
許容範囲を広げて誤検知を抑える。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* test(generator): relax integration-other perf threshold 1.5s -> 2.5s

CIで1.9秒前後で落ちる。誤検知を抑えるため許容範囲を拡大。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* test(generator): bump fontSubset test timeout 10s -> 30s

CIで10sタイムアウトしている (フォントsubset無効化での生成が重い)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 15:52:21 +09:00

51 lines
1.8 KiB
TypeScript

import generate from '../src/generate.js';
import { segmenter } from './assets/templates/index.js';
import { getInputFromTemplate } from '@pdfme/common';
import { text, multiVariableText, image, barcodes } from '@pdfme/schemas';
import { getFont, getImageSnapshotOptions, pdfToImages } from './utils.js';
const PERFORMANCE_THRESHOLD = parseFloat(process.env.PERFORMANCE_THRESHOLD || '3');
describe('generate integration test(segmenter)', () => {
describe.each([segmenter])('%s', (templateData) => {
const entries = Object.entries(templateData);
for (let l = 0; l < entries.length; l += 1) {
const [key, template] = entries[l];
// eslint-disable-next-line no-loop-func
test(`snapshot ${key}`, async () => {
const inputs = getInputFromTemplate(template);
const font = getFont();
font['NotoSerifJP-Regular'].fallback = false;
font.NotoSerifJP.fallback = false;
font.NotoSansJP.fallback = false;
const hrstart = process.hrtime();
const pdf = await generate({
inputs,
template,
plugins: { text, image, multiVariableText, ...barcodes },
options: { font },
});
const hrend = process.hrtime(hrstart);
const execSeconds = hrend[0] + hrend[1] / 1000000000;
if (process.env.CI) {
expect(execSeconds).toBeLessThan(PERFORMANCE_THRESHOLD);
} else if (execSeconds >= PERFORMANCE_THRESHOLD) {
console.warn(
`Warning: Execution time for ${key} is ${execSeconds} seconds, which is above the threshold of ${PERFORMANCE_THRESHOLD} seconds.`
);
}
const images = await pdfToImages(pdf);
for (let i = 0; i < images.length; i++) {
await expect(images[i]).toMatchImage(getImageSnapshotOptions(`${key}-${i + 1}`));
}
});
}
});
});