-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathurls.test.ts
More file actions
206 lines (201 loc) · 6.66 KB
/
Copy pathurls.test.ts
File metadata and controls
206 lines (201 loc) · 6.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
import assert from 'node:assert/strict'
import { describe, it } from 'node:test'
import { pubUrl, suburbUrl, absolutePubUrl, absoluteSuburbUrl, toSuburbSlug } from './urls'
// SEO TRIPWIRE — frozen snapshot of every live suburb's URL slug, captured
// 2026-05-30 from the production `pubs` table (150 distinct suburbs). Pub and
// suburb pages are statically generated at these exact paths and are indexed by
// Google. If a change to the slug logic alters even one of these, it silently
// 404s a live, indexed URL. This test must fail FIRST when that happens. Do not
// edit the snapshot to make it pass unless you intend to change live URLs and
// have a redirect plan. (Adding new suburbs over time is fine — they just are
// not covered here until added.)
const LIVE_SUBURB_SLUGS: Record<string, string> = {
"Alkimos": "alkimos",
"Applecross": "applecross",
"Ardross": "ardross",
"Armadale": "armadale",
"Ashby": "ashby",
"Attadale": "attadale",
"Balcatta": "balcatta",
"Baldivis": "baldivis",
"Ballajura": "ballajura",
"Baskerville": "baskerville",
"Bassendean": "bassendean",
"Bayswater": "bayswater",
"Bedfordale": "bedfordale",
"Beechboro": "beechboro",
"Belmont": "belmont",
"Bentley": "bentley",
"Bibra Lake": "bibra-lake",
"Bicton": "bicton",
"Bull Creek": "bull-creek",
"Burswood": "burswood",
"Calista": "calista",
"Canning Vale": "canning-vale",
"Cannington": "cannington",
"Carlisle": "carlisle",
"Carmel": "carmel",
"Carramar": "carramar",
"Casuarina": "casuarina",
"Caversham": "caversham",
"Chidlow": "chidlow",
"City Beach": "city-beach",
"Claremont": "claremont",
"Clarkson": "clarkson",
"Cloverdale": "cloverdale",
"Cockburn Central": "cockburn-central",
"Como": "como",
"Connolly": "connolly",
"Cooloongup": "cooloongup",
"Cottesloe": "cottesloe",
"Craigie": "craigie",
"Crawley": "crawley",
"Currambine": "currambine",
"Darch": "darch",
"Dawesville": "dawesville",
"Dianella": "dianella",
"Doubleview": "doubleview",
"Duncraig": "duncraig",
"East Fremantle": "east-fremantle",
"East Perth": "east-perth",
"East Victoria Park": "east-victoria-park",
"Ellenbrook": "ellenbrook",
"Floreat": "floreat",
"Forrestdale": "forrestdale",
"Forrestfield": "forrestfield",
"Fremantle": "fremantle",
"Gidgegannup": "gidgegannup",
"Girrawheen": "girrawheen",
"Gnangara": "gnangara",
"Gosnells": "gosnells",
"Greenwood": "greenwood",
"Guildford": "guildford",
"Hamilton Hill": "hamilton-hill",
"Hammond Park": "hammond-park",
"Henley Brook": "henley-brook",
"High Wycombe": "high-wycombe",
"Highgate": "highgate",
"Hillarys": "hillarys",
"Iluka": "iluka",
"Inglewood": "inglewood",
"Innaloo": "innaloo",
"Joondalup": "joondalup",
"Kalamunda": "kalamunda",
"Karrinyup": "karrinyup",
"Lathlain": "lathlain",
"Leederville": "leederville",
"Leeming": "leeming",
"Maddington": "maddington",
"Maida Vale": "maida-vale",
"Malaga": "malaga",
"Mandurah": "mandurah",
"Marangaroo": "marangaroo",
"Maylands": "maylands",
"Meadow Springs": "meadow-springs",
"Middle Swan": "middle-swan",
"Midland": "midland",
"Midvale": "midvale",
"Mindarie": "mindarie",
"Morley": "morley",
"Mosman Park": "mosman-park",
"Mount Hawthorn": "mount-hawthorn",
"Mount Helena": "mount-helena",
"Mount Lawley": "mount-lawley",
"Mullaloo": "mullaloo",
"Mundaring": "mundaring",
"Murdoch": "murdoch",
"Myaree": "myaree",
"Nedlands": "nedlands",
"Neerabup": "neerabup",
"North Beach": "north-beach",
"North Fremantle": "north-fremantle",
"North Perth": "north-perth",
"Northbridge": "northbridge",
"O'Connor": "oconnor",
"Ocean Reef": "ocean-reef",
"Osborne Park": "osborne-park",
"Parkerville": "parkerville",
"Parkwood": "parkwood",
"Peppermint Grove": "peppermint-grove",
"Perth": "perth",
"Perth Airport": "perth-airport",
"Perth CBD": "perth-cbd",
"Piara Waters": "piara-waters",
"Pickering Brook": "pickering-brook",
"Port Kennedy": "port-kennedy",
"Rivervale": "rivervale",
"Rockingham": "rockingham",
"Roleystone": "roleystone",
"Scarborough": "scarborough",
"Secret Harbour": "secret-harbour",
"Serpentine": "serpentine",
"Shoalwater": "shoalwater",
"South Fremantle": "south-fremantle",
"South Lake": "south-lake",
"South Perth": "south-perth",
"Southern River": "southern-river",
"Spearwood": "spearwood",
"Subiaco": "subiaco",
"Success": "success",
"Swan Valley": "swan-valley",
"Swan View": "swan-view",
"Swanbourne": "swanbourne",
"The Vines": "the-vines",
"Thornlie": "thornlie",
"Trigg": "trigg",
"Victoria Park": "victoria-park",
"Wangara": "wangara",
"Wanneroo": "wanneroo",
"Warnbro": "warnbro",
"Watermans Bay": "watermans-bay",
"Wattle Grove": "wattle-grove",
"Wellard": "wellard",
"Wembley": "wembley",
"Wembley Downs": "wembley-downs",
"West Leederville": "west-leederville",
"West Perth": "west-perth",
"Woodlands": "woodlands",
"Woodvale": "woodvale",
"Wooroloo": "wooroloo",
"Yanchep": "yanchep",
"Yangebup": "yangebup",
"Yokine": "yokine",
}
describe('live suburb slug snapshot (URL regression guard)', () => {
for (const [name, slug] of Object.entries(LIVE_SUBURB_SLUGS)) {
it(`${name} -> /${slug}`, () => {
assert.equal(toSuburbSlug(name), slug)
assert.equal(suburbUrl(name), `/${slug}`)
})
}
})
describe('toSuburbSlug edge cases', () => {
it("strips a straight apostrophe rather than hyphenating it (O'Connor -> oconnor)", () => {
// The single live case that distinguishes the canonical slug from the old
// SuburbLeague variant, which produced the now-404 \"o-connor\".
assert.equal(toSuburbSlug("O'Connor"), 'oconnor')
})
it('collapses internal whitespace and punctuation runs to one hyphen', () => {
assert.equal(toSuburbSlug('Mount Lawley'), 'mount-lawley')
})
it('lowercases and trims leading/trailing separators', () => {
assert.equal(toSuburbSlug(' South Perth '), 'south-perth')
})
})
describe('url builders', () => {
it('pubUrl builds /{suburb-slug}/{pub-slug}', () => {
assert.equal(pubUrl({ suburb: "O'Connor", slug: 'the-local' }), '/oconnor/the-local')
})
it('suburbUrl passes through an already-slugged value when isSlug=true', () => {
assert.equal(suburbUrl('south-perth', true), '/south-perth')
})
it('absolutePubUrl prefixes the production origin', () => {
assert.equal(
absolutePubUrl({ suburb: 'Fremantle', slug: 'the-norfolk-hotel' }),
'https://perthpintprices.com/fremantle/the-norfolk-hotel',
)
})
it('absoluteSuburbUrl prefixes the production origin (input is already a slug)', () => {
assert.equal(absoluteSuburbUrl('oconnor'), 'https://perthpintprices.com/oconnor')
})
})