mirror of
https://github.com/nexu-io/open-design.git
synced 2026-10-27 09:51:12 +01:00
* chore: enforce test directory conventions Move package, app, and tool tests out of src and add guard enforcement so source directories stay source-only. * ci: use guard and package-scoped tests Run the new repository guard in CI and keep test execution aligned with package-scoped commands after removing root aliases. * ci: align stable release guard check Use the new repository guard in stable release verification after replacing the residual-JS-only script. * chore: tighten test layout enforcement Enforce sibling tests directories, typecheck moved test suites with dedicated configs, and refresh remaining guidance that pointed at src-based tests. * chore: clarify no-emit test tsconfigs Explicitly disable declaration-only emit in test tsconfigs so review tooling sees they are no-emit typecheck configs.
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { renderToStaticMarkup } from 'react-dom/server';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
import { PreviewModal } from '../../src/components/PreviewModal';
|
|
|
|
describe('PreviewModal sandbox isolation', () => {
|
|
it('renders generated previews without same-origin sandbox access', () => {
|
|
const markup = renderToStaticMarkup(
|
|
<PreviewModal
|
|
title="Unsafe preview"
|
|
views={[
|
|
{
|
|
id: 'preview',
|
|
label: 'Preview',
|
|
html: '<script>window.parent.document.body.innerHTML="owned"</script>',
|
|
},
|
|
]}
|
|
exportTitleFor={() => 'unsafe-preview'}
|
|
onClose={() => {}}
|
|
/>,
|
|
);
|
|
|
|
expect(markup).toContain('sandbox="allow-scripts"');
|
|
expect(markup).not.toContain('allow-same-origin');
|
|
expect(markup).toContain('srcDoc=');
|
|
});
|
|
|
|
it('keeps deck srcdoc handling for deck preview views', () => {
|
|
const markup = renderToStaticMarkup(
|
|
<PreviewModal
|
|
title="Deck preview"
|
|
views={[
|
|
{
|
|
id: 'deck',
|
|
label: 'Deck',
|
|
html: '<section class="slide">one</section><section class="slide">two</section>',
|
|
deck: true,
|
|
},
|
|
]}
|
|
exportTitleFor={() => 'deck-preview'}
|
|
onClose={() => {}}
|
|
/>,
|
|
);
|
|
|
|
expect(markup).toContain('sandbox="allow-scripts"');
|
|
expect(markup).not.toContain('allow-same-origin');
|
|
expect(markup).toContain('od:slide');
|
|
});
|
|
});
|