A calm place to write long-form, and publish it to the open social web. skypress.blog/
0

Configure Feed

Select the types of activity you want to include in your feed.

at trunk 1.6 kB View raw
1import { describe, it, expect } from 'vitest'; 2import type { APIContext } from 'astro'; 3import { GET } from './client-metadata.json'; 4import { OAUTH_REDIRECT_PATHS } from '../lib/auth/config'; 5 6// Colocated under src/pages/, so the filename is underscore-prefixed to keep Astro's 7// file router from importing it during static-path collection (see AGENTS.md). 8 9async function metadata( origin: string ) { 10 const response = await GET( { 11 url: new URL( `${ origin }/client-metadata.json` ), 12 } as APIContext ); 13 return response.json() as Promise< { client_id: string; redirect_uris: string[] } >; 14} 15 16describe( '/client-metadata.json', () => { 17 it( 'registers a redirect URI for every OAuth-island route', async () => { 18 // Regression: with only /editor/ registered, signing in from /write returned the 19 // writer to /editor — losing the in-progress writing-first draft (the publish 20 // intent never resumed). Both surfaces must be registered redirect targets. 21 const { redirect_uris } = await metadata( 'https://skypress.blog' ); 22 expect( redirect_uris ).toEqual( 23 OAUTH_REDIRECT_PATHS.map( ( path ) => `https://skypress.blog${ path }` ) 24 ); 25 expect( redirect_uris ).toContain( 'https://skypress.blog/write/' ); 26 } ); 27 28 it( 'derives client_id and redirect_uris from the request origin', async () => { 29 const { client_id, redirect_uris } = await metadata( 'https://preview.example.com' ); 30 expect( client_id ).toBe( 'https://preview.example.com/client-metadata.json' ); 31 expect( redirect_uris[ 0 ] ).toBe( 'https://preview.example.com/editor/' ); 32 } ); 33} );