Files
OpenFrontIO/tests/client/NewsMarkdown.test.ts
Ryan 4bc168dffb make usernames linkable in news (#3200)
## Description:

make usernames linkable in news

now:
<img width="399" height="153" alt="image"
src="https://github.com/user-attachments/assets/39644fe2-9af1-4765-b839-9f8b5f9d0418"
/>


before:
<img width="409" height="82" alt="image"
src="https://github.com/user-attachments/assets/d7a1c37e-63cf-4417-ac61-c6db39a33851"
/>



## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

w.o.n

Co-authored-by: iamlewis <lewismmmm@gmail.com>
2026-02-16 11:11:10 -08:00

50 lines
1.5 KiB
TypeScript

import { normalizeNewsMarkdown } from "../../src/client/NewsMarkdown";
describe("normalizeNewsMarkdown", () => {
it("converts openfront pull request URLs to short markdown links", () => {
const input =
"Fix attack logic in https://github.com/openfrontio/OpenFrontIO/pull/1234";
const result = normalizeNewsMarkdown(input);
expect(result).toContain(
"[#1234](https://github.com/openfrontio/OpenFrontIO/pull/1234)",
);
});
it("converts openfront compare URLs to markdown links", () => {
const input =
"Full Changelog: https://github.com/openfrontio/OpenFrontIO/compare/v1.0.0...v1.1.0";
const result = normalizeNewsMarkdown(input);
expect(result).toContain(
"[v1.0.0...v1.1.0](https://github.com/openfrontio/OpenFrontIO/compare/v1.0.0...v1.1.0)",
);
});
it("converts github @mentions to profile links", () => {
const input = "- Feature by @evanpelle in release notes";
const result = normalizeNewsMarkdown(input);
expect(result).toContain("[@evanpelle](https://github.com/evanpelle)");
});
it("does not convert existing markdown-linked mentions", () => {
const input = "Credit [@evanpelle](https://github.com/evanpelle)";
const result = normalizeNewsMarkdown(input);
expect(result).toBe(input);
});
it("does not convert email addresses", () => {
const input = "Contact support@openfront.io for help";
const result = normalizeNewsMarkdown(input);
expect(result).toBe(input);
});
});