-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(desktop): align source_test metadata contract #7193
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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -65,7 +65,7 @@ export async function handleSourceTest( | |||||||||||||
| const lines: string[] = []; | ||||||||||||||
| let hasErrors = false; | ||||||||||||||
| let hasWarnings = false; | ||||||||||||||
| let connectionStatus: ConnectionStatus = 'unknown'; | ||||||||||||||
| let connectionStatus: ConnectionStatus = 'untested'; | ||||||||||||||
| let connectionError: string | undefined; | ||||||||||||||
|
|
||||||||||||||
| // 1. Check source exists | ||||||||||||||
|
|
@@ -122,19 +122,24 @@ export async function handleSourceTest( | |||||||||||||
| lines.push(...connectionResult.lines); | ||||||||||||||
| if (connectionResult.hasError) { | ||||||||||||||
| hasErrors = true; | ||||||||||||||
| connectionStatus = 'error'; | ||||||||||||||
| connectionStatus = 'failed'; | ||||||||||||||
| connectionError = connectionResult.error; | ||||||||||||||
| } else if (connectionResult.success) { | ||||||||||||||
| connectionStatus = 'connected'; | ||||||||||||||
| } else { | ||||||||||||||
| connectionStatus = 'disconnected'; | ||||||||||||||
| connectionStatus = 'untested'; | ||||||||||||||
|
Comment on lines
129
to
+130
Collaborator
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. [Suggestion] No test covers the Add a test with a source configuration that causes — qwen3.7-max via Qwen Code /review |
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // 7. Auth status | ||||||||||||||
| lines.push('\n## Authentication'); | ||||||||||||||
| const authResult = await checkAuthStatus(ctx, source, sourceSlug); | ||||||||||||||
| lines.push(...authResult.lines); | ||||||||||||||
| if (authResult.hasWarning) hasWarnings = true; | ||||||||||||||
| if (authResult.hasWarning) { | ||||||||||||||
| hasWarnings = true; | ||||||||||||||
| if (!connectionResult.hasError) { | ||||||||||||||
| connectionStatus = 'needs_auth'; | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+139
to
+141
Collaborator
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. [Suggestion] No test verifies that
Suggested change
Add a test combining — qwen3.7-max via Qwen Code /review |
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // 8. Auto-enable + metadata update | ||||||||||||||
| // Defaults to true; pass autoEnable: false to keep pure validation behavior. | ||||||||||||||
|
|
@@ -145,7 +150,7 @@ export async function handleSourceTest( | |||||||||||||
| if (ctx.saveSourceConfig) { | ||||||||||||||
| const updatedSource: SourceConfig = { | ||||||||||||||
| ...source, | ||||||||||||||
| lastTestedAt: new Date().toISOString(), | ||||||||||||||
| lastTestedAt: Date.now(), | ||||||||||||||
| connectionStatus, | ||||||||||||||
| connectionError, | ||||||||||||||
| // Fold enabled flip into the same save — one write, not two. | ||||||||||||||
|
|
||||||||||||||
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.
[Suggestion] The
assertSharedSourceMetadataContracthelper hardcodes the valid status values as a set literal, but TypeScript'sSet<T>type does not enforce exhaustiveness — if a new value is added toConnectionStatus, this set silently becomes a subset and the helper will reject the new valid value at test runtime with a misleading "unsupported connectionStatus" error from the test infrastructure. — Concrete cost: A developer adds a new status value and writes handler code that produces it; the test fails with an infrastructure error that looks like a bug in the handler, not the test helper.— qwen3.7-max via Qwen Code /review