Skip to content

Commit 2052de3

Browse files
sjsyrekclaude
andcommitted
refactor(test): tighten test suite for endpoint resolution PR
- Rewrite resolve-endpoint tests from 43 to 25 using table-driven it.each() (covers all 5 priority branches + edge cases: subdomain spoof, URL parsing) - Consolidate free-key-auth-init tests from 5 to 3 (drop redundant InitCommand) - Reduce voice wiring test from 4 to 1 (pin passthrough, not permutations) - Remove 55 expect(true).toBe(true) anti-pattern across integration/e2e tests - Add expect.assertions(N) guards to 10 must-fail tests (API key required, etc.) - Add InitCommand :fx key test to init-command.test.ts (closes coverage gap) Net: 3486 → 3464 tests, zero branch coverage lost, -466 lines of test code. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4e9ff02 commit 2052de3

14 files changed

Lines changed: 130 additions & 596 deletions

tests/e2e/cli-stdin-stdout.e2e.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ describe('CLI Stdin/Stdout E2E', () => {
125125
expect(content).toMatch(/\d+\.\d+\.\d+/);
126126
} catch (error) {
127127
// File may not exist if command failed, but shouldn't crash
128-
expect(true).toBe(true);
129128
}
130129
});
131130

@@ -144,7 +143,6 @@ describe('CLI Stdin/Stdout E2E', () => {
144143
expect(result).toContain('Usage:');
145144
} catch (error) {
146145
// May fail if grep doesn't find pattern, but shouldn't crash
147-
expect(true).toBe(true);
148146
}
149147
});
150148

tests/e2e/cli-workflow.e2e.test.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,16 +350,17 @@ describe('CLI Workflow E2E', () => {
350350
// Ignore if already cleared
351351
}
352352

353+
expect.assertions(1);
353354
try {
354355
runCLI('deepl glossary languages');
355-
expect(true).toBe(true);
356356
} catch (error: any) {
357357
const output = error.stderr ?? error.stdout ?? error.message;
358358
expect(output).toMatch(/API key|auth/i);
359359
}
360360
});
361361

362362
it('should not require any arguments', () => {
363+
expect.assertions(2);
363364
try {
364365
// Will fail without API key but should not require arguments
365366
runCLI('deepl glossary languages');
@@ -379,9 +380,9 @@ describe('CLI Workflow E2E', () => {
379380
// Ignore if already cleared
380381
}
381382

383+
expect.assertions(1);
382384
try {
383385
runCLI('deepl glossary languages');
384-
expect(true).toBe(true);
385386
} catch (error: any) {
386387
// Non-zero exit code
387388
expect(error.status).toBeGreaterThan(0);
@@ -760,9 +761,9 @@ describe('CLI Workflow E2E', () => {
760761
});
761762

762763
it('should require API key for style-rules list', () => {
764+
expect.assertions(1);
763765
try {
764766
runCLI('deepl style-rules list');
765-
expect(true).toBe(true);
766767
} catch (error: any) {
767768
const output = error.stderr ?? error.stdout;
768769
expect(output).toMatch(/API key|auth/i);
@@ -772,7 +773,6 @@ describe('CLI Workflow E2E', () => {
772773
it('should accept --detailed and pagination flags', () => {
773774
try {
774775
runCLI('deepl style-rules list --detailed --page 1 --page-size 10');
775-
expect(true).toBe(true);
776776
} catch (error: any) {
777777
const output = error.stderr ?? error.stdout;
778778
expect(output).not.toMatch(/unknown.*option/i);
@@ -784,7 +784,6 @@ describe('CLI Workflow E2E', () => {
784784
it('should accept extended language codes like Swahili', () => {
785785
try {
786786
runCLI('deepl translate "Hello" --to sw');
787-
expect(true).toBe(true);
788787
} catch (error: any) {
789788
const output = error.stderr ?? error.stdout;
790789
expect(output).not.toMatch(/Invalid target language/i);
@@ -794,7 +793,6 @@ describe('CLI Workflow E2E', () => {
794793
it('should accept ES-419 Latin American Spanish', () => {
795794
try {
796795
runCLI('deepl translate "Hello" --to es-419');
797-
expect(true).toBe(true);
798796
} catch (error: any) {
799797
const output = error.stderr ?? error.stdout;
800798
expect(output).not.toMatch(/Invalid target language/i);
@@ -804,7 +802,6 @@ describe('CLI Workflow E2E', () => {
804802
it('should accept Chinese simplified/traditional variants', () => {
805803
try {
806804
runCLI('deepl translate "Hello" --to zh-hant');
807-
expect(true).toBe(true);
808805
} catch (error: any) {
809806
const output = error.stderr ?? error.stdout;
810807
expect(output).not.toMatch(/Invalid target language/i);
@@ -818,7 +815,6 @@ describe('CLI Workflow E2E', () => {
818815
runCLI(
819816
'deepl translate "<p>Hello</p>" --to es --tag-handling html --tag-handling-version v2'
820817
);
821-
expect(true).toBe(true);
822818
} catch (error: any) {
823819
const output = error.stderr ?? error.stdout;
824820
expect(output).not.toMatch(/unknown.*option/i);

tests/integration/cli-auth.integration.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ describe('Auth CLI Integration', () => {
2727
it('should store valid API key in config file', () => {
2828
// This will fail validation but should test the storage logic
2929
// For now, skip actual execution as it requires API validation
30-
expect(true).toBe(true);
3130
});
3231

3332
it('should reject empty API key', () => {

tests/integration/cli-config.integration.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ describe('Config CLI Integration', () => {
170170
// Config file should be removed or reset
171171
// (implementation may vary - either delete or reset to defaults)
172172
// This test validates the reset command executes successfully
173-
expect(true).toBe(true);
174173
});
175174

176175
it('should abort without --yes in non-TTY mode', () => {

tests/integration/cli-glossary.integration.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ describe('Glossary CLI Integration', () => {
4242
// Ignore if already cleared
4343
}
4444

45+
expect.assertions(1);
4546
try {
4647
runCLI('deepl glossary list', { stdio: 'pipe' });
47-
expect(true).toBe(true);
4848
} catch (error: any) {
4949
const output = error.stderr ?? error.stdout;
5050
// Should indicate API key is required
@@ -113,7 +113,6 @@ describe('Glossary CLI Integration', () => {
113113
runCLI(`deepl glossary create "Test" en es "${csvFile}"`, {
114114
stdio: 'pipe',
115115
});
116-
expect(true).toBe(true);
117116
} catch (error: any) {
118117
const output = error.stderr ?? error.stdout;
119118
// Should not fail on file format

tests/integration/cli-hooks.integration.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ describe('Git Hooks Service Integration', () => {
155155

156156
it('should not throw error when uninstalling non-existent hook', () => {
157157
hooksService.uninstall('post-commit'); // Not installed
158-
expect(true).toBe(true); // Test passes without error
159158
});
160159

161160
it('should throw error when uninstalling non-DeepL hook', () => {

tests/integration/cli-style-rules.integration.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,31 @@ describe('Style Rules CLI Integration', () => {
5252
});
5353

5454
it('should require API key for style-rules list', () => {
55+
expect.assertions(1);
5556
try {
5657
runCLI('deepl style-rules list', { stdio: 'pipe' });
57-
expect(true).toBe(true);
5858
} catch (error: any) {
5959
const output = error.stderr ?? error.stdout;
6060
expect(output).toMatch(/API key|auth|not set/i);
6161
}
6262
});
6363

6464
it('should require API key for style-rules list --detailed', () => {
65+
expect.assertions(1);
6566
try {
6667
runCLI('deepl style-rules list --detailed', { stdio: 'pipe' });
67-
expect(true).toBe(true);
6868
} catch (error: any) {
6969
const output = error.stderr ?? error.stdout;
7070
expect(output).toMatch(/API key|auth|not set/i);
7171
}
7272
});
7373

7474
it('should require API key for style-rules list with pagination', () => {
75+
expect.assertions(1);
7576
try {
7677
runCLI('deepl style-rules list --page 1 --page-size 10', {
7778
stdio: 'pipe',
7879
});
79-
expect(true).toBe(true);
8080
} catch (error: any) {
8181
const output = error.stderr ?? error.stdout;
8282
expect(output).toMatch(/API key|auth|not set/i);

0 commit comments

Comments
 (0)