diff --git a/src/routes/__tests__/pdf.test.ts b/src/routes/__tests__/pdf.test.ts index 2b11924..196ad49 100644 --- a/src/routes/__tests__/pdf.test.ts +++ b/src/routes/__tests__/pdf.test.ts @@ -231,7 +231,7 @@ describe('PDF Output', () => { const req = createMockRequest({ url: 'https://example.com', format: 'pdf' }) const res = createMockResponse() - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[2].handle await handler(req, res, vi.fn()) // Should NOT call addWatermark for PDF diff --git a/src/routes/__tests__/playground.test.ts b/src/routes/__tests__/playground.test.ts index c0bd80c..735461b 100644 --- a/src/routes/__tests__/playground.test.ts +++ b/src/routes/__tests__/playground.test.ts @@ -61,7 +61,7 @@ describe('Playground Route', () => { const res = createMockResponse() // Get the handler from the router - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[0].handle await handler(req, res, vi.fn()) expect(res.status).toHaveBeenCalledWith(400) @@ -72,7 +72,7 @@ describe('Playground Route', () => { const req = createMockRequest({ url: 123 }) const res = createMockResponse() - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[0].handle await handler(req, res, vi.fn()) expect(res.status).toHaveBeenCalledWith(400) @@ -83,7 +83,7 @@ describe('Playground Route', () => { const req = createMockRequest({ url: "" }) const res = createMockResponse() - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[0].handle await handler(req, res, vi.fn()) expect(res.status).toHaveBeenCalledWith(400) @@ -103,7 +103,7 @@ describe('Playground Route', () => { const req = createMockRequest({ url: "https://example.com" }) const res = createMockResponse() - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[2].handle await handler(req, res, vi.fn()) expect(mockTakeScreenshot).toHaveBeenCalledWith({ @@ -135,7 +135,7 @@ describe('Playground Route', () => { }) const res = createMockResponse() - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[2].handle await handler(req, res, vi.fn()) expect(mockTakeScreenshot).toHaveBeenCalledWith(expect.objectContaining({ @@ -153,7 +153,7 @@ describe('Playground Route', () => { }) const res = createMockResponse() - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[2].handle await handler(req, res, vi.fn()) expect(mockTakeScreenshot).toHaveBeenCalledWith(expect.objectContaining({ @@ -172,7 +172,7 @@ describe('Playground Route', () => { }) const res = createMockResponse() - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[2].handle await handler(req, res, vi.fn()) expect(mockTakeScreenshot).toHaveBeenCalledWith(expect.objectContaining({ @@ -191,7 +191,7 @@ describe('Playground Route', () => { }) const res = createMockResponse() - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[2].handle await handler(req, res, vi.fn()) expect(mockTakeScreenshot).toHaveBeenCalledWith(expect.objectContaining({ @@ -209,7 +209,7 @@ describe('Playground Route', () => { }) const res = createMockResponse() - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[2].handle await handler(req, res, vi.fn()) expect(mockTakeScreenshot).toHaveBeenCalledWith(expect.objectContaining({ @@ -223,7 +223,7 @@ describe('Playground Route', () => { const req = createMockRequest({ url: "https://example.com" }) const res = createMockResponse() - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[2].handle await handler(req, res, vi.fn()) expect(res.status).toHaveBeenCalledWith(503) @@ -236,7 +236,7 @@ describe('Playground Route', () => { const req = createMockRequest({ url: "https://example.com" }) const res = createMockResponse() - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[2].handle await handler(req, res, vi.fn()) expect(res.status).toHaveBeenCalledWith(504) @@ -249,7 +249,7 @@ describe('Playground Route', () => { const req = createMockRequest({ url: "http://192.168.1.1" }) const res = createMockResponse() - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[2].handle await handler(req, res, vi.fn()) expect(res.status).toHaveBeenCalledWith(400) @@ -262,7 +262,7 @@ describe('Playground Route', () => { const req = createMockRequest({ url: "https://nonexistent.invalid" }) const res = createMockResponse() - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[2].handle await handler(req, res, vi.fn()) expect(res.status).toHaveBeenCalledWith(400) @@ -275,7 +275,7 @@ describe('Playground Route', () => { const req = createMockRequest({ url: "https://example.com" }) const res = createMockResponse() - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[2].handle await handler(req, res, vi.fn()) expect(res.status).toHaveBeenCalledWith(500) @@ -292,7 +292,7 @@ describe('Playground Route', () => { }) const res = createMockResponse() - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[2].handle await handler(req, res, vi.fn()) expect(mockTakeScreenshot).toHaveBeenCalledWith(expect.objectContaining({ @@ -310,7 +310,7 @@ describe('Playground Route', () => { }) const res = createMockResponse() - const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[1].handle + const handler = playgroundRouter.stack.find(layer => layer.route?.methods.post)?.route.stack[2].handle await handler(req, res, vi.fn()) expect(mockTakeScreenshot).toHaveBeenCalledWith(expect.objectContaining({