-
-
Notifications
You must be signed in to change notification settings - Fork 10
fix(test): fix CI hang, auth guard tests, and PR #610 test rewrite #616
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,8 @@ import { | |
| import { listCommand } from "../../../src/commands/log/list.js"; | ||
| // biome-ignore lint/performance/noNamespaceImport: needed for spyOn mocking | ||
| import * as apiClient from "../../../src/lib/api-client.js"; | ||
| // biome-ignore lint/performance/noNamespaceImport: needed for spyOn mocking | ||
| import * as dbAuth from "../../../src/lib/db/auth.js"; | ||
| import { | ||
| AuthError, | ||
| ContextError, | ||
|
|
@@ -237,6 +239,23 @@ const newerLogs: SentryLog[] = [ | |
| }, | ||
| ]; | ||
|
|
||
| // ============================================================================ | ||
| // Auth setup — mock getAuthConfig for all tests (auth guard added in #611) | ||
| // ============================================================================ | ||
|
|
||
| let getAuthConfigSpy: ReturnType<typeof spyOn>; | ||
|
|
||
| beforeEach(() => { | ||
| getAuthConfigSpy = spyOn(dbAuth, "getAuthConfig").mockReturnValue({ | ||
| token: "sntrys_test", | ||
| source: "oauth" as const, | ||
| }); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| getAuthConfigSpy.mockRestore(); | ||
| }); | ||
|
|
||
| // ============================================================================ | ||
| // Standard mode (project-scoped, no trace-id positional) | ||
| // ============================================================================ | ||
|
|
@@ -837,7 +856,14 @@ describe("listCommand.func — flag validation", () => { | |
|
|
||
| test("allows --sort newest with --follow", async () => { | ||
| // Should not throw ValidationError — the error (if any) comes from | ||
| // downstream resolution, not flag validation. | ||
| // downstream resolution, not flag validation. Mock resolution to reject | ||
| // with a non-ValidationError so we can verify flag validation passed. | ||
| const resolveOrgProjectSpy = spyOn( | ||
| resolveTarget, | ||
| "resolveOrgProjectFromArg" | ||
| ).mockRejectedValueOnce( | ||
| new ContextError("Organization", "sentry log list") | ||
| ); | ||
| const { context } = createMockContext(); | ||
| const func = await listCommand.loader(); | ||
| await expect( | ||
|
|
@@ -847,6 +873,7 @@ describe("listCommand.func — flag validation", () => { | |
| "my-org/my-project" | ||
| ) | ||
| ).rejects.not.toThrow(ValidationError); | ||
| resolveOrgProjectSpy.mockRestore(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spy cleanup skipped on assertion failureLow Severity The test creates |
||
| }); | ||
| }); | ||
|
|
||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Global client closed during reinitialization
Medium Severity
initSentrynow unconditionally callsSentry.getClient()?.close(0)before every init. InlibraryMode, concurrent SDK invocations can close another in-flight invocation’s client, which can drop telemetry and invalidate active spans. It can also close a pre-existing process-wide Sentry client not created by this module.