-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix a bug on MS, sanitize HTML, and test sanitization of HTML on MS
- Loading branch information
Showing
11 changed files
with
99 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from "react"; | ||
import { render, fireEvent } from "@testing-library/react"; | ||
import { ReduxWrapper } from "@mds/common/tests/utils/ReduxWrapper"; | ||
import HelpGuide, { HelpGuideContent } from "./HelpGuide"; | ||
import { AUTHENTICATION } from "@mds/common/constants/reducerTypes"; | ||
import { SystemFlagEnum } from "@mds/common/constants"; | ||
import { MS_USER_ACCESS_DATA } from "@mds/common/tests/mocks/dataMocks"; | ||
import { helpReducerType } from "@mds/common/redux/slices/helpSlice"; | ||
import { BrowserRouter } from "react-router-dom"; | ||
|
||
const msState = { | ||
[AUTHENTICATION]: { | ||
systemFlag: SystemFlagEnum.ms, | ||
userAccessData: MS_USER_ACCESS_DATA, | ||
isAuthenticated: true, | ||
}, | ||
[helpReducerType]: { | ||
helpGuides: {}, | ||
}, | ||
}; | ||
|
||
function mockFunction() { | ||
const original = jest.requireActual("react-router-dom"); | ||
return { | ||
...original, | ||
useParams: jest.fn().mockReturnValue({ | ||
tab: "overview", | ||
}), | ||
}; | ||
} | ||
|
||
jest.mock("react-router-dom", () => mockFunction()); | ||
|
||
describe("HelpGuide", () => { | ||
it("renders MS properly with default content", async () => { | ||
const helpKey = "Not-Exists"; | ||
const { findByTestId } = render( | ||
<BrowserRouter> | ||
<ReduxWrapper initialState={msState}> | ||
<HelpGuide /> | ||
<HelpGuideContent helpKey={helpKey} /> | ||
</ReduxWrapper> | ||
</BrowserRouter> | ||
); | ||
const helpButton = await findByTestId("help-open"); | ||
fireEvent.click(helpButton); | ||
|
||
const helpContent = await findByTestId("help-content"); | ||
|
||
expect(helpContent).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
services/common/src/components/help/__snapshots__/HelpGuide-ms.spec.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`HelpGuide renders MS properly with default content 1`] = ` | ||
<div | ||
data-testid="help-content" | ||
> | ||
<h2 | ||
class="ant-typography" | ||
data-testid="help-title" | ||
> | ||
Overview | ||
Help Guide | ||
</h2> | ||
<p> | ||
console.log('should not render as inline function');}>MS default content | ||
</p> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters