@@ -199,6 +199,8 @@ async function run() {
199199 firstPath ( / ^ \/ i n t e g r a t i o n s \/ [ ^ / ] + $ / ) ,
200200 firstPath ( / ^ \/ m o d e l s \/ a n t h r o p i c \/ [ ^ / ] + $ / ) ,
201201 '/models/context-windows' ,
202+ '/models/pricing-calculator' ,
203+ '/models/token-counter' ,
202204 firstPath ( / ^ \/ m o d e l s \/ c o m p a r e \/ [ ^ / ] + $ / ) ,
203205 ]
204206 const failures : string [ ] = [ ]
@@ -240,38 +242,58 @@ async function run() {
240242 }
241243 )
242244
243- await check ( 'model tool pages render, self-canonicalize, and are in the sitemap' , async ( ) => {
244- const failures : string [ ] = [ ]
245- for ( const [ path , titlePrefix ] of [
246- [ '/models/pricing-calculator' , 'LLM API Pricing Calculator' ] ,
247- [ '/models/token-counter' , 'Token Counter' ] ,
248- ] ) {
249- const { status, body } = await get ( path )
250- const title = decodeHtml ( / < t i t l e > ( [ ^ < ] * ) < \/ t i t l e > / . exec ( body ) ?. [ 1 ] ?? '' )
251- const canonical = / < l i n k r e l = " c a n o n i c a l " h r e f = " ( [ ^ " ] + ) " / . exec ( body ) ?. [ 1 ]
252- const robots = robotsDirectives ( body )
253- if (
254- status !== 200 ||
255- ! title . startsWith ( titlePrefix ) ||
256- title . length > 60 ||
257- ! canonical ||
258- new URL ( canonical ) . pathname !== path ||
259- robots . some ( ( directive ) => directive . includes ( 'noindex' ) ) ||
260- ! sitemap . has ( path )
261- ) {
262- failures . push ( `${ path } → ${ status } , title "${ title } ", canonical ${ canonical } ` )
245+ await check (
246+ 'model pages carry distinct search titles within 60 characters and self-canonicalize' ,
247+ async ( ) => {
248+ const comparePaths = sitemapPaths . filter ( ( path ) => path . startsWith ( '/models/compare/' ) )
249+ assert (
250+ comparePaths . length >= 5 ,
251+ `The sitemap lists only ${ comparePaths . length } compare pages`
252+ )
253+ const paths = [
254+ '/models' ,
255+ '/models/anthropic' ,
256+ '/models/context-windows' ,
257+ '/models/pricing-calculator' ,
258+ '/models/token-counter' ,
259+ ...comparePaths ,
260+ ]
261+ const pathByTitle = new Map < string , string > ( )
262+ let anthropicTitle = ''
263+ const failures : string [ ] = [ ]
264+ for ( const path of paths ) {
265+ const { status, body } = await get ( path )
266+ const title = pageTitle ( body )
267+ const canonical = canonicalPath ( body )
268+ const duplicateOf = pathByTitle . get ( title )
269+ pathByTitle . set ( title , duplicateOf ?? path )
270+ if ( path === '/models/anthropic' ) anthropicTitle = title
271+ if (
272+ status !== 200 ||
273+ ! title . endsWith ( ' | Sim' ) ||
274+ title . endsWith ( ' | Sim | Sim' ) ||
275+ title . length > 60 ||
276+ duplicateOf ||
277+ canonical !== path ||
278+ ! sitemap . has ( path )
279+ ) {
280+ failures . push (
281+ `${ path } → ${ status } , title "${ title } " (${ title . length } )${ duplicateOf ? ` duplicates ${ duplicateOf } ` : '' } , canonical ${ canonical } , in sitemap ${ sitemap . has ( path ) } `
282+ )
283+ }
263284 }
285+ assert . deepEqual ( failures , [ ] )
286+ assert . match ( anthropicTitle , / C l a u d e / , '/models/anthropic does not name Claude in its title' )
264287 }
265- assert . deepEqual ( failures , [ ] )
266- } )
288+ )
267289
268- await check ( 'token counter ships no tiktoken rank tables in its initial load' , async ( ) => {
290+ await check ( 'token counter ships no js- tiktoken code in its initial load' , async ( ) => {
269291 const { status, body } = await get ( '/models/token-counter' )
270292 assert . equal ( status , 200 )
271- // Every js-tiktoken rank table is an object keyed `bpe_ranks`; the tokenizer
272- // must load only after the visitor interacts with the text box .
293+ // Every js-tiktoken rank table is keyed `bpe_ranks` and its encoder reads that property, so the
294+ // name appears in any chunk that bundles the tokenizer, which must load only on interaction .
273295 const marker = / b p e _ r a n k s /
274- assert ( ! marker . test ( body ) , 'The initial HTML embeds a tiktoken rank table ' )
296+ assert ( ! marker . test ( body ) , 'The initial HTML embeds js- tiktoken code ' )
275297 const scripts = [ ...body . matchAll ( / < s c r i p t [ ^ > ] + s r c = " ( [ ^ " ] + ) " / g) ]
276298 . map ( ( match ) => new URL ( decodeHtml ( match [ 1 ] ) , baseUrl ) )
277299 . filter ( ( url ) => url . origin === baseUrl . origin )
@@ -281,7 +303,7 @@ async function run() {
281303 const script = await get ( `${ url . pathname } ${ url . search } ` )
282304 if ( marker . test ( script . body ) ) offenders . push ( url . pathname )
283305 }
284- assert . deepEqual ( offenders , [ ] , 'An initial script chunk bundles tiktoken rank tables ' )
306+ assert . deepEqual ( offenders , [ ] , 'An initial script chunk bundles js- tiktoken' )
285307 } )
286308
287309 await check ( 'docs integration slugs redirect to their landing page' , async ( ) => {
@@ -336,25 +358,6 @@ async function run() {
336358 assert . match ( title , / o n / , `${ resellerPath } title "${ title } " does not name the reseller` )
337359 } )
338360
339- await check ( 'model pricing pages carry their search titles and canonicals' , async ( ) => {
340- const comparePath = firstPath ( / ^ \/ m o d e l s \/ c o m p a r e \/ [ ^ / ] + - v s - [ ^ / ] + $ / )
341- const pages : Array < [ path : string , title : RegExp ] > = [
342- [ '/models/anthropic' , / ^ A n t h r o p i c \( C l a u d e \) A P I P r i c i n g & M o d e l s \| S i m $ / ] ,
343- [ '/models/context-windows' , / ^ L L M C o n t e x t W i n d o w C o m p a r i s o n \| S i m $ / ] ,
344- [ comparePath , / v s .+ \| S i m $ / ] ,
345- ]
346- const failures : string [ ] = [ ]
347- for ( const [ path , expected ] of pages ) {
348- const { status, body } = await get ( path )
349- const title = pageTitle ( body )
350- const canonical = canonicalPath ( body )
351- if ( status !== 200 || ! expected . test ( title ) || title . length > 60 || canonical !== path ) {
352- failures . push ( `${ path } → ${ status } , title "${ title } ", canonical ${ canonical } ` )
353- }
354- }
355- assert . deepEqual ( failures , [ ] )
356- } )
357-
358361 await check ( 'footer integration links stay on the landing site' , async ( ) => {
359362 const { body } = await get ( HOME_PATH )
360363 assert ( body . includes ( 'href="/integrations/slack"' ) , 'Footer does not link /integrations/slack' )
0 commit comments