fix preview sandbox and local analytics proxy
This commit is contained in:
@@ -117,6 +117,24 @@ test('buildChatSavePreviewUrls use local api routes', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('chat page previews keep generated scripts sandboxed and proxy analytics through Portal', async () => {
|
||||
const [pageSavePreview, chatSharePreview, viteConfig] = await Promise.all([
|
||||
fs.readFile(new URL('./src/components/PageSavePreviewPanel.tsx', import.meta.url), 'utf8'),
|
||||
fs.readFile(new URL('./src/components/ChatSharePreviewModal.tsx', import.meta.url), 'utf8'),
|
||||
fs.readFile(new URL('./vite.config.ts', import.meta.url), 'utf8'),
|
||||
]);
|
||||
|
||||
assert.match(pageSavePreview, /sandbox="allow-scripts allow-downloads"/);
|
||||
assert.match(chatSharePreview, /sandbox="allow-scripts allow-popups allow-downloads"/);
|
||||
for (const source of [pageSavePreview, chatSharePreview]) {
|
||||
assert.doesNotMatch(
|
||||
source,
|
||||
/sandbox="[^"]*(?:allow-scripts[^"]*allow-same-origin|allow-same-origin[^"]*allow-scripts)[^"]*"/,
|
||||
);
|
||||
}
|
||||
assert.match(viteConfig, /['"]\/analytics['"]\s*:\s*portalTarget/);
|
||||
});
|
||||
|
||||
test('findPublishHtml resolves nested public html by basename', async () => {
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'memind-chat-save-'));
|
||||
const publishDir = path.join(root, 'MindSpace', USER_ID, 'public');
|
||||
|
||||
Reference in New Issue
Block a user