11import { resolve } from "path" ;
2- import { LOCAL_EXPLORER_API_PATH , LOCAL_EXPLORER_BASE_PATH } from "miniflare" ;
2+ import { CorePaths } from "miniflare" ;
33import { afterAll , assert , beforeAll , describe , it } from "vitest" ;
44import { runWranglerDev } from "../../shared/src/run-wrangler-long-lived" ;
55
6+ const EXPLORER_API_PATH = `${ CorePaths . EXPLORER } /api` ;
7+
68describe ( "local explorer" , ( ) => {
79 let ip : string ;
810 let port : number ;
@@ -19,11 +21,11 @@ describe("local explorer", () => {
1921 await stop ?.( ) ;
2022 } ) ;
2123
22- it ( `returns local explorer API response for ${ LOCAL_EXPLORER_API_PATH } ` , async ( {
24+ it ( `returns local explorer API response for ${ EXPLORER_API_PATH } ` , async ( {
2325 expect,
2426 } ) => {
2527 const response = await fetch (
26- `http://${ ip } :${ port } ${ LOCAL_EXPLORER_API_PATH } /storage/kv/namespaces`
28+ `http://${ ip } :${ port } ${ EXPLORER_API_PATH } /storage/kv/namespaces`
2729 ) ;
2830 expect ( response . headers . get ( "Content-Type" ) ) . toBe ( "application/json" ) ;
2931 const json = await response . json ( ) ;
@@ -53,12 +55,8 @@ describe("local explorer", () => {
5355 expect ( text ) . toBe ( "Hello World!" ) ;
5456 } ) ;
5557
56- it ( `serves UI index.html at ${ LOCAL_EXPLORER_BASE_PATH } ` , async ( {
57- expect,
58- } ) => {
59- const response = await fetch (
60- `http://${ ip } :${ port } ${ LOCAL_EXPLORER_BASE_PATH } `
61- ) ;
58+ it ( `serves UI index.html at ${ CorePaths . EXPLORER } ` , async ( { expect } ) => {
59+ const response = await fetch ( `http://${ ip } :${ port } ${ CorePaths . EXPLORER } ` ) ;
6260 expect ( response . status ) . toBe ( 200 ) ;
6361 expect ( response . headers . get ( "Content-Type" ) ) . toBe (
6462 "text/html; charset=utf-8"
@@ -68,12 +66,12 @@ describe("local explorer", () => {
6866 expect ( text ) . toContain ( "Cloudflare Local Explorer" ) ;
6967 } ) ;
7068
71- it ( `serves UI assets at ${ LOCAL_EXPLORER_BASE_PATH } /assets/*` , async ( {
69+ it ( `serves UI assets at ${ CorePaths . EXPLORER } /assets/*` , async ( {
7270 expect,
7371 } ) => {
7472 // First get index.html to find the actual asset paths
7573 const indexResponse = await fetch (
76- `http://${ ip } :${ port } ${ LOCAL_EXPLORER_BASE_PATH } `
74+ `http://${ ip } :${ port } ${ CorePaths . EXPLORER } `
7775 ) ;
7876 const html = await indexResponse . text ( ) ;
7977
@@ -85,7 +83,7 @@ describe("local explorer", () => {
8583
8684 // Fetch the JS asset
8785 const jsResponse = await fetch (
88- `http://${ ip } :${ port } ${ LOCAL_EXPLORER_BASE_PATH } /${ jsPath } `
86+ `http://${ ip } :${ port } ${ CorePaths . EXPLORER } /${ jsPath } `
8987 ) ;
9088 expect ( jsResponse . status ) . toBe ( 200 ) ;
9189 expect ( jsResponse . headers . get ( "Content-Type" ) ) . toMatch (
@@ -96,7 +94,7 @@ describe("local explorer", () => {
9694 it ( "serves UI with SPA fallback for unknown routes" , async ( { expect } ) => {
9795 // Request a route that doesn't exist as a file but should be handled by the SPA
9896 const response = await fetch (
99- `http://${ ip } :${ port } ${ LOCAL_EXPLORER_BASE_PATH } /kv/some-namespace`
97+ `http://${ ip } :${ port } ${ CorePaths . EXPLORER } /kv/some-namespace`
10098 ) ;
10199 expect ( response . status ) . toBe ( 200 ) ;
102100 expect ( response . headers . get ( "Content-Type" ) ) . toBe (
@@ -123,12 +121,10 @@ describe("local explorer", () => {
123121 await stop ?.( ) ;
124122 } ) ;
125123
126- it ( " returns worker response for LOCAL_EXPLORER_API_PATH" , async ( {
124+ it ( ` returns worker response for ${ EXPLORER_API_PATH } ` , async ( {
127125 expect,
128126 } ) => {
129- const response = await fetch (
130- `http://${ ip } :${ port } ${ LOCAL_EXPLORER_API_PATH } `
131- ) ;
127+ const response = await fetch ( `http://${ ip } :${ port } ${ EXPLORER_API_PATH } ` ) ;
132128 const text = await response . text ( ) ;
133129 expect ( text ) . toBe ( "Hello World!" ) ;
134130 } ) ;
@@ -171,7 +167,7 @@ describe("local explorer", () => {
171167 expect,
172168 } ) => {
173169 const response = await fetch (
174- `http://${ ip } :${ port } ${ LOCAL_EXPLORER_API_PATH } /storage/kv/namespaces`
170+ `http://${ ip } :${ port } ${ EXPLORER_API_PATH } /storage/kv/namespaces`
175171 ) ;
176172 expect ( response . status ) . toBe ( 200 ) ;
177173 expect ( response . headers . get ( "Content-Type" ) ) . toBe ( "application/json" ) ;
@@ -180,9 +176,7 @@ describe("local explorer", () => {
180176 } ) ;
181177
182178 it ( `serves explorer UI` , async ( { expect } ) => {
183- const response = await fetch (
184- `http://${ ip } :${ port } ${ LOCAL_EXPLORER_BASE_PATH } `
185- ) ;
179+ const response = await fetch ( `http://${ ip } :${ port } ${ CorePaths . EXPLORER } ` ) ;
186180 expect ( response . status ) . toBe ( 200 ) ;
187181 expect ( response . headers . get ( "Content-Type" ) ) . toBe (
188182 "text/html; charset=utf-8"
0 commit comments