|
| 1 | +import { describe, it, expect } from "vitest"; |
| 2 | +import getIssueTagValues from "./get-issue-tag-values.js"; |
| 3 | +import { getServerContext } from "../test-setup.js"; |
| 4 | +import { UserInputError } from "../errors.js"; |
| 5 | + |
| 6 | +describe("get_issue_tag_values", () => { |
| 7 | + it("returns tag value distribution for an issue", async () => { |
| 8 | + const result = await getIssueTagValues.handler( |
| 9 | + { |
| 10 | + organizationSlug: "sentry-mcp-evals", |
| 11 | + issueId: "CLOUDFLARE-MCP-41", |
| 12 | + tagKey: "url", |
| 13 | + regionUrl: null, |
| 14 | + issueUrl: undefined, |
| 15 | + }, |
| 16 | + getServerContext(), |
| 17 | + ); |
| 18 | + expect(result).toMatchInlineSnapshot(` |
| 19 | + "# Tag Distribution: Url |
| 20 | +
|
| 21 | + **Issue**: CLOUDFLARE-MCP-41 |
| 22 | + **Tag Key**: \`url\` |
| 23 | + **Total Unique Values**: 156 |
| 24 | +
|
| 25 | + ## Top Values |
| 26 | +
|
| 27 | + | Value | Count | First Seen | Last Seen | |
| 28 | + |-------|-------|------------|----------| |
| 29 | + | \`/upload/github/org/repo/commit/abc123\` | 45 | 2024-01-10 | 2024-01-15 | |
| 30 | + | \`/api/v1/users/profile\` | 32 | 2024-01-11 | 2024-01-15 | |
| 31 | + | \`/dashboard/overview\` | 28 | 2024-01-12 | 2024-01-15 | |
| 32 | + | \`/settings/notifications\` | 21 | 2024-01-13 | 2024-01-14 | |
| 33 | + | \`/checkout/payment\` | 15 | 2024-01-14 | 2024-01-14 | |
| 34 | +
|
| 35 | + *Showing top 5 of 156 unique values* |
| 36 | +
|
| 37 | + ## Using this information |
| 38 | +
|
| 39 | + - Use \`get_issue_details(organizationSlug='sentry-mcp-evals', issueId='CLOUDFLARE-MCP-41')\` to see the full issue details |
| 40 | + - Try other tag keys like: url, browser, environment, release, os, device, user |
| 41 | + " |
| 42 | + `); |
| 43 | + }); |
| 44 | + |
| 45 | + it("works with issue URL parameter", async () => { |
| 46 | + const result = await getIssueTagValues.handler( |
| 47 | + { |
| 48 | + organizationSlug: undefined, |
| 49 | + issueId: undefined, |
| 50 | + tagKey: "browser", |
| 51 | + regionUrl: null, |
| 52 | + issueUrl: |
| 53 | + "https://sentry-mcp-evals.sentry.io/issues/CLOUDFLARE-MCP-41/", |
| 54 | + }, |
| 55 | + getServerContext(), |
| 56 | + ); |
| 57 | + expect(result).toContain("# Tag Distribution: Browser"); |
| 58 | + expect(result).toContain("**Tag Key**: `browser`"); |
| 59 | + }); |
| 60 | + |
| 61 | + it("throws error when neither issueId nor issueUrl provided", async () => { |
| 62 | + await expect( |
| 63 | + getIssueTagValues.handler( |
| 64 | + { |
| 65 | + organizationSlug: "sentry-mcp-evals", |
| 66 | + issueId: undefined, |
| 67 | + tagKey: "url", |
| 68 | + regionUrl: null, |
| 69 | + issueUrl: undefined, |
| 70 | + }, |
| 71 | + getServerContext(), |
| 72 | + ), |
| 73 | + ).rejects.toThrow(UserInputError); |
| 74 | + }); |
| 75 | + |
| 76 | + it("throws error when organizationSlug missing with issueId", async () => { |
| 77 | + await expect( |
| 78 | + getIssueTagValues.handler( |
| 79 | + { |
| 80 | + organizationSlug: undefined, |
| 81 | + issueId: "CLOUDFLARE-MCP-41", |
| 82 | + tagKey: "url", |
| 83 | + regionUrl: null, |
| 84 | + issueUrl: undefined, |
| 85 | + }, |
| 86 | + getServerContext(), |
| 87 | + ), |
| 88 | + ).rejects.toThrow(UserInputError); |
| 89 | + }); |
| 90 | + |
| 91 | + it("throws error when tagKey is missing", async () => { |
| 92 | + await expect( |
| 93 | + getIssueTagValues.handler( |
| 94 | + { |
| 95 | + organizationSlug: "sentry-mcp-evals", |
| 96 | + issueId: "CLOUDFLARE-MCP-41", |
| 97 | + tagKey: "", |
| 98 | + regionUrl: null, |
| 99 | + issueUrl: undefined, |
| 100 | + }, |
| 101 | + getServerContext(), |
| 102 | + ), |
| 103 | + ).rejects.toThrow(UserInputError); |
| 104 | + }); |
| 105 | + |
| 106 | + it("throws error when tagKey contains path traversal characters", async () => { |
| 107 | + await expect( |
| 108 | + getIssueTagValues.handler( |
| 109 | + { |
| 110 | + organizationSlug: "sentry-mcp-evals", |
| 111 | + issueId: "CLOUDFLARE-MCP-41", |
| 112 | + tagKey: "../../../admin", |
| 113 | + regionUrl: null, |
| 114 | + issueUrl: undefined, |
| 115 | + }, |
| 116 | + getServerContext(), |
| 117 | + ), |
| 118 | + ).rejects.toThrow(); |
| 119 | + }); |
| 120 | + |
| 121 | + it("throws error when tagKey contains slashes", async () => { |
| 122 | + await expect( |
| 123 | + getIssueTagValues.handler( |
| 124 | + { |
| 125 | + organizationSlug: "sentry-mcp-evals", |
| 126 | + issueId: "CLOUDFLARE-MCP-41", |
| 127 | + tagKey: "url/path", |
| 128 | + regionUrl: null, |
| 129 | + issueUrl: undefined, |
| 130 | + }, |
| 131 | + getServerContext(), |
| 132 | + ), |
| 133 | + ).rejects.toThrow(); |
| 134 | + }); |
| 135 | +}); |
0 commit comments