diff --git a/changelogs/fragments/7699.yml b/changelogs/fragments/7699.yml new file mode 100644 index 00000000000..24554fb4446 --- /dev/null +++ b/changelogs/fragments/7699.yml @@ -0,0 +1,2 @@ +feat: +- Add a unit test case to indicate React is anti-xss ([#7699](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7699)) \ No newline at end of file diff --git a/src/plugins/workspace/public/components/workspace_detail/workspace_detail.test.tsx b/src/plugins/workspace/public/components/workspace_detail/workspace_detail.test.tsx index d27f0187e5b..2562e7a7591 100644 --- a/src/plugins/workspace/public/components/workspace_detail/workspace_detail.test.tsx +++ b/src/plugins/workspace/public/components/workspace_detail/workspace_detail.test.tsx @@ -120,4 +120,17 @@ describe('WorkspaceDetail', () => { expect(screen.queryByText('Enter details')).not.toBeNull(); }); }); + + it('will not render xss content', async () => { + const alertSpy = jest.spyOn(window, 'alert').mockImplementation(() => {}); + const workspaceService = createWorkspacesSetupContractMockWithValue({ + ...workspaceObject, + name: '', + description: '', + }); + const { getByText } = render(WorkspaceDetailPage({ workspacesService: workspaceService })); + expect(getByText('')).toBeInTheDocument(); + expect(alertSpy).toBeCalledTimes(0); + alertSpy.mockRestore(); + }); });