-
Notifications
You must be signed in to change notification settings - Fork 22
test(docs): add comprehensive tests and monitoring for llms.txt endpoints #4676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
devin-ai-integration
wants to merge
17
commits into
app
Choose a base branch
from
devin/1762144039-add-llms-txt-tests-monitoring
base: app
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+606
−2
Open
Changes from 3 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e986247
test(docs): add comprehensive tests and monitoring for llms.txt endpo…
devin-ai-integration[bot] efbfae1
test(docs): remove middleware tests due to server-only constraints
devin-ai-integration[bot] a8466e7
Update scripts/monitor/check-llms-md-endpoints.ts
dsinghvi 043ea04
chore(ci): align incident secret naming and enable PR testing
devin-ai-integration[bot] 413d83c
Merge branch 'app' into devin/1762144039-add-llms-txt-tests-monitoring
devin-ai-integration[bot] dc7dd6d
fix(docs): use slug search parameter in markdown route
devin-ai-integration[bot] a423f9c
fix(ci): correct workflow trigger to use push instead of pull_request
devin-ai-integration[bot] 9278b68
Merge branch 'devin/1762144039-add-llms-txt-tests-monitoring' of http…
devin-ai-integration[bot] 9d1d53e
fix(ci): remove node-fetch install as Node 20 has global fetch
devin-ai-integration[bot] 39da4a4
fix(ci): fix URL construction in monitoring script to prevent path du…
devin-ai-integration[bot] 66bf31f
wip: add incident.io constants and interface for duplicate prevention
devin-ai-integration[bot] 5192121
Merge branch 'devin/1762144039-add-llms-txt-tests-monitoring' of http…
devin-ai-integration[bot] 07ec50a
fix(monitor): implement incident.io duplicate prevention and add DRY_…
devin-ai-integration[bot] d9e655a
feat(monitor): add TEST_MODE support to label incidents as tests
devin-ai-integration[bot] 423abe0
fix(monitor): use CANCELED status, add DRY_RUN guard to updateInciden…
devin-ai-integration[bot] 926ee56
Merge updates from app branch
devin-ai-integration[bot] d9c164b
fix(monitor): add response.ok check and make Slack alerts opt-in
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| name: Monitor LLM-friendly Docs Endpoints | ||
|
|
||
| on: | ||
| schedule: | ||
| # Run every 5 minutes | ||
| - cron: '*/5 * * * *' | ||
| workflow_dispatch: # Allow manual triggering | ||
|
|
||
| jobs: | ||
| monitor: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| npm install -g tsx | ||
| npm install node-fetch | ||
| - name: Run monitoring script | ||
| env: | ||
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_DOCS_INCIDENTS }} | ||
| INCIDENT_IO_API_KEY: ${{ secrets.INCIDENT_IO_API_KEY }} | ||
davidkonigsberg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| run: | | ||
| tsx scripts/monitor/check-llms-md-endpoints.ts | ||
| - name: Report status | ||
| if: always() | ||
davidkonigsberg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| run: | | ||
| if [ $? -eq 0 ]; then | ||
| echo "✅ All endpoints healthy" | ||
| else | ||
| echo "❌ Some endpoints failed - alerts sent" | ||
| fi | ||
vercel[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/fern-docs/bundle/src/app/[host]/[domain]/[lang]/fern-docs/markdown/route.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { NextRequest } from "next/server"; | ||
| import { describe, expect, it, vi } from "vitest"; | ||
|
|
||
| describe("markdown route slug handling", () => { | ||
| const createMockRequest = (pathname: string, searchParams: Record<string, string> = {}) => { | ||
| const url = new URL(`https://example.com${pathname}`); | ||
| Object.entries(searchParams).forEach(([key, value]) => { | ||
| url.searchParams.set(key, value); | ||
| }); | ||
| return new NextRequest(url); | ||
| }; | ||
|
|
||
| it("should prefer slug from search params over pathname", () => { | ||
| const request = createMockRequest("/api/fern-docs/markdown", { slug: "docs/quickstart" }); | ||
|
|
||
| const slugParam = request.nextUrl.searchParams.get("slug"); | ||
| const slug = slugParam ?? request.nextUrl.pathname.replace(/\.(md|mdx)$/, ""); | ||
|
|
||
| expect(slug).toBe("docs/quickstart"); | ||
| }); | ||
|
|
||
| it("should fallback to pathname parsing when slug param is not present", () => { | ||
| const request = createMockRequest("/docs/quickstart.md"); | ||
|
|
||
| const slugParam = request.nextUrl.searchParams.get("slug"); | ||
| const slug = slugParam ?? request.nextUrl.pathname.replace(/\.(md|mdx)$/, ""); | ||
|
|
||
| expect(slug).toBe("/docs/quickstart"); | ||
| }); | ||
|
|
||
| it("should handle .mdx extension in pathname fallback", () => { | ||
| const request = createMockRequest("/docs/quickstart.mdx"); | ||
|
|
||
| const slugParam = request.nextUrl.searchParams.get("slug"); | ||
| const slug = slugParam ?? request.nextUrl.pathname.replace(/\.(md|mdx)$/, ""); | ||
|
|
||
| expect(slug).toBe("/docs/quickstart"); | ||
| }); | ||
|
|
||
| it("should handle nested paths in slug param", () => { | ||
| const request = createMockRequest("/api/fern-docs/markdown", { | ||
| slug: "learn/sdks/overview/quickstart" | ||
| }); | ||
|
|
||
| const slugParam = request.nextUrl.searchParams.get("slug"); | ||
| const slug = slugParam ?? request.nextUrl.pathname.replace(/\.(md|mdx)$/, ""); | ||
|
|
||
| expect(slug).toBe("learn/sdks/overview/quickstart"); | ||
| }); | ||
|
|
||
| it("should handle empty slug param", () => { | ||
| const request = createMockRequest("/api/fern-docs/markdown", { slug: "" }); | ||
|
|
||
| const slugParam = request.nextUrl.searchParams.get("slug"); | ||
| const slug = slugParam ?? request.nextUrl.pathname.replace(/\.(md|mdx)$/, ""); | ||
|
|
||
| expect(slug).toBe(""); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.