AI Implementation feature(849): Landing Page and Login/Register Modal 1.00 (#12)
This commit was merged in pull request #12.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { renderMarkdownToHtml } from '../../frontend/src/app/core/services/markdown.pure';
|
||||
|
||||
describe('Landing welcome binding (mirrors landing.component.ts/.html)', () => {
|
||||
function welcomeHtmlFor(payload: { welcomeMarkdown: string } | null | undefined): string {
|
||||
return renderMarkdownToHtml(payload?.welcomeMarkdown ?? '');
|
||||
}
|
||||
|
||||
it('renders the welcome Markdown from the bootstrap payload', () => {
|
||||
const html = welcomeHtmlFor({
|
||||
welcomeMarkdown: '# Welcome\n\nCreate the first admin to get started.',
|
||||
});
|
||||
expect(typeof html).toBe('string');
|
||||
expect(html).toContain('<h1>Welcome</h1>');
|
||||
expect(html).toContain('Create the first admin to get started.');
|
||||
expect(html).not.toContain('=>{if');
|
||||
});
|
||||
|
||||
it('produces a safe empty string when payload is missing', () => {
|
||||
expect(typeof welcomeHtmlFor(null)).toBe('string');
|
||||
expect(welcomeHtmlFor(null)).not.toContain('=>{if');
|
||||
});
|
||||
|
||||
it('produces a safe empty string when welcomeMarkdown is empty', () => {
|
||||
expect(typeof welcomeHtmlFor({ welcomeMarkdown: '' })).toBe('string');
|
||||
expect(welcomeHtmlFor({ welcomeMarkdown: '' })).not.toContain('=>{if');
|
||||
});
|
||||
|
||||
it('keeps sanitization when the welcome Markdown contains hostile content', () => {
|
||||
const html = welcomeHtmlFor({
|
||||
welcomeMarkdown: '# Hello\n\n<script>alert(1)</script>\n\n[bad](javascript:alert(1))',
|
||||
});
|
||||
expect(html).toContain('<h1>Hello</h1>');
|
||||
expect(html).not.toContain('<script>');
|
||||
expect(html).not.toMatch(/href="javascript:/i);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user