Apply html utils sanitiser to embedded page (#33842)
* Apply html utils sanitiser to embedded page * Write tests
This commit is contained in:
@@ -47,4 +47,13 @@ describe("<EmbeddedPage />", () => {
|
||||
const { asFragment } = render(<EmbeddedPage />);
|
||||
expect(asFragment()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should sanitise input", async () => {
|
||||
fetchMock.get("https://other.page", `<h1>Foo</h1><iframe src="https://home.page" />`);
|
||||
|
||||
const { asFragment } = render(<EmbeddedPage url="https://other.page" />);
|
||||
await expect(screen.findByText("Foo")).resolves.toBeVisible();
|
||||
expect(screen.queryByRole("iframe")).not.toBeInTheDocument();
|
||||
expect(asFragment()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
+23
@@ -7,11 +7,29 @@ exports[`<EmbeddedPage /> should render nothing if no url given 1`] = `
|
||||
>
|
||||
<div
|
||||
class="undefined_body"
|
||||
dir="auto"
|
||||
/>
|
||||
</div>
|
||||
</DocumentFragment>
|
||||
`;
|
||||
|
||||
exports[`<EmbeddedPage /> should sanitise input 1`] = `
|
||||
<DocumentFragment>
|
||||
<div
|
||||
class="undefined_guest"
|
||||
>
|
||||
<div
|
||||
class="undefined_body"
|
||||
dir="auto"
|
||||
>
|
||||
<h1>
|
||||
Foo
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
</DocumentFragment>
|
||||
`;
|
||||
|
||||
exports[`<EmbeddedPage /> should show error if unable to load 1`] = `
|
||||
<DocumentFragment>
|
||||
<div
|
||||
@@ -19,6 +37,7 @@ exports[`<EmbeddedPage /> should show error if unable to load 1`] = `
|
||||
>
|
||||
<div
|
||||
class="undefined_body"
|
||||
dir="auto"
|
||||
>
|
||||
Couldn't load page
|
||||
</div>
|
||||
@@ -33,6 +52,7 @@ exports[`<EmbeddedPage /> should translate _t strings ["] 1`] = `
|
||||
>
|
||||
<div
|
||||
class="undefined_body"
|
||||
dir="auto"
|
||||
>
|
||||
<h1>
|
||||
Przeglądaj pokoje
|
||||
@@ -49,6 +69,7 @@ exports[`<EmbeddedPage /> should translate _t strings [] 1`] = `
|
||||
>
|
||||
<div
|
||||
class="undefined_body"
|
||||
dir="auto"
|
||||
>
|
||||
<h1>
|
||||
Przeglądaj pokoje
|
||||
@@ -65,6 +86,7 @@ exports[`<EmbeddedPage /> should translate _t strings ["] 1`] = `
|
||||
>
|
||||
<div
|
||||
class="undefined_body"
|
||||
dir="auto"
|
||||
>
|
||||
<h1>
|
||||
Przeglądaj pokoje
|
||||
@@ -81,6 +103,7 @@ exports[`<EmbeddedPage /> should translate _t strings ['] 1`] = `
|
||||
>
|
||||
<div
|
||||
class="undefined_body"
|
||||
dir="auto"
|
||||
>
|
||||
<h1>
|
||||
Przeglądaj pokoje
|
||||
|
||||
Reference in New Issue
Block a user