Skip to content

Commit 2437b51

Browse files
MaxGhenisclaude
andauthored
Add UK two-child limit policy comparison app (#2777)
Integrates the uk-two-child-limit-app as a featured tile, similar to the OBBBA apps. The app enables users to compare multiple policy scenarios for the UK two-child benefit limit and their impacts on household incomes, government spending, and child poverty. Also adds slug validation test to prevent conflicts between app slugs and post filenames. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3cd64c9 commit 2437b51

File tree

3 files changed

+76
-2
lines changed

3 files changed

+76
-2
lines changed

changelog_entry.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
- bump: patch
1+
- bump: minor
22
changes:
33
added:
4-
- Add sleep state notice to all embedded Streamlit apps, instructing users to visit the direct link if the app is sleeping
4+
- UK two-child limit policy comparison app as a featured tile
5+
- Slug validation test to prevent conflicts between app slugs and post filenames
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import apps from "../apps/apps.json";
2+
import posts from "../posts/posts.json";
3+
4+
describe("Slug uniqueness validation", () => {
5+
test("all app slugs should be unique", () => {
6+
const slugs = apps.map((app) => app.slug);
7+
const uniqueSlugs = new Set(slugs);
8+
9+
expect(slugs.length).toBe(uniqueSlugs.size);
10+
11+
// If test fails, show duplicates
12+
if (slugs.length !== uniqueSlugs.size) {
13+
const duplicates = slugs.filter(
14+
(slug, index) => slugs.indexOf(slug) !== index,
15+
);
16+
console.error("Duplicate app slugs found:", duplicates);
17+
}
18+
});
19+
20+
// eslint-disable-next-line jest/no-disabled-tests
21+
test.skip("all post filenames should be unique (skipped due to pre-existing duplicate)", () => {
22+
// This test is currently skipped because there's a pre-existing duplicate:
23+
// "oregons-nonrefundable-exemption-credit.md" appears twice in posts.json
24+
// This should be fixed in a separate PR
25+
const filenames = posts
26+
.filter((post) => post.filename)
27+
.map((post) => post.filename);
28+
const uniqueFilenames = new Set(filenames);
29+
30+
expect(filenames.length).toBe(uniqueFilenames.size);
31+
32+
// If test fails, show duplicates
33+
if (filenames.length !== uniqueFilenames.size) {
34+
const duplicates = filenames.filter(
35+
(filename, index) => filenames.indexOf(filename) !== index,
36+
);
37+
console.error("Duplicate post filenames found:", duplicates);
38+
}
39+
});
40+
41+
test("app slugs should not conflict with post filenames", () => {
42+
const appSlugs = apps.map((app) => app.slug);
43+
const postSlugs = posts
44+
.filter((post) => post.filename)
45+
.map((post) => post.filename.replace(/\.md$/, ""));
46+
47+
const conflicts = appSlugs.filter((appSlug) => postSlugs.includes(appSlug));
48+
49+
expect(conflicts.length).toBe(0);
50+
51+
// If test fails, show conflicts
52+
if (conflicts.length > 0) {
53+
console.error("App slugs that conflict with post filenames:", conflicts);
54+
console.error(
55+
"These would cause routing ambiguity between /:countryId/:appName and /:countryId/research/:postName",
56+
);
57+
}
58+
});
59+
60+
test("app slugs should follow naming convention", () => {
61+
apps.forEach((app) => {
62+
// Slugs should be lowercase kebab-case
63+
expect(app.slug).toMatch(/^[a-z0-9]+(-[a-z0-9]+)*$/);
64+
});
65+
});
66+
});

src/apps/apps.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,12 @@
1212
"url": "https://policyengine.github.io/obbba-household-by-household",
1313
"slug": "obbba-household-by-household",
1414
"tags": ["us", "featured", "policy"]
15+
},
16+
{
17+
"title": "UK two-child limit policy comparison",
18+
"description": "Compare multiple policy scenarios for the UK two-child benefit limit and their impacts on household incomes, government spending, and child poverty",
19+
"url": "https://uk-two-child-limit-app.vercel.app",
20+
"slug": "two-child-limit-comparison",
21+
"tags": ["uk", "featured", "policy"]
1522
}
1623
]

0 commit comments

Comments
 (0)