PSA/shared/lib/utils/__tests__/contentConversion.test.ts
Hermes 284313f908
Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Initial import of AlgaPSA codebase from PSA server
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz

Source: /opt/alga-psa on psa.joliet.tech
2026-06-22 16:12:17 -05:00

59 lines
2.3 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { convertHtmlToBlockNote } from '../contentConversion';
function textFromBlock(block: any): string {
const content = Array.isArray(block.content) ? block.content : [];
return content.map((item: any) => item.text ?? '').join('');
}
describe('convertHtmlToBlockNote email table handling', () => {
it('preserves table blocks by default', async () => {
const result = await convertHtmlToBlockNote(`
<table>
<tr><td>Name</td><td>Ada Lovelace</td></tr>
<tr><td>Business Email Address</td><td>ada@example.com</td></tr>
</table>
`);
expect(result.some((block) => block.type === 'table')).toBe(true);
});
it('preserves normal data tables as BlockNote table blocks even when email table cleanup is enabled', async () => {
const result = await convertHtmlToBlockNote(`
<table>
<tr><th>Name</th><th>Email</th></tr>
<tr><td>Ada Lovelace</td><td>ada@example.com</td></tr>
<tr><td>Grace Hopper</td><td>grace@example.com</td></tr>
</table>
`, { flattenTables: true });
const tableBlock = result.find((block) => block.type === 'table');
expect(tableBlock).toBeDefined();
expect((tableBlock?.content as any)?.rows).toHaveLength(3);
expect((tableBlock?.content as any)?.rows[0].cells).toHaveLength(2);
});
it('splits collapsed nested layout-table content into label/value paragraphs', async () => {
const result = await convertHtmlToBlockNote(`
<table>
<tr><td>
<h2>Entry Details</h2>
<table><tr><td>
<h2>Tools &amp; Resources</h2>
<table>
<tr><td><p><b>Name</b></p></td><td><p>Ada Lovelace</p></td></tr>
<tr><td><p><b>Business Email Address</b></p></td><td><p>ada@example.com</p></td></tr>
<tr><td><p><b>Description of Issue</b></p></td><td><p>Requesting a call back.</p></td></tr>
</table>
</td></tr></table>
</td></tr>
</table>
`, { flattenTables: true });
expect(result.every((block) => block.type === 'paragraph')).toBe(true);
expect(result.map(textFromBlock)).toContain('Name Ada Lovelace');
expect(result.map(textFromBlock)).toContain('Business Email Address ada@example.com');
expect(result.map(textFromBlock)).toContain('Description of Issue Requesting a call back.');
});
});