Skip to content

Commit afacac5

Browse files
VIA-299 SB Add 'target="_blank"' to any anchor tags we get from the content API in the callout component.
1 parent ab5adb8 commit afacac5

File tree

7 files changed

+291
-1
lines changed

7 files changed

+291
-1
lines changed

package-lock.json

Lines changed: 234 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"@opennextjs/aws": "^3.9.1",
7777
"@types/aws-lambda": "^8.10.159",
7878
"axios": "^1.13.2",
79+
"cheerio": "^1.1.2",
7980
"dotenv": "^17.2.3",
8081
"es-toolkit": "^1.42.0",
8182
"isomorphic-dompurify": "^2.33.0",

src/_lambda/content-cache-hydrator/handler.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ const mockMarkdownWithStylingHtml = "<ul><li>sausage</li><li>egg</li><li>chips</
3838
jest.mock("@project/src/app/_components/markdown/MarkdownWithStyling", () => ({
3939
MarkdownWithStyling: () => mockMarkdownWithStylingHtml,
4040
}));
41+
jest.mock("cheerio", () => ({
42+
load: jest.fn(() => {
43+
const selectorImpl = jest.fn(() => ({
44+
attr: jest.fn(),
45+
}));
46+
47+
const $ = Object.assign(selectorImpl, {
48+
html: jest.fn(() => "<p>HTML fragment</p>"),
49+
});
50+
51+
return $;
52+
}),
53+
}));
4154

4255
const mockValidCacheReadResult: ReadCachedContentResult = { cacheStatus: "valid", cacheContent: "some-content" };
4356
const mockInvalidatedCacheReadResult: ReadCachedContentResult = { cacheStatus: "invalidated", cacheContent: "" };

src/app/_components/vaccine/Vaccine.integration.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ jest.mock("next/headers", () => ({
2727
headers: jest.fn(),
2828
}));
2929
jest.mock("sanitize-data", () => ({ sanitize: jest.fn() }));
30+
jest.mock("cheerio", () => ({
31+
load: jest.fn(() => {
32+
const selectorImpl = jest.fn(() => ({
33+
attr: jest.fn(),
34+
}));
35+
36+
const $ = Object.assign(selectorImpl, {
37+
html: jest.fn(() => "<p>HTML fragment</p>"),
38+
});
39+
40+
return $;
41+
}),
42+
}));
3043

3144
const nhsNumber = "5123456789";
3245

src/services/content-api/content-service.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ const mockMarkdownWithStylingHtml = "<ul><li>sausage</li><li>egg</li><li>chips</
1414
jest.mock("@project/src/app/_components/markdown/MarkdownWithStyling", () => ({
1515
MarkdownWithStyling: () => mockMarkdownWithStylingHtml,
1616
}));
17+
jest.mock("cheerio", () => ({
18+
load: jest.fn(() => {
19+
const selectorImpl = jest.fn(() => ({
20+
attr: jest.fn(),
21+
}));
22+
23+
const $ = Object.assign(selectorImpl, {
24+
html: jest.fn(() => "<p>HTML fragment</p>"),
25+
});
26+
27+
return $;
28+
}),
29+
}));
1730

1831
describe("getContentForVaccine()", () => {
1932
const mockedConfig = config as ConfigMock;

src/services/content-api/parsers/content-styling-service.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ jest.mock("@project/src/app/_components/markdown/MarkdownWithStyling", () => ({
2828
}));
2929

3030
jest.mock("sanitize-data", () => ({ sanitize: jest.fn() }));
31+
jest.mock("cheerio", () => ({
32+
load: jest.fn(() => {
33+
const selectorImpl = jest.fn(() => ({
34+
attr: jest.fn(),
35+
}));
36+
37+
const $ = Object.assign(selectorImpl, {
38+
html: jest.fn(() => "<p>HTML fragment</p>"),
39+
});
40+
41+
return $;
42+
}),
43+
}));
3144

3245
describe("ContentStylingService", () => {
3346
const mockMarkdownSubsection: VaccinePageSubsection = {

0 commit comments

Comments
 (0)