fix(pdf): preserve accented names in revised CV and letter headings
This commit is contained in:
@@ -4,6 +4,7 @@ import path from 'node:path';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { previewDocumentHtml } from '../src/cvPreview';
|
||||
import { templateFixtures, templateProfile } from './pre-p10-template-fixtures';
|
||||
import { minimumNameInkClearance } from './helpers/nameInkClearance';
|
||||
|
||||
const api = 'http://localhost:5302/api';
|
||||
const output = path.resolve(process.env.CV_TEMPLATE_OUTPUT || '../.artifacts/pre-phase10-ux/templates-legacy');
|
||||
@@ -36,18 +37,22 @@ test('[PRE-P10 B] equivalent synthetic histories retain preview and native PDF e
|
||||
await fs.writeFile(path.join(output, 'synthetic-nonhuman-color-sample.png'), avatar);
|
||||
expect((await page.request.post(`${api}/auth/avatar`, { headers, multipart: { file: { name: 'synthetic-nonhuman.png', mimeType: 'image/png', buffer: avatar } } })).status()).toBe(200);
|
||||
const results: unknown[] = [];
|
||||
for (const sample of templateFixtures) {
|
||||
const europeanControls: unknown[] = [];
|
||||
const scenarios = [...templateFixtures.map(sample => ({ sample, european: false })),
|
||||
...(designVersion === 2 ? [{ sample: templateFixtures[0], european: true }] : [])];
|
||||
for (const { sample, european } of scenarios) {
|
||||
const { profile, markers } = templateProfile(sample);
|
||||
if (european) profile.contact.fullName = 'S01 Åse Émilie Müller Žák Łódź Sørensen';
|
||||
const current = await (await page.request.get(`${api}/career/profile`)).json();
|
||||
expect((await page.request.put(`${api}/career/profile`, { headers, data: { expectedVersion: current.revision, profile } })).status()).toBe(200);
|
||||
const source = await (await page.request.get(`${api}/career/profile`)).json();
|
||||
for (const theme of themes) {
|
||||
const fixture = `${sample.key}-${theme.id}`;
|
||||
const fixture = `${european ? 'european-no-photo' : sample.key}-${theme.id}`;
|
||||
const directory = path.join(output, fixture);
|
||||
await fs.mkdir(directory, { recursive: true });
|
||||
const started = performance.now();
|
||||
const created = await page.request.post(`${api}/cv/variants`, { headers, data: { name: fixture, settings: {
|
||||
themeId: theme.id, language: sample.language, showPhoto: true, showIcons: true,
|
||||
themeId: theme.id, language: sample.language, showPhoto: !european, showIcons: true,
|
||||
...(designVersion === undefined ? {} : { designVersion }),
|
||||
} } });
|
||||
expect(created.status(), fixture).toBe(200);
|
||||
@@ -59,6 +64,8 @@ test('[PRE-P10 B] equivalent synthetic histories retain preview and native PDF e
|
||||
await page.setViewportSize({ width: 794, height: 1123 });
|
||||
await page.setContent(previewDocumentHtml(rendered.html, 297 * 96 / 25.4));
|
||||
await expect.poll(() => page.evaluate(() => document.documentElement.dataset.cvPreviewReady), { message: fixture }).toBe('true');
|
||||
const nameInkClearancePx = await page.evaluate(minimumNameInkClearance, '.name');
|
||||
if (designVersion === 2) expect(nameInkClearancePx, `${fixture} full name ink stays inside print fragment`).toBeGreaterThanOrEqual(0);
|
||||
const measured = await page.evaluate(() => {
|
||||
const data = document.documentElement.dataset;
|
||||
const width = Number(data.cvPreviewWidth), height = Number(data.cvPreviewHeight);
|
||||
@@ -92,6 +99,7 @@ test('[PRE-P10 B] equivalent synthetic histories retain preview and native PDF e
|
||||
});
|
||||
expect(measured.tokens.map(token => token.token).sort(), `${fixture} preview marker completeness`).toEqual([...markers].sort());
|
||||
expect(measured.previewPages, fixture).toBeGreaterThan(0);
|
||||
expect(measured.photo, fixture).toBe(!european && theme.photoShape !== 'none');
|
||||
if (designVersion === 2) expect(measured.splitNameWords.filter(word => !word.includes('-')), `${fixture} unhyphenated name words`).toEqual([]);
|
||||
const exported = await page.request.post(`${api}/cv/variants/${variant.id}/export-pdf?expectedVersion=${variant.version}`, { headers });
|
||||
expect(exported.status(), fixture).toBe(200);
|
||||
@@ -105,11 +113,13 @@ test('[PRE-P10 B] equivalent synthetic histories retain preview and native PDF e
|
||||
}
|
||||
expect((await (await page.request.get(`${api}/cv/variants/${variant.id}`)).json()).version).toBe(variant.version);
|
||||
expect(await (await page.request.get(`${api}/career/profile`)).json()).toEqual(source);
|
||||
results.push({ fixture, settings: variant.settings, expectedMarkers: markers, profileSha256: hash(JSON.stringify(profile)), htmlSha256: hash(rendered.html), pdfSha256: hash(bytes),
|
||||
(european ? europeanControls : results).push({ fixture, settings: variant.settings, expectedMarkers: markers, expectedFullName: profile.contact.fullName, nameInkClearancePx,
|
||||
profileSha256: hash(JSON.stringify(profile)), htmlSha256: hash(rendered.html), pdfSha256: hash(bytes),
|
||||
durationMs: performance.now() - started, previewPages: measured.previewPages, measured });
|
||||
await fs.writeFile(path.join(output, 'measurements.json'), JSON.stringify({ browserVersion: browser.version(), designVersion: designVersion ?? 'legacy-absent', syntheticPhoto: 'Colored rectangles only; no human portrait', fixtures: results }, null, 2));
|
||||
await fs.writeFile(path.join(output, 'measurements.json'), JSON.stringify({ browserVersion: browser.version(), designVersion: designVersion ?? 'legacy-absent', syntheticPhoto: 'Colored rectangles only; no human portrait', fixtures: results, europeanControls }, null, 2));
|
||||
}
|
||||
}
|
||||
expect(results).toHaveLength(36);
|
||||
expect(europeanControls).toHaveLength(designVersion === 2 ? 9 : 0);
|
||||
await info.attach('template-library-measurements', { path: path.join(output, 'measurements.json'), contentType: 'application/json' });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user