/** * XSS Prevention Test Suite * * This test verifies that the XSS vulnerabilities in block-input and support-var-input * components have been properly fixed by replacing dangerouslySetInnerHTML with safe React rendering. */ import React from 'react' import { cleanup, render } from '@testing-library/react' import '@testing-library/jest-dom' import BlockInput from '../app/components/base/block-input' import SupportVarInput from '../app/components/workflow/nodes/_base/components/support-var-input' // Mock styles jest.mock('../app/components/app/configuration/base/var-highlight/style.module.css', () => ({ item: 'mock-item-class', })) describe('XSS Prevention - Block Input and Support Var Input Security', () => { afterEach(() => { cleanup() }) describe('BlockInput Component Security', () => { it('should safely render malicious variable names without executing scripts', () => { const testInput = 'user@test.com{{}}' const { container } = render() const scriptElements = container.querySelectorAll('script') expect(scriptElements).toHaveLength(0) const textContent = container.textContent expect(textContent).toContain(''} const { container } = render() const spanElement = container.querySelector('span') const scriptElements = container.querySelectorAll('script') expect(spanElement?.textContent).toBe('') expect(scriptElements).toHaveLength(0) }) }) }) export {}