Skip to content
Myr

fix(ssg): pass SSG_CONTEXT to forGetInfoURLRequest (#4810)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* fix(ssg): pass SSG_CONTEXT to forGetInfoURLRequest * add test ---------

authored by Yuin · committed by GitHub · parent d1722e3 · Browse files · 2 files+25 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Yusuke Wada <yusuke@kamawada.com>

Diff stats

2 files+25 added−1 removed

  • tests:+24 added−0 removed
  • other:+1 added−1 removed

2 files+25 added−1 removed

modified:src/helper/ssg/ssg.test.tsx+24 added
645 unmodified lines
646 expect(res.status).toBe(404)647 })648})649650describe('isSSGContext with disableSSG', () => {651 it('Should work correctly when used together', async () => {652 const app = new Hono()653654 app.use('*', async (c, next) => {655 if (!isSSGContext(c)) {656 return next()657 }658 await next()659 })660 app.get('/guarded', disableSSG(), (c) => c.html('<h1>should be skipped</h1>'))661 app.get('/page', (c) => c.html('<h1>hello</h1>'))662663 const fsMock: FileSystemModule = {664 writeFile: vi.fn(() => Promise.resolve()),665 mkdir: vi.fn(() => Promise.resolve()),666 }667668 await expect(toSSG(app, fsMock, { dir: './static' })).resolves.toBeDefined()669 expect(fsMock.writeFile).toHaveBeenCalledWith('static/page.html', expect.any(String))670 expect(fsMock.writeFile).not.toHaveBeenCalledWith('static/guarded.html', expect.any(String))671 })672})673674describe('Request hooks - filterPathsBeforeRequestHook and denyPathsBeforeRequestHook', () => {675 let app: Hono676 let fsMock: FileSystemModule677
347 unmodified lines
modified:src/helper/ssg/ssg.ts+1 added-1 removed
227 unmodified lines
228 }229 forGetInfoURLRequest = maybeRequest as unknown as AddedSSGDataRequest230 }231232 await pool.run(() => app.fetch(forGetInfoURLRequest))232 await pool.run(() => app.fetch(forGetInfoURLRequest, { [SSG_CONTEXT]: true }))233234 if (!forGetInfoURLRequest.ssgParams) {235 if (isDynamicRoute(route.path)) {236 resolveGetInfo(undefined)
223 unmodified lines