Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1a43dd3

Browse files
jaggederestclaude
andcommitted
docs: update TODO.md and CLAUDE.md with test improvements
- Update test coverage from 74.35% to 78.49%- Update unit test count from 359 to 405- Mark extension.ts refactoring as complete (93.07% coverage)- Mark test quality improvements as complete- Document comprehensive mock factory patterns- Add TDD refactoring example from extension.ts success- Update immediate next steps to focus on remote.ts🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
1 parent8b8edc7 commit1a43dd3

File tree

2 files changed

+84
-57
lines changed

2 files changed

+84
-57
lines changed

‎CLAUDE.md

Lines changed: 63 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Your goal is to help me arrive at the most elegant and effective solution by com
3232

3333
##Test Coverage Guidelines
3434

35-
Current status:**74.35% overall unit test coverage** with359 unit tests and 69 integration tests passing.
35+
Current status:**78.49% overall unit test coverage** with405 unit tests and 69 integration tests passing.
3636

3737
###TDD Approach for New Features
3838

@@ -52,9 +52,10 @@ Current status: **74.35% overall unit test coverage** with 359 unit tests and 69
5252

5353
###Testing Patterns to Follow
5454

55-
-**Create factory functions** for common test setups (see test-helpers.ts)
55+
-**Use mock factories from test-helpers.ts** - 30+ factory functions available for all common types
56+
-**No inline mock definitions** - always use factory functions for consistency
57+
-**Minimal`as any` usage** - reduced from 95 to 4 instances (96% reduction)
5658
-**Use createMockOutputChannelWithLogger()** for consistent Logger testing
57-
-**Avoid`as any`** - create proper mock types or use`as never` for VS Code mocks
5859
-**Mock external dependencies** properly using vi.mock() with TypeScript types
5960
-**Test core functionality first** - constructor, main methods, error paths
6061
-**Ensure backward compatibility** by adding compatibility methods during refactoring
@@ -63,34 +64,60 @@ Current status: **74.35% overall unit test coverage** with 359 unit tests and 69
6364
###Test Helper Patterns
6465

6566
```typescript
66-
// Example factory function from test-helpers.ts
67-
exportfunction createMockOutputChannelWithLogger(options?: {
68-
verbose?:boolean;
69-
}): {
70-
mockOutputChannel: { appendLine:ReturnType<typeofvi.fn> };
71-
logger:Logger;
72-
}
67+
// Example factory functions from test-helpers.ts
68+
69+
// Storage variants
70+
exportfunction createMockStorageWithAuth():Storage
71+
exportfunction createMockStorageMinimal():Storage
72+
73+
// Workspace variants
74+
exportfunction createMockWorkspaceRunning():Workspace
75+
exportfunction createMockWorkspaceStopped():Workspace
76+
exportfunction createMockWorkspaceFailed():Workspace
77+
78+
// VSCode components
79+
exportfunction createMockExtensionContext():vscode.ExtensionContext
80+
exportfunction createMockRemoteSSHExtension():vscode.Extension<unknown>
81+
exportfunction createMockTreeView<T>():vscode.TreeView<T>
82+
exportfunction createMockStatusBarItem():vscode.StatusBarItem
83+
exportfunction createMockQuickPick<T>():vscode.QuickPick<T>
84+
exportfunction createMockTerminal():vscode.Terminal
85+
exportfunction createMockOutputChannel():vscode.OutputChannel
86+
87+
// Other utilities
88+
exportfunction createMockWorkspaceProvider():WorkspaceProvider
89+
exportfunction createMockRemote():Remote
90+
exportfunction createMockCommands():Commands
91+
exportfunction createMockEventEmitter<T>():vscode.EventEmitter<T>
92+
exportfunction createMockAxiosInstance():AxiosInstance
93+
exportfunction createMockProxyAgent():ProxyAgent
94+
exportfunction createMockUri(path:string,scheme?:string):vscode.Uri
7395
```
7496

7597
###FileswithExcellentCoverage (>90%)-UseasExamples:
7698

7799
-featureSet.ts:100%
78100
-proxy.ts:100%
79101
-logger.ts:98.44% (goodTDDexample)
102+
-sshSupport.ts:98.13%
80103
-util.ts:97.31%
81104
-headers.ts:96.49%
82105
-api-helper.ts:96.36%
83106
-sshConfig.ts:96.21%
84107
-api.ts:95.52%
108+
-extension.ts:93.07% (refactoredfrom39.71%usingTDD)
109+
-workspaceMonitor.ts:92.37%
85110
-error.ts:90.44%
111+
-cliManager.ts:90.05%
86112

87113
###CurrentDevelopmentApproach
88114

89115
-**TDDfornewfeatures**-testfirst,implementsecond
90116
-**Incrementalrefactoring**-small,measurableimprovements
91117
-**Backwardcompatibility**-addcompatibilitymethodswhenchanginginterfaces
92-
-**Factory functions in test-helpers.ts** - reusable test setup patterns
93-
-**Systematic cleanup** - remove`as any` casts, add proper types
118+
-**Comprehensivemockfactories**-30+factoryfunctionsintest-helpers.ts
119+
-**Noinlinemocks**-alltestmocksusefactoryfunctions
120+
-**Type-safetesting**-minimal`as any`usage (only4instancesremain)
94121
-**Measureprogressconstantly**-run`yarn test:ci --coverage`aftereverychange
95122

96123
###RefactoringStrategy
@@ -102,32 +129,34 @@ When replacing legacy patterns (e.g., writeToCoderOutputChannel):
102129
3.Incrementallyreplaceusagestartingwithhighest-impactfiles
103130
4.Maintainfulltestsuitepassingthroughout
104131

105-
###Example:Logger Integration Pattern
132+
###Example:TDDRefactoringPattern (extension.tssuccessstory)
106133

107134
```typescript
108-
// 1. Add backward compatibility to new class
109-
classLogger {
110-
// ... new methods ...
111-
112-
// Backward compatibility for legacy code
113-
writeToCoderOutputChannel(message:string):void {
114-
this.info(message);
135+
// 1. Write test for extracted function FIRST
136+
describe("setupRemoteSSHExtension", () => {
137+
it("should configure remote SSH when available", () => {
138+
const mockExtension = createMockRemoteSSHExtension();
139+
const mockRemote = createMockRemote();
140+
141+
const result = setupRemoteSSHExtension(mockExtension);
142+
143+
expect(result).toBe(mockRemote);
144+
});
145+
});
146+
147+
// 2. Extract function to make test pass
148+
export function setupRemoteSSHExtension(
149+
remoteSSHExtension: vscode.Extension<unknown> | undefined,
150+
): Remote | undefined {
151+
if (!remoteSSHExtension) {
152+
return undefined;
115153
}
154+
// Implementation here
116155
}
117156
118-
// 2. Create factory in test-helpers.ts
119-
exportfunction createMockOutputChannelWithLogger() {
120-
const mockOutputChannel= { appendLine:vi.fn() };
121-
const logger=newLogger(mockOutputChannel);
122-
return {mockOutputChannel,logger };
123-
}
157+
// 3. Replace in original code
158+
const remoteSSHExtension = vscode.extensions.getExtension("ms-vscode-remote.remote-ssh");
159+
const remote = setupRemoteSSHExtension(remoteSSHExtension);
124160
125-
// 3. Test compatibility before refactoring
126-
it("should be backward compatible", ()=> {
127-
const { mockOutputChannel, logger }=createMockOutputChannelWithLogger();
128-
logger.writeToCoderOutputChannel("Test");
129-
expect(mockOutputChannel.appendLine).toHaveBeenCalledWith(
130-
expect.stringMatching(/\[.*\]\[INFO\] Test/)
131-
);
132-
});
161+
// Result: extension.ts coverage improved from 39.71% to 93.07%
133162
```

‎TODO.md

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
##Phase 1: Test Infrastructure & Coverage ✅ COMPLETED
44

5-
-**359 unit tests** passing with74.35% overall coverage
5+
-**405 unit tests** passing with78.49% overall coverage
66
-**69 integration tests** passing
77
-**18 files** with >90% coverage
88
- Established TDD workflow and testing patterns
@@ -37,18 +37,19 @@
3737

3838
##Phase 3: Code Quality Improvements
3939

40-
###Test Quality
40+
###Test Quality ✅ COMPLETED
4141

42-
-[x] test-helpers.ts with type-safe mock builders
43-
-[x] Removed most`as any` casts from tests
44-
-[ ] api.test.ts cleanup (30+`as any` with eslint-disable)
45-
-[ ] Fix private property access in remaining test files
42+
-[x] test-helpers.ts with comprehensive mock factories (30+ factory functions)
43+
-[x] Reduced`as any` casts from 95 to 4 (96% reduction)
44+
-[x] api.test.ts cleanup - removed eslint-disable and all inline mocks
45+
-[x] Consolidated all test mocks into reusable factory functions
46+
-[x] Migrated all test files to use consistent mock patterns
4647

4748
###Refactoring Priority
4849

49-
1.**extension.ts** (39.71% →81.51% coverage ✅) -Break down monolithic activate() function
50+
1.**extension.ts** (39.71% →93.07% coverage ✅ COMPLETED) -Refactored monolithic activate() function
5051

51-
Extract thesehelper functions(TDD - write tests first):
52+
Successfully extracted all 9helper functionsusing TDD:
5253

5354
-[x] setupRemoteSSHExtension() - Configure remote SSH extension
5455
-[x] initializeInfrastructure() - Create storage and logger
@@ -57,10 +58,8 @@
5758
-[x] registerUriHandler() - Handle vscode:// URIs
5859
-[x] registerCommands() - Register all VS Code commands
5960
-[x] handleRemoteEnvironment() - Setup remote workspace if needed
60-
-[ ] checkAuthentication() - Verify user auth and fetch workspaces
61-
-[ ] handleAutologin() - Process autologin configuration
62-
63-
Approach: Extract one function at a time, add tests, maintain passing suite
61+
-[x] checkAuthentication() - Verify user auth and fetch workspaces
62+
-[x] handleAutologin() - Process autologin configuration
6463

6564
2.**remote.ts** (49.21% coverage) - break down 400+ line methods
6665
3.**commands.ts** (64.19% coverage) - create UI abstraction layer
@@ -76,21 +75,20 @@
7675

7776
| Metric| Target| Current| Status|
7877
| ------------------------| ------| -------| -----------|
79-
| Unit test coverage| 80%+| 78.15%| 🔄 Progress|
78+
| Unit test coverage| 80%+| 78.49%| 🔄 Progress|
8079
| Integration tests| 60+| 69| ✅ Complete|
8180
| Logger adoption| 100%| 100%| ✅ Complete|
8281
| Files with <50% coverage| 0| 1| 🔄 Progress|
82+
| Test mock consolidation| 100%| 100%| ✅ Complete|
8383

8484
##Immediate Next Steps
8585

86-
1.**Refactor extension.ts using TDD**
87-
88-
- Start with setupRemoteSSHExtension() - write test first
89-
- Continue with initializeInfrastructure() and other functions
90-
- Run`yarn test:ci --coverage` after each extraction
91-
- Target: 39.71% → 60%+ coverage
86+
1.**Refactor remote.ts (49.21% coverage)**
87+
- Break down 400+ line methods into testable units
88+
- Apply TDD approach similar to extension.ts
89+
- Target: 49.21% → 80%+ coverage
9290

93-
2.**Clean up api.test.ts**
94-
-Remove eslint-disable comment
95-
-Create proper mock typesfor30+`as any` casts
96-
-Consider exposing test interfaces for better type safety
91+
2.**Improve commands.ts coverage (68.03%)**
92+
-Create UI abstraction layer for better testability
93+
-Add testsforuncovered command handlers
94+
-Target: 68.03% → 80%+ coverage

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp